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.272 by root, Wed Apr 2 11:13:56 2008 UTC vs.
Revision 1.278 by root, Sun Apr 20 00:44:13 2008 UTC

58 58
59typedef object_thawer &object_thawer_ref; 59typedef object_thawer &object_thawer_ref;
60typedef object_freezer &object_freezer_ref; 60typedef object_freezer &object_freezer_ref;
61 61
62typedef std::string std__string; 62typedef std::string std__string;
63
64#if IVSIZE >= 8
65 typedef IV val64;
66# define newSVval64 newSViv
67# define SvVAL64 SvIV
68#else
69 typedef double val64;
70# define newSVval64 newSVnv
71# define SvVAL64 SvNV
72#endif
73 63
74static PerlInterpreter *perl; 64static PerlInterpreter *perl;
75 65
76tstamp NOW, runtime; 66tstamp NOW, runtime;
77 67
444inline SV *to_sv (living & v) { return to_sv (&v); } 434inline SV *to_sv (living & v) { return to_sv (&v); }
445 435
446inline SV *to_sv (const std::string & v) { return newSVpvn (v.data (), v.size ()); } 436inline SV *to_sv (const std::string & v) { return newSVpvn (v.data (), v.size ()); }
447inline SV *to_sv (const treasurelist *v) { return to_sv (v->name); } 437inline SV *to_sv (const treasurelist *v) { return to_sv (v->name); }
448 438
449inline SV *to_sv (UUID v) 439inline SV *to_sv (UUID v) { return newSVpv (v.c_str (), 0); }
450{
451 char buf[128];
452 snprintf (buf, 128, "<1.%" PRIx64 ">", v.seq);
453 return newSVpv (buf, 0);
454}
455 440
456inline void sv_to (SV *sv, shstr &v) { v = SvOK (sv) ? SvPVutf8_nolen (sv) : 0; } 441inline void sv_to (SV *sv, shstr &v) { v = SvOK (sv) ? SvPVutf8_nolen (sv) : 0; }
457inline void sv_to (SV *sv, char * &v) { free (v); v = SvOK (sv) ? strdup (SvPV_nolen (sv)) : 0; } 442inline void sv_to (SV *sv, char * &v) { free (v); v = SvOK (sv) ? strdup (SvPV_nolen (sv)) : 0; }
458inline void sv_to (SV *sv, bool &v) { v = SvIV (sv); } 443inline void sv_to (SV *sv, bool &v) { v = SvIV (sv); }
459inline void sv_to (SV *sv, signed char &v) { v = SvIV (sv); } 444inline void sv_to (SV *sv, signed char &v) { v = SvIV (sv); }
501 v.assign (data, len); 486 v.assign (data, len);
502} 487}
503 488
504inline void sv_to (SV *sv, UUID &v) 489inline void sv_to (SV *sv, UUID &v)
505{ 490{
506 unsigned int version; 491 if (!v.parse (SvPV_nolen (sv)))
507
508 if (2 != sscanf (SvPV_nolen (sv), "<%d.%" SCNx64 ">", &version, &v.seq) || 1 != version)
509 croak ("unparsable uuid: %s", SvPV_nolen (sv)); 492 croak ("unparsable uuid: %s", SvPV_nolen (sv));
510} 493}
511 494
512inline void sv_to (SV *sv, object::flags_t::reference v) { v = SvTRUE (sv); } 495inline void sv_to (SV *sv, object::flags_t::reference v) { v = SvTRUE (sv); }
513 496
1419 const_iv (ATNR_PARALYZE) const_iv (ATNR_TURN_UNDEAD) const_iv (ATNR_FEAR) const_iv (ATNR_CANCELLATION) 1402 const_iv (ATNR_PARALYZE) const_iv (ATNR_TURN_UNDEAD) const_iv (ATNR_FEAR) const_iv (ATNR_CANCELLATION)
1420 const_iv (ATNR_DEPLETE) const_iv (ATNR_DEATH) const_iv (ATNR_CHAOS) const_iv (ATNR_COUNTERSPELL) 1403 const_iv (ATNR_DEPLETE) const_iv (ATNR_DEATH) const_iv (ATNR_CHAOS) const_iv (ATNR_COUNTERSPELL)
1421 const_iv (ATNR_GODPOWER) const_iv (ATNR_HOLYWORD) const_iv (ATNR_BLIND) const_iv (ATNR_INTERNAL) 1404 const_iv (ATNR_GODPOWER) const_iv (ATNR_HOLYWORD) const_iv (ATNR_BLIND) const_iv (ATNR_INTERNAL)
1422 const_iv (ATNR_LIFE_STEALING) const_iv (ATNR_DISEASE) 1405 const_iv (ATNR_LIFE_STEALING) const_iv (ATNR_DISEASE)
1423 1406
1424 const_iv (MAP_IN_MEMORY) const_iv (MAP_SWAPPED) const_iv (MAP_LOADING) const_iv (MAP_SAVING) 1407 const_iv (MAP_ACTIVE) const_iv (MAP_SWAPPED) const_iv (MAP_LOADING) const_iv (MAP_SAVING)
1408 const_iv (MAP_INACTIVE)
1425 1409
1426 const_iv (KLASS_ATTACHABLE) const_iv (KLASS_GLOBAL) const_iv (KLASS_OBJECT) 1410 const_iv (KLASS_ATTACHABLE) const_iv (KLASS_GLOBAL) const_iv (KLASS_OBJECT)
1427 const_iv (KLASS_CLIENT) const_iv (KLASS_PLAYER) const_iv (KLASS_MAP) 1411 const_iv (KLASS_CLIENT) const_iv (KLASS_PLAYER) const_iv (KLASS_MAP)
1428 1412
1429 const_iv (VERSION_CS) const_iv (VERSION_SC) 1413 const_iv (VERSION_CS) const_iv (VERSION_SC)
1534 } 1518 }
1535 1519
1536 SvCUR_set (data_sv, dst - SvPVX (data_sv)); 1520 SvCUR_set (data_sv, dst - SvPVX (data_sv));
1537} 1521}
1538 1522
1539void evthread_start () 1523void evthread_start (int aiofd)
1540 1524
1541void cede_to_tick () 1525void cede_to_tick ()
1542 CODE: 1526 CODE:
1543 coroapi::cede_to_tick (); 1527 coroapi::cede_to_tick ();
1544 1528
1697 1681
1698#if _POSIX_MEMLOCK 1682#if _POSIX_MEMLOCK
1699 1683
1700int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) 1684int mlockall (int flags = MCL_CURRENT | MCL_FUTURE)
1701 INIT: 1685 INIT:
1686#ifdef __linux
1702 mallopt (M_PERTURB, 0xaa); // bug-workaround for linux glibc+mlockall+calloc 1687 mallopt (M_PERTURB, 0xaa); // bug-workaround for linux glibc+mlockall+calloc
1688#endif
1703 1689
1704int munlockall () 1690int munlockall ()
1705 1691
1706#endif 1692#endif
1707 1693
1749 RETVAL = newSVpv (resist_plus[atnr], 0); 1735 RETVAL = newSVpv (resist_plus[atnr], 0);
1750 else 1736 else
1751 XSRETURN_UNDEF; 1737 XSRETURN_UNDEF;
1752 OUTPUT: RETVAL 1738 OUTPUT: RETVAL
1753 1739
1740UUID
1741uuid_cur ()
1742 CODE:
1743 RETVAL = UUID::cur;
1744 OUTPUT:
1745 RETVAL
1746
1747UUID
1748uuid_gen ()
1749 CODE:
1750 RETVAL = UUID::gen ();
1751 OUTPUT:
1752 RETVAL
1753
1754val64
1755uuid_seq (UUID uuid)
1756 CODE:
1757 RETVAL = uuid.seq;
1758 OUTPUT:
1759 RETVAL
1760
1761UUID
1762uuid_str (val64 seq)
1763 CODE:
1764 RETVAL.seq = seq;
1765 OUTPUT:
1766 RETVAL
1767
1768void
1769coin_names ()
1770 PPCODE:
1771 EXTEND (SP, NUM_COINS);
1772 for (int i = 0; i < NUM_COINS; ++i)
1773 PUSHs (sv_2mortal (newSVpv (coins [i], 0)));
1774
1775void
1776coin_archetypes ()
1777 PPCODE:
1778 EXTEND (SP, NUM_COINS);
1779 for (int i = 0; i < NUM_COINS; ++i)
1780 PUSHs (sv_2mortal (to_sv (archetype::find (coins [i]))));
1781
1754bool 1782bool
1755load_resource_file (octet_string filename) 1783load_resource_file_ (octet_string filename)
1756 1784
1757MODULE = cf PACKAGE = cf::attachable 1785MODULE = cf PACKAGE = cf::attachable
1758 1786
1759int 1787int
1760valid (SV *obj) 1788valid (SV *obj)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines