[mutter] plugin: Simplify META_PLUGIN_DECLARE() macro
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] plugin: Simplify META_PLUGIN_DECLARE() macro
- Date: Tue, 31 Jul 2018 22:42:54 +0000 (UTC)
commit 43eb724b94514f3905b5a2535f9c0a6a6ea10e11
Author: Florian Müllner <fmuellner gnome org>
Date: Mon Jul 23 20:23:01 2018 +0200
plugin: Simplify META_PLUGIN_DECLARE() macro
It's mostly boilerplate that G_DEFINE_DYNAMIC_TYPE() can take care
of, so use that internally.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/176
src/meta/meta-plugin.h | 58 ++++++--------------------------------------------
1 file changed, 6 insertions(+), 52 deletions(-)
---
diff --git a/src/meta/meta-plugin.h b/src/meta/meta-plugin.h
index afeea133e..f973ec6ce 100644
--- a/src/meta/meta-plugin.h
+++ b/src/meta/meta-plugin.h
@@ -312,63 +312,17 @@ struct _MetaPluginVersion
META_PLUGIN_API_VERSION \
}; \
\
- static GType g_define_type_id = 0; \
+ G_DEFINE_DYNAMIC_TYPE(ObjectName, object_name, META_TYPE_PLUGIN) \
\
- /* Prototypes */ \
- G_MODULE_EXPORT \
- GType object_name##_get_type (void); \
- \
- G_MODULE_EXPORT \
- GType object_name##_register_type (GTypeModule *type_module); \
- \
- G_MODULE_EXPORT \
- GType meta_plugin_register_type (GTypeModule *type_module); \
- \
- GType \
- object_name##_get_type (void) \
- { \
- return g_define_type_id; \
- } \
- \
- static void object_name##_init (ObjectName *self); \
- static void object_name##_class_init (ObjectName##Class *klass); \
- static gpointer object_name##_parent_class = NULL; \
- static void object_name##_class_intern_init (gpointer klass) \
- { \
- object_name##_parent_class = g_type_class_peek_parent (klass); \
- object_name##_class_init ((ObjectName##Class *) klass); \
- } \
- \
- GType \
- object_name##_register_type (GTypeModule *type_module) \
- { \
- static const GTypeInfo our_info = \
- { \
- sizeof (ObjectName##Class), \
- NULL, /* base_init */ \
- NULL, /* base_finalize */ \
- (GClassInitFunc) object_name##_class_intern_init, \
- NULL, \
- NULL, /* class_data */ \
- sizeof (ObjectName), \
- 0, /* n_preallocs */ \
- (GInstanceInitFunc) object_name##_init \
- }; \
- \
- g_define_type_id = g_type_module_register_type (type_module, \
- META_TYPE_PLUGIN, \
- #ObjectName, \
- &our_info, \
- 0); \
- \
- \
- return g_define_type_id; \
- } \
+ /* Unused, but required by G_DEFINE_DYNAMIC_TYPE */ \
+ static void \
+ object_name##_class_finalize (ObjectName##Class *klass) {} \
\
G_MODULE_EXPORT GType \
meta_plugin_register_type (GTypeModule *type_module) \
{ \
- return object_name##_register_type (type_module); \
+ object_name##_register_type (type_module); \
+ return object_name##_get_type (); \
} \
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]