gcc: Method signatures

1 
1 8.3.3 Method Signatures
1 -----------------------
1 
1 This section documents the encoding of method types, which is rarely
1 needed to use Objective-C. You should skip it at a first reading; the
1 runtime provides functions that will work on methods and can walk
1 through the list of parameters and interpret them for you.  These
1 functions are part of the public "API" and are the preferred way to
1 interact with method signatures from user code.
1 
1  But if you need to debug a problem with method signatures and need to
1 know how they are implemented (i.e., the "ABI"), read on.
1 
1  Methods have their "signature" encoded and made available to the
1 runtime.  The "signature" encodes all the information required to
1 dynamically build invocations of the method at runtime: return type and
1 arguments.
1 
1  The "signature" is a null-terminated string, composed of the following:
1 
1    * The return type, including type qualifiers.  For example, a method
1      returning 'int' would have 'i' here.
1 
1    * The total size (in bytes) required to pass all the parameters.
1      This includes the two hidden parameters (the object 'self' and the
1      method selector '_cmd').
1 
1    * Each argument, with the type encoding, followed by the offset (in
1      bytes) of the argument in the list of parameters.
1 
1  For example, a method with no arguments and returning 'int' would have
1 the signature 'i8@0:4' if the size of a pointer is 4.  The signature is
1 interpreted as follows: the 'i' is the return type (an 'int'), the '8'
1 is the total size of the parameters in bytes (two pointers each of size
1 4), the '@0' is the first parameter (an object at byte offset '0') and
1 ':4' is the second parameter (a 'SEL' at byte offset '4').
1 
1  You can easily find more examples by running the "strings" program on
1 an Objective-C object file compiled by GCC. You'll see a lot of strings
1 that look very much like 'i8@0:4'.  They are signatures of Objective-C
1 methods.
1