File Coverage

xs/import.xs
Criterion Covered Total %
statement 11 16 68.7
branch 7 14 50.0
condition n/a
subroutine n/a
pod n/a
total 18 30 60.0


line stmt bran cond sub pod time code
1             MODULE = PDF::Make PACKAGE = PDF::Make::Import
2             PROTOTYPES: ENABLE
3              
4             pdfmake_import_ctx_t *
5             new(class, reader_sv, doc_sv)
6             char *class
7             SV *reader_sv
8             SV *doc_sv
9             PREINIT:
10             pdfmake_reader_xs_t *reader_xs;
11             pdfmake_doc_t *doc;
12             IV tmp;
13             CODE:
14 24 50         if (!sv_isobject(reader_sv) || !sv_derived_from(reader_sv, "PDF::Make::Reader")) {
    50          
15 0           croak("PDF::Make::Import::new: first arg must be a PDF::Make::Reader");
16             }
17 24 50         if (!sv_isobject(doc_sv) || !sv_derived_from(doc_sv, "PDF::Make::Document")) {
    50          
18 0           croak("PDF::Make::Import::new: second arg must be a PDF::Make::Document");
19             }
20 24           tmp = SvIV((SV*)SvRV(reader_sv));
21 24           reader_xs = INT2PTR(pdfmake_reader_xs_t *, tmp);
22 24           tmp = SvIV((SV*)SvRV(doc_sv));
23 24           doc = INT2PTR(pdfmake_doc_t *, tmp);
24              
25 24           RETVAL = pdfmake_import_ctx_new(reader_xs->reader, doc);
26 24 50         if (!RETVAL) {
27 0           croak("PDF::Make::Import::new: failed to allocate context");
28             }
29             OUTPUT:
30             RETVAL
31              
32             UV
33             import_object(self, src_num)
34             pdfmake_import_ctx_t *self
35             UV src_num
36             CODE:
37 0 0         RETVAL = pdfmake_import_object(self, (uint32_t)src_num);
38             OUTPUT:
39             RETVAL
40              
41             IV
42             import_page(self, page_index)
43             pdfmake_import_ctx_t *self
44             UV page_index
45             PREINIT:
46             pdfmake_page_t *p;
47             CODE:
48 44           p = pdfmake_doc_import_page(self, (size_t)page_index);
49 44 100         RETVAL = p ? 1 : 0;
50             OUTPUT:
51             RETVAL
52              
53             UV
54             import_all_pages(self)
55             pdfmake_import_ctx_t *self
56             CODE:
57 0           RETVAL = (UV)pdfmake_doc_import_all_pages(self);
58             OUTPUT:
59             RETVAL
60              
61             void
62             DESTROY(self)
63             pdfmake_import_ctx_t *self
64             CODE:
65 24           pdfmake_import_ctx_free(self);