From 839eab556419b6af5046e44361bdcf14fe028d27 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Wed, 8 Feb 2012 12:56:52 -0500 Subject: Use glib-mkenums to generate enum types Rather than generating enum classes by hand (and complaining in each file that "this should really be standard"), use glib-mkenums. Unfortunately, we need a very new version of glib-mkenums in order to deal with NM's naming conventions and to fix a few other bugs, so just import that into the source tree temporarily. Also, to simplify the use of glib-mkenums, import Makefile.glib from https://bugzilla.gnome.org/654395. To avoid having to run glib-mkenums for every subdirectory of src/, add a new "generated" directory, and put the generated enums files there. Finally, use Makefile.glib for marshallers too, and generate separate ones for libnm-glib and NetworkManager. --- libnm-glib/Makefile.am | 32 +++++++++++++++++++++++++------- libnm-glib/libnm-glib.ver | 4 ++++ libnm-glib/nm-client.c | 4 ++-- libnm-glib/nm-device-modem.c | 2 +- libnm-glib/nm-device.c | 6 +++--- libnm-glib/nm-remote-settings.c | 24 ++---------------------- libnm-glib/nm-remote-settings.h | 3 --- libnm-glib/nm-secret-agent.c | 33 +++------------------------------ libnm-glib/nm-secret-agent.h | 2 -- libnm-glib/nm-types.h | 2 ++ libnm-glib/nm-vpn-connection.c | 6 +++--- libnm-glib/nm-vpn-plugin.c | 28 +--------------------------- libnm-glib/nm-vpn-plugin.h | 1 - 13 files changed, 46 insertions(+), 101 deletions(-) (limited to 'libnm-glib') diff --git a/libnm-glib/Makefile.am b/libnm-glib/Makefile.am index 6be78e129e..0e9c0bd5ad 100644 --- a/libnm-glib/Makefile.am +++ b/libnm-glib/Makefile.am @@ -1,3 +1,5 @@ +include $(GLIB_MAKEFILE) + SUBDIRS=. tests INCLUDES = \ @@ -71,12 +73,14 @@ libnminclude_HEADERS = \ nm-remote-settings.h \ nm-secret-agent.h \ nm-device-wimax.h \ - nm-wimax-nsp.h + nm-wimax-nsp.h \ + nm-glib-enum-types.h libnmvpn_HEADERS = \ nm-vpn-plugin.h \ nm-vpn-plugin-ui-interface.h \ - nm-vpn-plugin-utils.h + nm-vpn-plugin-utils.h \ + nm-vpn-enum-types.h libnm_glib_la_csources = \ nm-object.c \ @@ -100,22 +104,32 @@ libnm_glib_la_csources = \ nm-remote-settings.c \ nm-secret-agent.c \ nm-device-wimax.c \ - nm-wimax-nsp.c + nm-wimax-nsp.c \ + nm-glib-enum-types.c \ + nm-glib-marshal.c libnm_glib_la_private_headers = \ nm-object-private.h \ nm-device-private.h \ nm-types-private.h \ nm-object-cache.h \ - nm-remote-connection-private.h + nm-remote-connection-private.h \ + nm-glib-marshal.h libnm_glib_la_SOURCES = \ $(libnm_glib_la_csources) \ $(libnm_glib_la_private_headers) +GLIB_GENERATED = nm-glib-enum-types.h nm-glib-enum-types.c +nm_glib_enum_types_sources = $(libnminclude_HEADERS) +GLIB_MKENUMS_H_FLAGS = --identifier-prefix NM +GLIB_MKENUMS_C_FLAGS = --identifier-prefix NM + +GLIB_GENERATED += nm-glib-marshal.h nm-glib-marshal.c +nm_glib_marshal_sources = $(libnm_glib_la_SOURCES) + libnm_glib_la_LIBADD = \ $(top_builddir)/libnm-util/libnm-util.la \ - $(top_builddir)/marshallers/libmarshallers.la \ $(builddir)/libdeprecated-nm-glib.la \ $(GIO_LIBS) \ $(DBUS_LIBS) \ @@ -136,12 +150,17 @@ libnm_glib_test_LDADD = libnm-glib.la $(top_builddir)/libnm-util/libnm-util.la $ libnm_glib_vpn_la_SOURCES = \ nm-vpn-plugin.c \ nm-vpn-plugin-ui-interface.c \ - nm-vpn-plugin-utils.c + nm-vpn-plugin-utils.c \ + nm-vpn-enum-types.c +GLIB_GENERATED += nm-vpn-enum-types.h nm-vpn-enum-types.c +nm_vpn_enum_types_sources = $(libnmvpn_HEADERS) libnm_glib_vpn_la_CFLAGS = $(GIO_CFLAGS) $(DBUS_CFLAGS) libnm_glib_vpn_la_LIBADD = $(top_builddir)/libnm-util/libnm-util.la $(GIO_LIBS) $(DBUS_LIBS) libnm_glib_vpn_la_LDFLAGS = -Wl,--version-script=$(srcdir)/libnm-glib-vpn.ver \ -version-info "2:0:1" +BUILT_SOURCES += $(GLIB_GENERATED) + ##################################################### # Test libnm-glib stuff ##################################################### @@ -158,7 +177,6 @@ libnm_glib_test_la_SOURCES = \ libnm_glib_test_la_LIBADD = \ $(top_builddir)/libnm-util/libnm-util.la \ - $(top_builddir)/marshallers/libmarshallers.la \ $(GIO_LIBS) \ $(DBUS_LIBS) \ $(GUDEV_LIBS) diff --git a/libnm-glib/libnm-glib.ver b/libnm-glib/libnm-glib.ver index a08f061175..46f529b8e9 100644 --- a/libnm-glib/libnm-glib.ver +++ b/libnm-glib/libnm-glib.ver @@ -46,6 +46,8 @@ global: nm_client_new; nm_client_new_async; nm_client_new_finish; + nm_client_permission_get_type; + nm_client_permission_result_get_type; nm_client_sleep; nm_client_wimax_get_enabled; nm_client_wimax_hardware_get_enabled; @@ -169,6 +171,7 @@ global: nm_secret_agent_register; nm_secret_agent_save_secrets; nm_secret_agent_unregister; + nm_secret_agent_get_secrets_flags_get_type; nm_ssid_get_type; nm_string_array_get_type; nm_uint_array_get_type; @@ -182,6 +185,7 @@ global: nm_wimax_nsp_get_network_type; nm_wimax_nsp_get_signal_quality; nm_wimax_nsp_get_type; + nm_wimax_nsp_network_type_get_type; nm_wimax_nsp_new; local: *; diff --git a/libnm-glib/nm-client.c b/libnm-glib/nm-client.c index 811b739d0d..437210e194 100644 --- a/libnm-glib/nm-client.c +++ b/libnm-glib/nm-client.c @@ -29,7 +29,7 @@ #include "nm-device-ethernet.h" #include "nm-device-wifi.h" #include "nm-device-private.h" -#include "nm-marshal.h" +#include "nm-glib-marshal.h" #include "nm-types-private.h" #include "nm-object-private.h" #include "nm-active-connection.h" @@ -1739,7 +1739,7 @@ nm_client_class_init (NMClientClass *client_class) G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, 0, NULL, NULL, - _nm_marshal_VOID__UINT_UINT, + _nm_glib_marshal_VOID__UINT_UINT, G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT); } diff --git a/libnm-glib/nm-device-modem.c b/libnm-glib/nm-device-modem.c index dd43d3d217..05dab43a2d 100644 --- a/libnm-glib/nm-device-modem.c +++ b/libnm-glib/nm-device-modem.c @@ -31,7 +31,7 @@ #include "nm-device-modem.h" #include "nm-device-private.h" #include "nm-object-private.h" -#include "nm-marshal.h" +#include "nm-glib-marshal.h" G_DEFINE_TYPE (NMDeviceModem, nm_device_modem, NM_TYPE_DEVICE) diff --git a/libnm-glib/nm-device.c b/libnm-glib/nm-device.c index 9e8d8f9361..ccc50da4cd 100644 --- a/libnm-glib/nm-device.c +++ b/libnm-glib/nm-device.c @@ -36,7 +36,7 @@ #include "nm-device-private.h" #include "nm-object-private.h" #include "nm-object-cache.h" -#include "nm-marshal.h" +#include "nm-glib-marshal.h" #include "nm-dbus-glib-types.h" #include "nm-glib-compat.h" @@ -202,7 +202,7 @@ constructed (GObject *object) register_properties (NM_DEVICE (object)); - dbus_g_object_register_marshaller (_nm_marshal_VOID__UINT_UINT_UINT, + dbus_g_object_register_marshaller (_nm_glib_marshal_VOID__UINT_UINT_UINT, G_TYPE_NONE, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID); @@ -612,7 +612,7 @@ nm_device_class_init (NMDeviceClass *device_class) G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (NMDeviceClass, state_changed), NULL, NULL, - _nm_marshal_VOID__UINT_UINT_UINT, + _nm_glib_marshal_VOID__UINT_UINT_UINT, G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT); } diff --git a/libnm-glib/nm-remote-settings.c b/libnm-glib/nm-remote-settings.c index 588c120fa2..e4ed7827fb 100644 --- a/libnm-glib/nm-remote-settings.c +++ b/libnm-glib/nm-remote-settings.c @@ -25,7 +25,7 @@ #include #include -#include "nm-marshal.h" +#include "nm-glib-marshal.h" #include "nm-dbus-glib-types.h" #include "nm-remote-settings.h" #include "nm-remote-connection-private.h" @@ -102,26 +102,6 @@ nm_remote_settings_error_quark (void) return quark; } -/* This should really be standard. */ -#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } - -GType -nm_remote_settings_error_get_type (void) -{ - static GType etype = 0; - - if (etype == 0) { - static const GEnumValue values[] = { - ENUM_ENTRY (NM_REMOTE_SETTINGS_ERROR_UNKNOWN, "UnknownError"), - ENUM_ENTRY (NM_REMOTE_SETTINGS_ERROR_CONNECTION_REMOVED, "ConnectionRemoved"), - ENUM_ENTRY (NM_REMOTE_SETTINGS_ERROR_CONNECTION_UNAVAILABLE, "ConnectionUnavailable"), - { 0, 0, 0 } - }; - etype = g_enum_register_static ("NMRemoteSettingsError", values); - } - return etype; -} - /**********************************************************************/ typedef struct { @@ -812,7 +792,7 @@ constructed (GObject *object) "org.freedesktop.DBus"); g_assert (priv->dbus_proxy); - dbus_g_object_register_marshaller (_nm_marshal_VOID__STRING_STRING_STRING, + dbus_g_object_register_marshaller (_nm_glib_marshal_VOID__STRING_STRING_STRING, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); diff --git a/libnm-glib/nm-remote-settings.h b/libnm-glib/nm-remote-settings.h index 6eb8ae57f6..510c954016 100644 --- a/libnm-glib/nm-remote-settings.h +++ b/libnm-glib/nm-remote-settings.h @@ -55,9 +55,6 @@ typedef enum { NM_REMOTE_SETTINGS_ERROR_CONNECTION_UNAVAILABLE, } NMRemoteSettingsError; -#define NM_TYPE_REMOTE_SETTINGS_ERROR (nm_remote_settings_error_get_type ()) -GType nm_remote_settings_error_get_type (void); - #define NM_REMOTE_SETTINGS_ERROR nm_remote_settings_error_quark () GQuark nm_remote_settings_error_quark (void); diff --git a/libnm-glib/nm-secret-agent.c b/libnm-glib/nm-secret-agent.c index 4d0a825a53..d6a15f9b0b 100644 --- a/libnm-glib/nm-secret-agent.c +++ b/libnm-glib/nm-secret-agent.c @@ -25,7 +25,8 @@ #include #include "nm-secret-agent.h" -#include "nm-marshal.h" +#include "nm-glib-enum-types.h" +#include "nm-glib-marshal.h" #include "NetworkManager.h" static void impl_secret_agent_get_secrets (NMSecretAgent *self, @@ -111,34 +112,6 @@ nm_secret_agent_error_quark (void) return ret; } -#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } - -GType -nm_secret_agent_error_get_type (void) -{ - static GType etype = 0; - - if (etype == 0) { - static const GEnumValue values[] = { - /* Sender is not authorized to make this request */ - ENUM_ENTRY (NM_SECRET_AGENT_ERROR_NOT_AUTHORIZED, "NotAuthorized"), - /* Given connection details do not make a valid connection */ - ENUM_ENTRY (NM_SECRET_AGENT_ERROR_INVALID_CONNECTION, "InvalidConnection"), - /* The request was canceled explicitly by the user */ - ENUM_ENTRY (NM_SECRET_AGENT_ERROR_USER_CANCELED, "UserCanceled"), - /* The request was canceled, but not by the user */ - ENUM_ENTRY (NM_SECRET_AGENT_ERROR_AGENT_CANCELED, "AgentCanceled"), - /* Some internal error prevented returning secrets */ - ENUM_ENTRY (NM_SECRET_AGENT_ERROR_INTERNAL_ERROR, "InternalError"), - /* No secrets could be found to fulfill the request */ - ENUM_ENTRY (NM_SECRET_AGENT_ERROR_NO_SECRETS, "NoSecrets"), - { 0, 0, 0 } - }; - etype = g_enum_register_static ("NMSecretAgentError", values); - } - return etype; -} - /*************************************************************/ static const char * @@ -806,7 +779,7 @@ nm_secret_agent_init (NMSecretAgent *self) return; } - dbus_g_object_register_marshaller (_nm_marshal_VOID__STRING_STRING_STRING, + dbus_g_object_register_marshaller (_nm_glib_marshal_VOID__STRING_STRING_STRING, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); diff --git a/libnm-glib/nm-secret-agent.h b/libnm-glib/nm-secret-agent.h index 33ef22876e..6a513baed8 100644 --- a/libnm-glib/nm-secret-agent.h +++ b/libnm-glib/nm-secret-agent.h @@ -26,10 +26,8 @@ G_BEGIN_DECLS #define NM_SECRET_AGENT_ERROR (nm_secret_agent_error_quark ()) -#define NM_TYPE_SECRET_AGENT_ERROR (nm_secret_agent_error_get_type ()) GQuark nm_secret_agent_error_quark (void); -GType nm_secret_agent_error_get_type (void); typedef enum { NM_SECRET_AGENT_ERROR_NOT_AUTHORIZED = 0, diff --git a/libnm-glib/nm-types.h b/libnm-glib/nm-types.h index cb1bf872ea..adccafb729 100644 --- a/libnm-glib/nm-types.h +++ b/libnm-glib/nm-types.h @@ -26,6 +26,8 @@ #include #include +#include + G_BEGIN_DECLS #define NM_TYPE_SSID (nm_ssid_get_type ()) diff --git a/libnm-glib/nm-vpn-connection.c b/libnm-glib/nm-vpn-connection.c index 652206bb40..539342169c 100644 --- a/libnm-glib/nm-vpn-connection.c +++ b/libnm-glib/nm-vpn-connection.c @@ -25,7 +25,7 @@ #include "nm-vpn-connection.h" #include "NetworkManager.h" #include "nm-utils.h" -#include "nm-marshal.h" +#include "nm-glib-marshal.h" #include "nm-object-private.h" #include "nm-active-connection.h" @@ -178,7 +178,7 @@ constructed (GObject *object) nm_object_get_path (NM_OBJECT (object)), NM_DBUS_INTERFACE_VPN_CONNECTION); - dbus_g_object_register_marshaller (_nm_marshal_VOID__UINT_UINT, + dbus_g_object_register_marshaller (_nm_glib_marshal_VOID__UINT_UINT, G_TYPE_NONE, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID); @@ -271,7 +271,7 @@ nm_vpn_connection_class_init (NMVPNConnectionClass *connection_class) G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (NMVPNConnectionClass, vpn_state_changed), NULL, NULL, - _nm_marshal_VOID__UINT_UINT, + _nm_glib_marshal_VOID__UINT_UINT, G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT); } diff --git a/libnm-glib/nm-vpn-plugin.c b/libnm-glib/nm-vpn-plugin.c index 4c3813e34b..23685384ad 100644 --- a/libnm-glib/nm-vpn-plugin.c +++ b/libnm-glib/nm-vpn-plugin.c @@ -24,6 +24,7 @@ #include #include "nm-glib-compat.h" #include "nm-vpn-plugin.h" +#include "nm-vpn-enum-types.h" #include "nm-utils.h" #include "nm-connection.h" #include "nm-dbus-glib-types.h" @@ -107,33 +108,6 @@ nm_vpn_plugin_error_quark (void) return quark; } -#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } - -GType -nm_vpn_plugin_error_get_type (void) -{ - static GType etype = 0; - - if (etype == 0) { - static const GEnumValue values[] = { - ENUM_ENTRY (NM_VPN_PLUGIN_ERROR_GENERAL, "General"), - ENUM_ENTRY (NM_VPN_PLUGIN_ERROR_STARTING_IN_PROGRESS, "StartingInProgress"), - ENUM_ENTRY (NM_VPN_PLUGIN_ERROR_ALREADY_STARTED, "AlreadyStarted"), - ENUM_ENTRY (NM_VPN_PLUGIN_ERROR_STOPPING_IN_PROGRESS, "StoppingInProgress"), - ENUM_ENTRY (NM_VPN_PLUGIN_ERROR_ALREADY_STOPPED, "AlreadyStopped"), - ENUM_ENTRY (NM_VPN_PLUGIN_ERROR_WRONG_STATE, "WrongState"), - ENUM_ENTRY (NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS, "BadArguments"), - ENUM_ENTRY (NM_VPN_PLUGIN_ERROR_LAUNCH_FAILED, "LaunchFailed"), - ENUM_ENTRY (NM_VPN_PLUGIN_ERROR_CONNECTION_INVALID, "ConnectionInvalid"), - { 0, 0, 0 } - }; - - etype = g_enum_register_static ("NMVPNPluginError", values); - } - - return etype; -} - static void nm_vpn_plugin_set_connection (NMVPNPlugin *plugin, diff --git a/libnm-glib/nm-vpn-plugin.h b/libnm-glib/nm-vpn-plugin.h index 8a3c2f1d61..d80a3fc6c1 100644 --- a/libnm-glib/nm-vpn-plugin.h +++ b/libnm-glib/nm-vpn-plugin.h @@ -55,7 +55,6 @@ typedef enum { } NMVPNPluginError; #define NM_VPN_PLUGIN_ERROR (nm_vpn_plugin_error_quark ()) -#define NM_TYPE_VPN_PLUGIN_ERROR (nm_vpn_plugin_error_get_type ()) typedef struct { GObject parent; -- cgit v1.2.1