From ece434fa0fec6754e5164d881c1e967376729eca Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 19 May 2015 17:20:58 -0700 Subject: [PATCH] [gobject] Macroize value types Fixes user_data_t --- src/hb-gobject-structs.cc | 73 +++++++++++------------------------------------ 1 file changed, 17 insertions(+), 56 deletions(-) diff --git a/src/hb-gobject-structs.cc b/src/hb-gobject-structs.cc index 2451b66..1289c4b 100644 --- a/src/hb-gobject-structs.cc +++ b/src/hb-gobject-structs.cc @@ -54,6 +54,17 @@ hb_gobject_##name##_get_type (void) \ #define HB_DEFINE_OBJECT_TYPE(name) \ HB_DEFINE_BOXED_TYPE (name, hb_##name##_reference, hb_##name##_destroy); +#define HB_DEFINE_VALUE_TYPE(name) \ + static hb_##name##_t *_hb_##name##_reference (const hb_##name##_t *l) \ + { \ + hb_##name##_t *c = (hb_##name##_t *) calloc (1, sizeof (hb_##name##_t)); \ + if (unlikely (!c)) return NULL; \ + *c = *l; \ + return c; \ + } \ + static void _hb_##name##_destroy (hb_##name##_t *l) { free (l); } \ + HB_DEFINE_BOXED_TYPE (name, _hb_##name##_reference, _hb_##name##_destroy); + HB_DEFINE_OBJECT_TYPE (buffer) HB_DEFINE_OBJECT_TYPE (blob) HB_DEFINE_OBJECT_TYPE (face) @@ -62,59 +73,9 @@ HB_DEFINE_OBJECT_TYPE (font_funcs) HB_DEFINE_OBJECT_TYPE (set) HB_DEFINE_OBJECT_TYPE (shape_plan) HB_DEFINE_OBJECT_TYPE (unicode_funcs) - - -static hb_feature_t *feature_reference (hb_feature_t *g) -{ - hb_feature_t *c = (hb_feature_t *) calloc (1, sizeof (hb_feature_t)); - if (unlikely (!c)) return NULL; - *c = *g; - return c; -} -static void feature_destroy (hb_feature_t *g) { free (g); } -HB_DEFINE_BOXED_TYPE (feature, feature_reference, feature_destroy) - -static hb_glyph_info_t *glyph_info_reference (hb_glyph_info_t *g) -{ - hb_glyph_info_t *c = (hb_glyph_info_t *) calloc (1, sizeof (hb_glyph_info_t)); - if (unlikely (!c)) return NULL; - *c = *g; - return c; -} -static void glyph_info_destroy (hb_glyph_info_t *g) { free (g); } -HB_DEFINE_BOXED_TYPE (glyph_info, glyph_info_reference, glyph_info_destroy) - -static hb_glyph_position_t *glyph_position_reference (hb_glyph_position_t *g) -{ - hb_glyph_position_t *c = (hb_glyph_position_t *) calloc (1, sizeof (hb_glyph_position_t)); - if (unlikely (!c)) return NULL; - *c = *g; - return c; -} -static void glyph_position_destroy (hb_glyph_position_t *g) { free (g); } -HB_DEFINE_BOXED_TYPE (glyph_position, glyph_position_reference, glyph_position_destroy) - -static hb_segment_properties_t *segment_properties_reference (hb_segment_properties_t *g) -{ - hb_segment_properties_t *c = (hb_segment_properties_t *) calloc (1, sizeof (hb_segment_properties_t)); - if (unlikely (!c)) return NULL; - *c = *g; - return c; -} -static void segment_properties_destroy (hb_segment_properties_t *g) { free (g); } -HB_DEFINE_BOXED_TYPE (segment_properties, segment_properties_reference, segment_properties_destroy) - -static hb_user_data_key_t user_data_key_reference (hb_user_data_key_t l) { return l; } -static void user_data_key_destroy (hb_user_data_key_t l) { } -HB_DEFINE_BOXED_TYPE (user_data_key, user_data_key_reference, user_data_key_destroy) - - -static hb_language_t *language_reference (hb_language_t *l) -{ - hb_language_t *c = (hb_language_t *) calloc (1, sizeof (hb_language_t)); - if (unlikely (!c)) return NULL; - *c = *l; - return c; -} -static void language_destroy (hb_language_t *l) { free (l); } -HB_DEFINE_BOXED_TYPE (language, language_reference, language_destroy) +HB_DEFINE_VALUE_TYPE (feature) +HB_DEFINE_VALUE_TYPE (glyph_info) +HB_DEFINE_VALUE_TYPE (glyph_position) +HB_DEFINE_VALUE_TYPE (segment_properties) +HB_DEFINE_VALUE_TYPE (user_data_key) +HB_DEFINE_VALUE_TYPE (language) -- 2.7.4