gfx/harfbuzz/src/hb-gobject-structs.cc

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/harfbuzz/src/hb-gobject-structs.cc	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,120 @@
     1.4 +/*
     1.5 + * Copyright © 2011  Google, Inc.
     1.6 + *
     1.7 + *  This is part of HarfBuzz, a text shaping library.
     1.8 + *
     1.9 + * Permission is hereby granted, without written agreement and without
    1.10 + * license or royalty fees, to use, copy, modify, and distribute this
    1.11 + * software and its documentation for any purpose, provided that the
    1.12 + * above copyright notice and the following two paragraphs appear in
    1.13 + * all copies of this software.
    1.14 + *
    1.15 + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
    1.16 + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
    1.17 + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
    1.18 + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
    1.19 + * DAMAGE.
    1.20 + *
    1.21 + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
    1.22 + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
    1.23 + * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
    1.24 + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
    1.25 + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
    1.26 + *
    1.27 + * Google Author(s): Behdad Esfahbod
    1.28 + */
    1.29 +
    1.30 +#include "hb-private.hh"
    1.31 +
    1.32 +/* g++ didn't like older gtype.h gcc-only code path. */
    1.33 +#include <glib.h>
    1.34 +#if !GLIB_CHECK_VERSION(2,29,16)
    1.35 +#undef __GNUC__
    1.36 +#undef __GNUC_MINOR__
    1.37 +#define __GNUC__ 2
    1.38 +#define __GNUC_MINOR__ 6
    1.39 +#endif
    1.40 +
    1.41 +#include "hb-gobject.h"
    1.42 +
    1.43 +#define HB_DEFINE_BOXED_TYPE(name,copy_func,free_func) \
    1.44 +GType \
    1.45 +hb_gobject_##name##_get_type (void) \
    1.46 +{ \
    1.47 +   static gsize type_id = 0; \
    1.48 +   if (g_once_init_enter (&type_id)) { \
    1.49 +      GType id = g_boxed_type_register_static (g_intern_static_string ("hb_" #name "_t"), \
    1.50 +					       (GBoxedCopyFunc) copy_func, \
    1.51 +					       (GBoxedFreeFunc) free_func); \
    1.52 +      g_once_init_leave (&type_id, id); \
    1.53 +   } \
    1.54 +   return type_id; \
    1.55 +}
    1.56 +
    1.57 +#define HB_DEFINE_OBJECT_TYPE(name) \
    1.58 +	HB_DEFINE_BOXED_TYPE (name, hb_##name##_reference, hb_##name##_destroy);
    1.59 +
    1.60 +HB_DEFINE_OBJECT_TYPE (buffer)
    1.61 +HB_DEFINE_OBJECT_TYPE (blob)
    1.62 +HB_DEFINE_OBJECT_TYPE (face)
    1.63 +HB_DEFINE_OBJECT_TYPE (font)
    1.64 +HB_DEFINE_OBJECT_TYPE (font_funcs)
    1.65 +HB_DEFINE_OBJECT_TYPE (set)
    1.66 +HB_DEFINE_OBJECT_TYPE (shape_plan)
    1.67 +HB_DEFINE_OBJECT_TYPE (unicode_funcs)
    1.68 +
    1.69 +
    1.70 +static hb_feature_t *feature_reference (hb_feature_t *g)
    1.71 +{
    1.72 +  hb_feature_t *c = (hb_feature_t *) calloc (1, sizeof (hb_feature_t));
    1.73 +  if (unlikely (!c)) return NULL;
    1.74 +  *c = *g;
    1.75 +  return c;
    1.76 +}
    1.77 +static void feature_destroy (hb_feature_t *g) { free (g); }
    1.78 +HB_DEFINE_BOXED_TYPE (feature, feature_reference, feature_destroy)
    1.79 +
    1.80 +static hb_glyph_info_t *glyph_info_reference (hb_glyph_info_t *g)
    1.81 +{
    1.82 +  hb_glyph_info_t *c = (hb_glyph_info_t *) calloc (1, sizeof (hb_glyph_info_t));
    1.83 +  if (unlikely (!c)) return NULL;
    1.84 +  *c = *g;
    1.85 +  return c;
    1.86 +}
    1.87 +static void glyph_info_destroy (hb_glyph_info_t *g) { free (g); }
    1.88 +HB_DEFINE_BOXED_TYPE (glyph_info, glyph_info_reference, glyph_info_destroy)
    1.89 +
    1.90 +static hb_glyph_position_t *glyph_position_reference (hb_glyph_position_t *g)
    1.91 +{
    1.92 +  hb_glyph_position_t *c = (hb_glyph_position_t *) calloc (1, sizeof (hb_glyph_position_t));
    1.93 +  if (unlikely (!c)) return NULL;
    1.94 +  *c = *g;
    1.95 +  return c;
    1.96 +}
    1.97 +static void glyph_position_destroy (hb_glyph_position_t *g) { free (g); }
    1.98 +HB_DEFINE_BOXED_TYPE (glyph_position, glyph_position_reference, glyph_position_destroy)
    1.99 +
   1.100 +static hb_segment_properties_t *segment_properties_reference (hb_segment_properties_t *g)
   1.101 +{
   1.102 +  hb_segment_properties_t *c = (hb_segment_properties_t *) calloc (1, sizeof (hb_segment_properties_t));
   1.103 +  if (unlikely (!c)) return NULL;
   1.104 +  *c = *g;
   1.105 +  return c;
   1.106 +}
   1.107 +static void segment_properties_destroy (hb_segment_properties_t *g) { free (g); }
   1.108 +HB_DEFINE_BOXED_TYPE (segment_properties, segment_properties_reference, segment_properties_destroy)
   1.109 +
   1.110 +static hb_user_data_key_t user_data_key_reference (hb_user_data_key_t l) { return l; }
   1.111 +static void user_data_key_destroy (hb_user_data_key_t l) { }
   1.112 +HB_DEFINE_BOXED_TYPE (user_data_key, user_data_key_reference, user_data_key_destroy)
   1.113 +
   1.114 +
   1.115 +static hb_language_t *language_reference (hb_language_t *l)
   1.116 +{
   1.117 +  hb_language_t *c = (hb_language_t *) calloc (1, sizeof (hb_language_t));
   1.118 +  if (unlikely (!c)) return NULL;
   1.119 +  *c = *l;
   1.120 +  return c;
   1.121 +}
   1.122 +static void language_destroy (hb_language_t *l) { free (l); }
   1.123 +HB_DEFINE_BOXED_TYPE (language, language_reference, language_destroy)

mercurial