File Coverage

src/XS.xs
Criterion Covered Total %
statement 33 36 91.6
branch 21 34 61.7
condition n/a
subroutine n/a
pod n/a
total 54 70 77.1


line stmt bran cond sub pod time code
1             #include "xh_config.h"
2             #include "xh_core.h"
3              
4             MODULE = XML::Hash::XS PACKAGE = XML::Hash::XS
5              
6             PROTOTYPES: DISABLE
7              
8             xh_opts_t *
9             new(CLASS,...)
10             PREINIT:
11             xh_opts_t *opts;
12             CODE:
13 4           dXCPT;
14              
15 4 50         if ((opts = xh_create_opts()) == NULL)
16 0           croak("Malloc error in new()");
17              
18 4 100         XCPT_TRY_START
19             {
20 4           xh_parse_param(opts, 1, ax, items);
21 4           } XCPT_TRY_END
22              
23 4 100         XCPT_CATCH
24             {
25 2           xh_destroy_opts(opts);
26 2 50         XCPT_RETHROW;
    0          
27             }
28              
29 2           RETVAL = opts;
30             OUTPUT:
31             RETVAL
32              
33             SV *
34             hash2xml(...)
35             PREINIT:
36             xh_h2x_ctx_t ctx;
37             SV *result;
38             CODE:
39 42           dXCPT;
40 42 50         XCPT_TRY_START
41             {
42 42           xh_h2x_init_ctx(&ctx, ax, items);
43              
44             /* hack */
45             #ifdef XH_HAVE_DOM
46             if (ctx.opts.doc) {
47             result = xh_h2d(&ctx);
48             }
49             else {
50             result = xh_h2x(&ctx);
51             }
52             #else
53 42           result = xh_h2x(&ctx);
54             #endif
55 42           } XCPT_TRY_END
56              
57 42 50         XCPT_CATCH
58             {
59 0           xh_h2x_destroy_ctx(&ctx);
60 0 0         XCPT_RETHROW;
    0          
61             }
62              
63 42 100         if (ctx.opts.output != NULL) result = NULL;
64              
65 42           xh_h2x_destroy_ctx(&ctx);
66              
67 42 100         if (result == NULL) XSRETURN_UNDEF;
68              
69 40           RETVAL = result;
70              
71             OUTPUT:
72             RETVAL
73              
74             SV *
75             xml2hash(...)
76             PREINIT:
77             xh_x2h_ctx_t ctx;
78             SV *result;
79             CODE:
80 72           dXCPT;
81 72 100         XCPT_TRY_START
82             {
83 72           xh_x2h_init_ctx(&ctx, ax, items);
84              
85 72           result = xh_x2h(&ctx);
86 72           } XCPT_TRY_END
87              
88 72 100         XCPT_CATCH
89             {
90 12           xh_x2h_destroy_ctx(&ctx);
91 12 50         XCPT_RETHROW;
    0          
92             }
93              
94 60 100         if (ctx.opts.cb != NULL) result = NULL;
95              
96 60           xh_x2h_destroy_ctx(&ctx);
97              
98 60 100         if (result == NULL) XSRETURN_UNDEF;
99              
100 59           RETVAL = result;
101              
102             OUTPUT:
103             RETVAL
104              
105             void
106             DESTROY(opts)
107             xh_opts_t *opts;
108             CODE:
109 2           xh_destroy_opts(opts);
110 2           free(opts);