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 11, 2005, at 5:49 AM, Patrick Beard wrote:

Adding this variant works just fine:

    /* Plain msgSend */
    u.f = ((float (*) (id, SEL, float))objc_msgSend)(nc, sel, u.f);
    printf( "objc_msgSend: float u.f = %f\n", u.f );

Got float: 123.449997
objc_msgSend: float u.f = 124.449997

Of course, but the point is I'm trying to do it without having the method type at compile-time.


If I change your margs set up code to the following, I get the expected result:

/* Set up the marg_list */
. . .
((double*)margs)[0] = u.f;

As Greg said, go read objc-msg-ppc.s to understand why. The relevant comment describes the true layout of margs, which has an array of 13 doubles at the beginning, which are animage of the floating point parameter registers that must be set. In this case, the float parameter x is supposed to be in fp0.

Right. As I said, I've seen the marg_list layout in objc-msg-ppc.s and I do understand how it works. Like Sherm, I'm just a little puzzled why the marg_* macros aren't designed to take care of this. It's just confusing when a documented solution doesn't work on something as pervasive as floats and there's no mention of it in the docs. I guess it's not Apple's problem when I want do weird things like try to write Cocoa programs in OCaml. ;^) Still, just a *little* more information on how to do this properly would go a long way in helping people who want to access objective-c efficiently from other languages (including C, I might add).


Cheers,
-n8

--
>>>-- 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>)
 >Re: Sending floats using objc_msgSendv (From: Sherm Pendley <email@hidden>)
 >Re: Sending floats using objc_msgSendv (From: Nathaniel Gray <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.