Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sending floats using objc_msgSendv



On Aug 10, 2005, at 6:32 PM, Greg Parker wrote:

On Aug 10, 2005, at 6:02 PM, Nathaniel Gray wrote:

Is there any way to send float or double arguments to a method designated at runtime? I've tried using objc_msgSendv, casting it in various ways, and using -performv::, but nothing works.


Using objc_msgSendv() properly requires knowledge of your platform's ABI. In particular, floating-point values must be stored in a special place in the marg_list on PowerPC. objc-msg-ppc.s notes some of the details.

I saw this comment, but it doesn't jive with the offsets I get when I use the marg_* macros:


* ... So the "marg_list" is actually:
*
* typedef struct objc_sendv_margs {
*    double        floatingPointArgs[13];
*    int        linkageArea[6];
*    int        registerArgs[8];
*    int        stackArgs[variable];
* };

The offsets from method_getArgumentInfo() just start at 0. This suggests I should be using marg_adjustedOffset(), but if so I don't understand why things don't break for integer arguments when I use offsets from zero... :-/

Better options may be:
* using NSInvocation. It shields you from the ABI details.

I noticed NSInvocation but it seemed like quite a heavyweight solution. I count 5+n messages for an n-argument method call. It does appear to work, however, and I suppose that counts for something. ;^) Actually, I haven't timed anything yet so I can't say how that compares to an objc_msgSendv solution.


* using objc_msgSend() or objc_msgSend_stret() directly. Cast objc_msgSend() to a function pointer type that matches your method's signature, then make the call.

No-can-do. I don't know the method's signature at compile time.

Thanks a lot for your help!
-n8

PS: Please CC me with any replies.

--
>>>-- Nathaniel Gray -- Caltech Computer Science ------>
>>>-- Mojave Project -- http://mojave.cs.caltech.edu -->


_______________________________________________ Do not post admin requests to the list. They will be ignored. Objc-language mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/objc-language/email@hidden

This email sent to email@hidden
References: 
 >Sending floats using objc_msgSendv (From: Nathaniel Gray <email@hidden>)
 >Re: Sending floats using objc_msgSendv (From: Greg Parker <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.