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.79 by root, Thu Dec 14 05:09:32 2006 UTC vs.
Revision 1.81 by root, Thu Dec 14 21:46:34 2006 UTC

834 PL_exit_flags |= PERL_EXIT_DESTRUCT_END; 834 PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
835 835
836 char *argv[] = { 836 char *argv[] = {
837 "", 837 "",
838 "-e" 838 "-e"
839 "cf->bootstrap;" 839 "use Event;" // required for bootstrap
840 "cf->bootstrap;" // requiored for datadir :*>
840 "unshift @INC, cf::datadir ();" 841 "unshift @INC, cf::datadir ();"
841 "require cf;" 842 "require cf;"
842 }; 843 };
843 844
844 if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) || perl_run (perl)) 845 if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) || perl_run (perl))
1055cfperl_result_DOUBLE (int idx) 1056cfperl_result_DOUBLE (int idx)
1056{ 1057{
1057 return SvNV (cfperl_result (idx)); 1058 return SvNV (cfperl_result (idx));
1058} 1059}
1059 1060
1061/////////////////////////////////////////////////////////////////////////////
1062
1063struct EventAPI *watcher_base::GEventAPI;
1064
1065static void iow_dispatch (pe_event *ev)
1066{
1067 iow *w = (iow *)ev->ext_data;
1068 w->call (*w, ((pe_ioevent *)ev)->got);
1069}
1070
1071void
1072iow::alloc ()
1073{
1074 pe = GEventAPI->new_io (0, 0);
1075
1076 pe->base.callback = (void *)iow_dispatch;
1077 pe->base.ext_data = (void *)this;
1078
1079 pe->fd = -1;
1080 pe->poll = 0;
1081}
1082
1083iow &
1084iow::fd (int fd)
1085{
1086 pe->fd = fd;
1087
1088 return *this;
1089}
1090
1091int
1092iow::poll ()
1093{
1094 return pe->poll;
1095}
1096
1097iow &
1098iow::poll (int events)
1099{
1100 if (pe->poll != events)
1101 {
1102 if (pe->poll) stop ();
1103 pe->poll = events;
1104 if (pe->poll) start ();
1105 }
1106
1107 return *this;
1108}
1109
1060MODULE = cf PACKAGE = cf PREFIX = cf_ 1110MODULE = cf PACKAGE = cf PREFIX = cf_
1061 1111
1062BOOT: 1112BOOT:
1063{ 1113{
1064 HV *stash = gv_stashpv ("cf", 1); 1114 HV *stash = gv_stashpv ("cf", 1);
1115
1116 I_EVENT_API (PACKAGE);
1117 watcher_base::GEventAPI = GEventAPI;
1065 1118
1066 newCONSTSUB (stash, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1)); 1119 newCONSTSUB (stash, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1));
1067 1120
1068 static const struct { 1121 static const struct {
1069 const char *name; 1122 const char *name;
1580 av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); 1633 av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0));
1581 av_push (event, newSViv (eiv->klass)); 1634 av_push (event, newSViv (eiv->klass));
1582 av_store (av, eiv->iv, newRV_noinc ((SV *)event)); 1635 av_store (av, eiv->iv, newRV_noinc ((SV *)event));
1583 newCONSTSUB (stash, (char *)eiv->name, newSViv (eiv->iv)); 1636 newCONSTSUB (stash, (char *)eiv->name, newSViv (eiv->iv));
1584 } 1637 }
1585
1586 //I_EVENT_API (PACKAGE);
1587} 1638}
1588 1639
1589void _init_vars () 1640void _init_vars ()
1590 CODE: 1641 CODE:
1591 cb_global = get_av ("cf::CB_GLOBAL", 1); 1642 cb_global = get_av ("cf::CB_GLOBAL", 1);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines