From e109f9a6f9954f55a7ca2f336aa41a0235dca37b Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 5 Aug 2021 11:05:51 -0600 Subject: [PATCH] [util] Collect cmdline arg options outside of constructor --- util/hb-ot-shape-closure.cc | 8 ++------ util/hb-shape.cc | 11 ++++++++--- util/hb-subset.cc | 13 +++++++------ util/main-font-text.hh | 16 +++++++++++----- util/options.hh | 37 ++++++------------------------------- util/shape-consumer.hh | 9 +++++---- util/view-cairo.hh | 11 ++++++++--- 7 files changed, 47 insertions(+), 58 deletions(-) diff --git a/util/hb-ot-shape-closure.cc b/util/hb-ot-shape-closure.cc index 2e3ee2a33..7996c11f3 100644 --- a/util/hb-ot-shape-closure.cc +++ b/util/hb-ot-shape-closure.cc @@ -32,14 +32,10 @@ struct shape_closure_consumer_t : option_group_t { - shape_closure_consumer_t (option_parser_t *parser) - : shaper (parser) - { - add_options (parser); - } - void add_options (struct option_parser_t *parser) override { + shaper.add_options (parser); + GOptionEntry entries[] = { {"no-glyph-names", 0, G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &this->show_glyph_names, "Use glyph indices instead of names", nullptr}, diff --git a/util/hb-shape.cc b/util/hb-shape.cc index d2b86f1a8..8cf1901a2 100644 --- a/util/hb-shape.cc +++ b/util/hb-shape.cc @@ -30,11 +30,16 @@ struct output_buffer_t { - output_buffer_t (option_parser_t *parser) - : options (parser, hb_buffer_serialize_list_formats ()), - format (parser) + output_buffer_t () + : options (hb_buffer_serialize_list_formats ()) {} + void add_options (option_parser_t *parser) + { + options.add_options (parser); + format.add_options (parser); + } + void init (hb_buffer_t *buffer, const font_options_t *font_opts) { options.get_file_handle (); diff --git a/util/hb-subset.cc b/util/hb-subset.cc index 2d66d913c..4ff193137 100644 --- a/util/hb-subset.cc +++ b/util/hb-subset.cc @@ -36,10 +36,11 @@ struct subset_consumer_t { - subset_consumer_t (option_parser_t *parser) - : options (parser), - subset_options (parser) - {} + void add_options (option_parser_t *parser) + { + output_options.add_options (parser); + subset_options.add_options (parser); + } void init (hb_buffer_t *buffer_, const font_options_t *font_opts) @@ -108,7 +109,7 @@ struct subset_consumer_t if (!failed) { hb_blob_t *result = hb_face_reference_blob (new_face); - write_file (options.output_file, result); + write_file (output_options.output_file, result); hb_blob_destroy (result); } @@ -121,7 +122,7 @@ struct subset_consumer_t bool failed = false; private: - output_options_t options; + output_options_t output_options; subset_options_t subset_options; hb_face_t *face = nullptr; diff --git a/util/main-font-text.hh b/util/main-font-text.hh index 7915c3786..ddeab3da9 100644 --- a/util/main-font-text.hh +++ b/util/main-font-text.hh @@ -51,14 +51,21 @@ template struct shape_consumer_t { - shape_consumer_t (option_parser_t *parser) - : shaper (parser), - output (parser) - {} + void add_options (option_parser_t *parser) + { + shaper.add_options (parser); + output.add_options (parser); + } void init (hb_buffer_t *buffer_, const font_options_t *font_opts) diff --git a/util/view-cairo.hh b/util/view-cairo.hh index af58f15db..dbd99670c 100644 --- a/util/view-cairo.hh +++ b/util/view-cairo.hh @@ -34,15 +34,20 @@ struct view_cairo_t { - view_cairo_t (option_parser_t *parser) - : output_options (parser, helper_cairo_supported_formats), - view_options (parser) + view_cairo_t () + : output_options (helper_cairo_supported_formats) {} ~view_cairo_t () { cairo_debug_reset_static_data (); } + void add_options (option_parser_t *parser) + { + output_options.add_options (parser); + view_options.add_options (parser); + } + void init (hb_buffer_t *buffer, const font_options_t *font_opts) { lines = g_array_new (false, false, sizeof (helper_cairo_line_t));