Re: Passing C Style Function Callbacks in Cocoa
Re: Passing C Style Function Callbacks in Cocoa
- Subject: Re: Passing C Style Function Callbacks in Cocoa
- From: Allan Odgaard <email@hidden>
- Date: Fri, 5 Mar 2004 23:55:23 +0100
On 5. Mar 2004, at 23:13, Dustin Voss wrote:
The objc_msgSend function seems to return ints, BOOLs, etc. as an id.
I must confess I don't know how that works to return floating-point
values or long longs, since they don't fit into an id-sized register.
From objc-runtime.h:
* [...] The portable, correct way to call these functions
* is to cast them to your desired return type first.
*
* For example, `NSRect result = [myNSView frame]` could be written as:
* NSRect (*msgSend_stret_fn)(id, SEL, ...) = (NSRect(*)(id, SEL,
...))objc_msgSend_stret;
* NSRect result = (*msgSend_stret_fn)(myNSView, @selector(frame));
* or, without the function pointer:
* NSRect result = (*(NSRect(*)(id, SEL,
...))objc_msgSend_stret)(myNSView, @selector(frame));
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.