… | |
… | |
154 | int cfperl_result_INT (int idx); |
154 | int cfperl_result_INT (int idx); |
155 | |
155 | |
156 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
156 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
157 | |
157 | |
158 | INTERFACE_CLASS (attachable) |
158 | INTERFACE_CLASS (attachable) |
159 | struct attachable |
159 | struct attachable : refcnt_base |
160 | { |
160 | { |
161 | static MGVTBL vtbl; |
161 | static MGVTBL vtbl; |
162 | |
162 | |
163 | static unordered_vector<attachable *> mortals; |
163 | static unordered_vector<attachable *> mortals; |
164 | MTH static void check_mortals (); |
164 | MTH static void check_mortals (); |
165 | |
165 | |
166 | enum { |
166 | enum { |
167 | F_DESTROYED = 0x01, |
167 | F_DESTROYED = 0x01, |
168 | F_DEBUG_TRACE = 0x02, |
168 | F_DEBUG_TRACE = 0x02, |
169 | }; |
169 | }; |
|
|
170 | int ACC (RW, flags); |
170 | |
171 | |
171 | // object is delete'd after the refcount reaches 0 |
172 | // object is delete'd after the refcount reaches 0 |
172 | int ACC (RW, flags); |
|
|
173 | mutable int ACC (RW, refcnt); |
|
|
174 | |
|
|
175 | MTH void refcnt_inc () const { ++refcnt; } |
|
|
176 | MTH void refcnt_dec () const { --refcnt; } |
|
|
177 | |
|
|
178 | MTH int refcnt_cnt () const; |
173 | MTH int refcnt_cnt () const; |
179 | // check wether the object has died and destroy |
174 | // check wether the object has died and destroy |
180 | MTH void refcnt_chk () { if (expect_false (refcnt <= 0)) do_check (); } |
175 | MTH void refcnt_chk () { if (expect_false (refcnt <= 0)) do_check (); } |
181 | |
176 | |
182 | // destroy the object unless it was already destroyed |
177 | // destroy the object unless it was already destroyed |
… | |
… | |
201 | |
196 | |
202 | void sever_self (); // sever this object from its self, if it has one. |
197 | void sever_self (); // sever this object from its self, if it has one. |
203 | void optimise (); // possibly save some memory by destroying unneeded data |
198 | void optimise (); // possibly save some memory by destroying unneeded data |
204 | |
199 | |
205 | attachable () |
200 | attachable () |
206 | : flags (0), refcnt (0), self (0), cb (0), attach (0) |
201 | : flags (0), self (0), cb (0), attach (0) |
207 | { |
202 | { |
208 | } |
203 | } |
209 | |
204 | |
210 | attachable (const attachable &src) |
205 | attachable (const attachable &src) |
211 | : flags (0), refcnt (0), self (0), cb (0), attach (src.attach) |
206 | : flags (0), self (0), cb (0), attach (src.attach) |
212 | { |
207 | { |
213 | } |
208 | } |
214 | |
209 | |
215 | // set a custom key to the given value, or delete it if value = 0 |
210 | // set a custom key to the given value, or delete it if value = 0 |
216 | void set_key (const char *key, const char *value = 0); |
211 | void set_key (const char *key, const char *value = 0); |
… | |
… | |
416 | void get (sint32 &i) { i = get_sint32 (); } |
411 | void get (sint32 &i) { i = get_sint32 (); } |
417 | |
412 | |
418 | void get (uint32 &i) { i = get_sint64 (); } |
413 | void get (uint32 &i) { i = get_sint64 (); } |
419 | void get (sint64 &i) { i = get_sint64 (); } |
414 | void get (sint64 &i) { i = get_sint64 (); } |
420 | |
415 | |
|
|
416 | void parse_warn (const char *msg); |
421 | bool parse_error (const char *type = 0, const char *name = 0, bool skip = true); |
417 | bool parse_error (const char *type = 0, const char *name = 0, bool skip = true); |
422 | }; |
418 | }; |
423 | |
419 | |
424 | //TODO: remove |
420 | //TODO: remove |
425 | char *fgets (char *s, int n, object_thawer &thawer); |
421 | char *fgets (char *s, int n, object_thawer &thawer); |