[Mono-list] float p/invoke
Robert Jordan
robertj at gmx.net
Thu Nov 9 16:58:31 EST 2006
Andreas Färber wrote:
> Hello,
>
> I'm facing a weird marshalling issue...
>
> The Objective-C runtime on OS X exposes a method:
>
> id objc_msgSend(id, SEL, ...); // with id and SEL pointers
>
> I marshal it as IntPtr objc_msgSend(IntPtr, IntPtr, ...) using an SRE
> p/invoke method factory.
>
> This has worked fine so far, but now I noticed some marshalling
> problems. The method's semantic return value is not always a pointer
> but is apparently also used for int, unsigned int - which works fine
> through IntPtr casting, but not for float. To my understanding float
> is single-precision floating point number, thus 32 bits or 4 bytes
> wide and identical to IntPtr.Size in a 32-bit environment.
Floating point results are not returned the same way
as scalar results. For example, the x86 ABI returns
scalars in the EAX register, while floats are returned
in a FPU register => it's impossible to marshal them using
an IntPtr result type.
Robert
More information about the Mono-list
mailing list