4 ** $VER: BoopsiStubs.h 1.2 (1.9.97)
6 ** Copyright (C) 1997 Bernardo Innocenti. All rights reserved.
8 ** Use 4 chars wide TABs to read this file
10 ** Using these inline versions of the amiga.lib boopsi support functions
11 ** results in faster and smaller code against their linked library
12 ** counterparts. When debug is active, these functions will also
13 ** validate the parameters you pass in.
17 #ifndef COMPILERSPECIFIC_H
18 #include "CompilerSpecific.h"
19 #endif /* COMPILERSPECIFIC_H */
25 /* This definition will prevent the redefinition of the following stubs with
26 * their amiga.lib equivalents. This only works if you are using a patched
27 * version of <clib/alib_protos.h>
29 #define USE_BOOPSI_STUBS
33 /* the _HookPtr type is a shortcut for a pointer to a hook function */
35 typedef ASMCALL ULONG (*_HookPtr)
36 (REG(a0, Class *), REG(a2, Object *), REG(a1, APTR));
38 INLINE ULONG CoerceMethodA (struct IClass *cl, Object *o, Msg message)
43 return ((_HookPtr)cl->cl_Dispatcher.h_Entry) ((APTR)cl, (APTR)o, (APTR)message);
46 INLINE ULONG DoSuperMethodA (struct IClass *cl, Object *o, Msg message)
52 return ((_HookPtr)cl->cl_Dispatcher.h_Entry) ((APTR)cl, (APTR)o, (APTR)message);
55 INLINE ULONG DoMethodA (Object *o, Msg message)
62 return ((_HookPtr)cl->cl_Dispatcher.h_Entry) ((APTR)cl, (APTR)o, (APTR)message);
67 /* Var-args versions of the above functions. SAS/C is clever enough to inline these,
68 * while gcc and egcs refuse to inline a function with '...' (yikes!). The GCC
69 * versions of these functions are macro blocks similar to those used in the
70 * inline/#?.h headers.
72 #if defined(__SASC) || defined (__STORM__)
74 INLINE ULONG CoerceMethod (struct IClass *cl, Object *o, ULONG MethodID, ...)
79 return ((_HookPtr)cl->cl_Dispatcher.h_Entry) ((APTR)cl, (APTR)o, (APTR)&MethodID);
82 INLINE ULONG DoSuperMethod (struct IClass *cl, Object *o, ULONG MethodID, ...)
88 return ((_HookPtr)cl->cl_Dispatcher.h_Entry) ((APTR)cl, (APTR)o, (APTR)&MethodID);
91 INLINE ULONG DoMethod (Object *o, ULONG MethodID, ...)
99 return ((_HookPtr)cl->cl_Dispatcher.h_Entry) ((APTR)cl, (APTR)o, (APTR)&MethodID);
102 /* varargs stub for the OM_NOTIFY method */
103 INLINE void NotifyAttrs (Object *o, struct GadgetInfo *gi, ULONG flags, Tag attr1, ...)
108 DoMethod (o, OM_NOTIFY, &attr1, gi, flags);
111 /* varargs stub for the OM_UPDATE method */
112 INLINE void UpdateAttrs (Object *o, struct GadgetInfo *gi, ULONG flags, Tag attr1, ...)
117 DoMethod (o, OM_UPDATE, &attr1, gi, flags);
120 #elif defined(__GNUC__)
122 #define CoerceMethod(cl, o, msg...) \
124 ULONG _msg[] = { msg }; \
125 ASSERT_VALIDNO0(cl) \
127 ((_HookPtr)cl->cl_Dispatcher.h_Entry) ((APTR)cl, (APTR)o, (APTR)_msg); \
130 #define DoSuperMethod(cl, o, msg...) \
133 ULONG _msg[] = { msg }; \
135 ASSERT_VALIDNO0(cl) \
136 _cl = cl = cl->cl_Super; \
137 ASSERT_VALIDNO0(_cl) \
138 ((_HookPtr)_cl->cl_Dispatcher.h_Entry) ((APTR)_cl, (APTR)o, (APTR)_msg); \
141 #define DoMethod(o, msg...) \
144 ULONG _msg[] = { msg }; \
147 ASSERT_VALIDNO0(_cl) \
148 ((_HookPtr)_cl->cl_Dispatcher.h_Entry) ((APTR)_cl, (APTR)o, (APTR)_msg); \
151 /* Var-args stub for the OM_NOTIFY method */
152 #define NotifyAttrs(o, gi, flags, attrs...) \
155 ULONG _attrs[] = { attrs }; \
156 ULONG _msg[] = { OM_NOTIFY, (ULONG)_attrs, (ULONG)gi, flags }; \
159 ASSERT_VALIDNO0(_cl) \
161 ((_HookPtr)_cl->cl_Dispatcher.h_Entry) ((APTR)_cl, (APTR)o, (APTR)_msg); \
164 /* Var-args stub for the OM_UPDATE method */
165 #define UpdateAttrs(o, gi, flags, attrs...) \
168 ULONG _attrs[] = { attrs }; \
169 ULONG _msg[] = { OM_UPDATE, (ULONG)_attrs, (ULONG)gi, flags }; \
172 ASSERT_VALIDNO0(_cl) \
174 ((_HookPtr)_cl->cl_Dispatcher.h_Entry) ((APTR)_cl, (APTR)o, (APTR)_msg); \
178 /* Nobody else needs this anymore... */
181 #endif /* !BOOPSISTUBS_H */