gdb: pass/return setting setter/getter scalar values by value
The getter and setter in struct setting always receive and return values by const reference. This is not necessary for scalar values (like bool and int), but more importantly it makes it a bit annoying to write a getter, you have to use a scratch static variable or something similar that you can refer to: const bool & my_getter () { static bool value; value = function_returning_bool (); return value; } Change the getter and setter function signatures to receive and return value by value instead of by reference, when the underlying data type is scalar. This means that string-based settings will still use references, but all others will be by value. The getter above would then be re-written as: bool my_getter () { return function_returning_bool (); } This is useful for a patch later in this series that defines a boolean setting with a getter and a setter. Change-Id: Ieca3a2419fcdb75a6f75948b2c920b548a0af0fd
This commit is contained in:
parent
7ead06a8b6
commit
fcef6471ed
3 changed files with 82 additions and 62 deletions
|
@ -572,8 +572,8 @@ add_setshow_cmd_full (const char *name,
|
|||
var_types var_type, T *var,
|
||||
const char *set_doc, const char *show_doc,
|
||||
const char *help_doc,
|
||||
setting_setter_ftype<T> set_setting_func,
|
||||
setting_getter_ftype<T> get_setting_func,
|
||||
typename setting_func_types<T>::set set_setting_func,
|
||||
typename setting_func_types<T>::get get_setting_func,
|
||||
cmd_func_ftype *set_func,
|
||||
show_value_ftype *show_func,
|
||||
struct cmd_list_element **set_list,
|
||||
|
@ -628,8 +628,8 @@ set_show_commands
|
|||
add_setshow_enum_cmd (const char *name, command_class theclass,
|
||||
const char *const *enumlist, const char *set_doc,
|
||||
const char *show_doc, const char *help_doc,
|
||||
setting_setter_ftype<const char *> set_func,
|
||||
setting_getter_ftype<const char *> get_func,
|
||||
setting_func_types<const char *>::set set_func,
|
||||
setting_func_types<const char *>::get get_func,
|
||||
show_value_ftype *show_func,
|
||||
cmd_list_element **set_list,
|
||||
cmd_list_element **show_list)
|
||||
|
@ -682,8 +682,8 @@ set_show_commands
|
|||
add_setshow_auto_boolean_cmd (const char *name, command_class theclass,
|
||||
const char *set_doc, const char *show_doc,
|
||||
const char *help_doc,
|
||||
setting_setter_ftype<enum auto_boolean> set_func,
|
||||
setting_getter_ftype<enum auto_boolean> get_func,
|
||||
setting_func_types<enum auto_boolean>::set set_func,
|
||||
setting_func_types<enum auto_boolean>::get get_func,
|
||||
show_value_ftype *show_func,
|
||||
cmd_list_element **set_list,
|
||||
cmd_list_element **show_list)
|
||||
|
@ -737,8 +737,8 @@ set_show_commands
|
|||
add_setshow_boolean_cmd (const char *name, command_class theclass,
|
||||
const char *set_doc, const char *show_doc,
|
||||
const char *help_doc,
|
||||
setting_setter_ftype<bool> set_func,
|
||||
setting_getter_ftype<bool> get_func,
|
||||
setting_func_types<bool>::set set_func,
|
||||
setting_func_types<bool>::get get_func,
|
||||
show_value_ftype *show_func,
|
||||
cmd_list_element **set_list,
|
||||
cmd_list_element **show_list)
|
||||
|
@ -784,8 +784,8 @@ set_show_commands
|
|||
add_setshow_filename_cmd (const char *name, command_class theclass,
|
||||
const char *set_doc, const char *show_doc,
|
||||
const char *help_doc,
|
||||
setting_setter_ftype<std::string> set_func,
|
||||
setting_getter_ftype<std::string> get_func,
|
||||
setting_func_types<std::string>::set set_func,
|
||||
setting_func_types<std::string>::get get_func,
|
||||
show_value_ftype *show_func,
|
||||
cmd_list_element **set_list,
|
||||
cmd_list_element **show_list)
|
||||
|
@ -833,8 +833,8 @@ set_show_commands
|
|||
add_setshow_string_cmd (const char *name, command_class theclass,
|
||||
const char *set_doc, const char *show_doc,
|
||||
const char *help_doc,
|
||||
setting_setter_ftype<std::string> set_func,
|
||||
setting_getter_ftype<std::string> get_func,
|
||||
setting_func_types<std::string>::set set_func,
|
||||
setting_func_types<std::string>::get get_func,
|
||||
show_value_ftype *show_func,
|
||||
cmd_list_element **set_list,
|
||||
cmd_list_element **show_list)
|
||||
|
@ -883,8 +883,8 @@ set_show_commands
|
|||
add_setshow_string_noescape_cmd (const char *name, command_class theclass,
|
||||
const char *set_doc, const char *show_doc,
|
||||
const char *help_doc,
|
||||
setting_setter_ftype<std::string> set_func,
|
||||
setting_getter_ftype<std::string> get_func,
|
||||
setting_func_types<std::string>::set set_func,
|
||||
setting_func_types<std::string>::get get_func,
|
||||
show_value_ftype *show_func,
|
||||
cmd_list_element **set_list,
|
||||
cmd_list_element **show_list)
|
||||
|
@ -933,8 +933,8 @@ set_show_commands
|
|||
add_setshow_optional_filename_cmd (const char *name, command_class theclass,
|
||||
const char *set_doc, const char *show_doc,
|
||||
const char *help_doc,
|
||||
setting_setter_ftype<std::string> set_func,
|
||||
setting_getter_ftype<std::string> get_func,
|
||||
setting_func_types<std::string>::set set_func,
|
||||
setting_func_types<std::string>::get get_func,
|
||||
show_value_ftype *show_func,
|
||||
cmd_list_element **set_list,
|
||||
cmd_list_element **show_list)
|
||||
|
@ -1001,8 +1001,8 @@ set_show_commands
|
|||
add_setshow_integer_cmd (const char *name, command_class theclass,
|
||||
const char *set_doc, const char *show_doc,
|
||||
const char *help_doc,
|
||||
setting_setter_ftype<int> set_func,
|
||||
setting_getter_ftype<int> get_func,
|
||||
setting_func_types<int>::set set_func,
|
||||
setting_func_types<int>::get get_func,
|
||||
show_value_ftype *show_func,
|
||||
cmd_list_element **set_list,
|
||||
cmd_list_element **show_list)
|
||||
|
@ -1050,8 +1050,8 @@ set_show_commands
|
|||
add_setshow_uinteger_cmd (const char *name, command_class theclass,
|
||||
const char *set_doc, const char *show_doc,
|
||||
const char *help_doc,
|
||||
setting_setter_ftype<unsigned int> set_func,
|
||||
setting_getter_ftype<unsigned int> get_func,
|
||||
setting_func_types<unsigned int>::set set_func,
|
||||
setting_func_types<unsigned int>::get get_func,
|
||||
show_value_ftype *show_func,
|
||||
cmd_list_element **set_list,
|
||||
cmd_list_element **show_list)
|
||||
|
@ -1095,8 +1095,8 @@ set_show_commands
|
|||
add_setshow_zinteger_cmd (const char *name, command_class theclass,
|
||||
const char *set_doc, const char *show_doc,
|
||||
const char *help_doc,
|
||||
setting_setter_ftype<int> set_func,
|
||||
setting_getter_ftype<int> get_func,
|
||||
setting_func_types<int>::set set_func,
|
||||
setting_func_types<int>::get get_func,
|
||||
show_value_ftype *show_func,
|
||||
cmd_list_element **set_list,
|
||||
cmd_list_element **show_list)
|
||||
|
@ -1137,8 +1137,8 @@ set_show_commands
|
|||
add_setshow_zuinteger_unlimited_cmd (const char *name, command_class theclass,
|
||||
const char *set_doc, const char *show_doc,
|
||||
const char *help_doc,
|
||||
setting_setter_ftype<int> set_func,
|
||||
setting_getter_ftype<int> get_func,
|
||||
setting_func_types<int>::set set_func,
|
||||
setting_func_types<int>::get get_func,
|
||||
show_value_ftype *show_func,
|
||||
cmd_list_element **set_list,
|
||||
cmd_list_element **show_list)
|
||||
|
@ -1182,8 +1182,8 @@ set_show_commands
|
|||
add_setshow_zuinteger_cmd (const char *name, command_class theclass,
|
||||
const char *set_doc, const char *show_doc,
|
||||
const char *help_doc,
|
||||
setting_setter_ftype<unsigned int> set_func,
|
||||
setting_getter_ftype<unsigned int> get_func,
|
||||
setting_func_types<unsigned int>::set set_func,
|
||||
setting_func_types<unsigned int>::get get_func,
|
||||
show_value_ftype *show_func,
|
||||
cmd_list_element **set_list,
|
||||
cmd_list_element **show_list)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue