Does register_callback_handler()the context argument use (void *)? Most callback APIs do.
If so, then you can easily use NSInvocation. Or you can select a small structure that contains a reference to an object and a selector, and then select its own call.
If it takes only a function pointer, then you will potentially be pushing. You need something somewhere that uniquely identifies the context, even for pure C coding.
Given that your callback handler has a context pointer, you are all set up:
typedef struct {
id target;
SEL selector;
id someContextualSensitiveThing;
} TrampolineData;
void trampoline(void *freedata) {
TrampolineData *trampData = freedata;
[trampData->target performSelector: trampData->selector withObject: trampData-> someContextualSensitiveThing];
}
...
TrampolineData *td = malloc(sizeof(TrampolineData));
... fill in the struct here ...
register_callback_handler(..., trampoline, td);
. / , , . - objc_msgSend() , ( , objc_msgSend_stret()).