- Remove fixed-size feature/lookup arrays in hb-ot-map
-- Use templates instead of macros for objects?
-
API issues to fix before 1.0:
============================
{
hb_blob_t *blob;
- if (!length || !HB_OBJECT_DO_CREATE (hb_blob_t, blob)) {
+ if (!length || !(blob = hb_object_create<hb_blob_t> ())) {
if (destroy)
destroy (user_data);
return &_hb_blob_nil;
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<hb_blob_t> ()))
return &_hb_blob_nil;
pdata = hb_blob_lock (parent);
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);
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);
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);
{
hb_memory_mode_t mode;
- if (HB_OBJECT_IS_INERT (blob))
+ if (hb_object_is_inert (blob))
return FALSE;
hb_mutex_lock (blob->lock);
{
hb_memory_mode_t mode;
- if (HB_OBJECT_IS_INERT (blob))
+ if (hb_object_is_inert (blob))
return FALSE;
hb_mutex_lock (blob->lock);
{
hb_memory_mode_t mode;
- if (HB_OBJECT_IS_INERT (blob))
+ if (hb_object_is_inert (blob))
return FALSE;
hb_mutex_lock (blob->lock);
{
hb_buffer_t *buffer;
- if (!HB_OBJECT_DO_CREATE (hb_buffer_t, buffer))
+ if (!(buffer = hb_object_create<hb_buffer_t> ()))
return &_hb_buffer_nil;
if (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);
{
hb_font_funcs_t *ffuncs;
- if (!HB_OBJECT_DO_CREATE (hb_font_funcs_t, ffuncs))
+ if (!(ffuncs = hb_object_create<hb_font_funcs_t> ()))
return &_hb_font_funcs_nil;
ffuncs->v = _hb_font_funcs_nil.v;
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);
}
{
hb_font_funcs_t *ffuncs;
- if (!HB_OBJECT_DO_CREATE (hb_font_funcs_t, ffuncs))
+ if (!(ffuncs = hb_object_create<hb_font_funcs_t> ()))
return &_hb_font_funcs_nil;
ffuncs->v = other_ffuncs->v;
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;
{
hb_face_t *face;
- if (!HB_OBJECT_DO_CREATE (hb_face_t, face)) {
+ if (!(face = hb_object_create<hb_face_t> ())) {
if (destroy)
destroy (user_data);
return &_hb_face_nil;
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);
{
hb_font_t *font;
- if (!HB_OBJECT_DO_CREATE (hb_font_t, font))
+ if (!(font = hb_object_create<hb_font_t> ()))
return &_hb_font_nil;
font->klass = &_hb_font_funcs_nil;
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)
void *user_data,
hb_destroy_func_t destroy)
{
- if (HB_OBJECT_IS_INERT (font))
+ if (hb_object_is_inert (font))
return;
if (font->destroy)
*user_data = font->user_data;
*destroy = font->destroy;
- if (HB_OBJECT_IS_INERT (font))
+ if (hb_object_is_inert (font))
return;
font->klass = NULL;
int x_scale,
int y_scale)
{
- if (HB_OBJECT_IS_INERT (font))
+ if (hb_object_is_inert (font))
return;
font->x_scale = x_scale;
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;
}
-
HB_BEGIN_DECLS
-/* Object allocation and lifecycle manamgement macros */
-
-#define HB_OBJECT_DO_CREATE(Type, obj) likely (obj = hb_object_create<Type> ())
-#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 */
{
hb_unicode_funcs_t *ufuncs;
- if (!HB_OBJECT_DO_CREATE (hb_unicode_funcs_t, ufuncs))
+ if (!(ufuncs = hb_object_create<hb_unicode_funcs_t> ()))
return &_hb_unicode_funcs_nil;
if (parent != NULL)
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);
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;