… | |
… | |
1878 | struct transfer_args ta; |
1878 | struct transfer_args ta; |
1879 | SV **arg = PL_stack_base + TOPMARK + 1; |
1879 | SV **arg = PL_stack_base + TOPMARK + 1; |
1880 | int items = SP - arg; /* args without function object */ |
1880 | int items = SP - arg; /* args without function object */ |
1881 | int ix = PL_op->op_private & OPpENTERSUB_SLF; |
1881 | int ix = PL_op->op_private & OPpENTERSUB_SLF; |
1882 | struct CoroSLF *slf = 0; |
1882 | struct CoroSLF *slf = 0; |
|
|
1883 | SV *gv = *sp; |
1883 | |
1884 | |
1884 | /* do a quick consistency check on the "function" object, and if it isn't */ |
1885 | /* do a quick consistency check on the "function" object, and if it isn't */ |
1885 | /* for us, divert to the real entersub */ |
1886 | /* for us, divert to the real entersub */ |
1886 | if (SvTYPE (*sp) != SVt_PVGV || CvXSUB (GvCV (*sp)) != XS_Coro__State__set_stacklevel) |
1887 | if (SvTYPE (gv) != SVt_PVGV || CvXSUB (GvCV (gv)) != XS_Coro__State__set_stacklevel) |
1887 | return PL_ppaddr[OP_ENTERSUB](aTHX); |
1888 | return PL_ppaddr[OP_ENTERSUB](aTHX); |
1888 | |
1889 | |
1889 | /* pop args */ |
1890 | /* pop args */ |
1890 | SP = PL_stack_base + POPMARK; |
1891 | SP = PL_stack_base + POPMARK; |
1891 | |
1892 | |
… | |
… | |
1899 | |
1900 | |
1900 | PUTBACK; |
1901 | PUTBACK; |
1901 | |
1902 | |
1902 | if (!ix) |
1903 | if (!ix) |
1903 | { |
1904 | { |
1904 | slf = (struct CoroSLF *)CvSTART (GvCV (*sp)); |
1905 | slf = (struct CoroSLF *)CvXSUBANY (GvCV (gv)).any_ptr; |
1905 | ix = slf->prepare (aTHX_ arg, items); |
1906 | ix = slf->prepare (aTHX_ arg, items); |
1906 | } |
1907 | } |
1907 | |
1908 | |
1908 | switch (ix) |
1909 | switch (ix) |
1909 | { |
1910 | { |
… | |
… | |
1969 | PL_op->op_private = PL_op->op_private & ~OPpENTERSUB_SLF | ix; /* we potentially share our private flags with entersub */ |
1970 | PL_op->op_private = PL_op->op_private & ~OPpENTERSUB_SLF | ix; /* we potentially share our private flags with entersub */ |
1970 | |
1971 | |
1971 | PL_op = (OP *)&slf_restore; |
1972 | PL_op = (OP *)&slf_restore; |
1972 | } |
1973 | } |
1973 | |
1974 | |
|
|
1975 | static void |
|
|
1976 | api_execute_slf (pTHX_ CV *cv, const struct CoroSLF *slf, SV **arg, int items) |
|
|
1977 | { |
|
|
1978 | CvXSUBANY (cv).any_ptr = (void *)slf; |
|
|
1979 | coro_slf_patch (aTHX_ cv, CORO_SLF_CUSTOM, arg, items); |
|
|
1980 | } |
|
|
1981 | |
1974 | MODULE = Coro::State PACKAGE = Coro::State PREFIX = api_ |
1982 | MODULE = Coro::State PACKAGE = Coro::State PREFIX = api_ |
1975 | |
1983 | |
1976 | PROTOTYPES: DISABLE |
1984 | PROTOTYPES: DISABLE |
1977 | |
1985 | |
1978 | BOOT: |
1986 | BOOT: |
… | |
… | |
2007 | main_top_env = PL_top_env; |
2015 | main_top_env = PL_top_env; |
2008 | |
2016 | |
2009 | while (main_top_env->je_prev) |
2017 | while (main_top_env->je_prev) |
2010 | main_top_env = main_top_env->je_prev; |
2018 | main_top_env = main_top_env->je_prev; |
2011 | |
2019 | |
2012 | coroapi.ver = CORO_API_VERSION; |
2020 | coroapi.ver = CORO_API_VERSION; |
2013 | coroapi.rev = CORO_API_REVISION; |
2021 | coroapi.rev = CORO_API_REVISION; |
2014 | coroapi.transfer = api_transfer; |
2022 | coroapi.transfer = api_transfer; |
|
|
2023 | coroapi.execute_slf = api_execute_slf; |
2015 | |
2024 | |
2016 | { |
2025 | { |
2017 | SV **svp = hv_fetch (PL_modglobal, "Time::NVtime", 12, 0); |
2026 | SV **svp = hv_fetch (PL_modglobal, "Time::NVtime", 12, 0); |
2018 | |
2027 | |
2019 | if (!svp) croak ("Time::HiRes is required"); |
2028 | if (!svp) croak ("Time::HiRes is required"); |