2 * Copyright (c) 1999-2007 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
25 #import <objc/runtime.h>
30 #if !defined(__cplusplus) && !__OBJC2__
31 Class
class; /* For compatibility with old objc-runtime.h header */
35 /* super_class is the first class to search */
39 /* Basic Messaging Primitives
41 * On some architectures, use objc_msgSend_stret for some struct return types.
42 * On some architectures, use objc_msgSend_fpret for some float return types.
44 * These functions must be cast to an appropriate function pointer type
45 * before being called.
47 OBJC_EXPORT id
objc_msgSend(id self
, SEL op
, ...);
48 OBJC_EXPORT id
objc_msgSendSuper(struct objc_super
*super
, SEL op
, ...);
51 /* Struct-returning Messaging Primitives
53 * Use these functions to call methods that return structs on the stack.
54 * On some architectures, some structures are returned in registers.
55 * Consult your local function call ABI documentation for details.
57 * These functions must be cast to an appropriate function pointer type
58 * before being called.
60 #if defined(__OBJC2__)
61 OBJC_EXPORT
void objc_msgSend_stret(id self
, SEL op
, ...);
62 OBJC_EXPORT
void objc_msgSendSuper_stret(struct objc_super
*super
, SEL op
, ...);
63 #elif defined(__cplusplus)
64 /* For compatibility with old objc-runtime.h header */
65 OBJC_EXPORT id
objc_msgSend_stret(id self
, SEL op
, ...);
66 OBJC_EXPORT id
objc_msgSendSuper_stret(struct objc_super
*super
, SEL op
, ...);
68 /* For compatibility with old objc-runtime.h header */
69 OBJC_EXPORT
void objc_msgSend_stret(void * stretAddr
, id self
, SEL op
, ...);
70 OBJC_EXPORT
void objc_msgSendSuper_stret(void * stretAddr
, struct objc_super
*super
, SEL op
, ...);
74 /* Floating-point-returning Messaging Primitives
76 * Use these functions to call methods that return floating-point values
78 * Consult your local function call ABI documentation for details.
80 * ppc: objc_msgSend_fpret not used
81 * ppc64: objc_msgSend_fpret not used
82 * i386: objc_msgSend_fpret used for `float`, `double`, `long double`.
83 * x86-64: objc_msgSend_fpret used for `long double`.
85 * These functions must be cast to an appropriate function pointer type
86 * before being called.
89 OBJC_EXPORT
double objc_msgSend_fpret(id self
, SEL op
, ...);
90 /* Use objc_msgSendSuper() for fp-returning messages to super. */
91 /* See also objc_msgSendv_fpret() below. */
92 #elif defined(__x86_64__)
93 OBJC_EXPORT
long double objc_msgSend_fpret(id self
, SEL op
, ...);
94 /* Use objc_msgSendSuper() for fp-returning messages to super. */
95 /* See also objc_msgSendv_fpret() below. */
99 /* Direct Method Invocation Primitives
100 * Use these functions to call the implementation of a given Method.
101 * This is faster than calling method_getImplementation() and method_getName().
103 * The receiver must not be nil.
105 * These functions must be cast to an appropriate function pointer type
106 * before being called.
108 OBJC_EXPORT id
method_invoke(id receiver
, Method m
, ...)
109 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
;
110 OBJC_EXPORT
void method_invoke_stret(id receiver
, Method m
, ...)
111 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
;
114 /* Variable-argument Messaging Primitives
116 * Use these functions to call methods with a list of arguments, such
117 * as the one passed to forward:: .
119 * The contents of the argument list are architecture-specific.
120 * Consult your local function call ABI documentation for details.
122 * These functions must be cast to an appropriate function pointer type
123 * before being called, except for objc_msgSendv_stret() which must not
124 * be cast to a struct-returning type.
127 typedef void* marg_list
;
129 OBJC_EXPORT id
objc_msgSendv(id self
, SEL op
, size_t arg_size
, marg_list arg_frame
) OBJC2_UNAVAILABLE
;
130 OBJC_EXPORT
void objc_msgSendv_stret(void *stretAddr
, id self
, SEL op
, size_t arg_size
, marg_list arg_frame
) OBJC2_UNAVAILABLE
;
131 /* Note that objc_msgSendv_stret() does not return a structure type,
132 * and should not be cast to do so. This is unlike objc_msgSend_stret()
133 * and objc_msgSendSuper_stret().
135 #if defined(__i386__)
136 OBJC_EXPORT
double objc_msgSendv_fpret(id self
, SEL op
, unsigned arg_size
, marg_list arg_frame
) OBJC2_UNAVAILABLE
;
140 /* The following marg_list macros are of marginal utility. They
141 * are included for compatibility with the old objc-class.h header. */
145 #if defined(__ppc__) || defined(ppc)
146 #define marg_prearg_size (13*sizeof(double)+6*sizeof(uintptr_t))
148 #define marg_prearg_size 0
151 #define marg_malloc(margs, method) \
153 margs = (marg_list *)malloc (marg_prearg_size + ((7 + method_getSizeOfArguments(method)) & ~7)); \
156 #define marg_free(margs) \
161 #define marg_adjustedOffset(method, offset) \
162 (marg_prearg_size + offset)
164 #define marg_getRef(margs, offset, type) \
165 ( (type *)((char *)margs + marg_adjustedOffset(method,offset) ) )
167 #define marg_getValue(margs, offset, type) \
168 ( *marg_getRef(margs, offset, type) )
170 #define marg_setValue(margs, offset, type, value) \
171 ( marg_getValue(margs, offset, type) = (value) )