core: new `MMAsyncMethod' boxed type
Helps to bundle the async method implementation in a property.
This commit is contained in:
@@ -170,3 +170,40 @@ mm_pointer_array_get_type (void)
|
||||
|
||||
return g_define_type_id__volatile;
|
||||
}
|
||||
|
||||
static void
|
||||
async_method_free (MMAsyncMethod *method)
|
||||
{
|
||||
g_slice_free (MMAsyncMethod, method);
|
||||
}
|
||||
|
||||
static MMAsyncMethod *
|
||||
async_method_copy (MMAsyncMethod *original)
|
||||
{
|
||||
MMAsyncMethod *copy;
|
||||
|
||||
if (!original)
|
||||
return NULL;
|
||||
|
||||
copy = g_slice_new (MMAsyncMethod);
|
||||
copy->async = original->async;
|
||||
copy->finish = original->finish;
|
||||
return copy;
|
||||
}
|
||||
|
||||
GType
|
||||
mm_async_method_get_type (void)
|
||||
{
|
||||
static volatile gsize g_define_type_id__volatile = 0;
|
||||
|
||||
if (g_once_init_enter (&g_define_type_id__volatile)) {
|
||||
GType g_define_type_id =
|
||||
g_boxed_type_register_static (g_intern_static_string ("MMAsyncMethod"),
|
||||
(GBoxedCopyFunc) async_method_copy,
|
||||
(GBoxedFreeFunc) async_method_free);
|
||||
|
||||
g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
|
||||
}
|
||||
|
||||
return g_define_type_id__volatile;
|
||||
}
|
||||
|
@@ -34,6 +34,13 @@ GType mm_str_pair_array_get_type (void) G_GNUC_CONST;
|
||||
GType mm_pointer_array_get_type (void) G_GNUC_CONST;
|
||||
#define MM_TYPE_POINTER_ARRAY (mm_pointer_array_get_type ())
|
||||
|
||||
typedef struct {
|
||||
GCallback async;
|
||||
GCallback finish;
|
||||
} MMAsyncMethod;
|
||||
GType mm_async_method_get_type (void) G_GNUC_CONST;
|
||||
#define MM_TYPE_ASYNC_METHOD (mm_async_method_get_type ())
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __MM_PRIVATE_BOXED_TYPES_H__ */
|
||||
|
Reference in New Issue
Block a user