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.312 by root, Tue Dec 23 06:58:24 2008 UTC vs.
Revision 1.315 by root, Thu Jan 8 03:03:24 2009 UTC

158 SvREFCNT_inc (self); 158 SvREFCNT_inc (self);
159 hv_clear (self); 159 hv_clear (self);
160 sv_unmagic ((SV *)self, PERL_MAGIC_ext); 160 sv_unmagic ((SV *)self, PERL_MAGIC_ext);
161 SvREFCNT_dec (self); 161 SvREFCNT_dec (self);
162 162
163 // self *must* be null now because thats sv_unmagic's job. 163 // self *must* be null now because that's sv_unmagic's job.
164 assert (!this->self); 164 assert (!this->self);
165 } 165 }
166} 166}
167 167
168void 168void
405 croak ("perl code used %s object, but C object is already destroyed, caught", klass); 405 croak ("perl code used %s object, but C object is already destroyed, caught", klass);
406 406
407 return (long)mg->mg_ptr; 407 return (long)mg->mg_ptr;
408} 408}
409 409
410static long 410static long noinline
411SvPTR_ornull (SV *sv, const char *klass) 411SvPTR_ornull (SV *sv, const char *klass)
412{ 412{
413 if (SvOK (sv)) 413 if (SvOK (sv))
414 return SvPTR (sv, klass); 414 return SvPTR (sv, klass);
415 else 415 else
607 va_end (ap); 607 va_end (ap);
608 608
609 return sv; 609 return sv;
610} 610}
611 611
612// typemap support, mostly to avoid excessive inlining
613template<class type>
614static void noinline
615cf_obj_to (SV *arg, type &var)
616{
617 sv_to (arg, var);
618 if (!var)
619 croak ("must not pass invalid/null cf_obj here");
620}
621
622template<class object>
623static void noinline
624cf_obj_ornull_to (SV *arg, object *&var)
625{
626 if (SvOK (arg))
627 {
628 sv_to (arg, var);
629 if (!var)
630 croak ("unable to convert perl object to C++ object");
631 }
632 else
633 var = 0;
634}
635
612////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 636//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
613 637
614SV * 638SV *
615registry (attachable *ext) 639registry (attachable *ext)
616{ 640{
660 printf ("unable to bootstrap perl, aborting:\n%s", SvPV_nolen (ERRSV)); 684 printf ("unable to bootstrap perl, aborting:\n%s", SvPV_nolen (ERRSV));
661 exit (EXIT_FAILURE); 685 exit (EXIT_FAILURE);
662 } 686 }
663} 687}
664 688
689void
665void cfperl_main () 690cfperl_main ()
666{ 691{
667 dSP; 692 dSP;
668 693
669 PUSHMARK (SP); 694 PUSHMARK (SP);
670 PUTBACK; 695 PUTBACK;
695# undef def 720# undef def
696}; 721};
697 722
698#define KLASS_OF(event) (((unsigned int)event) < NUM_EVENT_TYPES ? klass_of [event] : KLASS_NONE) 723#define KLASS_OF(event) (((unsigned int)event) < NUM_EVENT_TYPES ? klass_of [event] : KLASS_NONE)
699 724
700static void 725static void noinline
701gather_callbacks (AV *&callbacks, AV *registry, event_type event) 726gather_callbacks (AV *&callbacks, AV *registry, event_type event)
702{ 727{
703 // event must be in array 728 // event must be in array
704 if (event >= 0 && event <= AvFILLp (registry)) 729 if (event >= 0 && event <= AvFILLp (registry))
705 { 730 {
791{ 816{
792 attachable::gather_callbacks (callbacks, event); 817 attachable::gather_callbacks (callbacks, event);
793 ::gather_callbacks (callbacks, cb_map, event); 818 ::gather_callbacks (callbacks, cb_map, event);
794} 819}
795 820
796void 821static void noinline
797_recalc_want (bitset<NUM_EVENT_TYPES> &set, AV *registry) 822_recalc_want (bitset<NUM_EVENT_TYPES> &set, AV *registry)
798{ 823{
799 for (int event = 0; event <= AvFILLp (registry); ++event) 824 for (int event = 0; event <= AvFILLp (registry); ++event)
800 { 825 {
801 SV *cbs_ = AvARRAY (registry)[event]; 826 SV *cbs_ = AvARRAY (registry)[event];
811 } 836 }
812 } 837 }
813} 838}
814 839
815// very slow and inefficient way to recalculate the global want bitsets 840// very slow and inefficient way to recalculate the global want bitsets
816void 841static void
817_recalc_want () 842_recalc_want ()
818{ 843{
819 ev_want_event.reset (); 844 ev_want_event.reset ();
820 845
821 _recalc_want (ev_want_event, cb_global); 846 _recalc_want (ev_want_event, cb_global);
931} 956}
932 957
933///////////////////////////////////////////////////////////////////////////// 958/////////////////////////////////////////////////////////////////////////////
934// various c++ => perl glue functions 959// various c++ => perl glue functions
935 960
961void
936void cfperl_tick () 962cfperl_tick ()
937{ 963{
938 tick_pending = 1; 964 tick_pending = 1;
939 965
940 if (tick_inhibit) 966 if (tick_inhibit)
941 return; 967 return;
1003 CALL_END; 1029 CALL_END;
1004 1030
1005 return can; 1031 return can;
1006} 1032}
1007 1033
1034void
1035cfperl_mapscript_activate (object *ob, object *activator, int state)
1036{
1037 CALL_BEGIN (3);
1038 CALL_ARG (ob);
1039 CALL_ARG (activator);
1040 CALL_ARG (state);
1041 CALL_CALL ("cf::mapscript::activate", G_VOID);
1042 CALL_END;
1043}
1044
1008player * 1045player *
1009player::find (const char *name) 1046player::find (const char *name)
1010{ 1047{
1011 CALL_BEGIN (1); 1048 CALL_BEGIN (1);
1012 CALL_ARG (name); 1049 CALL_ARG (name);
1155///////////////////////////////////////////////////////////////////////////// 1192/////////////////////////////////////////////////////////////////////////////
1156 1193
1157struct EVAPI *evapi::GEVAPI; 1194struct EVAPI *evapi::GEVAPI;
1158struct CoroAPI *coroapi::GCoroAPI; 1195struct CoroAPI *coroapi::GCoroAPI;
1159 1196
1197void
1160void coroapi::do_cede_to_tick () 1198coroapi::do_cede_to_tick ()
1161{ 1199{
1162 cede_pending = 0; 1200 cede_pending = 0;
1163 cede (); 1201 cede ();
1164} 1202}
1165 1203
1189 ev_io_set ((ev_io *)this, fd, events); 1227 ev_io_set ((ev_io *)this, fd, events);
1190 if (active) start (); 1228 if (active) start ();
1191 } 1229 }
1192} 1230}
1193 1231
1194void 1232static void
1195_connect_to_perl () 1233_connect_to_perl ()
1196{ 1234{
1197 stash_cf = gv_stashpv ("cf", 1); 1235 stash_cf = gv_stashpv ("cf", 1);
1198 1236
1199 stash_cf_object_wrap = gv_stashpv ("cf::object::wrap", 1); 1237 stash_cf_object_wrap = gv_stashpv ("cf::object::wrap", 1);
1289 const_iv (FORCE) const_iv (POTION_EFFECT) const_iv (EVENT_CONNECTOR) const_iv (CLOSE_CON) 1327 const_iv (FORCE) const_iv (POTION_EFFECT) const_iv (EVENT_CONNECTOR) const_iv (CLOSE_CON)
1290 const_iv (CONTAINER) const_iv (ARMOUR_IMPROVER) const_iv (WEAPON_IMPROVER) const_iv (SKILLSCROLL) 1328 const_iv (CONTAINER) const_iv (ARMOUR_IMPROVER) const_iv (WEAPON_IMPROVER) const_iv (SKILLSCROLL)
1291 const_iv (DEEP_SWAMP) const_iv (IDENTIFY_ALTAR) const_iv (MENU) const_iv (RUNE) 1329 const_iv (DEEP_SWAMP) const_iv (IDENTIFY_ALTAR) const_iv (MENU) const_iv (RUNE)
1292 const_iv (TRAP) const_iv (POWER_CRYSTAL) const_iv (CORPSE) const_iv (DISEASE) 1330 const_iv (TRAP) const_iv (POWER_CRYSTAL) const_iv (CORPSE) const_iv (DISEASE)
1293 const_iv (SYMPTOM) const_iv (BUILDER) const_iv (MATERIAL) const_iv (ITEM_TRANSFORMER) 1331 const_iv (SYMPTOM) const_iv (BUILDER) const_iv (MATERIAL) const_iv (ITEM_TRANSFORMER)
1332 const_iv (MAPSCRIPT) const_iv (SAFE_GROUND)
1294 1333
1295 const_iv (NUM_TYPES) const_iv (NUM_SUBTYPES) 1334 const_iv (NUM_TYPES) const_iv (NUM_SUBTYPES)
1296 1335
1297 const_iv (ST_BD_BUILD) const_iv (ST_BD_REMOVE) 1336 const_iv (ST_BD_BUILD) const_iv (ST_BD_REMOVE)
1298 const_iv (ST_MAT_FLOOR) const_iv (ST_MAT_WALL) const_iv (ST_MAT_ITEM) 1337 const_iv (ST_MAT_FLOOR) const_iv (ST_MAT_WALL) const_iv (ST_MAT_ITEM)
2108 2147
2109void push_button (object *op); 2148void push_button (object *op);
2110 2149
2111void use_trigger (object *op); 2150void use_trigger (object *op);
2112 2151
2113void add_button_link (object *button, maptile *map, int connected);
2114
2115void remove_button_link (object *op);
2116
2117void handle_apply_yield (object *op); 2152void handle_apply_yield (object *op);
2118 2153
2119 2154
2120MODULE = cf PACKAGE = cf::object PREFIX = cf_ 2155MODULE = cf PACKAGE = cf::object PREFIX = cf_
2121 2156
2445 } 2480 }
2446 2481
2447int out_of_map (maptile *map, int x, int y) 2482int out_of_map (maptile *map, int x, int y)
2448 2483
2449void 2484void
2450trigger (maptile *map, long connection, bool state = true) 2485find_link (maptile *map, shstr_tmp connection)
2451 CODE:
2452 activate_connection (map, connection, state);
2453
2454void
2455get_connection (maptile *map, long connection)
2456 PPCODE: 2486 PPCODE:
2457 oblinkpt *obp = get_connection_links (map, connection); 2487 if (oblinkpt *obp = map->find_link (connection))
2458 if (obp)
2459 for (objectlink *ol = obp->link; ol; ol = ol->next) 2488 for (objectlink *ol = obp->link; ol; ol = ol->next)
2460 XPUSHs (sv_2mortal (to_sv ((object *)ol->ob))); 2489 XPUSHs (sv_2mortal (to_sv ((object *)ol->ob)));
2461 2490
2462void 2491void
2463get_map_flags (maptile *map, int x, int y) 2492get_map_flags (maptile *map, int x, int y)
2693 PROTOTYPE: $ 2722 PROTOTYPE: $
2694 CODE: 2723 CODE:
2695 RETVAL = region::find (name); 2724 RETVAL = region::find (name);
2696 OUTPUT: RETVAL 2725 OUTPUT: RETVAL
2697 2726
2698region *find_fuzzy (utf8_string name)
2699 PROTOTYPE: $
2700 CODE:
2701 RETVAL = region::find_fuzzy (name);
2702 OUTPUT: RETVAL
2703
2704int specificity (region *rgn) 2727int specificity (region *rgn)
2705 CODE: 2728 CODE:
2706 RETVAL = 0; 2729 RETVAL = 0;
2707 while (rgn = rgn->parent) 2730 while (rgn = rgn->parent)
2708 RETVAL++; 2731 RETVAL++;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines