How do I loop over all the methods of a class in Perl?
How do you loop over all the methods of a class in Perl? Are there any good online references to Perl introspection or reflection? ...
How do you loop over all the methods of a class in Perl? Are there any good online references to Perl introspection or reflection? ...
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. Finally I'll form a string representation of the POJO. I could use ToStringBuilder, but I wa...
I've a Java object 'ChildObj' which is extended from 'ParentObj'. Now, if it is possible to retrieve all the attribute names and values of ChildObj, including the inherited attributes too, using Java reflection mechanism? Class.getFields gives me the array of public attributes, and Class.getDeclaredFields gives me the array of all field...
Is it possible to retrieve the names of all procedures and functions that reside within a particular package? I understand that they can be gleaned (smells hack-ish) from the ALL_SOURCE view, but I would prefer a more canonical strategy. ...
I am receiving an exception when I try to use the introspection engine: Could not load file or assembly 'Microsoft.Cci, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. An attempt was made to load a program with an incorrect format. Anyone got this exception? ...
My Java is rusty so please bear with me. In C I can do: int someFunc(void) { printf("I'm in %s\n", __func__); } In Java, can I lexically get to the name or class of the type currently being defined. For example, if I have: import org.apache.log4j.Logger; class myClass { private static final Logger logger = Logger.getLogger(m...
Suppose myapp/foo.py contains: def info(msg): caller_name = ???? print '[%s] %s' % (caller_name, msg) And myapp/bar.py contains: import foo foo.info('Hello') # => [myapp.foo] Hello I want caller_name to be set to the __name__ attribute of the calling functions' module (which is 'myapp.foo') in this case. How can this be don...
Example: >>> try: ... myapp.foo.doSomething() ... except Exception, e: ... print 'Thrown from:', modname(e) Thrown from: myapp.util.url In the above example, the exception was actually thrown at myapp/util/url.py module. Is there a way to get the __name__ of that module? My intention is to use this in logging.getLogger functio...
Ok I know you can use the dir() method to list everything in a module, but is there any way to see only the functions that are defined in that module? For example, assume my module looks like this: from datetime import date, datetime def test(): return "This is a real method" Even if i use inspect() to filter out the builtins, I...
Objective-C uses a sophisticated message-passing system when one object calls a method on another object. I want to know if it is possible, within the called method, to determine what the calling object was? For example: @implementation callingClass - (void)performTest { calledObject = [[[calledClass alloc] init] autorelease]; ...
A colleague asked me an interesting question today - is the C# keyword/operator "is" considered reflection? object tmp = "a string"; if(tmp is String) { } How is this operator implemented behind the scenes? Does it require reflection or introspection? Or because of the strongly typed nature of the language, is the Type of the object ...
I have came up with this: [a for a in dir(__builtins__) if str(type(getattr(__builtins__,a))) == "<type 'builtin_function_or_method'>"] I know its ugly. Can you show me a better/more pythonic way of doing this? ...
How do i get all classes within a package? ...
An easy question I guess, but in the documentation of the Type class they only talk of interfaces on the GetInterfaces method. i.e. typeof(ChildClass).XXX(typeof(ParentClass) ...
Suppose I have two Oracle databases. We'll call them database A and database B. Now suppose I have a table in database A that's defined like this: CREATE TABLE foo ( foo_id INT PRIMARY KEY, some_text VARCHAR2(10), other_table_id INT CONSTRAINT some_fk_constraint FOREIGN KEY (other_table_id) REFERENCES ...
I would like to trace out all messages sent by the Objective-C runtime to a particular class, say UITableView (or a particular instance) so I can better understand the inner workings of some classes. Is there a way to do this? Another use case is to trace out all delegate methods that are being called (say UITableViewDelegate methods) ...
I am trying to iterate through each of the members of an object. For each member, I check to see if it is a function or not. If it is a function, I want to get the name of it and perform some logic based on the name of the function. I don't know if this is even possible though. Is it? Any tips? example: var mems: Object = getMembe...
If I have a class, how can I list all its instance variable names? eg: @interface MyClass : NSObject { int myInt; NSString* myString; NSMutableArray* myArray; } I would like to get "myInt", "myString", and "myArray". Is there some way to perhaps get an array of names that I can iterate over? I've tried searching the Obj...
I have an object that has several properties. If I have a pointer to one of those properties, is it possible to get a pointer to the class instance to which that ivar belongs? for example: foo.bar, where I know the address of bar, can the address of foo be found? This seems related to: run time references but I didn't see any referen...
Given the function def f(): x, y = 1, 2 def get(): print 'get' def post(): print 'post' is there a way for me to access its local get() and post() functions in a way that I can call them? I'm looking for a function that will work like so with the function f() defined above: >>> get, post = get_local_func...