Move all callback functions in a vtable structs

This commit is contained in:
Behdad Esfahbod 2010-05-24 17:46:21 +01:00
parent bbc7a99d01
commit bf36a1074a
5 changed files with 47 additions and 39 deletions

View File

@ -44,10 +44,12 @@ struct _hb_font_funcs_t {
hb_bool_t immutable; hb_bool_t immutable;
struct {
hb_font_get_glyph_func_t get_glyph; hb_font_get_glyph_func_t get_glyph;
hb_font_get_contour_point_func_t get_contour_point; hb_font_get_contour_point_func_t get_contour_point;
hb_font_get_glyph_metrics_func_t get_glyph_metrics; hb_font_get_glyph_metrics_func_t get_glyph_metrics;
hb_font_get_kerning_func_t get_kerning; hb_font_get_kerning_func_t get_kerning;
} v;
}; };
extern HB_INTERNAL hb_font_funcs_t _hb_font_funcs_nil; extern HB_INTERNAL hb_font_funcs_t _hb_font_funcs_nil;

View File

@ -78,10 +78,12 @@ hb_font_funcs_t _hb_font_funcs_nil = {
TRUE, /* immutable */ TRUE, /* immutable */
{
hb_font_get_glyph_nil, hb_font_get_glyph_nil,
hb_font_get_contour_point_nil, hb_font_get_contour_point_nil,
hb_font_get_glyph_metrics_nil, hb_font_get_glyph_metrics_nil,
hb_font_get_kerning_nil hb_font_get_kerning_nil
}
}; };
hb_font_funcs_t * hb_font_funcs_t *
@ -149,7 +151,7 @@ hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs,
if (ffuncs->immutable) if (ffuncs->immutable)
return; return;
ffuncs->get_glyph = glyph_func ? glyph_func : hb_font_get_glyph_nil; ffuncs->v.get_glyph = glyph_func ? glyph_func : hb_font_get_glyph_nil;
} }
void void
@ -159,7 +161,7 @@ hb_font_funcs_set_contour_point_func (hb_font_funcs_t *ffuncs,
if (ffuncs->immutable) if (ffuncs->immutable)
return; return;
ffuncs->get_contour_point = contour_point_func ? contour_point_func : hb_font_get_contour_point_nil; ffuncs->v.get_contour_point = contour_point_func ? contour_point_func : hb_font_get_contour_point_nil;
} }
void void
@ -169,7 +171,7 @@ hb_font_funcs_set_glyph_metrics_func (hb_font_funcs_t *ffuncs,
if (ffuncs->immutable) if (ffuncs->immutable)
return; return;
ffuncs->get_glyph_metrics = glyph_metrics_func ? glyph_metrics_func : hb_font_get_glyph_metrics_nil; ffuncs->v.get_glyph_metrics = glyph_metrics_func ? glyph_metrics_func : hb_font_get_glyph_metrics_nil;
} }
void void
@ -179,7 +181,7 @@ hb_font_funcs_set_kerning_func (hb_font_funcs_t *ffuncs,
if (ffuncs->immutable) if (ffuncs->immutable)
return; return;
ffuncs->get_kerning = kerning_func ? kerning_func : hb_font_get_kerning_nil; ffuncs->v.get_kerning = kerning_func ? kerning_func : hb_font_get_kerning_nil;
} }
@ -187,7 +189,7 @@ hb_codepoint_t
hb_font_get_glyph (hb_font_t *font, hb_face_t *face, hb_font_get_glyph (hb_font_t *font, hb_face_t *face,
hb_codepoint_t unicode, hb_codepoint_t variation_selector) hb_codepoint_t unicode, hb_codepoint_t variation_selector)
{ {
return font->klass->get_glyph (font, face, font->user_data, return font->klass->v.get_glyph (font, face, font->user_data,
unicode, variation_selector); unicode, variation_selector);
} }
@ -197,7 +199,7 @@ hb_font_get_contour_point (hb_font_t *font, hb_face_t *face,
hb_codepoint_t glyph, hb_position_t *x, hb_position_t *y) hb_codepoint_t glyph, hb_position_t *x, hb_position_t *y)
{ {
*x = 0; *y = 0; *x = 0; *y = 0;
return font->klass->get_contour_point (font, face, font->user_data, return font->klass->v.get_contour_point (font, face, font->user_data,
point_index, point_index,
glyph, x, y); glyph, x, y);
} }
@ -207,7 +209,7 @@ hb_font_get_glyph_metrics (hb_font_t *font, hb_face_t *face,
hb_codepoint_t glyph, hb_glyph_metrics_t *metrics) hb_codepoint_t glyph, hb_glyph_metrics_t *metrics)
{ {
memset (metrics, 0, sizeof (*metrics)); memset (metrics, 0, sizeof (*metrics));
return font->klass->get_glyph_metrics (font, face, font->user_data, return font->klass->v.get_glyph_metrics (font, face, font->user_data,
glyph, metrics); glyph, metrics);
} }
@ -215,7 +217,7 @@ hb_position_t
hb_font_get_kerning (hb_font_t *font, hb_face_t *face, hb_font_get_kerning (hb_font_t *font, hb_face_t *face,
hb_codepoint_t first_glyph, hb_codepoint_t second_glyph) hb_codepoint_t first_glyph, hb_codepoint_t second_glyph)
{ {
return font->klass->get_kerning (font, face, font->user_data, return font->klass->v.get_kerning (font, face, font->user_data,
first_glyph, second_glyph); first_glyph, second_glyph);
} }

