diff options
author | Thomas Haller <thaller@redhat.com> | 2020-03-14 18:01:08 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-03-14 18:04:05 +0100 |
commit | 6b07b40c46a64a5b50eefcc73c06de94a867a370 (patch) | |
tree | 00dddef24eed1df47dc17d612673df628391ec18 | |
parent | 67c00353d36764b29225e4a6ad1c808f25dee7a6 (diff) | |
download | NetworkManager-6b07b40c46a64a5b50eefcc73c06de94a867a370.tar.gz |
libnm: hide NMVpnPluginInfo structs from public API
The NMVpnPluginInfo class is not intended to be subclassed. An API that
allows to be subclassed needs to be designed in a certain manner for
that to be useful. NMVpnPluginInfo does not want to support that.
Only because a user technically could do that (as the structs were
in the public headers), it does not make it supported. Not everything
that is possible in C is guaranteed to work.
Also, of course there exist no users in practice that would rely on this.
So, hide the structs.
Also, this allows to embed the private data in the GObject struct
itself, which is useful for debugging and for performance.
-rw-r--r-- | libnm-core/nm-vpn-plugin-info.c | 18 | ||||
-rw-r--r-- | libnm-core/nm-vpn-plugin-info.h | 19 |
2 files changed, 15 insertions, 22 deletions
diff --git a/libnm-core/nm-vpn-plugin-info.c b/libnm-core/nm-vpn-plugin-info.c index 7ef34a62c8..96f64d0b73 100644 --- a/libnm-core/nm-vpn-plugin-info.c +++ b/libnm-core/nm-vpn-plugin-info.c @@ -42,14 +42,26 @@ typedef struct { NMVpnEditorPlugin *editor_plugin; } NMVpnPluginInfoPrivate; +/** + * NMVpnPluginInfo: + */ +struct _NMVpnPluginInfo { + GObject parent; + NMVpnPluginInfoPrivate _priv; +}; + +struct _NMVpnPluginInfoClass { + GObjectClass parent; +}; + +#define NM_VPN_PLUGIN_INFO_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMVpnPluginInfo, NM_IS_VPN_PLUGIN_INFO) + static void nm_vpn_plugin_info_initable_iface_init (GInitableIface *iface); G_DEFINE_TYPE_WITH_CODE (NMVpnPluginInfo, nm_vpn_plugin_info, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, nm_vpn_plugin_info_initable_iface_init); ) -#define NM_VPN_PLUGIN_INFO_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_VPN_PLUGIN_INFO, NMVpnPluginInfoPrivate)) - /*****************************************************************************/ static NMVpnPluginInfo *_list_find_by_service (GSList *list, @@ -1261,8 +1273,6 @@ nm_vpn_plugin_info_class_init (NMVpnPluginInfoClass *plugin_class) { GObjectClass *object_class = G_OBJECT_CLASS (plugin_class); - g_type_class_add_private (object_class, sizeof (NMVpnPluginInfoPrivate)); - object_class->set_property = set_property; object_class->get_property = get_property; object_class->dispose = dispose; diff --git a/libnm-core/nm-vpn-plugin-info.h b/libnm-core/nm-vpn-plugin-info.h index c6242ac628..bc356cf2df 100644 --- a/libnm-core/nm-vpn-plugin-info.h +++ b/libnm-core/nm-vpn-plugin-info.h @@ -29,24 +29,7 @@ G_BEGIN_DECLS #define NM_VPN_PLUGIN_INFO_KF_GROUP_LIBNM "libnm" #define NM_VPN_PLUGIN_INFO_KF_GROUP_GNOME "GNOME" -struct _NMVpnPluginInfo; - -/** - * NMVpnPluginInfo: - */ -struct _NMVpnPluginInfo { - NM_AVAILABLE_IN_1_2 - GObject parent; -}; - -typedef struct { - NM_AVAILABLE_IN_1_2 - GObjectClass parent; - - /*< private >*/ - NM_AVAILABLE_IN_1_2 - gpointer padding[8]; -} NMVpnPluginInfoClass NM_AVAILABLE_IN_1_2; +typedef struct _NMVpnPluginInfoClass NMVpnPluginInfoClass; NM_AVAILABLE_IN_1_2 GType nm_vpn_plugin_info_get_type (void); |