1 #ifndef _object__h__included__
2 #define _object__h__included__
9 /* Object marked for garbage collection. */
10 #define OF_MARKED_FOR_GC 1
11 /* Already execuing message handler. */
12 #define OF_EXECUTING 2
20 /******************************************************************************
26 * object The object to read.
27 * slot Field slot number.
30 * Read value, or NULL if slot is invalid.
32 *****************************************************************************/
33 struct object
* object_read_field(struct object
* object
, size_t slot
);
35 /******************************************************************************
38 * Write object field. Writes to nonexistent slots are discarded.
41 * object The object to write.
42 * slot Field slot number.
43 * towrite Refrence to write.
45 *****************************************************************************/
46 void object_write_field(struct object
* object
, size_t slot
,
47 struct object
* towrite
);
49 /******************************************************************************
52 * Get class of object.
55 * object The object to interrogate.
60 *****************************************************************************/
61 struct class* object_class(struct object
* object
);
63 /******************************************************************************
66 * Check object EXECUTING flag.
69 * object The object to interrogate.
72 * 1 if object is executing, 0 otherwise.
74 *****************************************************************************/
75 unsigned object_is_executing(struct object
* object
);
77 /******************************************************************************
80 * Set object EXECUTING flag.
83 * object The object to manipulate.
85 *****************************************************************************/
86 void object_set_executing(struct object
* object
);
88 /******************************************************************************
91 * Clear object EXECUTING flag.
94 * object The object to manipulate.
96 *****************************************************************************/
97 void object_clear_executing(struct object
* object
);
100 /******************************************************************************
103 * Check object MARKED_FOR_GC flag.
106 * object The object to interrogate.
109 * 1 if object is marked for GC, 0 otherwise.
111 *****************************************************************************/
112 unsigned object_is_gcmark(struct object
* object
);
114 /******************************************************************************
117 * Set object MARKED_FOR_GC flag.
120 * object The object to manipulate.
122 *****************************************************************************/
123 void object_set_gcmark(struct object
* object
);
125 /******************************************************************************
128 * Clear object MARKED_FOR_GC flag.
131 * object The object to manipulate.
133 *****************************************************************************/
134 void object_clear_gcmark(struct object
* object
);
136 /******************************************************************************
139 * Create object of specified class.
142 * class The class of new object.
145 * The newly created object.
147 *****************************************************************************/
148 struct object
* object_create_ordinary(struct class* class);
150 /******************************************************************************
153 * Create special object.
156 * handler Handler object.
157 * fields Fields for local object. Note that if this
158 * is nonzero, new class is created and
162 * The newly created object.
164 *****************************************************************************/
165 struct object
* object_create_special(void (*handler
)(struct context
* ctx
,
166 struct message
* msg
), size_t fields
);
168 /******************************************************************************
171 * Create object list.
174 * The newly created object list.
176 *****************************************************************************/
177 struct objectlist
* objectlist_create();
179 /******************************************************************************
182 * Destroy object list and all objects in it.
185 * objectlist Object list to destroy.
187 *****************************************************************************/
188 void objectlist_destroy(struct objectlist
* objectlist
);
190 /******************************************************************************
193 * Add object to object list.
196 * objectlist Object list to add object to.
197 * object Object to add.
199 *****************************************************************************/
200 void objectlist_add(struct objectlist
* objectlist
, struct object
* object
);
202 /******************************************************************************
205 * Kill all marked objects from list.
208 * objectlist Object list to manipulate.
211 * 1 if more remain, 0 if all are gone.
213 *****************************************************************************/
214 unsigned objectlist_kill_marked(struct objectlist
* objectlist
);
216 /******************************************************************************
219 * Set object MARKED_FOR_GC flag for all objects in list.
222 * objectlist The object list to manipulate.
224 *****************************************************************************/
225 void objectlist_set_gcmark_all(struct objectlist
* objectlist
);
227 /******************************************************************************
230 * Execute special action, if any.
234 * ctx Context to pass in.
235 * msg Message to pass in.
238 * 1 if special action was executed, 0 if there is none.
240 *****************************************************************************/
241 unsigned object_exec_special(struct object
* object
, struct context
* ctx
,
242 struct message
* msg
);