diff --git a/TODO b/TODO index 941a8c89f4c66bd26db5fcea3e0066a3c377c668..d8d4d5612372e75be943b094f53f01eb46a6d45c 100644 --- a/TODO +++ b/TODO @@ -9,8 +9,6 @@ General fixes: - Remove fixed-size feature/lookup arrays in hb-ot-map -- Use templates instead of macros for objects? - API issues to fix before 1.0: ============================ diff --git a/src/hb-blob.cc b/src/hb-blob.cc index 7d1925f85eedf64a4d4cf4e3c891f6fb9298a8cb..435d37bb64ecdfd74424438e630fa701491a02b4 100644 --- a/src/hb-blob.cc +++ b/src/hb-blob.cc @@ -87,7 +87,7 @@ hb_blob_create (const char *data, { hb_blob_t *blob; - if (!length || !HB_OBJECT_DO_CREATE (hb_blob_t, blob)) { + if (!length || !(blob = hb_object_create ())) { if (destroy) destroy (user_data); return &_hb_blob_nil; @@ -122,7 +122,7 @@ hb_blob_create_sub_blob (hb_blob_t *parent, hb_blob_t *blob; const char *pdata; - if (!length || offset >= parent->length || !HB_OBJECT_DO_CREATE (hb_blob_t, blob)) + if (!length || offset >= parent->length || !(blob = hb_object_create ())) return &_hb_blob_nil; pdata = hb_blob_lock (parent); @@ -149,13 +149,13 @@ hb_blob_create_empty (void) hb_blob_t * hb_blob_reference (hb_blob_t *blob) { - HB_OBJECT_DO_REFERENCE (blob); + return hb_object_reference (blob); } void hb_blob_destroy (hb_blob_t *blob) { - HB_OBJECT_DO_DESTROY (blob); + if (!hb_object_destroy (blob)) return; _hb_blob_destroy_user_data (blob); @@ -171,7 +171,7 @@ hb_blob_get_length (hb_blob_t *blob) const char * hb_blob_lock (hb_blob_t *blob) { - if (HB_OBJECT_IS_INERT (blob)) + if (hb_object_is_inert (blob)) return NULL; hb_mutex_lock (blob->lock); @@ -190,7 +190,7 @@ hb_blob_lock (hb_blob_t *blob) void hb_blob_unlock (hb_blob_t *blob) { - if (HB_OBJECT_IS_INERT (blob)) + if (hb_object_is_inert (blob)) return; hb_mutex_lock (blob->lock); @@ -210,7 +210,7 @@ hb_blob_is_writable (hb_blob_t *blob) { hb_memory_mode_t mode; - if (HB_OBJECT_IS_INERT (blob)) + if (hb_object_is_inert (blob)) return FALSE; hb_mutex_lock (blob->lock); @@ -292,7 +292,7 @@ hb_blob_try_writable_inplace (hb_blob_t *blob) { hb_memory_mode_t mode; - if (HB_OBJECT_IS_INERT (blob)) + if (hb_object_is_inert (blob)) return FALSE; hb_mutex_lock (blob->lock); @@ -312,7 +312,7 @@ hb_blob_try_writable (hb_blob_t *blob) { hb_memory_mode_t mode; - if (HB_OBJECT_IS_INERT (blob)) + if (hb_object_is_inert (blob)) return FALSE; hb_mutex_lock (blob->lock); diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc index 54682702e395c5408176e9cbf26876098087d27e..2ae29cac7197be40333b1f21b3839e61ac68b98b 100644 --- a/src/hb-buffer.cc +++ b/src/hb-buffer.cc @@ -137,7 +137,7 @@ hb_buffer_create (unsigned int pre_alloc_size) { hb_buffer_t *buffer; - if (!HB_OBJECT_DO_CREATE (hb_buffer_t, buffer)) + if (!(buffer = hb_object_create ())) return &_hb_buffer_nil; if (pre_alloc_size) @@ -151,13 +151,13 @@ hb_buffer_create (unsigned int pre_alloc_size) hb_buffer_t * hb_buffer_reference (hb_buffer_t *buffer) { - HB_OBJECT_DO_REFERENCE (buffer); + return hb_object_reference (buffer); } void hb_buffer_destroy (hb_buffer_t *buffer) { - HB_OBJECT_DO_DESTROY (buffer); + if (!hb_object_destroy (buffer)) return; hb_unicode_funcs_destroy (buffer->unicode); diff --git a/src/hb-font.cc b/src/hb-font.cc index 149ca19660330c89ec5a936d7f1b3345f2f2ac8c..5506480e17de43bd997feab2db854bc4f05e9257 100644 --- a/src/hb-font.cc +++ b/src/hb-font.cc @@ -102,7 +102,7 @@ hb_font_funcs_create (void) { hb_font_funcs_t *ffuncs; - if (!HB_OBJECT_DO_CREATE (hb_font_funcs_t, ffuncs)) + if (!(ffuncs = hb_object_create ())) return &_hb_font_funcs_nil; ffuncs->v = _hb_font_funcs_nil.v; @@ -113,13 +113,13 @@ hb_font_funcs_create (void) hb_font_funcs_t * hb_font_funcs_reference (hb_font_funcs_t *ffuncs) { - HB_OBJECT_DO_REFERENCE (ffuncs); + return hb_object_reference (ffuncs); } void hb_font_funcs_destroy (hb_font_funcs_t *ffuncs) { - HB_OBJECT_DO_DESTROY (ffuncs); + if (!hb_object_destroy (ffuncs)) return; free (ffuncs); } @@ -129,7 +129,7 @@ hb_font_funcs_copy (hb_font_funcs_t *other_ffuncs) { hb_font_funcs_t *ffuncs; - if (!HB_OBJECT_DO_CREATE (hb_font_funcs_t, ffuncs)) + if (!(ffuncs = hb_object_create ())) return &_hb_font_funcs_nil; ffuncs->v = other_ffuncs->v; @@ -140,7 +140,7 @@ hb_font_funcs_copy (hb_font_funcs_t *other_ffuncs) void hb_font_funcs_make_immutable (hb_font_funcs_t *ffuncs) { - if (HB_OBJECT_IS_INERT (ffuncs)) + if (hb_object_is_inert (ffuncs)) return; ffuncs->immutable = TRUE; @@ -308,7 +308,7 @@ hb_face_create_for_tables (hb_get_table_func_t get_table, { hb_face_t *face; - if (!HB_OBJECT_DO_CREATE (hb_face_t, face)) { + if (!(face = hb_object_create ())) { if (destroy) destroy (user_data); return &_hb_face_nil; @@ -389,13 +389,13 @@ hb_face_create_for_data (hb_blob_t *blob, hb_face_t * hb_face_reference (hb_face_t *face) { - HB_OBJECT_DO_REFERENCE (face); + return hb_object_reference (face); } void hb_face_destroy (hb_face_t *face) { - HB_OBJECT_DO_DESTROY (face); + if (!hb_object_destroy (face)) return; _hb_ot_layout_free (face->ot_layout); @@ -454,7 +454,7 @@ hb_font_create (void) { hb_font_t *font; - if (!HB_OBJECT_DO_CREATE (hb_font_t, font)) + if (!(font = hb_object_create ())) return &_hb_font_nil; font->klass = &_hb_font_funcs_nil; @@ -465,13 +465,13 @@ hb_font_create (void) hb_font_t * hb_font_reference (hb_font_t *font) { - HB_OBJECT_DO_REFERENCE (font); + return hb_object_reference (font); } void hb_font_destroy (hb_font_t *font) { - HB_OBJECT_DO_DESTROY (font); + if (!hb_object_destroy (font)) return; hb_font_funcs_destroy (font->klass); if (font->destroy) @@ -486,7 +486,7 @@ hb_font_set_funcs (hb_font_t *font, void *user_data, hb_destroy_func_t destroy) { - if (HB_OBJECT_IS_INERT (font)) + if (hb_object_is_inert (font)) return; if (font->destroy) @@ -514,7 +514,7 @@ hb_font_unset_funcs (hb_font_t *font, *user_data = font->user_data; *destroy = font->destroy; - if (HB_OBJECT_IS_INERT (font)) + if (hb_object_is_inert (font)) return; font->klass = NULL; @@ -527,7 +527,7 @@ hb_font_set_scale (hb_font_t *font, int x_scale, int y_scale) { - if (HB_OBJECT_IS_INERT (font)) + if (hb_object_is_inert (font)) return; font->x_scale = x_scale; @@ -548,7 +548,7 @@ hb_font_set_ppem (hb_font_t *font, unsigned int x_ppem, unsigned int y_ppem) { - if (HB_OBJECT_IS_INERT (font)) + if (hb_object_is_inert (font)) return; font->x_ppem = x_ppem; diff --git a/src/hb-object-private.hh b/src/hb-object-private.hh index c3cdeb5414259059ce8d39337b33d25af43f2106..8fbddd478b8d716bc0b9b2c26ba0d0bcf5aa137d 100644 --- a/src/hb-object-private.hh +++ b/src/hb-object-private.hh @@ -123,18 +123,9 @@ static inline bool hb_object_destroy (Type *obj) } - HB_BEGIN_DECLS -/* Object allocation and lifecycle manamgement macros */ - -#define HB_OBJECT_DO_CREATE(Type, obj) likely (obj = hb_object_create ()) -#define HB_OBJECT_IS_INERT(obj) hb_object_is_inert (obj) -#define HB_OBJECT_DO_REFERENCE(obj) return hb_object_reference (obj) -#define HB_OBJECT_DO_DESTROY(obj) if (!hb_object_destroy (obj)) return - - HB_END_DECLS #endif /* HB_OBJECT_PRIVATE_HH */ diff --git a/src/hb-unicode.cc b/src/hb-unicode.cc index b756461bab54e24076e88a02526a8699324d8f7a..992295540bd969727a75060a1d903651e091eada 100644 --- a/src/hb-unicode.cc +++ b/src/hb-unicode.cc @@ -107,7 +107,7 @@ hb_unicode_funcs_create (hb_unicode_funcs_t *parent) { hb_unicode_funcs_t *ufuncs; - if (!HB_OBJECT_DO_CREATE (hb_unicode_funcs_t, ufuncs)) + if (!(ufuncs = hb_object_create ())) return &_hb_unicode_funcs_nil; if (parent != NULL) @@ -133,13 +133,13 @@ hb_unicode_funcs_create (hb_unicode_funcs_t *parent) hb_unicode_funcs_t * hb_unicode_funcs_reference (hb_unicode_funcs_t *ufuncs) { - HB_OBJECT_DO_REFERENCE (ufuncs); + return hb_object_reference (ufuncs); } void hb_unicode_funcs_destroy (hb_unicode_funcs_t *ufuncs) { - HB_OBJECT_DO_DESTROY (ufuncs); + if (!hb_object_destroy (ufuncs)) return; #define DESTROY(name) if (ufuncs->destroy.name) ufuncs->destroy.name (ufuncs->user_data.name) DESTROY (combining_class); @@ -158,7 +158,7 @@ hb_unicode_funcs_destroy (hb_unicode_funcs_t *ufuncs) void hb_unicode_funcs_make_immutable (hb_unicode_funcs_t *ufuncs) { - if (HB_OBJECT_IS_INERT (ufuncs)) + if (hb_object_is_inert (ufuncs)) return; ufuncs->immutable = TRUE;