• 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: Monitoring class loading
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Monitoring class loading


  • Subject: Re: Monitoring class loading
  • From: Kyle Moffett <email@hidden>
  • Date: Mon, 19 Aug 2002 15:56:52 -0400

I figured out how to do this:

I add the argument '-x objective-c' to the list of CFLAGS, so that my code
is compiled as objective-c, and I can use Obj-C declarations, messages,
etc. in the code.

I add Obj-C method calls to use NSInvocation, etc.

Done!!!

Yay, I've almost got it!!!

P.S. This will be sluggish. Is the source for NSInvocation available?

Thanks,
Kyle Moffett

On Monday, August 19, 2002, at 01:43 PM, Andrew Demkin wrote:
At 1:34 PM 8/19/02, John Hvrnkvist wrote:
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.

References: 
 >Re: Monitoring class loading (From: email@hidden (Andrew Demkin))

  • Prev by Date: Re: Store window size and location
  • Next by Date: Re: NSPopUpButton addItemsWithTitles is way slow [solved - sort of]
  • Previous by thread: Re: Monitoring class loading
  • Next by thread: Looking for ideas about displaying unkown-type data
  • Index(es):
    • Date
    • Thread