cli: fix signature of NMMetaAbstractType:get_fcn()
Depending on the get_type argument, we don't only want to return strings, but arbitrary pointers. The out_to_free argument still makes sense, but depending on the get-type you must know how to free the pointer.
This commit is contained in:
@@ -64,14 +64,14 @@ _meta_type_nmc_generic_info_get_nested (const NMMetaAbstractInfo *abstract_info,
|
|||||||
return (const NMMetaAbstractInfo *const*) info->nested;
|
return (const NMMetaAbstractInfo *const*) info->nested;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static gconstpointer
|
||||||
_meta_type_nmc_generic_info_get_fcn (const NMMetaEnvironment *environment,
|
_meta_type_nmc_generic_info_get_fcn (const NMMetaEnvironment *environment,
|
||||||
gpointer environment_user_data,
|
gpointer environment_user_data,
|
||||||
const NMMetaAbstractInfo *abstract_info,
|
const NMMetaAbstractInfo *abstract_info,
|
||||||
gpointer target,
|
gpointer target,
|
||||||
NMMetaAccessorGetType get_type,
|
NMMetaAccessorGetType get_type,
|
||||||
NMMetaAccessorGetFlags get_flags,
|
NMMetaAccessorGetFlags get_flags,
|
||||||
char **out_to_free)
|
gpointer *out_to_free)
|
||||||
{
|
{
|
||||||
const NmcMetaGenericInfo *info = (const NmcMetaGenericInfo *) abstract_info;
|
const NmcMetaGenericInfo *info = (const NmcMetaGenericInfo *) abstract_info;
|
||||||
|
|
||||||
|
@@ -104,13 +104,13 @@ struct _NmcMetaGenericInfo {
|
|||||||
const NMMetaType *meta_type;
|
const NMMetaType *meta_type;
|
||||||
const char *name;
|
const char *name;
|
||||||
const NmcMetaGenericInfo *const*nested;
|
const NmcMetaGenericInfo *const*nested;
|
||||||
const char *(*get_fcn) (const NMMetaEnvironment *environment,
|
gconstpointer (*get_fcn) (const NMMetaEnvironment *environment,
|
||||||
gpointer environment_user_data,
|
gpointer environment_user_data,
|
||||||
const NmcMetaGenericInfo *info,
|
const NmcMetaGenericInfo *info,
|
||||||
gpointer target,
|
gpointer target,
|
||||||
NMMetaAccessorGetType get_type,
|
NMMetaAccessorGetType get_type,
|
||||||
NMMetaAccessorGetFlags get_flags,
|
NMMetaAccessorGetFlags get_flags,
|
||||||
char **out_to_free);
|
gpointer *out_to_free);
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NMC_META_GENERIC(n, ...) \
|
#define NMC_META_GENERIC(n, ...) \
|
||||||
|
@@ -6632,32 +6632,37 @@ _meta_type_property_info_get_name (const NMMetaAbstractInfo *abstract_info)
|
|||||||
return ((const NMMetaPropertyInfo *) abstract_info)->property_name;
|
return ((const NMMetaPropertyInfo *) abstract_info)->property_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static gconstpointer
|
||||||
_meta_type_setting_info_editor_get_fcn (const NMMetaEnvironment *environment,
|
_meta_type_setting_info_editor_get_fcn (const NMMetaEnvironment *environment,
|
||||||
gpointer environment_user_data,
|
gpointer environment_user_data,
|
||||||
const NMMetaAbstractInfo *abstract_info,
|
const NMMetaAbstractInfo *abstract_info,
|
||||||
gpointer target,
|
gpointer target,
|
||||||
NMMetaAccessorGetType get_type,
|
NMMetaAccessorGetType get_type,
|
||||||
NMMetaAccessorGetFlags get_flags,
|
NMMetaAccessorGetFlags get_flags,
|
||||||
char **out_to_free)
|
gpointer *out_to_free)
|
||||||
{
|
{
|
||||||
nm_assert (out_to_free && !out_to_free);
|
nm_assert (out_to_free && !out_to_free);
|
||||||
g_return_val_if_reached (NULL);
|
g_return_val_if_reached (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static gconstpointer
|
||||||
_meta_type_property_info_get_fcn (const NMMetaEnvironment *environment,
|
_meta_type_property_info_get_fcn (const NMMetaEnvironment *environment,
|
||||||
gpointer environment_user_data,
|
gpointer environment_user_data,
|
||||||
const NMMetaAbstractInfo *abstract_info,
|
const NMMetaAbstractInfo *abstract_info,
|
||||||
gpointer target,
|
gpointer target,
|
||||||
NMMetaAccessorGetType get_type,
|
NMMetaAccessorGetType get_type,
|
||||||
NMMetaAccessorGetFlags get_flags,
|
NMMetaAccessorGetFlags get_flags,
|
||||||
char **out_to_free)
|
gpointer *out_to_free)
|
||||||
{
|
{
|
||||||
const NMMetaPropertyInfo *info = (const NMMetaPropertyInfo *) abstract_info;
|
const NMMetaPropertyInfo *info = (const NMMetaPropertyInfo *) abstract_info;
|
||||||
|
|
||||||
nm_assert (out_to_free && !out_to_free);
|
nm_assert (out_to_free && !out_to_free);
|
||||||
|
|
||||||
|
if (!NM_IN_SET (get_type,
|
||||||
|
NM_META_ACCESSOR_GET_TYPE_PARSABLE,
|
||||||
|
NM_META_ACCESSOR_GET_TYPE_PRETTY))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
return (*out_to_free = info->property_type->get_fcn (environment, environment_user_data,
|
return (*out_to_free = info->property_type->get_fcn (environment, environment_user_data,
|
||||||
info, target,
|
info, target,
|
||||||
get_type, get_flags));
|
get_type, get_flags));
|
||||||
|
@@ -149,13 +149,13 @@ struct _NMMetaType {
|
|||||||
const NMMetaAbstractInfo *const*(*get_nested) (const NMMetaAbstractInfo *abstract_info,
|
const NMMetaAbstractInfo *const*(*get_nested) (const NMMetaAbstractInfo *abstract_info,
|
||||||
guint *out_len,
|
guint *out_len,
|
||||||
gpointer *out_to_free);
|
gpointer *out_to_free);
|
||||||
const char *(*get_fcn) (const NMMetaEnvironment *environment,
|
gconstpointer (*get_fcn) (const NMMetaEnvironment *environment,
|
||||||
gpointer environment_user_data,
|
gpointer environment_user_data,
|
||||||
const NMMetaAbstractInfo *info,
|
const NMMetaAbstractInfo *info,
|
||||||
gpointer target,
|
gpointer target,
|
||||||
NMMetaAccessorGetType get_type,
|
NMMetaAccessorGetType get_type,
|
||||||
NMMetaAccessorGetFlags get_flags,
|
NMMetaAccessorGetFlags get_flags,
|
||||||
char **out_to_free);
|
gpointer *out_to_free);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _NMMetaAbstractInfo {
|
struct _NMMetaAbstractInfo {
|
||||||
|
Reference in New Issue
Block a user