diff options
author | Dan Winship <danw@redhat.com> | 2014-11-20 15:42:35 -0500 |
---|---|---|
committer | Dan Winship <danw@redhat.com> | 2014-11-20 15:42:35 -0500 |
commit | 19d78821c530f20263337f13d3709c4e9feadf49 (patch) | |
tree | f301df05a88fdfe00e3e050754cbacf378760550 | |
parent | 3592c5f199d75b5c5969e172a06831d2fcacdf30 (diff) | |
download | NetworkManager-danw/wip/ptrarray-introspection.tar.gz |
libnm: post-process NM-1.0.gir to fix GPtrArray property typesdanw/wip/ptrarray-introspection
Only super-new gobject-introspection can properly annotate the
Element-Type of a GPtrArray-valued property. So just do it manually
with a perl script instead.
NOTE: as of GNOME 3.12, this is pointless, because neither pygi nor
gjs pays attention to the annotations anyway.
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | libnm/Makefile.am | 6 | ||||
-rwxr-xr-x | libnm/fix-gir.pl | 48 | ||||
-rw-r--r-- | libnm/nm-active-connection.c | 2 | ||||
-rw-r--r-- | libnm/nm-client.c | 6 | ||||
-rw-r--r-- | libnm/nm-device-bond.c | 2 | ||||
-rw-r--r-- | libnm/nm-device-bridge.c | 2 | ||||
-rw-r--r-- | libnm/nm-device-team.c | 2 | ||||
-rw-r--r-- | libnm/nm-device-wifi.c | 2 | ||||
-rw-r--r-- | libnm/nm-device-wimax.c | 2 | ||||
-rw-r--r-- | libnm/nm-device.c | 2 |
11 files changed, 55 insertions, 20 deletions
diff --git a/.gitignore b/.gitignore index 89047a3442..077d43f71e 100644 --- a/.gitignore +++ b/.gitignore @@ -168,6 +168,7 @@ valgrind-*.log /libnm/nm-property-docs.xml /libnm/nm-setting-docs.xml /libnm/nm-setting-docs-overrides.xml +/libnm/NM-1.0.gir.fixup-stamp /libnm/tests/test-nm-client /libnm/tests/test-remote-settings-client /libnm/tests/test-secret-agent diff --git a/libnm/Makefile.am b/libnm/Makefile.am index e8915b4268..c3baf3d6c9 100644 --- a/libnm/Makefile.am +++ b/libnm/Makefile.am @@ -177,6 +177,12 @@ typelibdir = $(libdir)/girepository-1.0 typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib) CLEANFILES += $(gir_DATA) $(typelib_DATA) + +NM-1.0.typelib: NM-1.0.gir.fixup-stamp + +NM-1.0.gir.fixup-stamp: NM-1.0.gir fix-gir.pl + @($(srcdir)/fix-gir.pl $< > $<.tmp && mv $<.tmp $< && touch $@) || rm -f $<.tmp + endif check-local: diff --git a/libnm/fix-gir.pl b/libnm/fix-gir.pl new file mode 100755 index 0000000000..f72d3b9eed --- /dev/null +++ b/libnm/fix-gir.pl @@ -0,0 +1,48 @@ +#!/usr/bin/perl +# vim: ft=perl ts=2 sts=2 sw=2 et ai +# -*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + +# g-ir-scanner < 1.42 does not allow us to correctly annotate GArray-valued or +# GPtrArray-valued properties, so we need this... + +%fixups = ( 'NMActiveConnection:devices' => 'NMDevice', + 'NMClient:active-connections' => 'NMActiveConnection', + 'NMClient:connections' => 'NMRemoteConnection', + 'NMClient:devices' => 'NMDevice', + 'NMDevice:available-connections' => 'NMRemoteConnection', + 'NMDeviceBond:slaves' => 'NMDevice', + 'NMDeviceBridge:slaves' => 'NMDevice', + 'NMDeviceTeam:slaves' => 'NMDevice', + 'NMDeviceWifi:access-points' => 'NMAccessPoint', + 'NMDeviceWimax:nsps' => 'NMWimaxNsp', + 'NMSettingDcb:priority-bandwidth' => 'guint', + 'NMSettingDcb:priority-flow-control' => 'gboolean', + 'NMSettingDcb:priority-group-bandwidth' => 'guint', + 'NMSettingDcb:priority-group-id' => 'guint', + 'NMSettingDcb:priority-strict-bandwidth' => 'gboolean', + 'NMSettingDcb:priority-traffic-class' => 'guint', + 'NMSettingIPConfig:addresses' => 'NMIPAddress', + 'NMSettingIPConfig:routes' => 'NMIPRoute' + ); + +while (<>) { + if (/<class name="([^"]*)"/) { + $current_class = "NM$1"; + } elsif (/<property name="([^"]*)"/) { + $c_type = $fixups{"$current_class:$1"}; + } elsif (/<\/property>/) { + $c_type = ''; + } + + if ($c_type && /<type/) { + if ($c_type =~ /^NM(.*)/) { + $name = $1; + } else { + $name = $c_type; + } + s/name="([^"]*)"/name="$name"/; + s/c:type="([^"]*)"/c:type="$c_type"/; + } + + print; +} diff --git a/libnm/nm-active-connection.c b/libnm/nm-active-connection.c index 31f513280d..f6030e878d 100644 --- a/libnm/nm-active-connection.c +++ b/libnm/nm-active-connection.c @@ -593,8 +593,6 @@ nm_active_connection_class_init (NMActiveConnectionClass *ap_class) * NMActiveConnection:devices: * * The devices of the active connection. - * - * Element-type: NMDevice **/ g_object_class_install_property (object_class, PROP_DEVICES, diff --git a/libnm/nm-client.c b/libnm/nm-client.c index 2483ece0bb..46c38364c1 100644 --- a/libnm/nm-client.c +++ b/libnm/nm-client.c @@ -2045,8 +2045,6 @@ nm_client_class_init (NMClientClass *client_class) * NMClient:active-connections: * * The active connections. - * - * Element-type: NMActiveConnection **/ g_object_class_install_property (object_class, PROP_ACTIVE_CONNECTIONS, @@ -2098,8 +2096,6 @@ nm_client_class_init (NMClientClass *client_class) * NMClient:devices: * * List of known network devices. - * - * Element-type: NMDevice **/ g_object_class_install_property (object_class, PROP_DEVICES, @@ -2115,8 +2111,6 @@ nm_client_class_init (NMClientClass *client_class) * that this differs from the underlying D-Bus property, which may also * contain the object paths of connections that the user does not have * permission to read the details of.) - * - * Element-type: NMRemoteConnection */ g_object_class_install_property (object_class, PROP_CONNECTIONS, diff --git a/libnm/nm-device-bond.c b/libnm/nm-device-bond.c index 6bb673233d..cb2c68242c 100644 --- a/libnm/nm-device-bond.c +++ b/libnm/nm-device-bond.c @@ -259,8 +259,6 @@ nm_device_bond_class_init (NMDeviceBondClass *bond_class) * NMDeviceBond:slaves: * * The devices slaved to the bond device. - * - * Element-type: NMDevice **/ g_object_class_install_property (object_class, PROP_SLAVES, diff --git a/libnm/nm-device-bridge.c b/libnm/nm-device-bridge.c index ce28f2c2f4..7d8506b5f9 100644 --- a/libnm/nm-device-bridge.c +++ b/libnm/nm-device-bridge.c @@ -259,8 +259,6 @@ nm_device_bridge_class_init (NMDeviceBridgeClass *bridge_class) * NMDeviceBridge:slaves: * * The devices slaved to the bridge device. - * - * Element-type: NMDevice **/ g_object_class_install_property (object_class, PROP_SLAVES, diff --git a/libnm/nm-device-team.c b/libnm/nm-device-team.c index cff1d71849..91a1cea0e3 100644 --- a/libnm/nm-device-team.c +++ b/libnm/nm-device-team.c @@ -259,8 +259,6 @@ nm_device_team_class_init (NMDeviceTeamClass *team_class) * NMDeviceTeam:slaves: * * The devices enslaved to the team device. - * - * Element-type: NMDevice **/ g_object_class_install_property (object_class, PROP_SLAVES, diff --git a/libnm/nm-device-wifi.c b/libnm/nm-device-wifi.c index 4a19f2e5a5..c8374193ee 100644 --- a/libnm/nm-device-wifi.c +++ b/libnm/nm-device-wifi.c @@ -789,8 +789,6 @@ nm_device_wifi_class_init (NMDeviceWifiClass *wifi_class) * NMDeviceWifi:access-points: * * List of all Wi-Fi access points the device can see. - * - * Element-type: NMAccessPoint **/ g_object_class_install_property (object_class, PROP_ACCESS_POINTS, diff --git a/libnm/nm-device-wimax.c b/libnm/nm-device-wimax.c index f199b669fa..0942799159 100644 --- a/libnm/nm-device-wimax.c +++ b/libnm/nm-device-wimax.c @@ -630,8 +630,6 @@ nm_device_wimax_class_init (NMDeviceWimaxClass *wimax_class) * NMDeviceWimax:nsps: * * List of all WiMAX Network Service Providers the device can see. - * - * Element-type: NMWimaxNsp **/ g_object_class_install_property (object_class, PROP_NSPS, diff --git a/libnm/nm-device.c b/libnm/nm-device.c index e80ac707d8..9faa6b73a0 100644 --- a/libnm/nm-device.c +++ b/libnm/nm-device.c @@ -734,8 +734,6 @@ nm_device_class_init (NMDeviceClass *device_class) * NMDevice:available-connections: * * The available connections of the device - * - * Element-type: NMRemoteConnection **/ g_object_class_install_property (object_class, PROP_AVAILABLE_CONNECTIONS, |