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.
FUNCTION_VALUE
FUNCTION_SET_VALUE
GET_STRUCT_VALUE_ADDRESS
SET_STRUCT_VALUE_ADDRESS
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:
TYPE (char*): the Objective-C encoding of the return value
type
ARGS (void*): the arguments frame passed to
__builtin_apply
RESULT_FRAME (void*): the result frame returned by
__builtin_apply
RETURN_VALUE (void*): the memory zone where the value
should be set. This zone is already allocated.
FUNCTION_SET_VALUE should set the return value into the result
frame returned by the __builtin_apply. It has the following
arguments:
TYPE (char*): the Objective-C encoding of the return value
type
ARGS (void*): the arguments frame passed to
__builtin_apply
RESULT_FRAME (void*): the result frame returned by
__builtin_apply
RETURN_VALUE (void*): the memory zone where the returned
value should be copied from.
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:
ARGS (void*): the arguments frame passed to
__builtin_apply. Usually the address of return value is set here
by the __builtin_apply_args pseudo-function
RETTYPE (char*): the Objective-C encoding of the return
value type.
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:
ARGS (void*): the arguments frame that will be passed to
__builtin_apply
ADDR (void*): the address of the zone where the called
function should set the return value. This zone is already allocated.
RETTYPE (char*): the Objective-C encoding of the return
value type
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:
FRAME_DATA (void*): The address in the
__builtin_apply's frame where the argument's value has to be copied.
ARGUMENT_LOCATION (void*): The address where the argument
to be copied is located.
ARG_INFO (NSArgumentInfo): Describes the type of the
argument.
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.