Re: Monitoring class loading
Re: Monitoring class loading
- Subject: Re: Monitoring class loading
- From: email@hidden (Andrew Demkin)
- Date: Mon, 19 Aug 2002 10:43:55 -0700
At 1:34 PM 8/19/02, John Hvrnkvist wrote:
>
On Monday, August 19, 2002, at 03:56 AM, Andrew Demkin wrote:
>
>
> The compiler and runtime use a different mechanism for messages that return
>
> structures. Rather than objc_msgSend, they use objc_msgSend_stret.
>
>
>
> In order to determine which mechanism to use (or what the actual return
>
> type is), you'd probably have to parse @interface declarations as I don't
>
> think return types are encoded in any runtime structures.
>
>
>
>
I think it's in the method signature.
>
>
struct retval {int i; int j; int k;};
>
>
- (struct retval)myMethod
>
{
>
}
>
>
NSMethodSignature: types={_retval=iii}@: nargs=2 sizeOfParams=160
>
returnValueLength=12;
>
>
Look at /usr/include/objc/objc-class.h.
>
>
Regards,
>
John Hornkvist
My apologies... In the objc runtime I forgot that the method return type is
encoded as the first entry in the list of method argument types. Thanks for
correcting me.
The problem I was thinking about was that there's not always an inverse
function to go from the runtime type encoding information back to the
original source code. Object types are usually okay, but typedefs such as
BOOL will be encoded as 'char'. This may not be important for your tool,
but this was the issue I was thinking about when I wrote that you might
need to parse @interface declarations.
Curiously, the Obj-C runtime documentation from Apple has the following to
say about method type encodings:
Special Considerations
The compiler generates the method type encodings in a format that
includes information on the size of the stack and the size occupied
by the arguments. These numbers appear after each encoding in the
method_types string. However, because the compiler historically
generates them incorrectly, and because they differ depending on
the CPU type, the runtime ignores them if they are present.
These numbers are not required by the Objective-C runtime in Mac
OS X 10.0 or later versions.
I'm not sure what we can conclude from the above "warning" (e.g. type
encodings may not be present or may be incorrect?), but perhaps someone on
this list can clarify.
Andrew.
_______________________________________________
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.