The dynamic method call

Frank Benoit (keinfarbton) benoit at tionex.removethispart.de
Wed Feb 21 16:52:17 PST 2007


A function or method with a signature known at runtime shall be called.

What I need is code, that pushes the arguments on the stack, calls the
method and gets the return value.
Is asm needed?

Code:
union value{
 // some primite types bool, byte, .... long
}
//...
int CallIntMethod (void* obj, void* method, ...);
int CallIntMethodV(void* obj, void* method, va_list args);
int CallIntMethodA(void* obj, void* method, value *args);

long CallLongMethod(void* obj, void* method, ...);
long CallLongMethodV(void* obj, void* method, va_list args);
long CallLongMethodA(void* obj, void* method, value *args);

// ...
// more methods with the other return types


* obj is a void* ptr to the object
* method is the function ptr to the method

I am able to retrieve the methods signature with obj and method.
In this case the return type is known for each prototype.

Any hint for a implementation?




More information about the Digitalmars-d mailing list