On Mar 30, 2010, at 2:54 PM, Michael Ash wrote:
>> I see, I really wasn't enough clear. Lets say, I have a method
>> 
>> - someMethodWithArgument:(struct *)anArgument 
>> andSomeOtherArgument:(id)anotherArgument
>> {
>>        // Here I want to create an NSInvocation, capturing the call of this 
>> method. Something like:
>>        NSInvocation *anInvocation = [NSInvocation initWithArgframe: 
>> (arglist_t)frame selector: _cmd];
>> }
> I don't think that such a thing is possible in the general case
> without compiler support, because once your function begins executing,
> there's no guarantee that the arguments remain in their original
> locations on the stack frame. (Especially true on PPC and x86_64,
> where arguments are frequently passed in registers.) And no such
> compiler support exists.
> 
> I'd say that your best bet is probably to do some fancy method
> replacement stuff so that your IMP gets replaced with the forwarding
> IMP, then your -forwardInvocation: method can store the invocation
> somewhere and then pass control over to the real method, where it can
> retrieve it.


Another alternative would be to combine method_getNumberOfArguments() and 
method_copyArgumentType() with ffi_prep_cif() and ffi_call(), which I think is 
what libobjc itself does these days. libffi is available since at least 10.5. 
Pass the method's IMP to ffi_call() and don't forget to adjust the call to 
ffi_prep_cif() for the hidden self and _cmd arguments. libffi is available at 
least since 10.5.

-- Gwynne

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to