… | |
… | |
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)) |
… | |
… | |
1055 | cfperl_result_DOUBLE (int idx) |
1056 | cfperl_result_DOUBLE (int idx) |
1056 | { |
1057 | { |
1057 | return SvNV (cfperl_result (idx)); |
1058 | return SvNV (cfperl_result (idx)); |
1058 | } |
1059 | } |
1059 | |
1060 | |
|
|
1061 | ///////////////////////////////////////////////////////////////////////////// |
|
|
1062 | |
|
|
1063 | struct EventAPI *watcher_base::GEventAPI; |
|
|
1064 | |
|
|
1065 | static void iow_dispatch (pe_event *ev) |
|
|
1066 | { |
|
|
1067 | iow *w = (iow *)ev->ext_data; |
|
|
1068 | w->call (*w, ((pe_ioevent *)ev)->got); |
|
|
1069 | } |
|
|
1070 | |
|
|
1071 | void |
|
|
1072 | iow::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 | |
|
|
1083 | iow & |
|
|
1084 | iow::fd (int fd) |
|
|
1085 | { |
|
|
1086 | pe->fd = fd; |
|
|
1087 | |
|
|
1088 | return *this; |
|
|
1089 | } |
|
|
1090 | |
|
|
1091 | int |
|
|
1092 | iow::poll () |
|
|
1093 | { |
|
|
1094 | return pe->poll; |
|
|
1095 | } |
|
|
1096 | |
|
|
1097 | iow & |
|
|
1098 | iow::poll (int events) |
|
|
1099 | { |
|
|
1100 | pe->poll = events; |
|
|
1101 | |
|
|
1102 | return *this; |
|
|
1103 | } |
|
|
1104 | |
1060 | MODULE = cf PACKAGE = cf PREFIX = cf_ |
1105 | MODULE = cf PACKAGE = cf PREFIX = cf_ |
1061 | |
1106 | |
1062 | BOOT: |
1107 | BOOT: |
1063 | { |
1108 | { |
1064 | HV *stash = gv_stashpv ("cf", 1); |
1109 | HV *stash = gv_stashpv ("cf", 1); |
|
|
1110 | |
|
|
1111 | I_EVENT_API (PACKAGE); |
|
|
1112 | watcher_base::GEventAPI = GEventAPI; |
1065 | |
1113 | |
1066 | newCONSTSUB (stash, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1)); |
1114 | newCONSTSUB (stash, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1)); |
1067 | |
1115 | |
1068 | static const struct { |
1116 | static const struct { |
1069 | const char *name; |
1117 | const char *name; |
… | |
… | |
1580 | av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); |
1628 | av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); |
1581 | av_push (event, newSViv (eiv->klass)); |
1629 | av_push (event, newSViv (eiv->klass)); |
1582 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
1630 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
1583 | newCONSTSUB (stash, (char *)eiv->name, newSViv (eiv->iv)); |
1631 | newCONSTSUB (stash, (char *)eiv->name, newSViv (eiv->iv)); |
1584 | } |
1632 | } |
1585 | |
|
|
1586 | //I_EVENT_API (PACKAGE); |
|
|
1587 | } |
1633 | } |
1588 | |
1634 | |
1589 | void _init_vars () |
1635 | void _init_vars () |
1590 | CODE: |
1636 | CODE: |
1591 | cb_global = get_av ("cf::CB_GLOBAL", 1); |
1637 | cb_global = get_av ("cf::CB_GLOBAL", 1); |