View File

@ -283,7 +283,7 @@ hb_form_clusters (hb_buffer_t *buffer)
{ {
unsigned int count = buffer->len; unsigned int count = buffer->len;
for (unsigned int i = 1; i < count; i++) for (unsigned int i = 1; i < count; i++)
if (buffer->unicode->get_general_category (buffer->info[i].codepoint) == HB_CATEGORY_NON_SPACING_MARK) if (buffer->unicode->v.get_general_category (buffer->info[i].codepoint) == HB_CATEGORY_NON_SPACING_MARK)
buffer->info[i].cluster = buffer->info[i - 1].cluster; buffer->info[i].cluster = buffer->info[i - 1].cluster;
} }
@ -309,7 +309,7 @@ hb_ensure_native_direction (hb_buffer_t *buffer)
static void static void
hb_mirror_chars (hb_buffer_t *buffer) hb_mirror_chars (hb_buffer_t *buffer)
{ {
hb_unicode_get_mirroring_func_t get_mirroring = buffer->unicode->get_mirroring; hb_unicode_get_mirroring_func_t get_mirroring = buffer->unicode->v.get_mirroring;
if (HB_DIRECTION_IS_FORWARD (buffer->direction)) if (HB_DIRECTION_IS_FORWARD (buffer->direction))
return; return;

View File

@ -42,11 +42,13 @@ struct _hb_unicode_funcs_t {
hb_bool_t immutable; hb_bool_t immutable;
struct {
hb_unicode_get_general_category_func_t get_general_category; hb_unicode_get_general_category_func_t get_general_category;
hb_unicode_get_combining_class_func_t get_combining_class; hb_unicode_get_combining_class_func_t get_combining_class;
hb_unicode_get_mirroring_func_t get_mirroring; hb_unicode_get_mirroring_func_t get_mirroring;
hb_unicode_get_script_func_t get_script; hb_unicode_get_script_func_t get_script;
hb_unicode_get_eastasian_width_func_t get_eastasian_width; hb_unicode_get_eastasian_width_func_t get_eastasian_width;
} v;
}; };
extern HB_INTERNAL hb_unicode_funcs_t _hb_unicode_funcs_nil; extern HB_INTERNAL hb_unicode_funcs_t _hb_unicode_funcs_nil;

View File

@ -43,11 +43,13 @@ hb_unicode_funcs_t _hb_unicode_funcs_nil = {
TRUE, /* immutable */ TRUE, /* immutable */
{
hb_unicode_get_general_category_nil, hb_unicode_get_general_category_nil,
hb_unicode_get_combining_class_nil, hb_unicode_get_combining_class_nil,
hb_unicode_get_mirroring_nil, hb_unicode_get_mirroring_nil,
hb_unicode_get_script_nil, hb_unicode_get_script_nil,
hb_unicode_get_eastasian_width_nil hb_unicode_get_eastasian_width_nil
}
}; };
hb_unicode_funcs_t * hb_unicode_funcs_t *
@ -116,7 +118,7 @@ hb_unicode_funcs_set_mirroring_func (hb_unicode_funcs_t *ufuncs,
if (ufuncs->immutable) if (ufuncs->immutable)
return; return;
ufuncs->get_mirroring = mirroring_func ? mirroring_func : hb_unicode_get_mirroring_nil; ufuncs->v.get_mirroring = mirroring_func ? mirroring_func : hb_unicode_get_mirroring_nil;
} }
void void
@ -126,7 +128,7 @@ hb_unicode_funcs_set_general_category_func (hb_unicode_funcs_t *ufuncs,
if (ufuncs->immutable) if (ufuncs->immutable)
return; return;
ufuncs->get_general_category = general_category_func ? general_category_func : hb_unicode_get_general_category_nil; ufuncs->v.get_general_category = general_category_func ? general_category_func : hb_unicode_get_general_category_nil;
} }
void void
@ -136,7 +138,7 @@ hb_unicode_funcs_set_script_func (hb_unicode_funcs_t *ufuncs,
if (ufuncs->immutable) if (ufuncs->immutable)
return; return;
ufuncs->get_script = script_func ? script_func : hb_unicode_get_script_nil; ufuncs->v.get_script = script_func ? script_func : hb_unicode_get_script_nil;
} }
void void
@ -146,7 +148,7 @@ hb_unicode_funcs_set_combining_class_func (hb_unicode_funcs_t *ufuncs,
if (ufuncs->immutable) if (ufuncs->immutable)
return; return;
ufuncs->get_combining_class = combining_class_func ? combining_class_func : hb_unicode_get_combining_class_nil; ufuncs->v.get_combining_class = combining_class_func ? combining_class_func : hb_unicode_get_combining_class_nil;
} }
void void
@ -156,7 +158,7 @@ hb_unicode_funcs_set_eastasian_width_func (hb_unicode_funcs_t *ufuncs,
if (ufuncs->immutable) if (ufuncs->immutable)
return; return;
ufuncs->get_eastasian_width = eastasian_width_func ? eastasian_width_func : hb_unicode_get_eastasian_width_nil; ufuncs->v.get_eastasian_width = eastasian_width_func ? eastasian_width_func : hb_unicode_get_eastasian_width_nil;
} }
@ -164,35 +166,35 @@ hb_codepoint_t
hb_unicode_get_mirroring (hb_unicode_funcs_t *ufuncs, hb_unicode_get_mirroring (hb_unicode_funcs_t *ufuncs,
hb_codepoint_t unicode) hb_codepoint_t unicode)
{ {
return ufuncs->get_mirroring (unicode); return ufuncs->v.get_mirroring (unicode);
} }
hb_category_t hb_category_t
hb_unicode_get_general_category (hb_unicode_funcs_t *ufuncs, hb_unicode_get_general_category (hb_unicode_funcs_t *ufuncs,
hb_codepoint_t unicode) hb_codepoint_t unicode)
{ {
return ufuncs->get_general_category (unicode); return ufuncs->v.get_general_category (unicode);
} }
hb_script_t hb_script_t
hb_unicode_get_script (hb_unicode_funcs_t *ufuncs, hb_unicode_get_script (hb_unicode_funcs_t *ufuncs,
hb_codepoint_t unicode) hb_codepoint_t unicode)
{ {
return ufuncs->get_script (unicode); return ufuncs->v.get_script (unicode);
} }
unsigned int unsigned int
hb_unicode_get_combining_class (hb_unicode_funcs_t *ufuncs, hb_unicode_get_combining_class (hb_unicode_funcs_t *ufuncs,
hb_codepoint_t unicode) hb_codepoint_t unicode)
{ {
return ufuncs->get_combining_class (unicode); return ufuncs->v.get_combining_class (unicode);
} }
unsigned int unsigned int
hb_unicode_get_eastasian_width (hb_unicode_funcs_t *ufuncs, hb_unicode_get_eastasian_width (hb_unicode_funcs_t *ufuncs,
hb_codepoint_t unicode) hb_codepoint_t unicode)
{ {
return ufuncs->get_eastasian_width (unicode); return ufuncs->v.get_eastasian_width (unicode);
} }