libnm: add compare_fcn() to property meta data

So far, we only have NMSettingClass.compare_property() hook.
The ugliness is that this hook is per-setting, when basically
all implementations only compare one property.

It feels cleaner to have a per-property hook and call that consistently.

In step one, we give all properties (the same) compare_fcn() implementation,
which delegates to the existing NMSettingClass.compare_property().
In a second step, this will be untangled.

There is one problem with this approach: NMSettInfoPropertType grows by
one pointer size, and we have potentially many such types. That should
be addressed by unifying types in the future.
This commit is contained in:
Thomas Haller
2021-06-29 14:23:16 +02:00
parent d8292d462b
commit 7e7d2d173a
18 changed files with 154 additions and 55 deletions

View File

@@ -2112,11 +2112,13 @@ nm_setting_tc_config_class_init(NMSettingTCConfigClass *klass)
G_TYPE_PTR_ARRAY,
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE
| G_PARAM_STATIC_STRINGS);
_nm_properties_override_gobj(properties_override,
obj_properties[PROP_QDISCS],
NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aa{sv}"),
.to_dbus_fcn = tc_qdiscs_get,
.from_dbus_fcn = tc_qdiscs_set, ));
_nm_properties_override_gobj(
properties_override,
obj_properties[PROP_QDISCS],
NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aa{sv}"),
.to_dbus_fcn = tc_qdiscs_get,
.compare_fcn = _nm_setting_property_compare_fcn_default,
.from_dbus_fcn = tc_qdiscs_set, ));
/**
* NMSettingTCConfig:tfilters: (type GPtrArray(NMTCTfilter))
@@ -2254,6 +2256,7 @@ nm_setting_tc_config_class_init(NMSettingTCConfigClass *klass)
obj_properties[PROP_TFILTERS],
NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aa{sv}"),
.to_dbus_fcn = tc_tfilters_get,
.compare_fcn = _nm_setting_property_compare_fcn_default,
.from_dbus_fcn = tc_tfilters_set, ));
g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties);