|
|
|
|
|
by favorited
3120 days ago
|
|
It's really the functionality of a method taking an unspecified number of arguments and jumping directly to the implementation's function pointer. Though, now that you mention it, there's really no reason you need to do that. You could have your own calling convention where arguments aren't passed in registers or on the stack, but are boxed into some container. That way every method's implementation function could have the same signature, taking a pointer to the receiver ("self"), the method name, a box of arguments, and a place to pass the return value back out: typedef void (*IMP)(id, SEL, struct context *, void **); // arguments are `self`, the method name (`const char *`), a pointer to a structure containing the arguments, and a place to put your return value
I know of at least one Objective-C runtime implementation that does this. It won't be nearly as efficient – you have to pack/unpack the arguments, it pushes a stack frame instead of just jumping to the implementation, etc. – but it would certainly be portable. |
|