Questions tagged [introspection]

A capability of some object-oriented programming languages to determine the type of an object at runtime.

Some OOP languages providing Type Introspection ability : Ruby, Objective-C, C++, Java, PHP, Perl, Python, Object Pascal, Actionscript (as3)

The introspection is done differently, depending on the form of program, it is performed upon: inspecting a source code or compiled byte-code is called compile-time introspection, while inspecting properties of running code is a run-time introspection.

For example, Java supports both types of introspection: users of run-time introspection typically perform it via , while compile-time introspection can be implemented with tools or .

http://en.wikipedia.org/wiki/Type_introspection

1021 questions
18
votes
2 answers

Why is important to include ".moc" file at end of a Qt Source code file?

Why is it important to add an include for .moc file in a Qt cpp source code? This is a common step used in several Qt samples, including this one: http://doc.qt.io/qt-5/qttestlib-tutorial1-example.html; where the line #include "testqstring.moc"…
Daniel Santos
  • 14,328
  • 21
  • 91
  • 174
18
votes
4 answers

Generate SQL to update primary key

I want to change a primary key and all table rows which reference to this value. # table master master_id|name =============== foo|bar # table detail detail_id|master_id|name ======================== 1234|foo|blu If I give a script or function …
guettli
  • 25,042
  • 81
  • 346
  • 663
18
votes
3 answers

Accessing a method in a super class when it's not exposed

In a subclass, I'm overriding a method that is not exposed in the super class. I know that I have the correct signature as it is successfully overriding the superclass implementation. However, as part of the the new implementation, I need to call…
Chris Thompson
  • 35,167
  • 12
  • 80
  • 109
18
votes
6 answers

How to watch for a variable change in python without dunder setattr or pdb

There is large python project where one attribute of one class just have wrong value in some place. It should be sqlalchemy.orm.attributes.InstrumentedAttribute, but when I run tests it is constant value, let's say string. There is some way to run…
Bunyk
  • 7,635
  • 8
  • 47
  • 79
17
votes
4 answers

C++11 reflection library

I'm currently going to write big project in c++11. I'm searching for some time good c++11/c++ reflection library and I've found several different libraries, but most of them are simply not updated for last couple of years or their functionality is…
Wojciech Danilo
  • 11,573
  • 17
  • 66
  • 132
17
votes
2 answers

iOS Blocks introspection

I would like to know two things: 1- Is it possible by using objective-c introspection to know the return type of a block. For example: int (^CountBlock)(NSArray *array) I would like to know the type it will be returning is int. The second question…
Rui Peres
  • 25,741
  • 9
  • 87
  • 137
16
votes
5 answers

determine from which file a function is defined in python

I am programmatically printing out a list of function in python. I can get the name from name for ifunc,func in enumerate(list_of_functions): print(str(ifunc)+func.__name__) How to get the source filename where the function is defined as…
00__00__00
  • 4,834
  • 9
  • 41
  • 89
16
votes
1 answer

Does Perl 6 have an equivalent to Python's dir()?

I'm trying to become comfortable in Perl 6. One of the things I found handy in Python when I was at a REPL prompt was that I could do a dir(object) and find out the attributes of an object, which in Python includes the object's methods. This often…
Steve Piner
  • 175
  • 5
16
votes
3 answers

Get PHP class namespace dynamically

How can I retrieve a class namespace automatically? The magic var __NAMESPACE__ is unreliable since in subclasses it's not correctly defined. Example: class Foo\bar\A -> __NAMESPACE__ === Foo\bar class Ping\pong\B extends Foo\bar\A -> __NAMESPACE__…
daveoncode
  • 18,900
  • 15
  • 104
  • 159
15
votes
6 answers

Introspection in Clojure

What is the best way to do introspection in Clojure? Is there something like Python's dir function? I'm particularly interested in finding the methods that are available on java classes that I'm interoperating with, but I'm also interested in…
Frank Henard
  • 3,638
  • 3
  • 28
  • 41
15
votes
4 answers

How is introspection useful?

I have been programming mainly in PHP, and I am trying to make a switch to python. I am skilled with PHP, and I have never needed to use introspection / introspection like capabilities. What good is code introspection, and in what situations would…
Chris D.
  • 675
  • 7
  • 14
15
votes
2 answers

property type or class using reflection

I was wondering if it's possible to determine the class or primitive type of an Objects properties. Getting all properties names and values is pretty easy. SO answer So is there any way to get the properties class type while the property hast no…
Arndt Bieberstein
  • 1,128
  • 1
  • 14
  • 28
15
votes
3 answers

How to get the list of all attributes of a Java object using BeanUtils introspection?

I have method which gets a POJO as it's parameter. Now I want to programmatically get all the attributes of the POJO (because my code may not know what are all the attributes in it at run time) and need to get the values for the attributes also.…
Veera
  • 32,532
  • 36
  • 98
  • 137
14
votes
1 answer

How to see function signature in Python?

Is there a way to introspect a function so that it shows me information on the arguments it takes (like number of args, type if possible, name of arguments if named) and the return value? dir() doesn't seem to do what I want. The __doc__ string…
mindthief
  • 12,755
  • 14
  • 57
  • 61
14
votes
3 answers

How to do JavaScript object introspection?

What to do when after all probing, a reportedly valid object return 'undefined' for any attribute probed? I use jQuery, $('selector').mouseover(function() { }); Everything returns 'undefined' for $(this) inside the function scope. The selector is a…
Florin
  • 1,379
  • 3
  • 16
  • 21