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
0
votes
1 answer

How to determine the method type of stdlib methods written in C

The classify_class_attrs function from the inspect module can be used to determine what kind of object each of a class's attributes is, including whether a function is an instance method, a class method, or a static method. Here is an example: from…
Jimmy
  • 35,686
  • 13
  • 80
  • 98
0
votes
0 answers

Inspect the type of a Swift closure

How can I programatically inspect the type of a Swift object? Something similar to obtaining the class of an object in ObjectiveC with the class message. So, if I have func f(x: Int) -> Int{ return x * 3 } I want to get (Int)->Int as the type…
cfischer
  • 24,452
  • 37
  • 131
  • 214
0
votes
1 answer

Programmatically query Symfony / Doctrine ORM

I'm using Doctrine-defined Entity schema as a reference to create a C++/Qt API to access such data. Is there a way to programmatically iterate through all the fields and their parameters such that there is only one master schema (and the C++…
qdot
  • 6,195
  • 5
  • 44
  • 95
0
votes
2 answers

How to access an instance variable by an NSString generated at run-time (reflection)

I've got the following little code conundrum.. - (void) transmitArray { NSString* arrayName = @"array1"; NSArray* array1 = [NSArray arrayWithObject:@"This is Array 1"]; NSArray* array2 = [NSArray arrayWithObject:@"This is Array 2"]; …
CarlosTheJackal
  • 220
  • 1
  • 14
0
votes
1 answer

How to do introspection in Swift?

I notice properties that aren't defined anywhere in the Swift global definition, such as dynamicType and Type in Any.Type. How do I find out the properties that one can access but aren't documented? Is there a way to do introspection in Swift?
Boon
  • 40,656
  • 60
  • 209
  • 315
0
votes
2 answers

get an array variable in python

can I do this in a loop, by producing the file name from the name of the array to store ? ab = array.array('B', map( operator.xor, a, b ) ) f1 = open('ab', 'wb') ab.tofile(f1) f1.close ac = array.array('B', map( operator.xor, a, c ) ) f1 =…
lclevy
  • 23
  • 1
  • 6
0
votes
2 answers

Run code before class instanciation in ActionScript 3

I need to run code in a class declaration before its instanciation. This would be especially useful to automatically register classes in a factory. See: // Main.as public class Main extends Sprite { public function Main() : void { …
Warren Seine
  • 2,311
  • 2
  • 25
  • 38
0
votes
0 answers

get variable name of instance

Can a Python instance get the name of the variable which is used to access the object? This example code shows what I need: foo=MyClass() foo.get_name() --> 'foo' bar=foo bar.get_name() --> 'bar' I know that this is black magic and not clean code.…
guettli
  • 25,042
  • 81
  • 346
  • 663
0
votes
1 answer

Library to do introspection in java?

I need to do reflection and introspection in my java application, but I find that java.lang.reflect is a little bit complex to use, and I cannot easily find solutions for what I want to do. Do you know another library that do introspection?
Mouna
  • 3,221
  • 3
  • 27
  • 38
0
votes
1 answer

how to detect interface changes on iOS application

Is there any possible way to detect every change on User Interface during runtime?? I'm trying to find all objects in the current app interface. I'm trying to to get all nodes inspecting recursively the main Window, but, for example, how to know if…
Frade
  • 2,938
  • 4
  • 28
  • 39
0
votes
2 answers

Python - Import all files in a directory tree

I want to import all python files in a directory tree, i.e. if we have the following directory structure: tests/ tests/foo.py tests/subtests/bar.py (Imagine that the tree is of arbitrary depth). I would like to do import_all('tests') and load…
Marcin
  • 48,559
  • 18
  • 128
  • 201
0
votes
2 answers

Get parent class of a certain class

Given a class Car that extends the class Vehicle that extends NSObject. How is it possible to get programmatically the parent class Vehicle from the child class Car in Objective-C?
Giorgio
  • 13,129
  • 12
  • 48
  • 75
0
votes
1 answer

How to create python symtable when code has syntax errors?

When there are no syntax errors: >>> symtable.symtable("guido = 1; rossum = 2", "code", "exec").get_symbols() [, ] When there are syntax errors: >>> symtable.symtable("guido = 1; for", "code",…
Billy
  • 185
  • 8
0
votes
1 answer

Comparing [class] does not work?

I have a unit test: - (void)testFetchTrackByTrackIdIsATrack { [self addTrackWithSongId:@"123"]; Track *fetchedTrack = [self.library trackByTrackId:@"123"]; assertThat(fetchedTrack, instanceOf([Track class])); } Which fails…
Elliot Chance
  • 5,526
  • 10
  • 49
  • 80
0
votes
1 answer

In Python, class from which a given instance is inheriting a particular method

I know that in Python, given a class ClassA, with inspect.getmembers(ClassA, predicate=inspect.ismethod) I can iterate over the different methods present in ClassA. Inherited methods are also gathered, which is convenient in my case. But what I…
zeycus
  • 860
  • 1
  • 8
  • 20