2 * Copyright (C) 2007-2008, Parrot Foundation.
6 * Parrot class and object header stuff
7 * Data Structure and Algorithms:
13 #ifndef PARROT_OO_H_GUARD
14 #define PARROT_OO_H_GUARD
16 #include "parrot/parrot.h"
19 PCD_PARENTS
, /* An array of immediate parents */
20 PCD_CLASS_NAME
, /* A String PMC */
21 PCD_ATTRIBUTES
, /* class::attrib => offset hash */
22 PCD_CLASS_ATTRIBUTES
, /* Class attribute array */
23 PCD_OBJECT_VTABLE
, /* Vtable PMC that holds the vtable for objects of this class */
25 } PARROT_CLASS_DATA_ENUM
;
29 * The active destroy flag is necessary to free the malloced array.
32 #define get_attrib_num(x, y) ((PMC **)(x))[(y)]
33 #define set_attrib_num(o, x, y, z) \
35 Parrot_gc_write_barrier(interp, (o), ((PMC **)(x))[y], (z)); \
36 ((PMC **)(x))[(y)] = (z); \
43 #define GET_CLASS(obj) (obj)->vtable->pmc_class
45 /* HEADERIZER BEGIN: src/oo.c */
46 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
49 void Parrot_ComposeRole(PARROT_INTERP
,
55 ARGIN(PMC
*methods_hash
),
56 ARGIN(PMC
*roles_list
))
57 __attribute__nonnull__(1)
58 __attribute__nonnull__(2)
59 __attribute__nonnull__(3)
60 __attribute__nonnull__(5)
61 __attribute__nonnull__(7)
62 __attribute__nonnull__(8);
65 PARROT_WARN_UNUSED_RESULT
66 PARROT_CAN_RETURN_NULL
67 PMC
* Parrot_ComputeMRO_C3(PARROT_INTERP
, ARGIN(PMC
*_class
))
68 __attribute__nonnull__(1)
69 __attribute__nonnull__(2);
72 PARROT_CAN_RETURN_NULL
73 PARROT_WARN_UNUSED_RESULT
74 PMC
* Parrot_find_method_direct(PARROT_INTERP
,
76 ARGIN(STRING
*method_name
))
77 __attribute__nonnull__(1)
78 __attribute__nonnull__(2)
79 __attribute__nonnull__(3);
82 PARROT_CAN_RETURN_NULL
83 PARROT_WARN_UNUSED_RESULT
84 PMC
* Parrot_find_method_with_cache(PARROT_INTERP
,
86 ARGIN(STRING
*method_name
))
87 __attribute__nonnull__(1)
88 __attribute__nonnull__(2)
89 __attribute__nonnull__(3);
92 INTVAL
Parrot_get_vtable_index(PARROT_INTERP
, ARGIN(const STRING
*name
))
93 __attribute__nonnull__(1)
94 __attribute__nonnull__(2);
98 PARROT_CAN_RETURN_NULL
99 const char * Parrot_get_vtable_name(SHIM_INTERP
, INTVAL idx
);
102 void Parrot_invalidate_method_cache(PARROT_INTERP
,
103 ARGIN_NULLOK(STRING
*_class
))
104 __attribute__nonnull__(1);
107 PARROT_CAN_RETURN_NULL
108 PARROT_WARN_UNUSED_RESULT
109 PMC
* Parrot_oo_find_vtable_override(PARROT_INTERP
,
110 ARGIN(PMC
*classobj
),
112 __attribute__nonnull__(1)
113 __attribute__nonnull__(2)
114 __attribute__nonnull__(3);
117 PARROT_CAN_RETURN_NULL
118 PARROT_WARN_UNUSED_RESULT
119 PMC
* Parrot_oo_find_vtable_override_for_class(PARROT_INTERP
,
120 ARGIN(PMC
*classobj
),
122 __attribute__nonnull__(1)
123 __attribute__nonnull__(2)
124 __attribute__nonnull__(3);
127 PARROT_CAN_RETURN_NULL
128 PARROT_WARN_UNUSED_RESULT
129 PMC
* Parrot_oo_get_class(PARROT_INTERP
, ARGIN(PMC
*key
))
130 __attribute__nonnull__(1)
131 __attribute__nonnull__(2);
134 PARROT_CAN_RETURN_NULL
135 PARROT_WARN_UNUSED_RESULT
136 PMC
* Parrot_oo_get_class_str(PARROT_INTERP
, ARGIN(STRING
*name
))
137 __attribute__nonnull__(1)
138 __attribute__nonnull__(2);
140 void destroy_object_cache(PARROT_INTERP
)
141 __attribute__nonnull__(1);
143 void init_object_cache(PARROT_INTERP
)
144 __attribute__nonnull__(1);
146 void mark_object_cache(PARROT_INTERP
)
147 __attribute__nonnull__(1);
149 PARROT_CANNOT_RETURN_NULL
150 PMC
* Parrot_oo_clone_object(PARROT_INTERP
,
152 ARGMOD_NULLOK(PMC
*class_
),
153 ARGMOD_NULLOK(PMC
*dest
))
154 __attribute__nonnull__(1)
155 __attribute__nonnull__(2)
156 FUNC_MODIFIES(*class_
)
157 FUNC_MODIFIES(*dest
);
159 void Parrot_oo_extract_methods_from_namespace(PARROT_INTERP
,
162 __attribute__nonnull__(1)
163 __attribute__nonnull__(2)
164 __attribute__nonnull__(3);
166 PARROT_CAN_RETURN_NULL
167 PARROT_WARN_UNUSED_RESULT
168 PMC
* Parrot_oo_get_namespace(SHIM_INTERP
, ARGIN(const PMC
*classobj
))
169 __attribute__nonnull__(2);
171 PARROT_CAN_RETURN_NULL
172 PARROT_WARN_UNUSED_RESULT
173 PMC
* Parrot_oo_newclass_from_str(PARROT_INTERP
, ARGIN(STRING
*name
))
174 __attribute__nonnull__(1)
175 __attribute__nonnull__(2);
177 PARROT_WARN_UNUSED_RESULT
178 INTVAL
Parrot_oo_register_type(PARROT_INTERP
,
180 ARGIN(PMC
*_namespace
))
181 __attribute__nonnull__(1)
182 __attribute__nonnull__(2)
183 __attribute__nonnull__(3);
185 #define ASSERT_ARGS_Parrot_ComposeRole __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
186 PARROT_ASSERT_ARG(interp) \
187 , PARROT_ASSERT_ARG(role) \
188 , PARROT_ASSERT_ARG(exclude) \
189 , PARROT_ASSERT_ARG(alias) \
190 , PARROT_ASSERT_ARG(methods_hash) \
191 , PARROT_ASSERT_ARG(roles_list))
192 #define ASSERT_ARGS_Parrot_ComputeMRO_C3 __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
193 PARROT_ASSERT_ARG(interp) \
194 , PARROT_ASSERT_ARG(_class))
195 #define ASSERT_ARGS_Parrot_find_method_direct __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
196 PARROT_ASSERT_ARG(interp) \
197 , PARROT_ASSERT_ARG(_class) \
198 , PARROT_ASSERT_ARG(method_name))
199 #define ASSERT_ARGS_Parrot_find_method_with_cache __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
200 PARROT_ASSERT_ARG(interp) \
201 , PARROT_ASSERT_ARG(_class) \
202 , PARROT_ASSERT_ARG(method_name))
203 #define ASSERT_ARGS_Parrot_get_vtable_index __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
204 PARROT_ASSERT_ARG(interp) \
205 , PARROT_ASSERT_ARG(name))
206 #define ASSERT_ARGS_Parrot_get_vtable_name __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
207 #define ASSERT_ARGS_Parrot_invalidate_method_cache \
208 __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
209 PARROT_ASSERT_ARG(interp))
210 #define ASSERT_ARGS_Parrot_oo_find_vtable_override \
211 __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
212 PARROT_ASSERT_ARG(interp) \
213 , PARROT_ASSERT_ARG(classobj) \
214 , PARROT_ASSERT_ARG(name))
215 #define ASSERT_ARGS_Parrot_oo_find_vtable_override_for_class \
216 __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
217 PARROT_ASSERT_ARG(interp) \
218 , PARROT_ASSERT_ARG(classobj) \
219 , PARROT_ASSERT_ARG(name))
220 #define ASSERT_ARGS_Parrot_oo_get_class __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
221 PARROT_ASSERT_ARG(interp) \
222 , PARROT_ASSERT_ARG(key))
223 #define ASSERT_ARGS_Parrot_oo_get_class_str __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
224 PARROT_ASSERT_ARG(interp) \
225 , PARROT_ASSERT_ARG(name))
226 #define ASSERT_ARGS_destroy_object_cache __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
227 PARROT_ASSERT_ARG(interp))
228 #define ASSERT_ARGS_init_object_cache __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
229 PARROT_ASSERT_ARG(interp))
230 #define ASSERT_ARGS_mark_object_cache __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
231 PARROT_ASSERT_ARG(interp))
232 #define ASSERT_ARGS_Parrot_oo_clone_object __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
233 PARROT_ASSERT_ARG(interp) \
234 , PARROT_ASSERT_ARG(pmc))
235 #define ASSERT_ARGS_Parrot_oo_extract_methods_from_namespace \
236 __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
237 PARROT_ASSERT_ARG(interp) \
238 , PARROT_ASSERT_ARG(self) \
239 , PARROT_ASSERT_ARG(ns))
240 #define ASSERT_ARGS_Parrot_oo_get_namespace __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
241 PARROT_ASSERT_ARG(classobj))
242 #define ASSERT_ARGS_Parrot_oo_newclass_from_str __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
243 PARROT_ASSERT_ARG(interp) \
244 , PARROT_ASSERT_ARG(name))
245 #define ASSERT_ARGS_Parrot_oo_register_type __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
246 PARROT_ASSERT_ARG(interp) \
247 , PARROT_ASSERT_ARG(name) \
248 , PARROT_ASSERT_ARG(_namespace))
249 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
250 /* HEADERIZER END: src/oo.c */
252 #endif /* PARROT_OO_H_GUARD */
256 * c-file-style: "parrot"
258 * vim: expandtab shiftwidth=4: