… | |
… | |
60 | |
60 | |
61 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
61 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
62 | |
62 | |
63 | void cfperl_init (); |
63 | void cfperl_init (); |
64 | void cfperl_main (); |
64 | void cfperl_main (); |
|
|
65 | void cfperl_emergency_save (); |
65 | |
66 | |
66 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
67 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
67 | |
68 | |
68 | // virtual server time, excluding time jumps and lag |
69 | // virtual server time, excluding time jumps and lag |
69 | extern double runtime; |
70 | extern double runtime; |
… | |
… | |
129 | |
130 | |
130 | static unordered_vector<attachable *> mortals; |
131 | static unordered_vector<attachable *> mortals; |
131 | MTH static void check_mortals (); |
132 | MTH static void check_mortals (); |
132 | |
133 | |
133 | enum { |
134 | enum { |
134 | F_DESTROYED = 0x01, |
135 | F_DESTROYED = 0x01, |
135 | F_BORROWED = 0x02, |
136 | F_DEBUG_TRACE = 0x02, |
136 | }; |
137 | }; |
137 | |
138 | |
138 | // object is delete'd after the refcount reaches 0 |
139 | // object is delete'd after the refcount reaches 0 |
139 | mutable int ACC (RW, refcnt); |
140 | mutable int ACC (RW, refcnt); |
140 | int ACC (RW, flags); |
141 | int ACC (RW, flags); |
141 | |
142 | |
142 | MTH void refcnt_inc () const { ++refcnt; } |
143 | MTH void refcnt_inc () const { ++refcnt; } |
143 | MTH void refcnt_dec () const { --refcnt; } |
144 | MTH void refcnt_dec () const { --refcnt; } |
144 | |
145 | |
|
|
146 | MTH int refcnt_cnt () const; |
145 | // check wether the object has died and destroy |
147 | // check wether the object has died and destroy |
146 | MTH void refcnt_chk () { if (refcnt <= 0) do_check (); } |
148 | MTH void refcnt_chk () { if (refcnt <= 0) do_check (); } |
147 | |
149 | |
148 | // destroy the object unless it was already destroyed |
150 | // destroy the object unless it was already destroyed |
149 | // this politely asks everybody interested the reduce |
151 | // this politely asks everybody interested the reduce |
… | |
… | |
163 | |
165 | |
164 | HV *self; // CF+ perl self |
166 | HV *self; // CF+ perl self |
165 | AV *cb; // CF+ callbacks |
167 | AV *cb; // CF+ callbacks |
166 | shstr attach; // generic extension attachment information |
168 | shstr attach; // generic extension attachment information |
167 | |
169 | |
|
|
170 | void sever_self (); // sever this object from its self, if it has one. |
168 | void optimise (); // possibly save some memory by destroying unneeded data |
171 | void optimise (); // possibly save some memory by destroying unneeded data |
169 | |
172 | |
170 | attachable () |
173 | attachable () |
171 | : flags (0), refcnt (0), self (0), cb (0), attach (0) |
174 | : flags (0), refcnt (0), self (0), cb (0), attach (0) |
172 | { |
175 | { |
173 | } |
176 | } |
… | |
… | |
180 | virtual ~attachable (); |
183 | virtual ~attachable (); |
181 | |
184 | |
182 | attachable &operator =(const attachable &src); |
185 | attachable &operator =(const attachable &src); |
183 | |
186 | |
184 | bool invoke (event_type event, ...); |
187 | bool invoke (event_type event, ...); |
185 | void instantiate (); |
188 | MTH void instantiate (); |
186 | void reattach (); |
189 | void reattach (); |
187 | |
190 | |
188 | protected: |
191 | protected: |
189 | // do the real refcount checking work |
192 | // do the real refcount checking work |
190 | void do_check (); |
193 | void do_check (); |
… | |
… | |
338 | |
341 | |
339 | struct object_thawer |
342 | struct object_thawer |
340 | { |
343 | { |
341 | SV *text; // text part |
344 | SV *text; // text part |
342 | AV *av; // perl part |
345 | AV *av; // perl part |
|
|
346 | int linenum; |
343 | char *line; // current beginning of line |
347 | char *line; // current beginning of line |
344 | char *last_keyword, *last_value; |
348 | char *last_keyword, *last_value; |
345 | const char *name; |
349 | const char *name; |
346 | |
350 | |
347 | operator bool () { return !!text; } |
351 | operator bool () { return !!text; } |
… | |
… | |
375 | void get (uint16 &i) { i = get_sint32 (); } |
379 | void get (uint16 &i) { i = get_sint32 (); } |
376 | void get (sint32 &i) { i = get_sint32 (); } |
380 | void get (sint32 &i) { i = get_sint32 (); } |
377 | |
381 | |
378 | void get (uint32 &i) { i = get_sint64 (); } |
382 | void get (uint32 &i) { i = get_sint64 (); } |
379 | void get (sint64 &i) { i = get_sint64 (); } |
383 | void get (sint64 &i) { i = get_sint64 (); } |
380 | }; |
|
|
381 | |
384 | |
|
|
385 | bool parse_error (keyword kw, const char *type = 0, const char *name = 0, bool skip = true); |
|
|
386 | }; |
|
|
387 | |
|
|
388 | //TODO: remove |
382 | char *fgets (char *s, int n, object_thawer &thawer); |
389 | char *fgets (char *s, int n, object_thawer &thawer); |
383 | |
390 | |
384 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
391 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
385 | |
392 | |
386 | struct coroapi { |
393 | struct coroapi { |