| 1 |
|
| MODULE = PDF::Make PACKAGE = PDF::Make::Markup::Render |
| 2 |
|
| |
| 3 |
|
| PROTOTYPES: DISABLE |
| 4 |
|
| |
| 5 |
|
| # Template, then markup, then PDF, through one function that every other entry |
| 6 |
|
| # point uses. One rendering path means one place where output can change, |
| 7 |
|
| # which is what makes the engine version promise checkable rather than |
| 8 |
|
| # aspirational. |
| 9 |
|
| |
| 10 |
|
| # The engine version this build renders. A template pins the version it was |
| 11 |
|
| # written against and always renders on that one. It exists from the first |
| 12 |
|
| # release with exactly one version in it, because adding it later would mean |
| 13 |
|
| # the documents already in the world were rendered by "whatever was current", |
| 14 |
|
| # and there is then no answer to "why does this year's invoice not match last |
| 15 |
|
| # year's". |
| 16 |
|
| IV |
| 17 |
|
| engine_version(class = NULL) |
| 18 |
|
| SV *class |
| 19 |
|
| CODE: |
| 20 |
|
| PERL_UNUSED_VAR(class); |
| 21 |
0 |
▶ | RETVAL = PDFMAKE_ENGINE_VERSION; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = PDFMAKE_ENGINE_VERSION; |
0 |
0 |
0 |
|
| 22 |
|
| OUTPUT: |
| 23 |
|
| RETVAL |
| 24 |
|
| |
| 25 |
|
| void |
| 26 |
|
| supported(class = NULL) |
| 27 |
|
| SV *class |
| 28 |
|
| PPCODE: |
| 29 |
|
| { |
| 30 |
|
| int i; |
| 31 |
|
| PERL_UNUSED_VAR(class); |
| 32 |
0 |
▶ | EXTEND(SP, PDFMAKE_ENGINE_VERSION); |
Branch: 1 branch
| Branch | True | False | Total |
| EXTEND(SP, PDFMAKE_ENGINE_VERSION); |
0 |
0 |
0 |
|
| 33 |
0 |
▶ | for (i = 1; i <= PDFMAKE_ENGINE_VERSION; i++) |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 1; i <= PDFMAKE_ENGINE_VERSION; i++) |
0 |
0 |
0 |
|
| 34 |
0 |
| mPUSHi(i); |
| 35 |
0 |
| XSRETURN(PDFMAKE_ENGINE_VERSION); |
| 36 |
|
| } |
| 37 |
|
| |
| 38 |
|
| SV * |
| 39 |
|
| render(class, template, data = &PL_sv_undef, ...) |
| 40 |
|
| SV *class |
| 41 |
|
| SV *template |
| 42 |
|
| SV *data |
| 43 |
|
| ALIAS: |
| 44 |
|
| render_markup = 1 |
| 45 |
|
| CODE: |
| 46 |
|
| { |
| 47 |
21 |
| HV *opts = (HV *)sv_2mortal((SV *)newHV()); |
| 48 |
21 |
| SV *file_name = NULL; |
| 49 |
|
| int i; |
| 50 |
|
| |
| 51 |
|
| PERL_UNUSED_VAR(class); |
| 52 |
|
| |
| 53 |
|
| /* render_markup takes no data, so its options begin one argument |
| 54 |
|
| * earlier. Getting this wrong made render_markup($markup) - the |
| 55 |
|
| * shortest possible call - look like an odd option list. */ |
| 56 |
|
| { |
| 57 |
21 |
▶ | int first = ix ? 2 : 3; |
Branch: 1 branch
| Branch | True | False | Total |
| int first = ix ? 2 : 3; |
21 |
0 |
21 |
|
| 58 |
21 |
▶ | if (items > first && ((items - first) % 2)) |
Branch: 2 branches
| Branch | True | False | Total |
| if (items > first && ((items - first) % 2)) |
0 |
21 |
21 |
| if (items > first && ((items - first) % 2)) |
0 |
0 |
0 |
|
| 59 |
0 |
▶ | croak("PDF::Make::Markup::Render->%s: odd number of options", |
Branch: 1 branch
| Branch | True | False | Total |
| croak("PDF::Make::Markup::Render->%s: odd number of options", |
0 |
0 |
0 |
|
| 60 |
|
| ix ? "render_markup" : "render"); |
| 61 |
21 |
▶ | for (i = first; i + 1 < items; i += 2) |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = first; i + 1 < items; i += 2) |
0 |
21 |
21 |
|
| 62 |
0 |
| (void)hv_store_ent(opts, ST(i), newSVsv(ST(i + 1)), 0); |
| 63 |
|
| } |
| 64 |
|
| |
| 65 |
|
| { /* the version gate, before anything is rendered */ |
| 66 |
21 |
| SV **want = hv_fetchs(opts, "engine_version", 0); |
| 67 |
21 |
▶ | if (want && SvOK(*want)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (want && SvOK(*want)) { |
0 |
21 |
21 |
| if (want && SvOK(*want)) { |
0 |
0 |
0 |
|
| 68 |
|
| STRLEN wlen; |
| 69 |
0 |
| const char *w = SvPV(*want, wlen); |
| 70 |
|
| STRLEN k; |
| 71 |
|
| IV v; |
| 72 |
|
| |
| 73 |
0 |
▶ | for (k = 0; k < wlen; k++) |
Branch: 1 branch
| Branch | True | False | Total |
| for (k = 0; k < wlen; k++) |
0 |
0 |
0 |
|
| 74 |
0 |
▶ | if (w[k] < '0' || w[k] > '9') |
Branch: 2 branches
| Branch | True | False | Total |
| if (w[k] < '0' || w[k] > '9') |
0 |
0 |
0 |
| if (w[k] < '0' || w[k] > '9') |
0 |
0 |
0 |
|
| 75 |
0 |
| croak("engine_version '%" SVf "' is not a version " |
| 76 |
|
| "number", SVfARG(*want)); |
| 77 |
0 |
▶ | if (!wlen) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!wlen) |
0 |
0 |
0 |
|
| 78 |
0 |
| croak("engine_version '' is not a version number"); |
| 79 |
|
| |
| 80 |
0 |
| v = SvIV(*want); |
| 81 |
0 |
▶ | if (v < 1 || v > PDFMAKE_ENGINE_VERSION) |
Branch: 2 branches
| Branch | True | False | Total |
| if (v < 1 || v > PDFMAKE_ENGINE_VERSION) |
0 |
0 |
0 |
| if (v < 1 || v > PDFMAKE_ENGINE_VERSION) |
0 |
0 |
0 |
|
| 82 |
0 |
▶ | croak("engine version %" IVdf " is not available in this " |
Branch: 1 branch
| Branch | True | False | Total |
| croak("engine version %" IVdf " is not available in this " |
0 |
0 |
0 |
|
| 83 |
|
| "build (it renders 1..%d). %s", |
| 84 |
|
| v, PDFMAKE_ENGINE_VERSION, |
| 85 |
|
| v > PDFMAKE_ENGINE_VERSION |
| 86 |
|
| ? "The template was written for a newer engine " |
| 87 |
|
| "than this one." |
| 88 |
|
| : "That version has been retired."); |
| 89 |
|
| } |
| 90 |
|
| } |
| 91 |
|
| |
| 92 |
21 |
| file_name = hv_fetchs(opts, "file_name", 0) |
| 93 |
21 |
▶ | ? *hv_fetchs(opts, "file_name", 0) : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| ? *hv_fetchs(opts, "file_name", 0) : NULL; |
0 |
21 |
21 |
|
| 94 |
|
| |
| 95 |
21 |
▶ | RETVAL = pdfmake_markup_render_sv(aTHX_ template, |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = pdfmake_markup_render_sv(aTHX_ template, |
0 |
21 |
21 |
|
| 96 |
|
| ix ? NULL : data, |
| 97 |
|
| opts, file_name); |
| 98 |
|
| } |
| 99 |
|
| OUTPUT: |
| 100 |
|
| RETVAL |