File Coverage

Lift.xs
Criterion Covered Total %
statement 28 32 87.5
branch 10 20 50.0
condition n/a
subroutine n/a
pod n/a
total 38 52 73.0


line stmt bran cond sub pod time code
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 50         if (errors) {
29 0           ++PL_parser->error_count;
30 0           code = NULL;
31             }
32             else {
33 10 100         if ( CvROOT(code) == NULL ) {
34 4           code = NULL;
35             }
36             else {
37 6 50         if (CvCLONE(code)) {
38 6           code = cv_clone(code);
39             }
40             }
41             }
42              
43 10 100         return code ? newRV_inc((SV*) code) : NULL;
44             }
45              
46 10           static OP *parser_callback(pTHX_ GV *namegv, SV *psobj, U32 *flagsp) {
47 10           dSP;
48 10 50         PUSHMARK(SP);
49 10 50         mXPUSHs(args_builder(flagsp));
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 50         if (SvTYPE(keyword) != SVt_RV && SvTYPE(SvRV(keyword)) != SVt_PVCV) {
    0          
67 0           croak("'keyword' argument is not a CODE reference");
68             }
69 7 50         if (SvTYPE(handler) != SVt_RV && SvTYPE(SvRV(handler)) != SVt_PVCV) {
    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