[util] Initialize struct members inline
This commit is contained in:
parent
21f1054d47
commit
e57dd66889
|
@ -32,9 +32,8 @@
|
||||||
|
|
||||||
struct shape_closure_consumer_t : option_group_t
|
struct shape_closure_consumer_t : option_group_t
|
||||||
{
|
{
|
||||||
shape_closure_consumer_t (option_parser_t *parser) :
|
shape_closure_consumer_t (option_parser_t *parser)
|
||||||
shaper (parser),
|
: shaper (parser)
|
||||||
show_glyph_names (true)
|
|
||||||
{
|
{
|
||||||
add_options (parser);
|
add_options (parser);
|
||||||
}
|
}
|
||||||
|
@ -104,11 +103,11 @@ struct shape_closure_consumer_t : option_group_t
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
shape_options_t shaper;
|
shape_options_t shaper;
|
||||||
hb_bool_t show_glyph_names;
|
hb_bool_t show_glyph_names = false;
|
||||||
|
|
||||||
hb_set_t *glyphs;
|
hb_set_t *glyphs = nullptr;
|
||||||
hb_font_t *font;
|
hb_font_t *font = nullptr;
|
||||||
hb_buffer_t *buffer;
|
hb_buffer_t *buffer = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
@ -31,13 +31,9 @@
|
||||||
struct output_buffer_t
|
struct output_buffer_t
|
||||||
{
|
{
|
||||||
output_buffer_t (option_parser_t *parser)
|
output_buffer_t (option_parser_t *parser)
|
||||||
: options (parser, hb_buffer_serialize_list_formats ()),
|
: options (parser, hb_buffer_serialize_list_formats ()),
|
||||||
format (parser),
|
format (parser)
|
||||||
gs (nullptr),
|
{}
|
||||||
line_no (0),
|
|
||||||
font (nullptr),
|
|
||||||
output_format (HB_BUFFER_SERIALIZE_FORMAT_INVALID),
|
|
||||||
format_flags (HB_BUFFER_SERIALIZE_FLAG_DEFAULT) {}
|
|
||||||
|
|
||||||
void init (hb_buffer_t *buffer, const font_options_t *font_opts)
|
void init (hb_buffer_t *buffer, const font_options_t *font_opts)
|
||||||
{
|
{
|
||||||
|
@ -147,11 +143,11 @@ struct output_buffer_t
|
||||||
output_options_t options;
|
output_options_t options;
|
||||||
format_options_t format;
|
format_options_t format;
|
||||||
|
|
||||||
GString *gs;
|
GString *gs = nullptr;
|
||||||
unsigned int line_no;
|
unsigned int line_no = 0;
|
||||||
hb_font_t *font;
|
hb_font_t *font = nullptr;
|
||||||
hb_buffer_serialize_format_t output_format;
|
hb_buffer_serialize_format_t output_format = HB_BUFFER_SERIALIZE_FORMAT_INVALID;
|
||||||
hb_buffer_serialize_flags_t format_flags;
|
hb_buffer_serialize_flags_t format_flags = HB_BUFFER_SERIALIZE_FLAG_DEFAULT;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <int eol = '\n'>
|
template <int eol = '\n'>
|
||||||
|
|
|
@ -37,7 +37,9 @@
|
||||||
struct subset_consumer_t
|
struct subset_consumer_t
|
||||||
{
|
{
|
||||||
subset_consumer_t (option_parser_t *parser)
|
subset_consumer_t (option_parser_t *parser)
|
||||||
: failed (false), options (parser), subset_options (parser), face (nullptr), input (nullptr) {}
|
: options (parser),
|
||||||
|
subset_options (parser)
|
||||||
|
{}
|
||||||
|
|
||||||
void init (hb_buffer_t *buffer_,
|
void init (hb_buffer_t *buffer_,
|
||||||
const font_options_t *font_opts)
|
const font_options_t *font_opts)
|
||||||
|
@ -116,14 +118,14 @@ struct subset_consumer_t
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool failed;
|
bool failed = false;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
output_options_t options;
|
output_options_t options;
|
||||||
subset_options_t subset_options;
|
subset_options_t subset_options;
|
||||||
|
|
||||||
hb_face_t *face;
|
hb_face_t *face = nullptr;
|
||||||
hb_subset_input_t *input;
|
hb_subset_input_t *input = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <int eol = '\n'>
|
template <int eol = '\n'>
|
||||||
|
|
212
util/options.hh
212
util/options.hh
|
@ -67,12 +67,10 @@ struct option_group_t
|
||||||
struct option_parser_t
|
struct option_parser_t
|
||||||
{
|
{
|
||||||
option_parser_t (const char *usage)
|
option_parser_t (const char *usage)
|
||||||
|
: usage_str (usage),
|
||||||
|
context (g_option_context_new (usage)),
|
||||||
|
to_free (g_ptr_array_new ())
|
||||||
{
|
{
|
||||||
memset (this, 0, sizeof (*this));
|
|
||||||
usage_str = usage;
|
|
||||||
context = g_option_context_new (usage);
|
|
||||||
to_free = g_ptr_array_new ();
|
|
||||||
|
|
||||||
add_main_options ();
|
add_main_options ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,14 +119,6 @@ struct view_options_t : option_group_t
|
||||||
{
|
{
|
||||||
view_options_t (option_parser_t *parser)
|
view_options_t (option_parser_t *parser)
|
||||||
{
|
{
|
||||||
annotate = false;
|
|
||||||
fore = nullptr;
|
|
||||||
back = nullptr;
|
|
||||||
line_space = 0;
|
|
||||||
have_font_extents = false;
|
|
||||||
font_extents.ascent = font_extents.descent = font_extents.line_gap = 0;
|
|
||||||
margin.t = margin.r = margin.b = margin.l = DEFAULT_MARGIN;
|
|
||||||
|
|
||||||
add_options (parser);
|
add_options (parser);
|
||||||
}
|
}
|
||||||
~view_options_t () override
|
~view_options_t () override
|
||||||
|
@ -139,17 +129,17 @@ struct view_options_t : option_group_t
|
||||||
|
|
||||||
void add_options (option_parser_t *parser) override;
|
void add_options (option_parser_t *parser) override;
|
||||||
|
|
||||||
hb_bool_t annotate;
|
hb_bool_t annotate = false;
|
||||||
char *fore;
|
char *fore = nullptr;
|
||||||
char *back;
|
char *back = nullptr;
|
||||||
double line_space;
|
double line_space = 0;
|
||||||
bool have_font_extents;
|
bool have_font_extents = false;
|
||||||
struct font_extents_t {
|
struct font_extents_t {
|
||||||
double ascent, descent, line_gap;
|
double ascent, descent, line_gap;
|
||||||
} font_extents;
|
} font_extents = {0., 0., 0.};
|
||||||
struct margin_t {
|
struct margin_t {
|
||||||
double t, r, b, l;
|
double t, r, b, l;
|
||||||
} margin;
|
} margin = {DEFAULT_MARGIN, DEFAULT_MARGIN, DEFAULT_MARGIN, DEFAULT_MARGIN};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -157,18 +147,6 @@ struct shape_options_t : option_group_t
|
||||||
{
|
{
|
||||||
shape_options_t (option_parser_t *parser)
|
shape_options_t (option_parser_t *parser)
|
||||||
{
|
{
|
||||||
direction = language = script = nullptr;
|
|
||||||
bot = eot = preserve_default_ignorables = remove_default_ignorables = false;
|
|
||||||
features = nullptr;
|
|
||||||
num_features = 0;
|
|
||||||
shapers = nullptr;
|
|
||||||
utf8_clusters = false;
|
|
||||||
invisible_glyph = 0;
|
|
||||||
cluster_level = HB_BUFFER_CLUSTER_LEVEL_DEFAULT;
|
|
||||||
normalize_glyphs = false;
|
|
||||||
verify = false;
|
|
||||||
num_iterations = 1;
|
|
||||||
|
|
||||||
add_options (parser);
|
add_options (parser);
|
||||||
}
|
}
|
||||||
~shape_options_t () override
|
~shape_options_t () override
|
||||||
|
@ -431,25 +409,25 @@ struct shape_options_t : option_group_t
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Buffer properties */
|
/* Buffer properties */
|
||||||
char *direction;
|
char *direction = nullptr;
|
||||||
char *language;
|
char *language = nullptr;
|
||||||
char *script;
|
char *script = nullptr;
|
||||||
|
|
||||||
/* Buffer flags */
|
/* Buffer flags */
|
||||||
hb_bool_t bot;
|
hb_bool_t bot = false;
|
||||||
hb_bool_t eot;
|
hb_bool_t eot = false;
|
||||||
hb_bool_t preserve_default_ignorables;
|
hb_bool_t preserve_default_ignorables = false;
|
||||||
hb_bool_t remove_default_ignorables;
|
hb_bool_t remove_default_ignorables = false;
|
||||||
|
|
||||||
hb_feature_t *features;
|
hb_feature_t *features = nullptr;
|
||||||
unsigned int num_features;
|
unsigned int num_features = 0;
|
||||||
char **shapers;
|
char **shapers = nullptr;
|
||||||
hb_bool_t utf8_clusters;
|
hb_bool_t utf8_clusters = false;
|
||||||
hb_codepoint_t invisible_glyph;
|
hb_codepoint_t invisible_glyph = 0;
|
||||||
hb_buffer_cluster_level_t cluster_level;
|
hb_buffer_cluster_level_t cluster_level = HB_BUFFER_CLUSTER_LEVEL_DEFAULT;
|
||||||
hb_bool_t normalize_glyphs;
|
hb_bool_t normalize_glyphs = false;
|
||||||
hb_bool_t verify;
|
hb_bool_t verify = false;
|
||||||
unsigned int num_iterations;
|
unsigned int num_iterations = 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -458,23 +436,11 @@ struct font_options_t : option_group_t
|
||||||
font_options_t (option_parser_t *parser,
|
font_options_t (option_parser_t *parser,
|
||||||
int default_font_size_,
|
int default_font_size_,
|
||||||
unsigned int subpixel_bits_)
|
unsigned int subpixel_bits_)
|
||||||
|
: default_font_size (default_font_size_),
|
||||||
|
subpixel_bits (subpixel_bits_),
|
||||||
|
font_size_x (default_font_size_),
|
||||||
|
font_size_y (default_font_size_)
|
||||||
{
|
{
|
||||||
variations = nullptr;
|
|
||||||
num_variations = 0;
|
|
||||||
default_font_size = default_font_size_;
|
|
||||||
x_ppem = 0;
|
|
||||||
y_ppem = 0;
|
|
||||||
ptem = 0.;
|
|
||||||
subpixel_bits = subpixel_bits_;
|
|
||||||
font_file = nullptr;
|
|
||||||
face_index = 0;
|
|
||||||
font_size_x = font_size_y = default_font_size;
|
|
||||||
font_funcs = nullptr;
|
|
||||||
ft_load_flags = 2;
|
|
||||||
|
|
||||||
blob = nullptr;
|
|
||||||
font = nullptr;
|
|
||||||
|
|
||||||
add_options (parser);
|
add_options (parser);
|
||||||
}
|
}
|
||||||
~font_options_t () override
|
~font_options_t () override
|
||||||
|
@ -489,23 +455,23 @@ struct font_options_t : option_group_t
|
||||||
|
|
||||||
hb_font_t *get_font () const;
|
hb_font_t *get_font () const;
|
||||||
|
|
||||||
char *font_file;
|
char *font_file = nullptr;
|
||||||
mutable hb_blob_t *blob;
|
mutable hb_blob_t *blob = nullptr;
|
||||||
unsigned face_index;
|
unsigned face_index = 0;
|
||||||
hb_variation_t *variations;
|
hb_variation_t *variations = nullptr;
|
||||||
unsigned int num_variations;
|
unsigned int num_variations = 0;
|
||||||
int default_font_size;
|
int default_font_size = FONT_SIZE_UPEM;
|
||||||
int x_ppem;
|
int x_ppem = 0;
|
||||||
int y_ppem;
|
int y_ppem = 0;
|
||||||
double ptem;
|
double ptem = 0.;
|
||||||
unsigned int subpixel_bits;
|
unsigned int subpixel_bits = 0;
|
||||||
mutable double font_size_x;
|
mutable double font_size_x = FONT_SIZE_UPEM;
|
||||||
mutable double font_size_y;
|
mutable double font_size_y = FONT_SIZE_UPEM;
|
||||||
char *font_funcs;
|
char *font_funcs = nullptr;
|
||||||
int ft_load_flags;
|
int ft_load_flags = 2;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable hb_font_t *font;
|
mutable hb_font_t *font = nullptr;
|
||||||
|
|
||||||
static struct cache_t
|
static struct cache_t
|
||||||
{
|
{
|
||||||
|
@ -528,18 +494,6 @@ struct text_options_t : option_group_t
|
||||||
{
|
{
|
||||||
text_options_t (option_parser_t *parser)
|
text_options_t (option_parser_t *parser)
|
||||||
{
|
{
|
||||||
text_before = nullptr;
|
|
||||||
text_after = nullptr;
|
|
||||||
|
|
||||||
text_len = -1;
|
|
||||||
text = nullptr;
|
|
||||||
text_file = nullptr;
|
|
||||||
|
|
||||||
fp = nullptr;
|
|
||||||
gs = nullptr;
|
|
||||||
line = nullptr;
|
|
||||||
line_len = UINT_MAX;
|
|
||||||
|
|
||||||
add_options (parser);
|
add_options (parser);
|
||||||
}
|
}
|
||||||
~text_options_t () override
|
~text_options_t () override
|
||||||
|
@ -565,32 +519,26 @@ struct text_options_t : option_group_t
|
||||||
|
|
||||||
const char *get_line (unsigned int *len, int eol = '\n');
|
const char *get_line (unsigned int *len, int eol = '\n');
|
||||||
|
|
||||||
char *text_before;
|
char *text_before = nullptr;
|
||||||
char *text_after;
|
char *text_after = nullptr;
|
||||||
|
|
||||||
int text_len;
|
int text_len = -1;
|
||||||
char *text;
|
char *text = nullptr;
|
||||||
char *text_file;
|
char *text_file = nullptr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FILE *fp;
|
FILE *fp = nullptr;
|
||||||
GString *gs;
|
GString *gs = nullptr;
|
||||||
char *line;
|
char *line = nullptr;
|
||||||
unsigned int line_len;
|
unsigned int line_len = UINT_MAX;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct output_options_t : option_group_t
|
struct output_options_t : option_group_t
|
||||||
{
|
{
|
||||||
output_options_t (option_parser_t *parser,
|
output_options_t (option_parser_t *parser,
|
||||||
const char **supported_formats_ = nullptr)
|
const char **supported_formats_ = nullptr)
|
||||||
|
: supported_formats (supported_formats_)
|
||||||
{
|
{
|
||||||
output_file = nullptr;
|
|
||||||
output_format = nullptr;
|
|
||||||
supported_formats = supported_formats_;
|
|
||||||
explicit_output_format = false;
|
|
||||||
|
|
||||||
fp = nullptr;
|
|
||||||
|
|
||||||
add_options (parser);
|
add_options (parser);
|
||||||
}
|
}
|
||||||
~output_options_t () override
|
~output_options_t () override
|
||||||
|
@ -623,28 +571,17 @@ struct output_options_t : option_group_t
|
||||||
|
|
||||||
FILE *get_file_handle ();
|
FILE *get_file_handle ();
|
||||||
|
|
||||||
char *output_file;
|
char *output_file = nullptr;
|
||||||
char *output_format;
|
char *output_format = nullptr;
|
||||||
const char **supported_formats;
|
const char **supported_formats = nullptr;
|
||||||
bool explicit_output_format;
|
bool explicit_output_format = false;
|
||||||
|
|
||||||
mutable FILE *fp;
|
mutable FILE *fp = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct format_options_t : option_group_t
|
struct format_options_t : option_group_t
|
||||||
{
|
{
|
||||||
format_options_t (option_parser_t *parser) {
|
format_options_t (option_parser_t *parser) {
|
||||||
show_glyph_names = true;
|
|
||||||
show_positions = true;
|
|
||||||
show_advances = true;
|
|
||||||
show_clusters = true;
|
|
||||||
show_text = false;
|
|
||||||
show_unicode = false;
|
|
||||||
show_line_num = false;
|
|
||||||
show_extents = false;
|
|
||||||
show_flags = false;
|
|
||||||
trace = false;
|
|
||||||
|
|
||||||
add_options (parser);
|
add_options (parser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -677,24 +614,23 @@ struct format_options_t : option_group_t
|
||||||
GString *gs);
|
GString *gs);
|
||||||
|
|
||||||
|
|
||||||
hb_bool_t show_glyph_names;
|
hb_bool_t show_glyph_names = true;
|
||||||
hb_bool_t show_positions;
|
hb_bool_t show_positions = true;
|
||||||
hb_bool_t show_advances;
|
hb_bool_t show_advances = true;
|
||||||
hb_bool_t show_clusters;
|
hb_bool_t show_clusters = true;
|
||||||
hb_bool_t show_text;
|
hb_bool_t show_text = false;
|
||||||
hb_bool_t show_unicode;
|
hb_bool_t show_unicode = false;
|
||||||
hb_bool_t show_line_num;
|
hb_bool_t show_line_num = false;
|
||||||
hb_bool_t show_extents;
|
hb_bool_t show_extents = false;
|
||||||
hb_bool_t show_flags;
|
hb_bool_t show_flags = false;
|
||||||
hb_bool_t trace;
|
hb_bool_t trace = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct subset_options_t : option_group_t
|
struct subset_options_t : option_group_t
|
||||||
{
|
{
|
||||||
subset_options_t (option_parser_t *parser)
|
subset_options_t (option_parser_t *parser)
|
||||||
|
: input (hb_subset_input_create_or_fail ())
|
||||||
{
|
{
|
||||||
input = hb_subset_input_create_or_fail ();
|
|
||||||
num_iterations = 1;
|
|
||||||
add_options (parser);
|
add_options (parser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -715,8 +651,6 @@ struct subset_options_t : option_group_t
|
||||||
return &flags[sizeof(int) * 8 - 1];
|
return &flags[sizeof(int) * 8 - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned num_iterations;
|
|
||||||
|
|
||||||
hb_subset_input_t * get_input ()
|
hb_subset_input_t * get_input ()
|
||||||
{
|
{
|
||||||
hb_subset_flags_t flags_set = HB_SUBSET_FLAGS_DEFAULT;
|
hb_subset_flags_t flags_set = HB_SUBSET_FLAGS_DEFAULT;
|
||||||
|
@ -729,9 +663,9 @@ struct subset_options_t : option_group_t
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned num_iterations = 1;
|
||||||
|
hb_subset_input_t *input = nullptr;
|
||||||
hb_bool_t flags[sizeof(int) * 8] = {0};
|
hb_bool_t flags[sizeof(int) * 8] = {0};
|
||||||
|
|
||||||
hb_subset_input_t *input;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* fallback implementation for scalbn()/scalbnf() for pre-2013 MSVC */
|
/* fallback implementation for scalbn()/scalbnf() for pre-2013 MSVC */
|
||||||
|
|
|
@ -35,11 +35,9 @@ template <typename output_t>
|
||||||
struct shape_consumer_t
|
struct shape_consumer_t
|
||||||
{
|
{
|
||||||
shape_consumer_t (option_parser_t *parser)
|
shape_consumer_t (option_parser_t *parser)
|
||||||
: failed (false),
|
: shaper (parser),
|
||||||
shaper (parser),
|
output (parser)
|
||||||
output (parser),
|
{}
|
||||||
font (nullptr),
|
|
||||||
buffer (nullptr) {}
|
|
||||||
|
|
||||||
void init (hb_buffer_t *buffer_,
|
void init (hb_buffer_t *buffer_,
|
||||||
const font_options_t *font_opts)
|
const font_options_t *font_opts)
|
||||||
|
@ -87,14 +85,14 @@ struct shape_consumer_t
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool failed;
|
bool failed = false;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
shape_options_t shaper;
|
shape_options_t shaper;
|
||||||
output_t output;
|
output_t output;
|
||||||
|
|
||||||
hb_font_t *font;
|
hb_font_t *font = nullptr;
|
||||||
hb_buffer_t *buffer;
|
hb_buffer_t *buffer = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,11 +35,11 @@
|
||||||
struct view_cairo_t
|
struct view_cairo_t
|
||||||
{
|
{
|
||||||
view_cairo_t (option_parser_t *parser)
|
view_cairo_t (option_parser_t *parser)
|
||||||
: output_options (parser, helper_cairo_supported_formats),
|
: output_options (parser, helper_cairo_supported_formats),
|
||||||
view_options (parser),
|
view_options (parser)
|
||||||
direction (HB_DIRECTION_INVALID),
|
{}
|
||||||
lines (0), scale_bits (0) {}
|
~view_cairo_t ()
|
||||||
~view_cairo_t () {
|
{
|
||||||
cairo_debug_reset_static_data ();
|
cairo_debug_reset_static_data ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,14 +82,14 @@ struct view_cairo_t
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
void render (const font_options_t *font_opts);
|
||||||
|
|
||||||
output_options_t output_options;
|
output_options_t output_options;
|
||||||
view_options_t view_options;
|
view_options_t view_options;
|
||||||
|
|
||||||
void render (const font_options_t *font_opts);
|
hb_direction_t direction = HB_DIRECTION_INVALID; // Remove this, make segment_properties accessible
|
||||||
|
GArray *lines = nullptr;
|
||||||
hb_direction_t direction; // Remove this, make segment_properties accessible
|
int scale_bits = 0;
|
||||||
GArray *lines;
|
|
||||||
int scale_bits;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue