tagged release 0.6.4
[parrot.git] / include / parrot / oo.h
blob563894078172943297ee05cf3e11ef962a756d34
1 /* objects.h
2 * Copyright (C) 2007-2008, The Perl Foundation.
3 * SVN Info
4 * $Id$
5 * Overview:
6 * Parrot class and object header stuff
7 * Data Structure and Algorithms:
8 * History:
9 * Notes:
10 * References:
13 #ifndef PARROT_OO_H_GUARD
14 #define PARROT_OO_H_GUARD
16 #include "parrot/parrot.h"
18 typedef enum {
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 */
24 PCD_MAX
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.
34 #define SLOTTYPE PMC*
35 #define get_attrib_num(x, y) ((PMC **)(x))[(y)]
36 #define set_attrib_num(o, x, y, z) \
37 do { \
38 GC_WRITE_BARRIER(interp, (o), ((PMC **)(x))[y], (z)); \
39 ((PMC **)(x))[(y)] = (z); \
40 } while (0)
41 #define set_attrib_flags(x) do { \
42 PObj_data_is_PMC_array_SET(x); \
43 PObj_active_destroy_SET(x); \
44 } while (0)
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); \
48 } while (0)
51 * class macros
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. */
60 PARROT_API
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);
67 PARROT_API
68 void Parrot_ComposeRole(PARROT_INTERP,
69 ARGIN(PMC *role),
70 ARGIN(PMC *exclude),
71 int got_exclude,
72 ARGIN(PMC *alias),
73 int got_alias,
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);
83 PARROT_API
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);
90 PARROT_API
91 PARROT_CAN_RETURN_NULL
92 PARROT_WARN_UNUSED_RESULT
93 PMC * Parrot_find_method_direct(PARROT_INTERP,
94 ARGIN(PMC *_class),
95 ARGIN(STRING *method_name))
96 __attribute__nonnull__(1)
97 __attribute__nonnull__(2)
98 __attribute__nonnull__(3);
100 PARROT_API
101 PARROT_CAN_RETURN_NULL
102 PARROT_WARN_UNUSED_RESULT
103 PMC * Parrot_find_method_with_cache(PARROT_INTERP,
104 ARGIN(PMC *_class),
105 ARGIN(STRING *method_name))
106 __attribute__nonnull__(1)
107 __attribute__nonnull__(2)
108 __attribute__nonnull__(3);
110 PARROT_API
111 INTVAL Parrot_get_vtable_index(PARROT_INTERP, ARGIN(const STRING *name))
112 __attribute__nonnull__(1)
113 __attribute__nonnull__(2);
115 PARROT_API
116 void Parrot_instantiate_object(PARROT_INTERP, ARGMOD(PMC *object))
117 __attribute__nonnull__(1)
118 __attribute__nonnull__(2)
119 FUNC_MODIFIES(*object);
121 PARROT_API
122 void Parrot_instantiate_object_init(PARROT_INTERP,
123 ARGIN(PMC *object),
124 ARGIN(PMC *init))
125 __attribute__nonnull__(1)
126 __attribute__nonnull__(2)
127 __attribute__nonnull__(3);
129 PARROT_API
130 void Parrot_invalidate_method_cache(PARROT_INTERP,
131 ARGIN_NULLOK(STRING *_class),
132 ARGIN(STRING *meth))
133 __attribute__nonnull__(1)
134 __attribute__nonnull__(3);
136 PARROT_API
137 PARROT_PURE_FUNCTION
138 INTVAL Parrot_MMD_method_idx(SHIM_INTERP, ARGIN(const char *name))
139 __attribute__nonnull__(2);
141 PARROT_API
142 PARROT_PURE_FUNCTION
143 PARROT_CAN_RETURN_NULL
144 const char* Parrot_MMD_method_name(SHIM_INTERP, INTVAL idx);
146 PARROT_API
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);
153 PARROT_API
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);
160 PARROT_API
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);
170 PARROT_API
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,
193 ARGIN(PMC *self),
194 ARGIN(PMC *ns))
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),
203 ARGIN(STRING *name))
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),
212 ARGIN(STRING *name))
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 */
239 * Local variables:
240 * c-file-style: "parrot"
241 * End:
242 * vim: expandtab shiftwidth=4: