From 03f3369f35b2303166e8d36547c8a0aba6626c1b Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Wed, 26 Jan 2022 17:02:30 -0500 Subject: [PATCH] QPDFJob: use manually named end functions for Config classes Use named functions rather than just end() for clarity. --- generate_auto_job | 11 ++++------- include/qpdf/QPDFJob.hh | 10 ++++++++++ include/qpdf/auto_job_c_att.hh | 1 - include/qpdf/auto_job_c_copy_att.hh | 1 - include/qpdf/auto_job_c_enc.hh | 1 - include/qpdf/auto_job_c_pages.hh | 1 - include/qpdf/auto_job_c_uo.hh | 1 - job.sums | 14 +++++++------- job.yml | 6 +++--- libqpdf/QPDFJob_argv.cc | 10 +++++----- libqpdf/QPDFJob_config.cc | 10 +++++----- 11 files changed, 34 insertions(+), 32 deletions(-) diff --git a/generate_auto_job b/generate_auto_job index a13cc3b2..06fb6d25 100755 --- a/generate_auto_job +++ b/generate_auto_job @@ -72,13 +72,10 @@ class Main: self.config_decls = {} self.declared_configs = set() for o in data['options']: - table = o['table'] config = o.get('config', None) if config is not None: self.DESTS[config] = f'include/qpdf/auto_job_{config}.hh' self.config_decls[config] = [] - if table != 'main': - self.config_decls[config].append('QPDF_DLL Config& end();') if self.check_hashes(): exit(0) @@ -314,11 +311,11 @@ class Main: # Generate declarations for config methods separately by # config object. - config_class = prefix + 'Config' + config_prefix = prefix + 'Config' arg = '' if decl_arg: arg = 'char const* parameter' - fn = f'{config_class}& {identifier}({arg})' + fn = f'{config_prefix}& {identifier}({arg})' if fn not in self.declared_configs: self.declared_configs.add(fn) self.config_decls[cfg].append(f'QPDF_DLL {fn};') @@ -430,7 +427,7 @@ class Main: self.handle_flag(i, identifier, kind, v) else: identifier = self.to_identifier(i, '', False) - prefix = o.get('config_class', table_prefix) + prefix = o.get('config_prefix', table_prefix) self.handle_trivial( i, identifier, config, prefix, kind, v) @@ -523,7 +520,7 @@ class Main: ['choices', 'options', 'no-json', 'json'])) for o in data['options']: self.check_keys('top', o, set( - ['table', 'prefix', 'config', 'config_class', + ['table', 'prefix', 'config', 'config_prefix', 'manual', 'bare', 'positional', 'optional_parameter', 'required_parameter', 'required_choices', 'optional_choices'])) diff --git a/include/qpdf/QPDFJob.hh b/include/qpdf/QPDFJob.hh index 274a19f6..99199b89 100644 --- a/include/qpdf/QPDFJob.hh +++ b/include/qpdf/QPDFJob.hh @@ -153,6 +153,8 @@ class QPDFJob friend class QPDFJob; friend class Config; public: + QPDF_DLL + Config& endAddAttachment(); QPDF_DLL AttConfig& path(char const* parameter); @@ -171,6 +173,8 @@ class QPDFJob friend class QPDFJob; friend class Config; public: + QPDF_DLL + Config& endCopyAttachmentsFrom(); QPDF_DLL CopyAttConfig& path(char const* parameter); @@ -189,6 +193,8 @@ class QPDFJob friend class QPDFJob; friend class Config; public: + QPDF_DLL + Config& endPages(); QPDF_DLL PagesConfig& pageSpec(std::string const& filename, std::string const& range, @@ -208,6 +214,8 @@ class QPDFJob friend class QPDFJob; friend class Config; public: + QPDF_DLL + Config& endUnderlayOverlay(); QPDF_DLL UOConfig& path(char const* parameter); @@ -225,6 +233,8 @@ class QPDFJob friend class QPDFJob; friend class Config; public: + QPDF_DLL + Config& endEncrypt(); QPDF_DLL EncConfig& path(char const* parameter); diff --git a/include/qpdf/auto_job_c_att.hh b/include/qpdf/auto_job_c_att.hh index ac0f4223..156964a8 100644 --- a/include/qpdf/auto_job_c_att.hh +++ b/include/qpdf/auto_job_c_att.hh @@ -3,7 +3,6 @@ // Edits will be automatically overwritten if the build is // run in maintainer mode. // -QPDF_DLL Config& end(); QPDF_DLL AttConfig& replace(); QPDF_DLL AttConfig& key(char const* parameter); QPDF_DLL AttConfig& filename(char const* parameter); diff --git a/include/qpdf/auto_job_c_copy_att.hh b/include/qpdf/auto_job_c_copy_att.hh index d389611f..bae11e9d 100644 --- a/include/qpdf/auto_job_c_copy_att.hh +++ b/include/qpdf/auto_job_c_copy_att.hh @@ -3,6 +3,5 @@ // Edits will be automatically overwritten if the build is // run in maintainer mode. // -QPDF_DLL Config& end(); QPDF_DLL CopyAttConfig& prefix(char const* parameter); QPDF_DLL CopyAttConfig& password(char const* parameter); diff --git a/include/qpdf/auto_job_c_enc.hh b/include/qpdf/auto_job_c_enc.hh index e808de6c..8c84fc81 100644 --- a/include/qpdf/auto_job_c_enc.hh +++ b/include/qpdf/auto_job_c_enc.hh @@ -3,7 +3,6 @@ // Edits will be automatically overwritten if the build is // run in maintainer mode. // -QPDF_DLL Config& end(); QPDF_DLL EncConfig& extract(char const* parameter); QPDF_DLL EncConfig& annotate(char const* parameter); QPDF_DLL EncConfig& print(char const* parameter); diff --git a/include/qpdf/auto_job_c_pages.hh b/include/qpdf/auto_job_c_pages.hh index 0d81c336..d6cbecfe 100644 --- a/include/qpdf/auto_job_c_pages.hh +++ b/include/qpdf/auto_job_c_pages.hh @@ -3,4 +3,3 @@ // Edits will be automatically overwritten if the build is // run in maintainer mode. // -QPDF_DLL Config& end(); diff --git a/include/qpdf/auto_job_c_uo.hh b/include/qpdf/auto_job_c_uo.hh index 39b54511..4e4afd49 100644 --- a/include/qpdf/auto_job_c_uo.hh +++ b/include/qpdf/auto_job_c_uo.hh @@ -3,7 +3,6 @@ // Edits will be automatically overwritten if the build is // run in maintainer mode. // -QPDF_DLL Config& end(); QPDF_DLL UOConfig& to(char const* parameter); QPDF_DLL UOConfig& from(char const* parameter); QPDF_DLL UOConfig& repeat(char const* parameter); diff --git a/job.sums b/job.sums index 47ba95f9..08753eb3 100644 --- a/job.sums +++ b/job.sums @@ -1,12 +1,12 @@ # Generated by generate_auto_job -generate_auto_job 207b392d0d199a6cc0e5eb52044e9adbc729323c9a58f9d547605272a0d9b29c -include/qpdf/auto_job_c_att.hh ecc3f8f711b486b491e811176362a90c022eb225ff12157df3a10ca021be87b1 -include/qpdf/auto_job_c_copy_att.hh caffae3d1faf2cd92a07ba77da638cce31da3e074a047918834195c0f3ed508a -include/qpdf/auto_job_c_enc.hh e2e1a163a7ffebbf8af169dc4a28ab00df3b8d229864bca7d203dde8b56f0864 +generate_auto_job 3108658e47e17655e761842cd76bab48fdaf5e9792942c8bf1ca03f6f1934809 +include/qpdf/auto_job_c_att.hh 9d21a86169938a187c55e56e1ef915cd4211d13745c21d85c5c06306fd8ed023 +include/qpdf/auto_job_c_copy_att.hh d954c29ca74ef2e3abf0a0d99446bb974585700750fad8cee31340cbf2304a94 +include/qpdf/auto_job_c_enc.hh 7a64974ba970390f38bcea9c2471e620b92329c71eb7fa428ad0e09844007ca8 include/qpdf/auto_job_c_main.hh e7f23e24ddbd16b5e7cb720c7da9ef76b89c2e23b5c4eecc5d8e10f0c0d60f4e -include/qpdf/auto_job_c_pages.hh 79ee6e52a36fedfd0e6ca60bd926bc25a3e975ab6fa984a7e798a48791e8ba86 -include/qpdf/auto_job_c_uo.hh 80404376f19fe57d67421ad0c5fb1755811758c73870df96f081f032b196deff -job.yml be8cd97408ab17bc83970c1b512cac3d3d3b502afd40d71ec59f66054525e6b1 +include/qpdf/auto_job_c_pages.hh 931840b329a36ca0e41401190e04537b47f2867671a6643bfd8da74014202671 +include/qpdf/auto_job_c_uo.hh 0fd370c70a1974197804f62c308ca2ec44727bf2f95a89cde48c4284823b6fbc +job.yml 1590fd16fd17ed40db9aa56b6713c844cfd61b3a6d0441a3ccd122b7371c68e9 libqpdf/qpdf/auto_job_decl.hh 9f79396ec459f191be4c5fe34cf88c265cf47355a1a945fa39169d1c94cf04f6 libqpdf/qpdf/auto_job_help.hh 383eea80e2c185ef5295fc126246457a7ceeffea759fdb90bb2e6727532ea538 libqpdf/qpdf/auto_job_init.hh 3b6323189480a7d782563c9d2b5bc29b8dcd19c6dcc89840b207e38cb503d3f1 diff --git a/job.yml b/job.yml index 171d1981..4709e9d0 100644 --- a/job.yml +++ b/job.yml @@ -169,7 +169,7 @@ options: positional: true - table: 40-bit encryption config: c_enc - config_class: Enc + config_prefix: Enc prefix: Enc40 required_choices: extract: yn @@ -178,7 +178,7 @@ options: modify: yn - table: 128-bit encryption config: c_enc - config_class: Enc + config_prefix: Enc prefix: Enc128 bare: - cleartext-metadata @@ -195,7 +195,7 @@ options: use-aes: yn - table: 256-bit encryption config: c_enc - config_class: Enc + config_prefix: Enc prefix: Enc256 bare: - cleartext-metadata diff --git a/libqpdf/QPDFJob_argv.cc b/libqpdf/QPDFJob_argv.cc index f4c15e31..36a2a2a6 100644 --- a/libqpdf/QPDFJob_argv.cc +++ b/libqpdf/QPDFJob_argv.cc @@ -365,7 +365,7 @@ void ArgParser::argEndPages() { argPagesPositional(nullptr); - c_pages->end(); + c_pages->endPages(); c_pages = nullptr; } @@ -400,7 +400,7 @@ ArgParser::argCopyAttachmentsFrom() void ArgParser::argEndEncryption() { - c_enc->end(); + c_enc->endEncrypt(); c_enc = nullptr; } @@ -431,7 +431,7 @@ ArgParser::argUOPositional(char* arg) void ArgParser::argEndUnderlayOverlay() { - c_uo->end(); + c_uo->endUnderlayOverlay(); c_uo = nullptr; } @@ -444,7 +444,7 @@ ArgParser::argAttPositional(char* arg) void ArgParser::argEndAttachment() { - c_att->end(); + c_att->endAddAttachment(); c_att = nullptr; } @@ -457,7 +457,7 @@ ArgParser::argCopyAttPositional(char* arg) void ArgParser::argEndCopyAttachment() { - c_copy_att->end(); + c_copy_att->endCopyAttachmentsFrom(); c_copy_att = nullptr; } diff --git a/libqpdf/QPDFJob_config.cc b/libqpdf/QPDFJob_config.cc index 621d788a..a13dee4b 100644 --- a/libqpdf/QPDFJob_config.cc +++ b/libqpdf/QPDFJob_config.cc @@ -781,7 +781,7 @@ QPDFJob::CopyAttConfig::password(char const* parameter) } QPDFJob::Config& -QPDFJob::CopyAttConfig::end() +QPDFJob::CopyAttConfig::endCopyAttachmentsFrom() { if (this->caf.path.empty()) { @@ -871,7 +871,7 @@ QPDFJob::AttConfig::replace() } QPDFJob::Config& -QPDFJob::AttConfig::end() +QPDFJob::AttConfig::endAddAttachment() { static std::string now = QUtil::qpdf_time_to_pdf_time( QUtil::get_current_qpdf_time()); @@ -921,7 +921,7 @@ QPDFJob::Config::pages() } QPDFJob::Config& -QPDFJob::PagesConfig::end() +QPDFJob::PagesConfig::endPages() { if (this->config.o.m->page_specs.empty()) { @@ -960,7 +960,7 @@ QPDFJob::UOConfig::UOConfig(Config& c) : } QPDFJob::Config& -QPDFJob::UOConfig::end() +QPDFJob::UOConfig::endUnderlayOverlay() { if (config.o.m->under_overlay->filename.empty()) { @@ -1042,7 +1042,7 @@ QPDFJob::EncConfig::EncConfig(Config& c) : } QPDFJob::Config& -QPDFJob::EncConfig::end() +QPDFJob::EncConfig::endEncrypt() { config.o.m->encrypt = true; config.o.m->decrypt = false;