… | |
… | |
270 | AV *av = (AV *)mg->mg_obj; |
270 | AV *av = (AV *)mg->mg_obj; |
271 | |
271 | |
272 | /* casting is fun. */ |
272 | /* casting is fun. */ |
273 | while (&PL_sv_undef != (SV *)(padlist = (AV *)av_pop (av))) |
273 | while (&PL_sv_undef != (SV *)(padlist = (AV *)av_pop (av))) |
274 | free_padlist (aTHX_ padlist); |
274 | free_padlist (aTHX_ padlist); |
|
|
275 | |
|
|
276 | SvREFCNT_dec (av); |
275 | } |
277 | } |
276 | |
278 | |
277 | #define PERL_MAGIC_coro PERL_MAGIC_ext |
279 | #define PERL_MAGIC_coro PERL_MAGIC_ext |
278 | |
280 | |
279 | static MGVTBL vtbl_coro = {0, 0, 0, 0, coro_cv_free}; |
281 | static MGVTBL vtbl_coro = {0, 0, 0, 0, coro_cv_free}; |
… | |
… | |
979 | croak ("Coro::State::_newprocess expects an arrayref"); |
981 | croak ("Coro::State::_newprocess expects an arrayref"); |
980 | |
982 | |
981 | Newz (0, coro, 1, struct coro); |
983 | Newz (0, coro, 1, struct coro); |
982 | |
984 | |
983 | coro->args = (AV *)SvREFCNT_inc (SvRV (args)); |
985 | coro->args = (AV *)SvREFCNT_inc (SvRV (args)); |
984 | coro->mainstack = 0; /* actual work is done inside transfer */ |
986 | /*coro->mainstack = 0; *//*actual work is done inside transfer */ |
985 | coro->stack = 0; |
987 | /*coro->stack = 0;*/ |
986 | |
988 | |
987 | /* same as JMPENV_BOOTSTRAP */ |
989 | /* same as JMPENV_BOOTSTRAP */ |
988 | /* we might be able to recycle start_env, but safe is safe */ |
990 | /* we might be able to recycle start_env, but safe is safe */ |
989 | //Zero(&coro->start_env, 1, JMPENV); |
991 | /*Zero(&coro->start_env, 1, JMPENV);*/ |
990 | coro->start_env.je_ret = -1; |
992 | coro->start_env.je_ret = -1; |
991 | coro->start_env.je_mustcatch = TRUE; |
993 | coro->start_env.je_mustcatch = TRUE; |
992 | |
994 | |
993 | RETVAL = coro; |
995 | RETVAL = coro; |
994 | OUTPUT: |
996 | OUTPUT: |
… | |
… | |
1015 | if (coro->mainstack && coro->mainstack != main_mainstack) |
1017 | if (coro->mainstack && coro->mainstack != main_mainstack) |
1016 | { |
1018 | { |
1017 | struct coro temp; |
1019 | struct coro temp; |
1018 | |
1020 | |
1019 | PUTBACK; |
1021 | PUTBACK; |
1020 | SAVE(aTHX_ (&temp), TRANSFER_SAVE_ALL); |
1022 | SAVE (aTHX_ (&temp), TRANSFER_SAVE_ALL); |
1021 | LOAD(aTHX_ coro); |
1023 | LOAD (aTHX_ coro); |
1022 | SPAGAIN; |
1024 | SPAGAIN; |
1023 | |
1025 | |
1024 | destroy_stacks (aTHX); |
1026 | destroy_stacks (aTHX); |
1025 | |
1027 | |
1026 | LOAD((&temp)); /* this will get rid of defsv etc.. */ |
1028 | LOAD ((&temp)); /* this will get rid of defsv etc.. */ |
1027 | SPAGAIN; |
1029 | SPAGAIN; |
1028 | |
1030 | |
1029 | coro->mainstack = 0; |
1031 | coro->mainstack = 0; |
1030 | } |
1032 | } |
1031 | |
1033 | |
… | |
… | |
1060 | av_clear (defav); |
1062 | av_clear (defav); |
1061 | av_fill (defav, items - 1); |
1063 | av_fill (defav, items - 1); |
1062 | while (items--) |
1064 | while (items--) |
1063 | av_store (defav, items, SvREFCNT_inc (ST(items))); |
1065 | av_store (defav, items, SvREFCNT_inc (ST(items))); |
1064 | |
1066 | |
1065 | mg_get (returnstk); /* isn't documentation wrong for mg_get? */ |
1067 | SvGETMAGIC (returnstk); /* isn't documentation wrong for mg_get? */ |
1066 | sv = av_pop ((AV *)SvRV (returnstk)); |
1068 | sv = av_pop ((AV *)SvRV (returnstk)); |
1067 | prev = (struct coro *)SvIV ((SV*)SvRV (*av_fetch ((AV *)SvRV (sv), 0, 0))); |
1069 | prev = (struct coro *)SvIV ((SV*)SvRV (*av_fetch ((AV *)SvRV (sv), 0, 0))); |
1068 | next = (struct coro *)SvIV ((SV*)SvRV (*av_fetch ((AV *)SvRV (sv), 1, 0))); |
1070 | next = (struct coro *)SvIV ((SV*)SvRV (*av_fetch ((AV *)SvRV (sv), 1, 0))); |
1069 | SvREFCNT_dec (sv); |
1071 | SvREFCNT_dec (sv); |
1070 | |
1072 | |
1071 | transfer(aTHX_ prev, next, 0); |
1073 | transfer (aTHX_ prev, next, 0); |
1072 | |
1074 | |
1073 | MODULE = Coro::State PACKAGE = Coro |
1075 | MODULE = Coro::State PACKAGE = Coro |
1074 | |
1076 | |
1075 | # this is slightly dirty (should expose a c-level api) |
1077 | # this is slightly dirty (should expose a c-level api) |
1076 | |
1078 | |