[paint] Add get_empty / [sg]et_user_data

This commit is contained in:
Behdad Esfahbod 2022-12-18 13:50:34 -07:00
parent 21a9db875e
commit ee2204469e
4 changed files with 74 additions and 2 deletions

View File

@ -161,7 +161,7 @@ HB_DEFINE_VTABLE (set);
HB_DEFINE_VTABLE (shape_plan);
HB_DEFINE_VTABLE (unicode_funcs);
HB_DEFINE_VTABLE (draw_funcs);
//HB_DEFINE_VTABLE (paint_funcs);
HB_DEFINE_VTABLE (paint_funcs);
#undef HB_DEFINE_VTABLE

View File

@ -213,7 +213,6 @@ hb_draw_funcs_get_empty ()
return const_cast<hb_draw_funcs_t *> (&Null (hb_draw_funcs_t));
}
/**
* hb_draw_funcs_reference: (skip)
* @dfuncs: draw functions

View File

@ -225,6 +225,21 @@ DEFINE_NULL_INSTANCE (hb_paint_funcs_t) =
}
};
/**
* hb_paint_funcs_get_empty:
*
* Fetches the singleton empty paint-functions structure.
*
* Return value: (transfer full): The empty paint-functions structure
*
* Since: REPLACEME
**/
hb_paint_funcs_t *
hb_paint_funcs_get_empty ()
{
return const_cast<hb_paint_funcs_t *> (&Null (hb_paint_funcs_t));
}
/**
* hb_paint_funcs_reference: (skip)
* @funcs: The paint-functions structure
@ -270,6 +285,49 @@ hb_paint_funcs_destroy (hb_paint_funcs_t *funcs)
hb_free (funcs);
}
/**
* hb_paint_funcs_set_user_data: (skip)
* @pfuncs: The paint-functions structure
* @key: The user-data key
* @data: A pointer to the user data
* @destroy: (nullable): A callback to call when @data is not needed anymore
* @replace: Whether to replace an existing data with the same key
*
* Attaches a user-data key/data pair to the specified paint-functions structure.
*
* Return value: `true` if success, `false` otherwise
*
* Since: REPLACEME
**/
hb_bool_t
hb_paint_funcs_set_user_data (hb_paint_funcs_t *pfuncs,
hb_user_data_key_t *key,
void * data,
hb_destroy_func_t destroy,
hb_bool_t replace)
{
return hb_object_set_user_data (pfuncs, key, data, destroy, replace);
}
/**
* hb_paint_funcs_get_user_data: (skip)
* @pfuncs: The paint-functions structure
* @key: The user-data key to query
*
* Fetches the user-data associated with the specified key,
* attached to the specified paint-functions structure.
*
* Return value: (transfer none): A pointer to the user data
*
* Since: REPLACEME
**/
void *
hb_paint_funcs_get_user_data (const hb_paint_funcs_t *pfuncs,
hb_user_data_key_t *key)
{
return hb_object_get_user_data (pfuncs, key);
}
/**
* hb_paint_funcs_make_immutable:
* @funcs: The paint-functions structure

View File

@ -65,12 +65,27 @@ typedef struct hb_paint_funcs_t hb_paint_funcs_t;
HB_EXTERN hb_paint_funcs_t *
hb_paint_funcs_create (void);
HB_EXTERN hb_paint_funcs_t *
hb_paint_funcs_get_empty (void);
HB_EXTERN hb_paint_funcs_t *
hb_paint_funcs_reference (hb_paint_funcs_t *funcs);
HB_EXTERN void
hb_paint_funcs_destroy (hb_paint_funcs_t *funcs);
HB_EXTERN hb_bool_t
hb_paint_funcs_set_user_data (hb_paint_funcs_t *funcs,
hb_user_data_key_t *key,
void * data,
hb_destroy_func_t destroy,
hb_bool_t replace);
HB_EXTERN void *
hb_paint_funcs_get_user_data (const hb_paint_funcs_t *funcs,
hb_user_data_key_t *key);
HB_EXTERN void
hb_paint_funcs_make_immutable (hb_paint_funcs_t *funcs);