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

Comparing deliantra/server/server/cfperl.xs (file contents):
Revision 1.332 by root, Fri Nov 6 13:21:20 2009 UTC vs.
Revision 1.333 by root, Sat Nov 7 18:30:06 2009 UTC

294 294
295 attach = src.attach; 295 attach = src.attach;
296 return *this; 296 return *this;
297} 297}
298 298
299#if 0
299template<typename T> 300template<typename T>
300static bool 301static bool
301find_backref (void *ptr, T *obj) 302find_backref (void *ptr, T *obj)
302{ 303{
303 char *s = (char *)obj; 304 char *s = (char *)obj;
311 312
312 return false; 313 return false;
313} 314}
314 315
315// for debugging, find "live" objects containing this ptr 316// for debugging, find "live" objects containing this ptr
316void 317static void
317find_backref (void *ptr) 318find_backref (void *ptr)
318{ 319{
319 for_all_objects (op) 320 for_all_objects (op)
320 if (find_backref (ptr, op)) 321 if (find_backref (ptr, op))
321 fprintf (stderr, "O %p %d:'%s'\n", op, op->count, &op->name); 322 fprintf (stderr, "O %p %d:'%s'\n", op, op->count, &op->name);
326 327
327 for_all_clients (ns) 328 for_all_clients (ns)
328 if (find_backref (ptr, ns)) 329 if (find_backref (ptr, ns))
329 fprintf (stderr, "C %p\n", ns); 330 fprintf (stderr, "C %p\n", ns);
330} 331}
332#endif
331 333
332////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 334//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
333 335
334static SV * 336static SV *
335newSVptr (void *ptr, HV *stash, HV *hv = newHV ()) 337newSVptr (void *ptr, HV *stash, HV *hv = newHV ())
423 return SvPTR (sv, klass); 425 return SvPTR (sv, klass);
424 else 426 else
425 return 0; 427 return 0;
426} 428}
427 429
428inline SV *to_sv (const shstr & v) { return newSVpvn_utf8 ((const char *)v, v.length (), 1); } 430static inline SV *to_sv (const shstr & v) { return newSVpvn_utf8 ((const char *)v, v.length (), 1); }
429inline SV *to_sv (const char * v) { return v ? newSVpv (v, 0) : newSV (0); } 431static inline SV *to_sv (const char * v) { return v ? newSVpv (v, 0) : newSV (0); }
430inline SV *to_sv (bool v) { return newSViv (v); } 432static inline SV *to_sv (bool v) { return newSViv (v); }
431inline SV *to_sv ( signed char v) { return newSViv (v); } 433static inline SV *to_sv ( signed char v) { return newSViv (v); }
432inline SV *to_sv (unsigned char v) { return newSViv (v); } 434static inline SV *to_sv (unsigned char v) { return newSViv (v); }
433inline SV *to_sv ( signed short v) { return newSViv (v); } 435static inline SV *to_sv ( signed short v) { return newSViv (v); }
434inline SV *to_sv (unsigned short v) { return newSVuv (v); } 436static inline SV *to_sv (unsigned short v) { return newSVuv (v); }
435inline SV *to_sv ( signed int v) { return newSViv (v); } 437static inline SV *to_sv ( signed int v) { return newSViv (v); }
436inline SV *to_sv (unsigned int v) { return newSVuv (v); } 438static inline SV *to_sv (unsigned int v) { return newSVuv (v); }
437inline SV *to_sv ( signed long v) { return newSViv (v); } 439static inline SV *to_sv ( signed long v) { return newSViv (v); }
438inline SV *to_sv (unsigned long v) { return newSVuv (v); } 440static inline SV *to_sv (unsigned long v) { return newSVuv (v); }
439inline SV *to_sv ( signed long long v) { return newSVval64 (v); } 441static inline SV *to_sv ( signed long long v) { return newSVval64 (v); }
440inline SV *to_sv (unsigned long long v) { return newSVval64 (v); } 442static inline SV *to_sv (unsigned long long v) { return newSVval64 (v); }
441inline SV *to_sv (float v) { return newSVnv (v); } 443static inline SV *to_sv (float v) { return newSVnv (v); }
442inline SV *to_sv (double v) { return newSVnv (v); } 444static inline SV *to_sv (double v) { return newSVnv (v); }
443inline SV *to_sv (client * v) { return newSVattachable (v, stash_cf_client_wrap); } 445static inline SV *to_sv (client * v) { return newSVattachable (v, stash_cf_client_wrap); }
444inline SV *to_sv (player * v) { return newSVattachable (v, stash_cf_player_wrap); } 446static inline SV *to_sv (player * v) { return newSVattachable (v, stash_cf_player_wrap); }
445inline SV *to_sv (object * v) { return newSVattachable (v, v && v->type == PLAYER ? stash_cf_object_player_wrap : stash_cf_object_wrap); } 447static inline SV *to_sv (object * v) { return newSVattachable (v, v && v->type == PLAYER ? stash_cf_object_player_wrap : stash_cf_object_wrap); }
446inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); } 448static inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); }
447inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); } 449static inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); }
448inline SV *to_sv (region * v) { return newSVattachable (v, stash_cf_region_wrap); } 450static inline SV *to_sv (region * v) { return newSVattachable (v, stash_cf_region_wrap); }
449inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); } 451static inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); }
450inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } 452static inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); }
451inline SV *to_sv (mapspace * v) { return newSVptr (v, stash_cf_mapspace_wrap); } 453static inline SV *to_sv (mapspace * v) { return newSVptr (v, stash_cf_mapspace_wrap); }
452 454
453inline SV *to_sv (object & v) { return to_sv (&v); } 455static inline SV *to_sv (object & v) { return to_sv (&v); }
454inline SV *to_sv (living & v) { return to_sv (&v); } 456static inline SV *to_sv (living & v) { return to_sv (&v); }
455 457
456inline SV *to_sv (const std::string & v) { return newSVpvn (v.data (), v.size ()); } 458static inline SV *to_sv (const std::string & v) { return newSVpvn (v.data (), v.size ()); }
457inline SV *to_sv (const treasurelist *v) { return to_sv (v->name); } 459static inline SV *to_sv (const treasurelist *v) { return to_sv (v->name); }
458 460
459inline SV *to_sv (UUID v) { return newSVpv (v.c_str (), 0); } 461static inline SV *to_sv (UUID v) { return newSVpv (v.c_str (), 0); }
460 462
461inline SV *to_sv (dynbuf * v) 463static inline SV *to_sv (dynbuf * v)
462{ 464{
463 SV *sv = newSV (0); 465 SV *sv = newSV (0);
464 466
465 sv_upgrade (sv, SVt_PV); 467 sv_upgrade (sv, SVt_PV);
466 SvGROW (sv, v->size () + 1); 468 SvGROW (sv, v->size () + 1);
470 *SvEND (sv) = 0; 472 *SvEND (sv) = 0;
471 473
472 return sv; 474 return sv;
473} 475}
474 476
475inline SV *to_sv (dynbuf_text * v) 477static inline SV *to_sv (dynbuf_text * v)
476{ 478{
477 SV *sv = to_sv (static_cast<dynbuf *> (v)); 479 SV *sv = to_sv (static_cast<dynbuf *> (v));
478 SvUTF8_on (sv); 480 SvUTF8_on (sv);
479 return sv; 481 return sv;
480} 482}
481 483
482inline void sv_to (SV *sv, shstr &v) { v = SvOK (sv) ? SvPVutf8_nolen (sv) : 0; } 484static inline void sv_to (SV *sv, shstr &v) { v = SvOK (sv) ? SvPVutf8_nolen (sv) : 0; }
483inline void sv_to (SV *sv, char * &v) { free (v); v = SvOK (sv) ? strdup (SvPV_nolen (sv)) : 0; } 485static inline void sv_to (SV *sv, char * &v) { free (v); v = SvOK (sv) ? strdup (SvPV_nolen (sv)) : 0; }
484inline void sv_to (SV *sv, bool &v) { v = SvIV (sv); } 486static inline void sv_to (SV *sv, bool &v) { v = SvIV (sv); }
485inline void sv_to (SV *sv, signed char &v) { v = SvIV (sv); } 487static inline void sv_to (SV *sv, signed char &v) { v = SvIV (sv); }
486inline void sv_to (SV *sv, unsigned char &v) { v = SvIV (sv); } 488static inline void sv_to (SV *sv, unsigned char &v) { v = SvIV (sv); }
487inline void sv_to (SV *sv, signed short &v) { v = SvIV (sv); } 489static inline void sv_to (SV *sv, signed short &v) { v = SvIV (sv); }
488inline void sv_to (SV *sv, unsigned short &v) { v = SvIV (sv); } 490static inline void sv_to (SV *sv, unsigned short &v) { v = SvIV (sv); }
489inline void sv_to (SV *sv, signed int &v) { v = SvIV (sv); } 491static inline void sv_to (SV *sv, signed int &v) { v = SvIV (sv); }
490inline void sv_to (SV *sv, unsigned int &v) { v = SvUV (sv); } 492static inline void sv_to (SV *sv, unsigned int &v) { v = SvUV (sv); }
491inline void sv_to (SV *sv, signed long &v) { v = SvIV (sv); } 493static inline void sv_to (SV *sv, signed long &v) { v = SvIV (sv); }
492inline void sv_to (SV *sv, unsigned long &v) { v = SvUV (sv); } 494static inline void sv_to (SV *sv, unsigned long &v) { v = SvUV (sv); }
493inline void sv_to (SV *sv, signed long long &v) { v = ( signed long long)SvVAL64 (sv); } 495static inline void sv_to (SV *sv, signed long long &v) { v = ( signed long long)SvVAL64 (sv); }
494inline void sv_to (SV *sv, unsigned long long &v) { v = (unsigned long long)SvVAL64 (sv); } 496static inline void sv_to (SV *sv, unsigned long long &v) { v = (unsigned long long)SvVAL64 (sv); }
495inline void sv_to (SV *sv, float &v) { v = SvNV (sv); } 497static inline void sv_to (SV *sv, float &v) { v = SvNV (sv); }
496inline void sv_to (SV *sv, double &v) { v = SvNV (sv); } 498static inline void sv_to (SV *sv, double &v) { v = SvNV (sv); }
497inline void sv_to (SV *sv, client * &v) { v = (client *)(attachable *)SvPTR_ornull (sv, "cf::client"); } 499static inline void sv_to (SV *sv, client * &v) { v = (client *)(attachable *)SvPTR_ornull (sv, "cf::client"); }
498inline void sv_to (SV *sv, player * &v) { v = (player *)(attachable *)SvPTR_ornull (sv, "cf::player"); } 500static inline void sv_to (SV *sv, player * &v) { v = (player *)(attachable *)SvPTR_ornull (sv, "cf::player"); }
499inline void sv_to (SV *sv, object * &v) { v = (object *)(attachable *)SvPTR_ornull (sv, "cf::object"); } 501static inline void sv_to (SV *sv, object * &v) { v = (object *)(attachable *)SvPTR_ornull (sv, "cf::object"); }
500inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)(attachable *)SvPTR_ornull (sv, "cf::arch"); } 502static inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)(attachable *)SvPTR_ornull (sv, "cf::arch"); }
501inline void sv_to (SV *sv, maptile * &v) { v = (maptile *)(attachable *)SvPTR_ornull (sv, "cf::map"); } 503static inline void sv_to (SV *sv, maptile * &v) { v = (maptile *)(attachable *)SvPTR_ornull (sv, "cf::map"); }
502inline void sv_to (SV *sv, region * &v) { v = (region *)(attachable *)SvPTR_ornull (sv, "cf::region"); } 504static inline void sv_to (SV *sv, region * &v) { v = (region *)(attachable *)SvPTR_ornull (sv, "cf::region"); }
503inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } 505static inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); }
504inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } 506static inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); }
505inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } 507static inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); }
506inline void sv_to (SV *sv, mapspace * &v) { v = (mapspace *)SvPTR_ornull (sv, "cf::mapspace"); } 508static inline void sv_to (SV *sv, mapspace * &v) { v = (mapspace *)SvPTR_ornull (sv, "cf::mapspace"); }
507inline void sv_to (SV *sv, object_freezer * &v) { v = (object_freezer *)SvPTR_ornull (sv, "cf::object::freezer"); } 509static inline void sv_to (SV *sv, object_freezer * &v) { v = (object_freezer *)SvPTR_ornull (sv, "cf::object::freezer"); }
508inline void sv_to (SV *sv, object_thawer * &v) { v = (object_thawer *)SvPTR_ornull (sv, "cf::object::thawer" ); } 510static inline void sv_to (SV *sv, object_thawer * &v) { v = (object_thawer *)SvPTR_ornull (sv, "cf::object::thawer" ); }
509 511
510//inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; } 512//static inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; }
511inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); } 513static inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); }
512 514
513template<class T> 515template<class T>
514inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; } 516static inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; }
515 517
516template<int N> 518template<int N>
517inline void sv_to (SV *sv, char (&v)[N]) { assign (v, SvPV_nolen (sv)); } 519static inline void sv_to (SV *sv, char (&v)[N]) { assign (v, SvPV_nolen (sv)); }
518 520
519inline void sv_to (SV *sv, bowtype_t &v) { v = (bowtype_t) SvIV (sv); } 521static inline void sv_to (SV *sv, bowtype_t &v) { v = (bowtype_t) SvIV (sv); }
520inline void sv_to (SV *sv, petmode_t &v) { v = (petmode_t) SvIV (sv); } 522static inline void sv_to (SV *sv, petmode_t &v) { v = (petmode_t) SvIV (sv); }
521inline void sv_to (SV *sv, usekeytype &v) { v = (usekeytype) SvIV (sv); } 523static inline void sv_to (SV *sv, usekeytype &v) { v = (usekeytype) SvIV (sv); }
522inline void sv_to (SV *sv, unapplymode &v) { v = (unapplymode) SvIV (sv); } 524static inline void sv_to (SV *sv, unapplymode &v) { v = (unapplymode) SvIV (sv); }
523 525
524inline void sv_to (SV *sv, std::string &v) 526static inline void sv_to (SV *sv, std::string &v)
525{ 527{
526 STRLEN len; 528 STRLEN len;
527 char *data = SvPVbyte (sv, len); 529 char *data = SvPVbyte (sv, len);
528 v.assign (data, len); 530 v.assign (data, len);
529} 531}
530 532
531inline void sv_to (SV *sv, UUID &v) 533static inline void sv_to (SV *sv, UUID &v)
532{ 534{
533 if (!v.parse (SvPV_nolen (sv))) 535 if (!v.parse (SvPV_nolen (sv)))
534 croak ("unparsable uuid: %s", SvPV_nolen (sv)); 536 croak ("unparsable uuid: %s", SvPV_nolen (sv));
535} 537}
536 538
537inline void sv_to (SV *sv, object::flags_t::reference v) { v = SvTRUE (sv); } 539static inline void sv_to (SV *sv, object::flags_t::reference v) { v = SvTRUE (sv); }
538 540
539static SV * 541static SV *
540newSVdt_va (va_list &ap, data_type type) 542newSVdt_va (va_list &ap, data_type type)
541{ 543{
542 SV *sv; 544 SV *sv;
642 var = 0; 644 var = 0;
643} 645}
644 646
645////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 647//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
646 648
647SV * 649static SV *
648registry (attachable *ext) 650registry (attachable *ext)
649{ 651{
650 if (!ext->cb) 652 if (!ext->cb)
651 ext->cb = newAV (); 653 ext->cb = newAV ();
652 654
936 CALL_END; 938 CALL_END;
937 939
938 return count; 940 return count;
939} 941}
940 942
941SV * 943static SV *
942cfperl_result (int idx) 944cfperl_result (int idx)
943{ 945{
944 AV *av = get_av ("cf::INVOKE_RESULTS", 0); 946 AV *av = get_av ("cf::INVOKE_RESULTS", 0);
945 if (!av) 947 if (!av)
946 return &PL_sv_undef; 948 return &PL_sv_undef;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines