cli: use macro for list of argument for NmcMetaGenericInfo.get_fcn()
The reasons are: - I want to locate all implmenetations of the get_fcn() handler. By consistently using this macro, you can just grep for the macro and find them all. - all implementations should follow the same style. This macro enforces the same names for arguments and avoids copy&paste. - if we are going to add or change an argument, it becomes easier. That's because we can easily identify all implementation and can change arguments in one place.
This commit is contained in:
@@ -100,15 +100,7 @@ _ip_config_get_routes (NMIPConfig *cfg)
|
||||
}
|
||||
|
||||
static gconstpointer
|
||||
_metagen_ip4_config_get_fcn (const NMMetaEnvironment *environment,
|
||||
gpointer environment_user_data,
|
||||
const NmcMetaGenericInfo *info,
|
||||
gpointer target,
|
||||
NMMetaAccessorGetType get_type,
|
||||
NMMetaAccessorGetFlags get_flags,
|
||||
NMMetaAccessorGetOutFlags *out_flags,
|
||||
gboolean *out_is_default,
|
||||
gpointer *out_to_free)
|
||||
_metagen_ip4_config_get_fcn (NMC_META_GENERIC_INFO_GET_FCN_ARGS)
|
||||
{
|
||||
NMIPConfig *cfg4 = target;
|
||||
GPtrArray *ptr_array;
|
||||
@@ -183,15 +175,7 @@ arr_out:
|
||||
}
|
||||
|
||||
static gconstpointer
|
||||
_metagen_ip6_config_get_fcn (const NMMetaEnvironment *environment,
|
||||
gpointer environment_user_data,
|
||||
const NmcMetaGenericInfo *info,
|
||||
gpointer target,
|
||||
NMMetaAccessorGetType get_type,
|
||||
NMMetaAccessorGetFlags get_flags,
|
||||
NMMetaAccessorGetOutFlags *out_flags,
|
||||
gboolean *out_is_default,
|
||||
gpointer *out_to_free)
|
||||
_metagen_ip6_config_get_fcn (NMC_META_GENERIC_INFO_GET_FCN_ARGS)
|
||||
{
|
||||
NMIPConfig *cfg6 = target;
|
||||
GPtrArray *ptr_array;
|
||||
|
@@ -172,15 +172,7 @@ _NM_UTILS_LOOKUP_DEFINE (static, permission_result_to_color, NMClientPermissionR
|
||||
static const NmcMetaGenericInfo *const metagen_general_status[];
|
||||
|
||||
static gconstpointer
|
||||
_metagen_general_status_get_fcn (const NMMetaEnvironment *environment,
|
||||
gpointer environment_user_data,
|
||||
const NmcMetaGenericInfo *info,
|
||||
gpointer target,
|
||||
NMMetaAccessorGetType get_type,
|
||||
NMMetaAccessorGetFlags get_flags,
|
||||
NMMetaAccessorGetOutFlags *out_flags,
|
||||
gboolean *out_is_default,
|
||||
gpointer *out_to_free)
|
||||
_metagen_general_status_get_fcn (NMC_META_GENERIC_INFO_GET_FCN_ARGS)
|
||||
{
|
||||
NmCli *nmc = target;
|
||||
const char *value;
|
||||
@@ -280,15 +272,7 @@ static const NmcMetaGenericInfo *const metagen_general_status[_NMC_GENERIC_INFO_
|
||||
/*****************************************************************************/
|
||||
|
||||
static gconstpointer
|
||||
_metagen_general_permissions_get_fcn (const NMMetaEnvironment *environment,
|
||||
gpointer environment_user_data,
|
||||
const NmcMetaGenericInfo *info,
|
||||
gpointer target,
|
||||
NMMetaAccessorGetType get_type,
|
||||
NMMetaAccessorGetFlags get_flags,
|
||||
NMMetaAccessorGetOutFlags *out_flags,
|
||||
gboolean *out_is_default,
|
||||
gpointer *out_to_free)
|
||||
_metagen_general_permissions_get_fcn (NMC_META_GENERIC_INFO_GET_FCN_ARGS)
|
||||
{
|
||||
NMClientPermission perm = GPOINTER_TO_UINT (target);
|
||||
NmCli *nmc = environment_user_data;
|
||||
@@ -329,15 +313,7 @@ typedef struct {
|
||||
} GetGeneralLoggingData;
|
||||
|
||||
static gconstpointer
|
||||
_metagen_general_logging_get_fcn (const NMMetaEnvironment *environment,
|
||||
gpointer environment_user_data,
|
||||
const NmcMetaGenericInfo *info,
|
||||
gpointer target,
|
||||
NMMetaAccessorGetType get_type,
|
||||
NMMetaAccessorGetFlags get_flags,
|
||||
NMMetaAccessorGetOutFlags *out_flags,
|
||||
gboolean *out_is_default,
|
||||
gpointer *out_to_free)
|
||||
_metagen_general_logging_get_fcn (NMC_META_GENERIC_INFO_GET_FCN_ARGS)
|
||||
{
|
||||
NmCli *nmc = environment_user_data;
|
||||
GetGeneralLoggingData *d = target;
|
||||
|
@@ -93,7 +93,8 @@ _meta_type_nmc_generic_info_get_fcn (const NMMetaAbstractInfo *abstract_info,
|
||||
nm_assert (out_to_free || NM_IN_SET (get_type, NM_META_ACCESSOR_GET_TYPE_COLOR));
|
||||
|
||||
if (info->get_fcn) {
|
||||
return info->get_fcn (environment, environment_user_data,
|
||||
return info->get_fcn (environment,
|
||||
environment_user_data,
|
||||
info, target,
|
||||
get_type,
|
||||
get_flags,
|
||||
|
@@ -138,15 +138,19 @@ struct _NmcMetaGenericInfo {
|
||||
const char *name;
|
||||
const char *name_header;
|
||||
const NmcMetaGenericInfo *const*nested;
|
||||
gconstpointer (*get_fcn) (const NMMetaEnvironment *environment,
|
||||
gpointer environment_user_data,
|
||||
const NmcMetaGenericInfo *info,
|
||||
gpointer target,
|
||||
NMMetaAccessorGetType get_type,
|
||||
NMMetaAccessorGetFlags get_flags,
|
||||
NMMetaAccessorGetOutFlags *out_flags,
|
||||
gboolean *out_is_default,
|
||||
gpointer *out_to_free);
|
||||
|
||||
#define NMC_META_GENERIC_INFO_GET_FCN_ARGS \
|
||||
const NMMetaEnvironment *environment, \
|
||||
gpointer environment_user_data, \
|
||||
const NmcMetaGenericInfo *info, \
|
||||
gpointer target, \
|
||||
NMMetaAccessorGetType get_type, \
|
||||
NMMetaAccessorGetFlags get_flags, \
|
||||
NMMetaAccessorGetOutFlags *out_flags, \
|
||||
gboolean *out_is_default, \
|
||||
gpointer *out_to_free
|
||||
|
||||
gconstpointer (*get_fcn) (NMC_META_GENERIC_INFO_GET_FCN_ARGS);
|
||||
};
|
||||
|
||||
#define NMC_META_GENERIC(n, ...) \
|
||||
|
Reference in New Issue
Block a user