Commit fa9676557e3065d75f732622bd498d5572ba686e
1 parent
3b60224b
QDPFJob: incorporate change to JSONHandler for array start function
Showing
5 changed files
with
101 additions
and
21 deletions
generate_auto_job
| ... | ... | @@ -562,8 +562,21 @@ class Main: |
| 562 | 562 | if isinstance(v[0], dict): |
| 563 | 563 | is_dict = True |
| 564 | 564 | schema_value = [{}] |
| 565 | + subpath = f'{path}.{schema_key}' | |
| 566 | + identifier = self.to_identifier(subpath, '', False) | |
| 567 | + self.json_decls.append( | |
| 568 | + f'void begin{identifier}Array(JSON);') | |
| 569 | + self.json_decls.append( | |
| 570 | + f'void end{identifier}Array();') | |
| 571 | + self.json_init.append( | |
| 572 | + f'beginArray("{flag}",' | |
| 573 | + f' bindJSON(&Handlers::begin{identifier}Array),' | |
| 574 | + f' bindBare(&Handlers::end{identifier}Array));' | |
| 575 | + f' // {subpath}[]') | |
| 565 | 576 | build_schema(v[0], schema_value[0], |
| 566 | - schema_key, f'{path}.{schema_key}') | |
| 577 | + schema_key, subpath) | |
| 578 | + self.json_init.append( | |
| 579 | + f'endContainer(); // {subpath}[]') | |
| 567 | 580 | elif schema_value is None: |
| 568 | 581 | raise Exception(f'unknown schema value for {k}') |
| 569 | 582 | s[schema_key] = schema_value |
| ... | ... | @@ -573,7 +586,7 @@ class Main: |
| 573 | 586 | else: |
| 574 | 587 | self.handle_json_manual(schema_key, path) |
| 575 | 588 | if flag: |
| 576 | - self.json_init.append(f'endDict(); // {path}') | |
| 589 | + self.json_init.append(f'endContainer(); // {path}') | |
| 577 | 590 | |
| 578 | 591 | build_schema(data['json'], self.schema, '', '') |
| 579 | 592 | if options_seen != set(expected.keys()): | ... | ... |
job.sums
| 1 | 1 | # Generated by generate_auto_job |
| 2 | -generate_auto_job e4a071599697cc0f4d985367735ac6ed6110575e2cbfa01406d048780466d546 | |
| 2 | +generate_auto_job 68c39a9f6d1f10c1b9cf9af539036621589d6b0bbf3d05a2e1ddd1c9919d7383 | |
| 3 | 3 | include/qpdf/auto_job_c_att.hh 7ad43bb374c1370ef32ebdcdcb7b73a61d281f7f4e3f12755585872ab30fb60e |
| 4 | 4 | include/qpdf/auto_job_c_copy_att.hh 32275d03cdc69b703dd7e02ba0bbe15756e714e9ad185484773a6178dc09e1ee |
| 5 | 5 | include/qpdf/auto_job_c_enc.hh 72e138c7b96ed5aacdce78c1dec04b1c20d361faec4f8faf52f64c1d6be99265 |
| ... | ... | @@ -10,8 +10,8 @@ job.yml 6389b89c25f0f07fa54bfc3d9f24f814aac5566ace43666f81476781db616ea1 |
| 10 | 10 | libqpdf/qpdf/auto_job_decl.hh 9f79396ec459f191be4c5fe34cf88c265cf47355a1a945fa39169d1c94cf04f6 |
| 11 | 11 | libqpdf/qpdf/auto_job_help.hh 23c79f1d2c02bda28f64aace17f69487205c797e7ae2234892cbbabab49d6d47 |
| 12 | 12 | libqpdf/qpdf/auto_job_init.hh 8e9e31b6099a662497339b27f6e2d7f779f35011e88a834bee8811c33405a0fe |
| 13 | -libqpdf/qpdf/auto_job_json_decl.hh 8a6e3b25e01969f1c8e2c9ec781f7f2e89b57e67e65d5dc7445ad9124b694b9a | |
| 14 | -libqpdf/qpdf/auto_job_json_init.hh 48888c602de4cc13040cff26569e162d6ebb5aec6ab959164d432cfe1058eb23 | |
| 13 | +libqpdf/qpdf/auto_job_json_decl.hh f349b55cf85d07a28aeb4bef257bdbcbe16f76b8065d01154161897b1e0fa643 | |
| 14 | +libqpdf/qpdf/auto_job_json_init.hh 9ea198c4daa6badb30690e2814f3d6ab761c09973a0712341081dabcb2097006 | |
| 15 | 15 | libqpdf/qpdf/auto_job_schema.hh 9e19fb0b8ddd6fe13da12f1f98c27f6d558fc4706a56a63697e529b3140a457c |
| 16 | 16 | manual/_ext/qpdf.py e9ac9d6c70642a3d29281ee5ad92ae2422dee8be9306fb8a0bc9dba0ed5e28f3 |
| 17 | 17 | manual/cli.rst 79140e023faa0cb77afe0b1dc512dd120ee5617f4db82f842596e4f239f93882 | ... | ... |
libqpdf/QPDFJob_json.cc
| ... | ... | @@ -37,7 +37,10 @@ namespace |
| 37 | 37 | void beginDict(std::string const& key, |
| 38 | 38 | json_handler_t start_fn, |
| 39 | 39 | bare_handler_t end_fn); |
| 40 | - void endDict(); | |
| 40 | + void beginArray(std::string const& key, | |
| 41 | + json_handler_t start_fn, | |
| 42 | + bare_handler_t end_fn); | |
| 43 | + void endContainer(); | |
| 41 | 44 | |
| 42 | 45 | bare_handler_t bindBare(void (Handlers::*f)()); |
| 43 | 46 | json_handler_t bindJSON(void (Handlers::*f)(JSON)); |
| ... | ... | @@ -194,7 +197,23 @@ Handlers::beginDict(std::string const& key, |
| 194 | 197 | } |
| 195 | 198 | |
| 196 | 199 | void |
| 197 | -Handlers::endDict() | |
| 200 | +Handlers::beginArray(std::string const& key, | |
| 201 | + json_handler_t start_fn, | |
| 202 | + bare_handler_t end_fn) | |
| 203 | +{ | |
| 204 | + auto new_jh = std::make_shared<JSONHandler>(); | |
| 205 | + auto item_jh = std::make_shared<JSONHandler>(); | |
| 206 | + new_jh->addArrayHandlers( | |
| 207 | + [start_fn](std::string const&, JSON j){ start_fn(j); }, | |
| 208 | + [end_fn](std::string const&){ end_fn(); }, | |
| 209 | + item_jh); | |
| 210 | + this->jh->addDictKeyHandler(key, new_jh); | |
| 211 | + this->json_handlers.push_back(item_jh); | |
| 212 | + this->jh = item_jh.get(); | |
| 213 | +} | |
| 214 | + | |
| 215 | +void | |
| 216 | +Handlers::endContainer() | |
| 198 | 217 | { |
| 199 | 218 | this->json_handlers.pop_back(); |
| 200 | 219 | this->jh = this->json_handlers.back().get(); |
| ... | ... | @@ -405,6 +424,18 @@ Handlers::endInspect() |
| 405 | 424 | } |
| 406 | 425 | |
| 407 | 426 | void |
| 427 | +Handlers::beginOptionsAddAttachmentArray(JSON) | |
| 428 | +{ | |
| 429 | + // QXXXQ | |
| 430 | +} | |
| 431 | + | |
| 432 | +void | |
| 433 | +Handlers::endOptionsAddAttachmentArray() | |
| 434 | +{ | |
| 435 | + // QXXXQ | |
| 436 | +} | |
| 437 | + | |
| 438 | +void | |
| 408 | 439 | Handlers::beginOptionsAddAttachment(JSON) |
| 409 | 440 | { |
| 410 | 441 | this->c_att = c_main->addAttachment(); |
| ... | ... | @@ -426,6 +457,18 @@ Handlers::setupOptionsAddAttachmentPath(std::string const& key) |
| 426 | 457 | } |
| 427 | 458 | |
| 428 | 459 | void |
| 460 | +Handlers::beginOptionsCopyAttachmentsFromArray(JSON) | |
| 461 | +{ | |
| 462 | + // QXXXQ | |
| 463 | +} | |
| 464 | + | |
| 465 | +void | |
| 466 | +Handlers::endOptionsCopyAttachmentsFromArray() | |
| 467 | +{ | |
| 468 | + // QXXXQ | |
| 469 | +} | |
| 470 | + | |
| 471 | +void | |
| 429 | 472 | Handlers::beginOptionsCopyAttachmentsFrom(JSON) |
| 430 | 473 | { |
| 431 | 474 | this->c_copy_att = c_main->copyAttachmentsFrom(); |
| ... | ... | @@ -455,6 +498,18 @@ Handlers::setupOptionsCopyAttachmentsFromPassword(std::string const& key) |
| 455 | 498 | } |
| 456 | 499 | |
| 457 | 500 | void |
| 501 | +Handlers::beginOptionsPagesArray(JSON) | |
| 502 | +{ | |
| 503 | + // QXXXQ | |
| 504 | +} | |
| 505 | + | |
| 506 | +void | |
| 507 | +Handlers::endOptionsPagesArray() | |
| 508 | +{ | |
| 509 | + // QXXXQ | |
| 510 | +} | |
| 511 | + | |
| 512 | +void | |
| 458 | 513 | Handlers::beginOptionsPages(JSON) |
| 459 | 514 | { |
| 460 | 515 | // QXXXQ | ... | ... |
libqpdf/qpdf/auto_job_json_decl.hh
| ... | ... | @@ -28,13 +28,19 @@ void beginInspect(JSON); |
| 28 | 28 | void endInspect(); |
| 29 | 29 | void beginOptions(JSON); |
| 30 | 30 | void endOptions(); |
| 31 | +void beginOptionsAddAttachmentArray(JSON); | |
| 32 | +void endOptionsAddAttachmentArray(); | |
| 31 | 33 | void beginOptionsAddAttachment(JSON); |
| 32 | 34 | void endOptionsAddAttachment(); |
| 33 | 35 | void setupOptionsAddAttachmentPath(std::string const&); |
| 36 | +void beginOptionsCopyAttachmentsFromArray(JSON); | |
| 37 | +void endOptionsCopyAttachmentsFromArray(); | |
| 34 | 38 | void beginOptionsCopyAttachmentsFrom(JSON); |
| 35 | 39 | void endOptionsCopyAttachmentsFrom(); |
| 36 | 40 | void setupOptionsCopyAttachmentsFromPath(std::string const&); |
| 37 | 41 | void setupOptionsCopyAttachmentsFromPassword(std::string const&); |
| 42 | +void beginOptionsPagesArray(JSON); | |
| 43 | +void endOptionsPagesArray(); | |
| 38 | 44 | void beginOptionsPages(JSON); |
| 39 | 45 | void endOptionsPages(); |
| 40 | 46 | void setupOptionsPagesFile(std::string const&); | ... | ... |
libqpdf/qpdf/auto_job_json_init.hh
| ... | ... | @@ -19,7 +19,7 @@ doSetup("filename", bindSetup(&Handlers::setupInputFilename)); |
| 19 | 19 | doSetup("password", bindSetup(&Handlers::setupInputPassword)); |
| 20 | 20 | addParameter("passwordFile", [this](char const* p) { c_main->passwordFile(p); }); |
| 21 | 21 | doSetup("empty", bindSetup(&Handlers::setupInputEmpty)); |
| 22 | -endDict(); // .input | |
| 22 | +endContainer(); // .input | |
| 23 | 23 | beginDict("output", bindJSON(&Handlers::beginOutput), bindBare(&Handlers::endOutput)); // .output |
| 24 | 24 | doSetup("filename", bindSetup(&Handlers::setupOutputFilename)); |
| 25 | 25 | doSetup("replaceInput", bindSetup(&Handlers::setupOutputReplaceInput)); |
| ... | ... | @@ -53,7 +53,7 @@ addChoices("annotate", yn_choices, [this](char const* p) { c_enc->annotate(p); } |
| 53 | 53 | addChoices("extract", yn_choices, [this](char const* p) { c_enc->extract(p); }); |
| 54 | 54 | addChoices("modify", modify128_choices, [this](char const* p) { c_enc->modify(p); }); |
| 55 | 55 | addChoices("print", print128_choices, [this](char const* p) { c_enc->print(p); }); |
| 56 | -endDict(); // .output.options.encrypt.40bit | |
| 56 | +endContainer(); // .output.options.encrypt.40bit | |
| 57 | 57 | beginDict("128bit", bindJSON(&Handlers::beginOutputOptionsEncrypt128bit), bindBare(&Handlers::endOutputOptionsEncrypt128bit)); // .output.options.encrypt.128bit |
| 58 | 58 | addChoices("accessibility", yn_choices, [this](char const* p) { c_enc->accessibility(p); }); |
| 59 | 59 | addChoices("annotate", yn_choices, [this](char const* p) { c_enc->annotate(p); }); |
| ... | ... | @@ -66,7 +66,7 @@ addChoices("modify", modify128_choices, [this](char const* p) { c_enc->modify(p) |
| 66 | 66 | addChoices("print", print128_choices, [this](char const* p) { c_enc->print(p); }); |
| 67 | 67 | addBare("forceV4", [this]() { c_enc->forceV4(); }); |
| 68 | 68 | addChoices("useAes", yn_choices, [this](char const* p) { c_enc->useAes(p); }); |
| 69 | -endDict(); // .output.options.encrypt.128bit | |
| 69 | +endContainer(); // .output.options.encrypt.128bit | |
| 70 | 70 | beginDict("256bit", bindJSON(&Handlers::beginOutputOptionsEncrypt256bit), bindBare(&Handlers::endOutputOptionsEncrypt256bit)); // .output.options.encrypt.256bit |
| 71 | 71 | addChoices("accessibility", yn_choices, [this](char const* p) { c_enc->accessibility(p); }); |
| 72 | 72 | addChoices("annotate", yn_choices, [this](char const* p) { c_enc->annotate(p); }); |
| ... | ... | @@ -79,10 +79,10 @@ addChoices("modify", modify128_choices, [this](char const* p) { c_enc->modify(p) |
| 79 | 79 | addChoices("print", print128_choices, [this](char const* p) { c_enc->print(p); }); |
| 80 | 80 | addBare("allowInsecure", [this]() { c_enc->allowInsecure(); }); |
| 81 | 81 | addBare("forceR5", [this]() { c_enc->forceR5(); }); |
| 82 | -endDict(); // .output.options.encrypt.256bit | |
| 83 | -endDict(); // .output.options.encrypt | |
| 84 | -endDict(); // .output.options | |
| 85 | -endDict(); // .output | |
| 82 | +endContainer(); // .output.options.encrypt.256bit | |
| 83 | +endContainer(); // .output.options.encrypt | |
| 84 | +endContainer(); // .output.options | |
| 85 | +endContainer(); // .output | |
| 86 | 86 | beginDict("inspect", bindJSON(&Handlers::beginInspect), bindBare(&Handlers::endInspect)); // .inspect |
| 87 | 87 | addBare("check", [this]() { c_main->check(); }); |
| 88 | 88 | addBare("checkLinearization", [this]() { c_main->checkLinearization(); }); |
| ... | ... | @@ -103,7 +103,7 @@ addParameter("showAttachment", [this](char const* p) { c_main->showAttachment(p) |
| 103 | 103 | addBare("json", [this]() { c_main->json(); }); |
| 104 | 104 | addChoices("jsonKey", json_key_choices, [this](char const* p) { c_main->jsonKey(p); }); |
| 105 | 105 | addParameter("jsonObject", [this](char const* p) { c_main->jsonObject(p); }); |
| 106 | -endDict(); // .inspect | |
| 106 | +endContainer(); // .inspect | |
| 107 | 107 | beginDict("options", bindJSON(&Handlers::beginOptions), bindBare(&Handlers::endOptions)); // .options |
| 108 | 108 | addBare("allowWeakCrypto", [this]() { c_main->allowWeakCrypto(); }); |
| 109 | 109 | addBare("deterministicId", [this]() { c_main->deterministicId(); }); |
| ... | ... | @@ -122,6 +122,7 @@ addParameter("compressionLevel", [this](char const* p) { c_main->compressionLeve |
| 122 | 122 | addBare("externalizeInlineImages", [this]() { c_main->externalizeInlineImages(); }); |
| 123 | 123 | addParameter("iiMinBytes", [this](char const* p) { c_main->iiMinBytes(p); }); |
| 124 | 124 | addChoices("removeUnreferencedResources", remove_unref_choices, [this](char const* p) { c_main->removeUnreferencedResources(p); }); |
| 125 | +beginArray("options", bindJSON(&Handlers::beginOptionsAddAttachmentArray), bindBare(&Handlers::endOptionsAddAttachmentArray)); // .options.addAttachment[] | |
| 125 | 126 | beginDict("addAttachment", bindJSON(&Handlers::beginOptionsAddAttachment), bindBare(&Handlers::endOptionsAddAttachment)); // .options.addAttachment |
| 126 | 127 | doSetup("path", bindSetup(&Handlers::setupOptionsAddAttachmentPath)); |
| 127 | 128 | addParameter("creationdate", [this](char const* p) { c_att->creationdate(p); }); |
| ... | ... | @@ -131,13 +132,16 @@ addParameter("key", [this](char const* p) { c_att->key(p); }); |
| 131 | 132 | addParameter("mimetype", [this](char const* p) { c_att->mimetype(p); }); |
| 132 | 133 | addParameter("moddate", [this](char const* p) { c_att->moddate(p); }); |
| 133 | 134 | addBare("replace", [this]() { c_att->replace(); }); |
| 134 | -endDict(); // .options.addAttachment | |
| 135 | +endContainer(); // .options.addAttachment | |
| 136 | +endContainer(); // .options.addAttachment[] | |
| 135 | 137 | addParameter("removeAttachment", [this](char const* p) { c_main->removeAttachment(p); }); |
| 138 | +beginArray("options", bindJSON(&Handlers::beginOptionsCopyAttachmentsFromArray), bindBare(&Handlers::endOptionsCopyAttachmentsFromArray)); // .options.copyAttachmentsFrom[] | |
| 136 | 139 | beginDict("copyAttachmentsFrom", bindJSON(&Handlers::beginOptionsCopyAttachmentsFrom), bindBare(&Handlers::endOptionsCopyAttachmentsFrom)); // .options.copyAttachmentsFrom |
| 137 | 140 | doSetup("path", bindSetup(&Handlers::setupOptionsCopyAttachmentsFromPath)); |
| 138 | 141 | doSetup("password", bindSetup(&Handlers::setupOptionsCopyAttachmentsFromPassword)); |
| 139 | 142 | addParameter("prefix", [this](char const* p) { c_copy_att->prefix(p); }); |
| 140 | -endDict(); // .options.copyAttachmentsFrom | |
| 143 | +endContainer(); // .options.copyAttachmentsFrom | |
| 144 | +endContainer(); // .options.copyAttachmentsFrom[] | |
| 141 | 145 | addParameter("collate", [this](char const* p) { c_main->collate(p); }); |
| 142 | 146 | addChoices("flattenAnnotations", flatten_choices, [this](char const* p) { c_main->flattenAnnotations(p); }); |
| 143 | 147 | addBare("flattenRotation", [this]() { c_main->flattenRotation(); }); |
| ... | ... | @@ -147,11 +151,13 @@ addParameter("oiMinArea", [this](char const* p) { c_main->oiMinArea(p); }); |
| 147 | 151 | addParameter("oiMinHeight", [this](char const* p) { c_main->oiMinHeight(p); }); |
| 148 | 152 | addParameter("oiMinWidth", [this](char const* p) { c_main->oiMinWidth(p); }); |
| 149 | 153 | addBare("optimizeImages", [this]() { c_main->optimizeImages(); }); |
| 154 | +beginArray("options", bindJSON(&Handlers::beginOptionsPagesArray), bindBare(&Handlers::endOptionsPagesArray)); // .options.pages[] | |
| 150 | 155 | beginDict("pages", bindJSON(&Handlers::beginOptionsPages), bindBare(&Handlers::endOptionsPages)); // .options.pages |
| 151 | 156 | doSetup("file", bindSetup(&Handlers::setupOptionsPagesFile)); |
| 152 | 157 | doSetup("password", bindSetup(&Handlers::setupOptionsPagesPassword)); |
| 153 | 158 | doSetup("range", bindSetup(&Handlers::setupOptionsPagesRange)); |
| 154 | -endDict(); // .options.pages | |
| 159 | +endContainer(); // .options.pages | |
| 160 | +endContainer(); // .options.pages[] | |
| 155 | 161 | addBare("removePageLabels", [this]() { c_main->removePageLabels(); }); |
| 156 | 162 | addParameter("rotate", [this](char const* p) { c_main->rotate(p); }); |
| 157 | 163 | beginDict("overlay", bindJSON(&Handlers::beginOptionsOverlay), bindBare(&Handlers::endOptionsOverlay)); // .options.overlay |
| ... | ... | @@ -160,12 +166,12 @@ doSetup("password", bindSetup(&Handlers::setupOptionsOverlayPassword)); |
| 160 | 166 | addParameter("from", [this](char const* p) { c_uo->from(p); }); |
| 161 | 167 | addParameter("repeat", [this](char const* p) { c_uo->repeat(p); }); |
| 162 | 168 | addParameter("to", [this](char const* p) { c_uo->to(p); }); |
| 163 | -endDict(); // .options.overlay | |
| 169 | +endContainer(); // .options.overlay | |
| 164 | 170 | beginDict("underlay", bindJSON(&Handlers::beginOptionsUnderlay), bindBare(&Handlers::endOptionsUnderlay)); // .options.underlay |
| 165 | 171 | doSetup("file", bindSetup(&Handlers::setupOptionsUnderlayFile)); |
| 166 | 172 | doSetup("password", bindSetup(&Handlers::setupOptionsUnderlayPassword)); |
| 167 | 173 | addParameter("from", [this](char const* p) { c_uo->from(p); }); |
| 168 | 174 | addParameter("repeat", [this](char const* p) { c_uo->repeat(p); }); |
| 169 | 175 | addParameter("to", [this](char const* p) { c_uo->to(p); }); |
| 170 | -endDict(); // .options.underlay | |
| 171 | -endDict(); // .options | |
| 176 | +endContainer(); // .options.underlay | |
| 177 | +endContainer(); // .options | ... | ... |