ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/cfperl.h
(Generate patch)

Comparing deliantra/server/include/cfperl.h (file contents):
Revision 1.20 by root, Thu Aug 31 18:59:24 2006 UTC vs.
Revision 1.21 by root, Sun Sep 3 22:45:56 2006 UTC

27// but does not initialise their state structures. 27// but does not initialise their state structures.
28#undef random 28#undef random
29#undef crypt 29#undef crypt
30 30
31void cfperl_init (); 31void cfperl_init ();
32void cfperl_boot ();
33void cfperl_main (); 32void cfperl_main ();
34 33
35enum event_klass 34enum event_klass
36{ 35{
37 KLASS_NONE, 36 KLASS_NONE,
82 81
83struct attachable_base 82struct attachable_base
84{ 83{
85 SV *self; 84 SV *self;
86 AV *cb; // CF+ perl self and callback 85 AV *cb; // CF+ perl self and callback
87 const char *attach; // generic extension attachment information 86 shstr attach; // generic extension attachment information
88 87
89 void clear (); // called when free'ing objects 88 void clear (); // called when free'ing objects
90 void optimise (); // possibly save some memory by destroying unneeded data 89 void optimise (); // possibly save some memory by destroying unneeded data
91 void instantiate (data_type type, void *obj); 90 void instantiate (data_type type, void *obj);
92 91
224 223
225// compatibility support, should be removed when no longer needed 224// compatibility support, should be removed when no longer needed
226int fprintf (object_freezer &freezer, const char *format, ...); 225int fprintf (object_freezer &freezer, const char *format, ...);
227int fputs (const char *s, object_freezer &freezer); 226int fputs (const char *s, object_freezer &freezer);
228 227
229// a single key-value line from a file
230struct token {
231 keyword k;
232 const char *v;
233
234 token (keyword k, const char *v = 0) : k(k), v(v) { }
235};
236
237struct object_thawer 228struct object_thawer
238{ 229{
239 AV *av; 230 SV *text; // text part
240 FILE *fp; 231 AV *av; // perl part
241 char line[1024]; 232 char *line; // current beginning of line
233 char *last_value;
234
235 operator bool () { return !!text; }
242 236
243 object_thawer (const char *filename = 0); 237 object_thawer (const char *filename = 0);
244 ~object_thawer (); 238 ~object_thawer ();
245 239
246 void get (data_type type, void *obj, attachable_base *ext, int oid); 240 void get (data_type type, void *obj, attachable_base *ext, int oid);
250 { 244 {
251 if (av) 245 if (av)
252 get ((data_type) cftype<subclass>::dt, (subclass *)obj, obj, oid); 246 get ((data_type) cftype<subclass>::dt, (subclass *)obj, obj, oid);
253 } 247 }
254 248
255 token get_token (); 249 keyword get_kv (); // also parse value for later use
256 250
257 operator FILE *() { return fp; } 251 const char *get_str () { return last_value; } // may be 0
252
253 void get (shstr &sh) const;
254 void get_ornull (shstr &sh) const { sh = last_value; }
255 void get_ml (keyword kend, shstr &sh);
256
257 sint32 get_sint32 () const;
258 sint64 get_sint64 () const;
259 double get_double () const;
260
261 void get (float &v) { v = get_double (); }
262 void get (double &v) { v = get_double (); }
263
264 void get (sint8 &i) { i = get_sint32 (); }
265 void get (uint8 &i) { i = get_sint32 (); }
266 void get (sint16 &i) { i = get_sint32 (); }
267 void get (uint16 &i) { i = get_sint32 (); }
268 void get (sint32 &i) { i = get_sint32 (); }
269
270 void get (uint32 &i) { i = get_sint64 (); }
271 void get (sint64 &i) { i = get_sint64 (); }
258}; 272};
273
274char *fgets (char *s, int n, object_thawer &thawer);
259 275
260#endif 276#endif
261 277

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines