xs/markup.xs

filter: Statementstmt 71.4% 25 / 35 Branchbran 55.0% 11 / 20 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 65.4% 36 / 55 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« src/pdfmake_font_write.c ↑ Summary src/pdfmake_font.c »
1 MODULE = PDF::Make PACKAGE = PDF::Make::Markup::Parse
2  
3 PROTOTYPES: DISABLE
4  
5 # The parser's Perl face. The grammar, the entity table, the UTF-8 validation
6 # and every position live in src/pdfmake_markup.c; what is here names the
7 # interface and nothing else.
8  
9 SV *
10 check(class, src)
11 SV *class
12 SV *src
13 CODE:
14 PERL_UNUSED_VAR(class);
15 2343 RETVAL = pdfmake_markup_parse_sv(aTHX_ src);
16 OUTPUT:
17 RETVAL
18  
19 # The same parse, throwing with the position in the message - what an editor
20 # underlines and what a CI log needs in order to be useful.
21 SV *
22 parse(class, src)
23 SV *class
24 SV *src
25 CODE:
26 {
27 SV *res;
28 HV *h;
29 SV **ok;
30  
31 PERL_UNUSED_VAR(class);
32 73 res = sv_2mortal(pdfmake_markup_parse_sv(aTHX_ src));
33 73 h = (HV *)SvRV(res);
34 73 ok = hv_fetchs(h, "ok", 0);
35  
36 73 ▶ if (!ok || !SvTRUE(*ok)) {
Branch: 2 branches
BranchTrueFalseTotal
if (!ok || !SvTRUE(*ok)) { 73 0 73
if (!ok || !SvTRUE(*ok)) { 1 72 73
37 1 SV **msg = hv_fetchs(h, "error", 0);
38 1 SV **line = hv_fetchs(h, "line", 0);
39 1 SV **col = hv_fetchs(h, "col", 0);
40 1 ▶ croak("markup error at line %" IVdf ", column %" IVdf ": %" SVf,
Branch: 3 branches
BranchTrueFalseTotal
croak("markup error at line %" IVdf ", column %" IVdf ": %" SVf, 1 0 1
croak("markup error at line %" IVdf ", column %" IVdf ": %" SVf, 1 0 1
croak("markup error at line %" IVdf ", column %" IVdf ": %" SVf, 1 0 1
41 line ? (IV)SvIV(*line) : (IV)0,
42 col ? (IV)SvIV(*col) : (IV)0,
43 SVfARG(msg ? *msg : &PL_sv_undef));
44 }
45 {
46 72 SV **root = hv_fetchs(h, "root", 0);
47 72 ▶ RETVAL = root ? newSVsv(*root) : newSV(0);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = root ? newSVsv(*root) : newSV(0); 72 0 72
48 }
49 }
50 OUTPUT:
51 RETVAL
52  
53 # The tag set as the parser holds it, so the documentation and the tests read
54 # what the engine actually accepts.
55 void
56 tags(class = NULL)
57 SV *class
58 PPCODE:
59 {
60 int t;
61 4 I32 pushed = 0;
62 PERL_UNUSED_VAR(class);
63 4 ▶ EXTEND(SP, (SSize_t)PDFMAKE_MK_MAX);
Branch: 1 branch
BranchTrueFalseTotal
EXTEND(SP, (SSize_t)PDFMAKE_MK_MAX); 0 4 4
64 112 ▶ for (t = 1; t < PDFMAKE_MK_MAX; t++) {
Branch: 1 branch
BranchTrueFalseTotal
for (t = 1; t < PDFMAKE_MK_MAX; t++) { 108 4 112
65 108 const char *name = pdfmake_markup_tag_name((pdfmake_markup_tag_t)t);
66 HV *h;
67 uint32_t f;
68 108 ▶ if (!name) continue;
Branch: 1 branch
BranchTrueFalseTotal
if (!name) continue; 0 108 108
69 108 f = pdfmake_markup_tag_flags((pdfmake_markup_tag_t)t);
70 108 h = newHV();
71 108 (void)hv_stores(h, "name", newSVpv(name, 0));
72 108 (void)hv_stores(h, "void", newSViv((f & PDFMAKE_MKF_VOID) ? 1 : 0));
73 108 (void)hv_stores(h, "container", newSViv((f & PDFMAKE_MKF_CONTAINER) ? 1 : 0));
74 108 (void)hv_stores(h, "inline", newSViv((f & PDFMAKE_MKF_INLINE) ? 1 : 0));
75 108 mPUSHs(newRV_noinc((SV *)h));
76 108 pushed++;
77 }
78 4 XSRETURN(pushed);
79 }
80  
81 SV *
82 tag_info(class, name)
83 SV *class
84 SV *name
85 CODE:
86 {
87 STRLEN len;
88 const char *n;
89 pdfmake_markup_tag_t t;
90 HV *h;
91 uint32_t f;
92  
93 PERL_UNUSED_VAR(class);
94 0 n = pdfmake_markup_sv_bytes(aTHX_ name, &len);
95 0 t = pdfmake_markup_tag_id(n, len);
96 0 ▶ if (t == PDFMAKE_MK_INVALID) XSRETURN_UNDEF;
Branch: 1 branch
BranchTrueFalseTotal
if (t == PDFMAKE_MK_INVALID) XSRETURN_UNDEF; 0 0 0
97  
98 0 f = pdfmake_markup_tag_flags(t);
99 0 h = newHV();
100 0 (void)hv_stores(h, "name", newSVpv(pdfmake_markup_tag_name(t), 0));
101 0 (void)hv_stores(h, "void", newSViv((f & PDFMAKE_MKF_VOID) ? 1 : 0));
102 0 (void)hv_stores(h, "container", newSViv((f & PDFMAKE_MKF_CONTAINER) ? 1 : 0));
103 0 (void)hv_stores(h, "inline", newSViv((f & PDFMAKE_MKF_INLINE) ? 1 : 0));
104 0 RETVAL = newRV_noinc((SV *)h);
105 }
106 OUTPUT:
107 RETVAL
« src/pdfmake_font_write.c ↑ Summary src/pdfmake_font.c »