| 1 |
|
| #include "EXTERN.h" |
| 2 |
|
| #include "perl.h" |
| 3 |
|
| #include "callparser1.h" |
| 4 |
|
| #include "XSUB.h" |
| 5 |
|
| |
| 6 |
|
| #ifndef cv_clone |
| 7 |
|
| #define cv_clone(a) Perl_cv_clone(aTHX_ a) |
| 8 |
|
| #endif |
| 9 |
|
| |
| 10 |
10 |
| static SV *args_builder(U32 *flagsp) { |
| 11 |
|
| I32 floor; |
| 12 |
|
| CV *code; |
| 13 |
|
| U8 errors; |
| 14 |
|
| |
| 15 |
10 |
| ENTER; |
| 16 |
|
| |
| 17 |
10 |
| PL_curcop = &PL_compiling; |
| 18 |
10 |
| SAVEVPTR(PL_op); |
| 19 |
10 |
| SAVEI8(PL_parser->error_count); |
| 20 |
10 |
| PL_parser->error_count = 0; |
| 21 |
|
| |
| 22 |
10 |
| floor = start_subparse(0, CVf_ANON); |
| 23 |
10 |
| code = newATTRSUB(floor, NULL, NULL, NULL, parse_args_list(flagsp)); |
| 24 |
10 |
| errors = PL_parser->error_count; |
| 25 |
|
| |
| 26 |
10 |
| LEAVE; |
| 27 |
|
| |
| 28 |
10 |
▶ | if (errors) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (errors) { |
0 |
10 |
10 |
|
| 29 |
0 |
| ++PL_parser->error_count; |
| 30 |
0 |
| code = NULL; |
| 31 |
|
| } |
| 32 |
|
| else { |
| 33 |
10 |
▶ | if ( CvROOT(code) == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( CvROOT(code) == NULL ) { |
4 |
6 |
10 |
|
| 34 |
4 |
| code = NULL; |
| 35 |
|
| } |
| 36 |
|
| else { |
| 37 |
6 |
▶ | if (CvCLONE(code)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (CvCLONE(code)) { |
6 |
0 |
6 |
|
| 38 |
6 |
| code = cv_clone(code); |
| 39 |
|
| } |
| 40 |
|
| } |
| 41 |
|
| } |
| 42 |
|
| |
| 43 |
10 |
▶ | return code ? newRV_inc((SV*) code) : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| return code ? newRV_inc((SV*) code) : NULL; |
6 |
4 |
10 |
|
| 44 |
|
| } |
| 45 |
|
| |
| 46 |
10 |
| static OP *parser_callback(pTHX_ GV *namegv, SV *psobj, U32 *flagsp) { |
| 47 |
10 |
| dSP; |
| 48 |
10 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
10 |
10 |
|
| 49 |
10 |
▶ | mXPUSHs(args_builder(flagsp)); |
Branch: 1 branch
| Branch | True | False | Total |
| mXPUSHs(args_builder(flagsp)); |
0 |
10 |
10 |
|
| 50 |
10 |
| PUTBACK; |
| 51 |
10 |
| call_sv(psobj, G_VOID); |
| 52 |
9 |
| SPAGAIN; |
| 53 |
9 |
| PUTBACK; |
| 54 |
9 |
| return newNULLLIST(); |
| 55 |
|
| } |
| 56 |
|
| |
| 57 |
|
| MODULE = BEGIN::Lift PACKAGE = BEGIN::Lift::Util |
| 58 |
|
| |
| 59 |
|
| PROTOTYPES: DISABLE |
| 60 |
|
| |
| 61 |
|
| void |
| 62 |
|
| install_keyword_handler(keyword, handler) |
| 63 |
|
| SV *keyword |
| 64 |
|
| SV *handler |
| 65 |
|
| CODE: |
| 66 |
7 |
▶ | if (SvTYPE(keyword) != SVt_RV && SvTYPE(SvRV(keyword)) != SVt_PVCV) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvTYPE(keyword) != SVt_RV && SvTYPE(SvRV(keyword)) != SVt_PVCV) { |
0 |
7 |
7 |
| if (SvTYPE(keyword) != SVt_RV && SvTYPE(SvRV(keyword)) != SVt_PVCV) { |
0 |
0 |
0 |
|
| 67 |
0 |
| croak("'keyword' argument is not a CODE reference"); |
| 68 |
|
| } |
| 69 |
7 |
▶ | if (SvTYPE(handler) != SVt_RV && SvTYPE(SvRV(handler)) != SVt_PVCV) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvTYPE(handler) != SVt_RV && SvTYPE(SvRV(handler)) != SVt_PVCV) { |
0 |
7 |
7 |
| if (SvTYPE(handler) != SVt_RV && SvTYPE(SvRV(handler)) != SVt_PVCV) { |
0 |
0 |
0 |
|
| 70 |
0 |
| croak("'handler' argument is not a CODE reference"); |
| 71 |
|
| } |
| 72 |
7 |
| cv_set_call_parser( (CV*) SvRV( keyword ), parser_callback, handler ); |
| 73 |
|
| |
| 74 |
|
| |
| 75 |
|
| |
| 76 |
|
| |
| 77 |
|
| |
| 78 |
|
| |
| 79 |
|
| |