introspection

name of the class that contains the method code

I'm trying to find the name of the class that contains method code. In the example underneath I use self.__class__.__name__, but of course this returns the name of the class of which self is an instance and not class that contains the test() method code. b.test() will print 'B' while I would like to get 'A'. I looked into the inspect m...

SQLAlchemy introspection of ORM classes/objects

I am looking for a way to introspect SQLAlchemy ORM classes/entities to determine the types and other constraints (like maximum lengths) of an entity's properties. For example, if I have a declarative class: class User(Base): __tablename__ = "USER_TABLE" id = sa.Column(sa.types.Integer, primary_key=True) fullname = sa.Colu...

Cocoa Question: How do I get a string representation of a SEL?

Is it possible, given a SEL to generate a string representation of the method it refers to? For context: I have an object instance initialized thusly: -(id) initWithTarget:(id)object action: (SEL)action; Within the instance I would like to echo the string name of the method referred to by SEL. How do I do that? ...

C# expression tree for ordinary code

It's possible to create an expression tree, if you declare it as such. But is it possible to get an expression tree for an ordinary chunk of code such as a method or property getter? What I'm trying to do is, let's say for an order processing system, I have a class for order items: class Item : Entity { [Cascade] public Docume...

Print all local variables accessible to the current scope in Lua

I know how to print "all" global variables using the following code for k,v in pairs(_G) do print("Global key", k, "value", v) end So my question is how to do that for all variables that are accessible from the currently executing function, something that can do what locals() does for Python. ...

How do I introspect on a SQL Server?

I have a server with a vendor application which is heavily database-reliant. I need to make some minor changes to the data in a few tables in the database in an automated fashion. Just INSERTs and UPDATEs, nothing fancy. Vendors being vendors, I can never be quite sure when they change the schema of a database during upgrade. To tha...

Testing for undefined and null child objects in ActionsScript/Flex

Hi Everyone, I use this pattern to test for undefined and null values in ActionScript/Flex : if(obj) { execute() } Unfortunately, a ReferenceError is always thrown when I use the pattern to test for child objects : if(obj.child) { execute() } ReferenceError: Error #1069: Property child not found on obj and there is no defau...

Why is there no way to do introspection in Objective C with Objects?

I have seen examples (on here especially) of calling hideous C functions and getting structures back that have to be iterated, replete with reams of underbars. Why can't I do this (pseudo to follow): Money *cost = [[Money alloc] init]; for (Property *property in [[cost class] properties]){ .. } for (Method *method in [[c...

Is there a way to introspect an array's size?

In C++ given an array like this: unsigned char bogus1[] = { 0x2e, 0x2e, 0x2e, 0x2e }; Is there a way to introspect bogus1 to find out is is four characters long? ...

How to make Spring accept fluent (non-void) setters?

Hi, I have an API which I am turning into an internal DSL. As such, most methods in my PoJos return a reference to this so that I can chain methods together declaratively as such (syntactic sugar). myComponent .setID("MyId") .setProperty("One") .setProperty2("Two") .setAssociation(anotherComponent) .execute(); My ...

Trying to recognize _NSFaultingMutableSet as member of NSSet

I'm trying to recognize the result of a generic query to a managed object as an NSSet. Currently the class returned is a member of _NSFaultingMutableSet, which is clearly related, but fails the isMemberOf:[NSSet class] and isKindOf:[NSSet class] calls. Given that Cocoa doesn't do a direct implementation of NSSet, it's not surprising th...

How to find hidden properties/methods in Javascript objects?

I would like to automatically determine all of the properties (including the hidden ones) in a given Javascript object, via a generalization of this function: function keys(obj) { var ll = []; for(var pp in obj) { ll.push(pp); } return ll; } This works for user defined objects but fails for many builtins: re...

Python Code Introspection and Analysis

Hi, I am trying to write a Python code analyzer, and I am trying to avoid having to parse bare Python text files. I was hoping that once the Python compiler/interpreter parses the code there's a way to get to the object code or parse tree from within a running Python program. Is there anyway to do this? Thank you ...

Flex: How do you list private attributes of a class?

Hi, I try to serialize objects with their private attributes, in Flex. The introspection API does not seem to allow it: "The describeType() method returns only public members. The method does not return private members of the caller's superclass or any other class where the caller is not an instance." Is there another way for an insta...

How to generate GIR files from the Vala compiler?

I am trying to create python bindings to a vala library using pygi with gobject introspection. However, I am having trouble generating the GIR files (that I am planning to compile to typelib files subsequently). According to the documentation valac should support generating GIR files. Compiling the following helloworld.vala public s...

get object from a method in as3

Hi, Is there a way to know from which object a method (a Function object) came from? tx ...

SQL request to list all databases in an instance of Sql-Server ?

Hello, Is there a way to list all of the existing databases in an instance of Sql Server via a SQL request ? More generally can I use SQL to fully read the schema of the databases (tables, columns, ..) ? Thank you Jerome Wagner ...

How to load an arbitrary java .class file from the filesystem and reflect on it?

I want to make a command-line utility that does some operations based on reflection of external class files. I would pass in a path to .class files or source files(possibly wildcards). At some point during the execution, I need to get Class objects for each class, not knowing their package names beforehand. What would it take to do th...

javascript namespace as string

I have the following namespace (com.myCompany.myProject): var com = { myCompany: { myProject: { x: 1, y: 2, o: function() { } } } }; For example, I have the following code: var self = com.myCompany.myProject; How can I show this namespace as a string, e.g. "com.myCompany.myProject" ? I've tried ...

Retrieveing the Query that Created a Doctrine_Collection

I have a Doctrine_Collection object that was created with code that looks something like. $collection = Doctrine_Query::create() ->from('FooBazBar') ->where('widget_id = ?',$some_var) ->execute(); Short of writing it down somewhere, is it possible to to retrieve the where clause that was used to create the collection? That is, I want...