mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-29 10:20:11 +01:00
libnm: add and use NM_SETT_INFO_PROPERT_TYPE_*_INIT() macros
The advantage is that we use similar macros for initializing the
static structs like
const NMSettInfoPropertType nm_sett_info_propert_type_cloned_mac_address;
and the ad-hoc locations that use NM_SETT_INFO_PROPERT_TYPE().
The former exist for property types that are used more than once.
The latter exist for convenience, where a property type is implemented
at only one place.
Also, there are few direct references to _nm_setting_property_to_dbus_fcn_gprop().
all users use NM_SETT_INFO_PROPERT_TYPE_GPROP() or
NM_SETT_INFO_PROPERT_TYPE_GPROP_INIT().
(cherry picked from commit 6fc2e03677)
This commit is contained in:
parent
0d95b3c300
commit
d2e0a8cc0e
5 changed files with 80 additions and 85 deletions
|
|
@ -762,12 +762,11 @@ _nm_setting_dcb_uint_array_from_dbus(GVariant *dbus_value, GValue *prop_value)
|
|||
set_gvalue_from_array(prop_value, (guint *) array, length);
|
||||
}
|
||||
|
||||
static const NMSettInfoPropertType nm_sett_info_propert_type_dcb_au = {
|
||||
.dbus_type = NM_G_VARIANT_TYPE("au"),
|
||||
.to_dbus_fcn = _nm_setting_property_to_dbus_fcn_gprop,
|
||||
.gprop_to_dbus_fcn = _nm_setting_dcb_uint_array_to_dbus,
|
||||
.gprop_from_dbus_fcn = _nm_setting_dcb_uint_array_from_dbus,
|
||||
};
|
||||
static const NMSettInfoPropertType nm_sett_info_propert_type_dcb_au =
|
||||
NM_SETT_INFO_PROPERT_TYPE_GPROP_INIT(NM_G_VARIANT_TYPE("au"),
|
||||
.gprop_to_dbus_fcn = _nm_setting_dcb_uint_array_to_dbus,
|
||||
.gprop_from_dbus_fcn =
|
||||
_nm_setting_dcb_uint_array_from_dbus, );
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
|
|
|||
|
|
@ -317,20 +317,29 @@ _nm_setting_class_commit(NMSettingClass *setting_class, NMMetaSettingType meta_t
|
|||
|
||||
#define NM_SETT_INFO_SETT_DETAIL(...) (&((const NMSettInfoSettDetail){__VA_ARGS__}))
|
||||
|
||||
#define NM_SETT_INFO_PROPERT_TYPE(...) \
|
||||
({ \
|
||||
static const NMSettInfoPropertType _g = {__VA_ARGS__}; \
|
||||
\
|
||||
&_g; \
|
||||
#define NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(_dbus_type, ...) \
|
||||
{ \
|
||||
.dbus_type = _dbus_type, __VA_ARGS__ \
|
||||
}
|
||||
|
||||
#define NM_SETT_INFO_PROPERT_TYPE_GPROP_INIT(_dbus_type, ...) \
|
||||
{ \
|
||||
.dbus_type = _dbus_type, .to_dbus_fcn = _nm_setting_property_to_dbus_fcn_gprop, \
|
||||
__VA_ARGS__ \
|
||||
}
|
||||
|
||||
#define NM_SETT_INFO_PROPERT_TYPE(init) \
|
||||
({ \
|
||||
static const NMSettInfoPropertType _g = init; \
|
||||
\
|
||||
&_g; \
|
||||
})
|
||||
|
||||
#define NM_SETT_INFO_PROPERT_TYPE_DBUS(_dbus_type, ...) \
|
||||
NM_SETT_INFO_PROPERT_TYPE(.dbus_type = _dbus_type, __VA_ARGS__)
|
||||
NM_SETT_INFO_PROPERT_TYPE(NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(_dbus_type, __VA_ARGS__))
|
||||
|
||||
#define NM_SETT_INFO_PROPERT_TYPE_GPROP(_dbus_type, ...) \
|
||||
NM_SETT_INFO_PROPERT_TYPE_DBUS(_dbus_type, \
|
||||
.to_dbus_fcn = _nm_setting_property_to_dbus_fcn_gprop, \
|
||||
__VA_ARGS__)
|
||||
#define NM_SETT_INFO_PROPERT_TYPE_GPROP(_dbus_type, ...) \
|
||||
NM_SETT_INFO_PROPERT_TYPE(NM_SETT_INFO_PROPERT_TYPE_GPROP_INIT(_dbus_type, __VA_ARGS__))
|
||||
|
||||
#define NM_SETT_INFO_PROPERTY(...) (&((const NMSettInfoProperty){__VA_ARGS__}))
|
||||
|
||||
|
|
|
|||
|
|
@ -2325,30 +2325,28 @@ _nm_setting_get_deprecated_virtual_interface_name(const NMSettInfoSetting *
|
|||
return NULL;
|
||||
}
|
||||
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_interface_name = {
|
||||
.dbus_type = G_VARIANT_TYPE_STRING,
|
||||
.to_dbus_fcn = _nm_setting_get_deprecated_virtual_interface_name,
|
||||
};
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_interface_name =
|
||||
NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_STRING,
|
||||
.to_dbus_fcn =
|
||||
_nm_setting_get_deprecated_virtual_interface_name, );
|
||||
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_ignore_i = {
|
||||
.dbus_type = G_VARIANT_TYPE_INT32,
|
||||
/* No functions set. This property type is to silently ignore the value on D-Bus. */
|
||||
};
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_ignore_i =
|
||||
NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(
|
||||
G_VARIANT_TYPE_INT32,
|
||||
/* No functions set. This property type is to silently ignore the value on D-Bus. */
|
||||
);
|
||||
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_ignore_u = {
|
||||
.dbus_type = G_VARIANT_TYPE_UINT32,
|
||||
/* No functions set. This property type is to silently ignore the value on D-Bus. */
|
||||
};
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_ignore_u =
|
||||
NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(
|
||||
G_VARIANT_TYPE_UINT32,
|
||||
/* No functions set. This property type is to silently ignore the value on D-Bus. */
|
||||
);
|
||||
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_plain_i = {
|
||||
.dbus_type = G_VARIANT_TYPE_INT32,
|
||||
.to_dbus_fcn = _nm_setting_property_to_dbus_fcn_gprop,
|
||||
};
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_plain_i =
|
||||
NM_SETT_INFO_PROPERT_TYPE_GPROP_INIT(G_VARIANT_TYPE_INT32);
|
||||
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_plain_u = {
|
||||
.dbus_type = G_VARIANT_TYPE_UINT32,
|
||||
.to_dbus_fcn = _nm_setting_property_to_dbus_fcn_gprop,
|
||||
};
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_plain_u =
|
||||
NM_SETT_INFO_PROPERT_TYPE_GPROP_INIT(G_VARIANT_TYPE_UINT32);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
|
|
|||
|
|
@ -2786,31 +2786,27 @@ _nm_team_settings_property_from_dbus_link_watchers(GVariant *dbus_value, GValue
|
|||
_nm_utils_team_link_watchers_from_variant(dbus_value, FALSE, NULL));
|
||||
}
|
||||
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_team_b = {
|
||||
.dbus_type = G_VARIANT_TYPE_BOOLEAN,
|
||||
.to_dbus_fcn = _nm_team_settings_property_to_dbus,
|
||||
};
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_team_b =
|
||||
NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_BOOLEAN,
|
||||
.to_dbus_fcn = _nm_team_settings_property_to_dbus, );
|
||||
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_team_i = {
|
||||
.dbus_type = G_VARIANT_TYPE_INT32,
|
||||
.to_dbus_fcn = _nm_team_settings_property_to_dbus,
|
||||
};
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_team_i =
|
||||
NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_INT32,
|
||||
.to_dbus_fcn = _nm_team_settings_property_to_dbus, );
|
||||
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_team_s = {
|
||||
.dbus_type = G_VARIANT_TYPE_STRING,
|
||||
.to_dbus_fcn = _nm_team_settings_property_to_dbus,
|
||||
};
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_team_s =
|
||||
NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_STRING,
|
||||
.to_dbus_fcn = _nm_team_settings_property_to_dbus, );
|
||||
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_team_as = {
|
||||
.dbus_type = NM_G_VARIANT_TYPE("as"),
|
||||
.to_dbus_fcn = _nm_team_settings_property_to_dbus,
|
||||
};
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_team_as =
|
||||
NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(NM_G_VARIANT_TYPE("as"),
|
||||
.to_dbus_fcn = _nm_team_settings_property_to_dbus, );
|
||||
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_team_link_watchers = {
|
||||
.dbus_type = NM_G_VARIANT_TYPE("aa{sv}"),
|
||||
.to_dbus_fcn = _nm_team_settings_property_to_dbus,
|
||||
.gprop_from_dbus_fcn = _nm_team_settings_property_from_dbus_link_watchers,
|
||||
};
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_team_link_watchers =
|
||||
NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(NM_G_VARIANT_TYPE("aa{sv}"),
|
||||
.to_dbus_fcn = _nm_team_settings_property_to_dbus,
|
||||
.gprop_from_dbus_fcn =
|
||||
_nm_team_settings_property_from_dbus_link_watchers, );
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
|
|
|||
|
|
@ -779,12 +779,10 @@ _nm_utils_strdict_from_dbus(GVariant *dbus_value, GValue *prop_value)
|
|||
g_value_take_boxed(prop_value, hash);
|
||||
}
|
||||
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_strdict = {
|
||||
.dbus_type = NM_G_VARIANT_TYPE("a{ss}"),
|
||||
.to_dbus_fcn = _nm_setting_property_to_dbus_fcn_gprop,
|
||||
.gprop_to_dbus_fcn = _nm_utils_strdict_to_dbus,
|
||||
.gprop_from_dbus_fcn = _nm_utils_strdict_from_dbus,
|
||||
};
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_strdict =
|
||||
NM_SETT_INFO_PROPERT_TYPE_GPROP_INIT(NM_G_VARIANT_TYPE("a{ss}"),
|
||||
.gprop_to_dbus_fcn = _nm_utils_strdict_to_dbus,
|
||||
.gprop_from_dbus_fcn = _nm_utils_strdict_from_dbus, );
|
||||
|
||||
GHashTable *
|
||||
_nm_utils_copy_strdict(GHashTable *strdict)
|
||||
|
|
@ -4068,12 +4066,11 @@ _nm_utils_hwaddr_cloned_not_set(NMSetting * setting,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_cloned_mac_address = {
|
||||
.dbus_type = G_VARIANT_TYPE_BYTESTRING,
|
||||
.to_dbus_fcn = _nm_utils_hwaddr_cloned_get,
|
||||
.from_dbus_fcn = _nm_utils_hwaddr_cloned_set,
|
||||
.missing_from_dbus_fcn = _nm_utils_hwaddr_cloned_not_set,
|
||||
};
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_cloned_mac_address =
|
||||
NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_BYTESTRING,
|
||||
.to_dbus_fcn = _nm_utils_hwaddr_cloned_get,
|
||||
.from_dbus_fcn = _nm_utils_hwaddr_cloned_set,
|
||||
.missing_from_dbus_fcn = _nm_utils_hwaddr_cloned_not_set, );
|
||||
|
||||
static GVariant *
|
||||
_nm_utils_hwaddr_cloned_data_synth(const NMSettInfoSetting * sett_info,
|
||||
|
|
@ -4132,11 +4129,10 @@ _nm_utils_hwaddr_cloned_data_set(NMSetting * setting,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_assigned_mac_address = {
|
||||
.dbus_type = G_VARIANT_TYPE_STRING,
|
||||
.to_dbus_fcn = _nm_utils_hwaddr_cloned_data_synth,
|
||||
.from_dbus_fcn = _nm_utils_hwaddr_cloned_data_set,
|
||||
};
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_assigned_mac_address =
|
||||
NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_STRING,
|
||||
.to_dbus_fcn = _nm_utils_hwaddr_cloned_data_synth,
|
||||
.from_dbus_fcn = _nm_utils_hwaddr_cloned_data_set, );
|
||||
|
||||
static GVariant *
|
||||
_nm_utils_hwaddr_to_dbus(const GValue *prop_value)
|
||||
|
|
@ -4155,12 +4151,10 @@ _nm_utils_hwaddr_from_dbus(GVariant *dbus_value, GValue *prop_value)
|
|||
g_value_take_string(prop_value, str);
|
||||
}
|
||||
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_mac_address = {
|
||||
.dbus_type = G_VARIANT_TYPE_BYTESTRING,
|
||||
.to_dbus_fcn = _nm_setting_property_to_dbus_fcn_gprop,
|
||||
.gprop_to_dbus_fcn = _nm_utils_hwaddr_to_dbus,
|
||||
.gprop_from_dbus_fcn = _nm_utils_hwaddr_from_dbus,
|
||||
};
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_mac_address =
|
||||
NM_SETT_INFO_PROPERT_TYPE_GPROP_INIT(G_VARIANT_TYPE_BYTESTRING,
|
||||
.gprop_to_dbus_fcn = _nm_utils_hwaddr_to_dbus,
|
||||
.gprop_from_dbus_fcn = _nm_utils_hwaddr_from_dbus, );
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
|
@ -5560,11 +5554,10 @@ _nm_utils_bridge_vlans_from_dbus(NMSetting * setting,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_bridge_vlans = {
|
||||
.dbus_type = NM_G_VARIANT_TYPE("aa{sv}"),
|
||||
.to_dbus_fcn = _nm_utils_bridge_vlans_to_dbus,
|
||||
.from_dbus_fcn = _nm_utils_bridge_vlans_from_dbus,
|
||||
};
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_bridge_vlans =
|
||||
NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(NM_G_VARIANT_TYPE("aa{sv}"),
|
||||
.to_dbus_fcn = _nm_utils_bridge_vlans_to_dbus,
|
||||
.from_dbus_fcn = _nm_utils_bridge_vlans_from_dbus, );
|
||||
|
||||
gboolean
|
||||
_nm_utils_bridge_vlan_verify_list(GPtrArray * vlans,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue