• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Which flavor of objc_msgSend for NSSize return
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Which flavor of objc_msgSend for NSSize return


  • Subject: Re: Which flavor of objc_msgSend for NSSize return
  • From: Sherm Pendley <email@hidden>
  • Date: Fri, 11 May 2007 21:28:39 -0400

When I call objc_msgSend_stret() in CamelBones, I call it as documented in the runtime reference, returning the struct by reference in the first argument. It's much simpler, with no need for the typecast. Does this variation work for you?

Yes, I'm aware of the note regarding typecasting in objc-runtime.h; IMHO, the runtime reference docs are the official last word, and take precedence over a cryptic comment buried in a header file. That comment has been there for at least six years, to my knowledge, and all the while the runtime reference has made no mention of this function being unreliable for future use.

#import <Foundation/Foundation.h>
#import <objc/objc-runtime.h>
@interface Foo : NSObject {} @end
@implementation Foo
+ (NSPoint)point { return NSMakePoint(1, 2); }
@end

int main(int argc, const char *argv[])
{
[NSAutoreleasePool new];
NSPoint point;
objc_msgSend_stret(&point, [Foo class], @selector(point));
NSLog(@"Point is %@", NSStringFromPoint(point));
return 0;
}

sherm--

On May 11, 2007, at 8:35 PM, Rosyna wrote:

Hmm, it's not passing my test on the ICBM.

#import <Foundation/Foundation.h>
#import <objc/objc-runtime.h>
@interface Foo : NSObject {} @end
@implementation Foo
+ (NSPoint)point { return NSMakePoint(1, 2); }
@end

int main(int argc, const char *argv[])
{
[NSAutoreleasePool new];
NSLog(@"Point is %@", NSStringFromPoint(((NSPoint (*)(id, SEL, ...)) objc_msgSend_stret)([Foo class], @selector(point))));
return 0;
}


[stability-drive:~/Desktop] rosyna% gcc -framework Foundation donkey.m
[stability-drive:~/Desktop] rosyna% ./a.out
Segmentation fault


Changing objc_msgSend_stret to objc_msgSend works without crashing, however.


Ack, at 5/11/07, Sherm Pendley said:

The runtime reference simply says to call _stret for all structure return types - it doesn't distinguish between struct sizes. I followed that rule for CamelBones, and it passes all its self- tests on i386, as well as running every app I've tried without fail.

--


Sincerely, Rosyna Keller Technical Support/Carbon troll/Always needs a hug

Unsanity: Unsane Tools for Insanely Great People

It's either this, or imagining Phil Schiller in a thong.

Web Hosting by West Virginians, for West Virginians: http://wv-www.net Cocoa programming in Perl: http://camelbones.sourceforge.net


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Which flavor of objc_msgSend for NSSize return
      • From: Rosyna <email@hidden>
References: 
 >Which flavor of objc_msgSend for NSSize return (From: Rosyna <email@hidden>)
 >Re: Which flavor of objc_msgSend for NSSize return (From: Sherm Pendley <email@hidden>)
 >Re: Which flavor of objc_msgSend for NSSize return (From: Rosyna <email@hidden>)
 >Re: Which flavor of objc_msgSend for NSSize return (From: Sherm Pendley <email@hidden>)
 >Re: Which flavor of objc_msgSend for NSSize return (From: Rosyna <email@hidden>)

  • Prev by Date: Re: Which flavor of objc_msgSend for NSSize return
  • Next by Date: Re: Which flavor of objc_msgSend for NSSize return
  • Previous by thread: Re: Which flavor of objc_msgSend for NSSize return
  • Next by thread: Re: Which flavor of objc_msgSend for NSSize return
  • Index(es):
    • Date
    • Thread