2 * Copyright (C) 2007-2008, The Perl 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
;
28 /* Objects, classes and PMCarrays all use the same data scheme:
29 * PMC_data() holds a malloced array, PMC_int_val() is the size of it
30 * this simplifies DOD mark a lot
32 * The active destroy flag is necessary to free the malloced array.
35 #define get_attrib_num(x, y) ((PMC **)(x))[(y)]
36 #define set_attrib_num(o, x, y, z) \
38 GC_WRITE_BARRIER(interp, (o), ((PMC **)(x))[y], (z)); \
39 ((PMC **)(x))[(y)] = (z); \
41 #define set_attrib_flags(x) do { \
42 PObj_data_is_PMC_array_SET(x); \
43 PObj_active_destroy_SET(x); \
45 #define set_attrib_array_size(o, y) do { \
46 PMC_data(o) = mem_sys_allocate_zeroed((sizeof (PMC *)*(y))); \
47 PMC_int_val(o) = (y); \
54 #define CLASS_ATTRIB_COUNT(cl) PMC_int_val2(cl)
55 #define GET_CLASS(obj) (obj)->vtable->pmc_class
57 /* HEADERIZER BEGIN: src/oo.c */
58 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
61 PARROT_CAN_RETURN_NULL
62 PARROT_WARN_UNUSED_RESULT
63 PMC
* Parrot_class_lookup(PARROT_INTERP
, ARGIN(STRING
*class_name
))
64 __attribute__nonnull__(1)
65 __attribute__nonnull__(2);
68 void Parrot_ComposeRole(PARROT_INTERP
,
74 ARGIN(PMC
*methods_hash
),
75 ARGIN(PMC
*roles_list
))
76 __attribute__nonnull__(1)
77 __attribute__nonnull__(2)
78 __attribute__nonnull__(3)
79 __attribute__nonnull__(5)
80 __attribute__nonnull__(7)
81 __attribute__nonnull__(8);
84 PARROT_WARN_UNUSED_RESULT
85 PARROT_CAN_RETURN_NULL
86 PMC
* Parrot_ComputeMRO_C3(PARROT_INTERP
, ARGIN(PMC
*_class
))
87 __attribute__nonnull__(1)
88 __attribute__nonnull__(2);
91 PARROT_CAN_RETURN_NULL
92 PARROT_WARN_UNUSED_RESULT
93 PMC
* Parrot_find_method_direct(PARROT_INTERP
,
95 ARGIN(STRING
*method_name
))
96 __attribute__nonnull__(1)
97 __attribute__nonnull__(2)
98 __attribute__nonnull__(3);
101 PARROT_CAN_RETURN_NULL
102 PARROT_WARN_UNUSED_RESULT
103 PMC
* Parrot_find_method_with_cache(PARROT_INTERP
,
105 ARGIN(STRING
*method_name
))
106 __attribute__nonnull__(1)
107 __attribute__nonnull__(2)
108 __attribute__nonnull__(3);
111 INTVAL
Parrot_get_vtable_index(PARROT_INTERP
, ARGIN(const STRING
*name
))
112 __attribute__nonnull__(1)
113 __attribute__nonnull__(2);
116 void Parrot_instantiate_object(PARROT_INTERP
, ARGMOD(PMC
*object
))
117 __attribute__nonnull__(1)
118 __attribute__nonnull__(2)
119 FUNC_MODIFIES(*object
);
122 void Parrot_instantiate_object_init(PARROT_INTERP
,
125 __attribute__nonnull__(1)
126 __attribute__nonnull__(2)
127 __attribute__nonnull__(3);
130 void Parrot_invalidate_method_cache(PARROT_INTERP
,
131 ARGIN_NULLOK(STRING
*_class
),
133 __attribute__nonnull__(1)
134 __attribute__nonnull__(3);
138 INTVAL
Parrot_MMD_method_idx(SHIM_INTERP
, ARGIN(const char *name
))
139 __attribute__nonnull__(2);
143 PARROT_CAN_RETURN_NULL
144 const char* Parrot_MMD_method_name(SHIM_INTERP
, INTVAL idx
);
147 PARROT_CAN_RETURN_NULL
148 PARROT_WARN_UNUSED_RESULT
149 PMC
* Parrot_oo_get_class(PARROT_INTERP
, ARGIN(PMC
*key
))
150 __attribute__nonnull__(1)
151 __attribute__nonnull__(2);
154 PARROT_CAN_RETURN_NULL
155 PARROT_WARN_UNUSED_RESULT
156 PMC
* Parrot_oo_get_class_str(PARROT_INTERP
, ARGIN(STRING
*name
))
157 __attribute__nonnull__(1)
158 __attribute__nonnull__(2);
161 PARROT_IGNORABLE_RESULT
162 PARROT_CAN_RETURN_NULL
163 PMC
* Parrot_remove_parent(PARROT_INTERP
,
164 ARGIN(PMC
*removed_class
),
165 ARGIN(PMC
*existing_class
))
166 __attribute__nonnull__(1)
167 __attribute__nonnull__(2)
168 __attribute__nonnull__(3);
171 PARROT_WARN_UNUSED_RESULT
172 PARROT_CANNOT_RETURN_NULL
173 STRING
* readable_name(PARROT_INTERP
, ARGIN(PMC
*name
))
174 __attribute__nonnull__(1)
175 __attribute__nonnull__(2);
177 void destroy_object_cache(PARROT_INTERP
)
178 __attribute__nonnull__(1);
180 void init_object_cache(PARROT_INTERP
)
181 __attribute__nonnull__(1);
183 void mark_object_cache(PARROT_INTERP
)
184 __attribute__nonnull__(1);
186 PARROT_CAN_RETURN_NULL
187 PARROT_WARN_UNUSED_RESULT
188 PMC
* Parrot_class_lookup_p(PARROT_INTERP
, ARGIN(PMC
*class_name
))
189 __attribute__nonnull__(1)
190 __attribute__nonnull__(2);
192 void Parrot_oo_extract_methods_from_namespace(PARROT_INTERP
,
195 __attribute__nonnull__(1)
196 __attribute__nonnull__(2)
197 __attribute__nonnull__(3);
199 PARROT_CAN_RETURN_NULL
200 PARROT_WARN_UNUSED_RESULT
201 PMC
* Parrot_oo_find_vtable_override(PARROT_INTERP
,
202 ARGIN(PMC
*classobj
),
204 __attribute__nonnull__(1)
205 __attribute__nonnull__(2)
206 __attribute__nonnull__(3);
208 PARROT_CAN_RETURN_NULL
209 PARROT_WARN_UNUSED_RESULT
210 PMC
* Parrot_oo_find_vtable_override_for_class(PARROT_INTERP
,
211 ARGIN(PMC
*classobj
),
213 __attribute__nonnull__(1)
214 __attribute__nonnull__(2)
215 __attribute__nonnull__(3);
217 PARROT_CAN_RETURN_NULL
218 PARROT_WARN_UNUSED_RESULT
219 PMC
* Parrot_oo_get_namespace(SHIM_INTERP
, ARGIN(const PMC
*classobj
))
220 __attribute__nonnull__(2);
222 PARROT_CAN_RETURN_NULL
223 PARROT_WARN_UNUSED_RESULT
224 PMC
* Parrot_oo_newclass_from_str(PARROT_INTERP
, ARGIN(STRING
*name
))
225 __attribute__nonnull__(1)
226 __attribute__nonnull__(2);
228 PARROT_WARN_UNUSED_RESULT
229 INTVAL
Parrot_oo_register_type(PARROT_INTERP
, ARGIN(PMC
*name
))
230 __attribute__nonnull__(1)
231 __attribute__nonnull__(2);
233 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
234 /* HEADERIZER END: src/oo.c */
236 #endif /* PARROT_OO_H_GUARD */
240 * c-file-style: "parrot"
242 * vim: expandtab shiftwidth=4: