summaryrefslogtreecommitdiff
path: root/src/libnm-core-impl/nm-setting-private.h
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2021-06-29 07:57:41 +0200
committerThomas Haller <thaller@redhat.com>2021-07-12 13:56:38 +0200
commit3c801ec4f35eb3a2f2ba42413072ba555f5a25fd (patch)
tree527f0674cd53b9d477961d1e4163b6c88571d6a2 /src/libnm-core-impl/nm-setting-private.h
parent27621dde45586b8beba773966ceac4f1c61d7e75 (diff)
downloadNetworkManager-3c801ec4f35eb3a2f2ba42413072ba555f5a25fd.tar.gz
libnm: add direct_offset for uint32 properties
And as example, implement NMSettingVrf.table this way. This also makes all properties of NMSettingVrf implemened as "direct" properties, and we can drop the explicit getter/setters.
Diffstat (limited to 'src/libnm-core-impl/nm-setting-private.h')
-rw-r--r--src/libnm-core-impl/nm-setting-private.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/libnm-core-impl/nm-setting-private.h b/src/libnm-core-impl/nm-setting-private.h
index 047dccb283..48f225b6d4 100644
--- a/src/libnm-core-impl/nm-setting-private.h
+++ b/src/libnm-core-impl/nm-setting-private.h
@@ -300,6 +300,7 @@ extern const NMSettInfoPropertType nm_sett_info_propert_type_plain_i;
extern const NMSettInfoPropertType nm_sett_info_propert_type_plain_u;
extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_boolean;
+extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_uint32;
extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_string;
NMSettingVerifyResult
@@ -496,6 +497,51 @@ _nm_properties_override(GArray *properties_override, const NMSettInfoProperty *p
/*****************************************************************************/
+#define _nm_setting_property_define_direct_uint32(properties_override, \
+ obj_properties, \
+ prop_name, \
+ prop_id, \
+ min_value, \
+ max_value, \
+ default_value, \
+ param_flags, \
+ private_struct_type, \
+ private_struct_field, \
+ ... /* extra NMSettInfoProperty fields */) \
+ G_STMT_START \
+ { \
+ GParamSpec *_param_spec; \
+ \
+ G_STATIC_ASSERT( \
+ !NM_FLAGS_ANY((param_flags), \
+ ~(NM_SETTING_PARAM_FUZZY_IGNORE | NM_SETTING_PARAM_INFERRABLE))); \
+ G_STATIC_ASSERT((min_value) <= (guint64) G_MAXUINT32); \
+ G_STATIC_ASSERT((max_value) <= (guint64) G_MAXUINT32); \
+ G_STATIC_ASSERT((default_value) <= (guint64) G_MAXUINT32); \
+ \
+ _param_spec = \
+ g_param_spec_uint("" prop_name "", \
+ "", \
+ "", \
+ (min_value), \
+ (max_value), \
+ (default_value), \
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | (param_flags)); \
+ \
+ (obj_properties)[(prop_id)] = _param_spec; \
+ \
+ _nm_properties_override_gobj( \
+ (properties_override), \
+ _param_spec, \
+ &nm_sett_info_propert_type_direct_uint32, \
+ .direct_offset = \
+ NM_STRUCT_OFFSET_ENSURE_TYPE(guint32, private_struct_type, private_struct_field), \
+ __VA_ARGS__); \
+ } \
+ G_STMT_END
+
+/*****************************************************************************/
+
#define _nm_setting_property_define_direct_string_full(properties_override, \
obj_properties, \
prop_name, \