Go to the first, previous, next, last section, table of contents.


Porting NSInvocation

The NSInvocation is highly dependent on the target machine. The code that depends on the target machine is carefully separated from the independent part of the class. This code is written as macros in the `config/processor/operating-system'.

NSInvocation is implemented using the __builtin_apply and __builtin_return built-in pseudo-functions that are available in the GNU C compiler. See the GNU C compiler documentation of these functions.

The following macros have to be defined for a given target machine. Defining them is a though process, they closely follow the native convention calls defined for the target in the GCC target dependent files. We intend to take advantage of the knowledge that's already in the compiler and move the NSInvocation's code into the Objective-C runtime library.

In addition, if the target system does not work as expected copying the arguments onto and from the __builtin_apply's frame, you can define in addition the FRAME_SET_ARGUMENT and FRAME_GET_ARGUMENT macros.

FUNCTION_VALUE should copy the return value from the result frame returned by the __builtin_apply pseudo-function into a memory zone received as argument. This macro has the following arguments:

FUNCTION_SET_VALUE should set the return value into the result frame returned by the __builtin_apply. It has the following arguments:

GET_STRUCT_VALUE_ADDRESS is an expression that should produce the return value address in the case this is returned by reference or NULL if the return value is not returned by reference. Usually only the aggregates (structures and unions) are returned by reference. This macro has the following arguments:

SET_STRUCT_VALUE_ADDRESS should set in the arguments frame that will be passed to __builtin_apply the address of the return value if this is returned by reference. The arguments are:

FRAME_SET_ARGUMENT should be used whenever the default mechanism of copying the argument onto the __builtin_apply's frame is not working. The default mechanism is implemented in the NSInvocation's -setArgument:atIndex: method. If you do not define this macro the default mechanism is used.

The arguments of this macro are:

The FRAME_GET_ARGUMENT macros is similar with FRAME_SET_ARGUMENT but does the opposite job.

For an example of how the above macros are implemented you can take a look in the `config' directory in the libFoundation's distribution.


Go to the first, previous, next, last section, table of contents.