summaryrefslogtreecommitdiff
path: root/libnm-core/nm-setting-private.h
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2014-08-07 17:19:40 -0400
committerDan Winship <danw@gnome.org>2014-09-04 09:18:44 -0400
commit40bb402898903d90b76f5f01f783717b838ba090 (patch)
tree142d0000cc75f798a94f9afdb8067ad11469a10c /libnm-core/nm-setting-private.h
parent8faef95dae8a473edffd2e9289df7941dfeeba88 (diff)
downloadNetworkManager-40bb402898903d90b76f5f01f783717b838ba090.tar.gz
libnm-core: simplify _nm_register_setting(), register error types too
Simplify the use of _nm_register_setting() by having it splice together various symbol names itself rather than requiring them to be specified explicitly, and extend it to also ensure that the type's corresponding error type is registered (allowing one to find it via g_type_from_name() if necessary).
Diffstat (limited to 'libnm-core/nm-setting-private.h')
-rw-r--r--libnm-core/nm-setting-private.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/libnm-core/nm-setting-private.h b/libnm-core/nm-setting-private.h
index 97f1d7b3f4..00c66ba0db 100644
--- a/libnm-core/nm-setting-private.h
+++ b/libnm-core/nm-setting-private.h
@@ -23,6 +23,7 @@
#include "nm-setting.h"
#include "nm-connection.h"
+#include "nm-core-enum-types.h"
#include "nm-glib-compat.h"
#include "nm-core-internal.h"
@@ -48,8 +49,11 @@ void _nm_register_setting (const char *name,
const guint32 priority,
const GQuark error_quark);
-/* Ensure, that name is a compile time constant string. Put the function name in parenthesis to suppress expansion. */
-#define _nm_register_setting(name, type, priority, error_quark) _nm_register_setting ((name ""), type, priority, error_quark)
+#define _nm_register_setting(name, priority) \
+ G_STMT_START { \
+ _nm_register_setting (NM_SETTING_ ## name ## _SETTING_NAME "", g_define_type_id, priority, NM_SETTING_ ## name ## _ERROR); \
+ g_type_ensure (NM_TYPE_SETTING_ ## name ## _ERROR); \
+ } G_STMT_END
gboolean _nm_setting_is_base_type (NMSetting *setting);
gboolean _nm_setting_type_is_base_type (GType type);