diff options
author | Kurtis Rader <krader@skepticism.us> | 2016-04-30 20:31:02 -0700 |
---|---|---|
committer | Kurtis Rader <krader@skepticism.us> | 2016-04-30 20:37:46 -0700 |
commit | d3f155d895dbaeb92ef780c3aae355898b69bd27 (patch) | |
tree | b483f781a1eb4a0303e30266595c836e809e2469 /src/function.h | |
parent | 075811e58836bc82de3052d064e9f0aa9335b6e7 (diff) |
restyle function module to match project style
Reduces lint errors from 39 to 27 (-31%). Line count from 619 to 498 (-20%).
Another step in resolving issue #2902.
Diffstat (limited to 'src/function.h')
-rw-r--r-- | src/function.h | 201 |
1 files changed, 75 insertions, 126 deletions
diff --git a/src/function.h b/src/function.h index 8ac45a11..04829cbe 100644 --- a/src/function.h +++ b/src/function.h @@ -1,194 +1,143 @@ -/** \file function.h - - Prototypes for functions for storing and retrieving function - information. These functions also take care of autoloading - functions in the $fish_function_path. Actual function evaluation - is taken care of by the parser and to some degree the builtin - handling library. -*/ +// Prototypes for functions for storing and retrieving function information. These functions also +// take care of autoloading functions in the $fish_function_path. Actual function evaluation is +// taken care of by the parser and to some degree the builtin handling library. #ifndef FISH_FUNCTION_H #define FISH_FUNCTION_H -#include <vector> -#include <map> #include <stdbool.h> +#include <map> +#include <vector> #include "common.h" -#include "event.h" #include "env.h" +#include "event.h" class parser_t; -/** - Structure describing a function. This is used by the parser to - store data on a function while parsing it. It is not used - internally to store functions, the function_internal_data_t - structure is used for that purpose. Parhaps these two should be - merged. - */ -struct function_data_t -{ - /** - Name of function - */ +/// Structure describing a function. This is used by the parser to store data on a function while +/// parsing it. It is not used internally to store functions, the function_internal_data_t structure +/// is used for that purpose. Parhaps these two should be merged. +struct function_data_t { + /// Name of function. wcstring name; - /** - Description of function - */ + /// Description of function. wcstring description; - /** - Function definition - */ + /// Function definition. const wchar_t *definition; - /** - List of all event handlers for this function - */ + /// List of all event handlers for this function. std::vector<event_t> events; - /** - List of all named arguments for this function - */ + /// List of all named arguments for this function. wcstring_list_t named_arguments; - /** - List of all variables that are inherited from the function definition scope. - The variable values are snapshotted when function_add() is called. - */ + /// List of all variables that are inherited from the function definition scope. The variable + /// values are snapshotted when function_add() is called. wcstring_list_t inherit_vars; - /** - Set to non-zero if invoking this function shadows the variables - of the underlying function. - */ + /// Set to non-zero if invoking this function shadows the variables of the underlying function. int shadows; }; -class function_info_t -{ -public: - /** Constructs relevant information from the function_data */ - function_info_t(const function_data_t &data, const wchar_t *filename, int def_offset, bool autoload); +class function_info_t { + public: + /// Constructs relevant information from the function_data. + function_info_t(const function_data_t &data, const wchar_t *filename, int def_offset, + bool autoload); - /** Used by function_copy */ - function_info_t(const function_info_t &data, const wchar_t *filename, int def_offset, bool autoload); + /// Used by function_copy. + function_info_t(const function_info_t &data, const wchar_t *filename, int def_offset, + bool autoload); - /** Function definition */ + /// Function definition. const wcstring definition; - /** Function description. Only the description may be changed after the function is created. */ + /// Function description. Only the description may be changed after the function is created. wcstring description; - /** File where this function was defined (intern'd string) */ - const wchar_t * const definition_file; + /// File where this function was defined (intern'd string). + const wchar_t *const definition_file; - /** Line where definition started */ + /// Line where definition started. const int definition_offset; - /** List of all named arguments for this function */ + /// List of all named arguments for this function. const wcstring_list_t named_arguments; - /** Mapping of all variables that were inherited from the function definition scope to their values */ - const std::map<wcstring,env_var_t> inherit_vars; + /// Mapping of all variables that were inherited from the function definition scope to their + /// values. + const std::map<wcstring, env_var_t> inherit_vars; - /** Flag for specifying that this function was automatically loaded */ + /// Flag for specifying that this function was automatically loaded. const bool is_autoload; - /** Set to true if invoking this function shadows the variables of the underlying function. */ + /// Set to true if invoking this function shadows the variables of the underlying function. const bool shadows; }; - -/** - Initialize function data -*/ +/// Initialize function data. void function_init(); -/** Add a function. definition_line_offset is the line number of the function's definition within its source file */ -void function_add(const function_data_t &data, const parser_t &parser, int definition_line_offset = 0); +/// Add a function. definition_line_offset is the line number of the function's definition within +/// its source file. +void function_add(const function_data_t &data, const parser_t &parser, + int definition_line_offset = 0); -/** - Remove the function with the specified name. -*/ +/// Remove the function with the specified name. void function_remove(const wcstring &name); -/** - Returns by reference the definition of the function with the name \c name. - Returns true if successful, false if no function with the given name exists. -*/ +/// Returns by reference the definition of the function with the name \c name. Returns true if +/// successful, false if no function with the given name exists. bool function_get_definition(const wcstring &name, wcstring *out_definition); -/** - Returns by reference the description of the function with the name \c name. - Returns true if the function exists and has a nonempty description, false if it does not. -*/ +/// Returns by reference the description of the function with the name \c name. Returns true if the +/// function exists and has a nonempty description, false if it does not. bool function_get_desc(const wcstring &name, wcstring *out_desc); -/** - Sets the description of the function with the name \c name. -*/ +/// Sets the description of the function with the name \c name. void function_set_desc(const wcstring &name, const wcstring &desc); -/** - Returns true if the function with the name name exists. -*/ +/// Returns true if the function with the name name exists. int function_exists(const wcstring &name); -/** Attempts to load a function if not yet loaded. This is used by the completion machinery. */ +/// Attempts to load a function if not yet loaded. This is used by the completion machinery. void function_load(const wcstring &name); -/** - Returns true if the function with the name name exists, without triggering autoload. -*/ +/// Returns true if the function with the name name exists, without triggering autoload. int function_exists_no_autoload(const wcstring &name, const env_vars_snapshot_t &vars); -/** - Returns all function names. - - \param get_hidden whether to include hidden functions, i.e. ones starting with an underscore -*/ +/// Returns all function names. +/// +/// \param get_hidden whether to include hidden functions, i.e. ones starting with an underscore. wcstring_list_t function_get_names(int get_hidden); -/** - Returns tha absolute path of the file where the specified function - was defined. Returns 0 if the file was defined on the commandline. - - This function does not autoload functions, it will only work on - functions that have already been defined. - - This returns an intern'd string. -*/ +/// Returns tha absolute path of the file where the specified function was defined. Returns 0 if the +/// file was defined on the commandline. +/// +/// This function does not autoload functions, it will only work on functions that have already been +/// defined. +/// +/// This returns an intern'd string. const wchar_t *function_get_definition_file(const wcstring &name); -/** - Returns the linenumber where the definition of the specified - function started. - - This function does not autoload functions, it will only work on - functions that have already been defined. -*/ +/// Returns the linenumber where the definition of the specified function started. +/// +/// This function does not autoload functions, it will only work on functions that have already been +/// defined. int function_get_definition_offset(const wcstring &name); -/** - Returns a list of all named arguments of the specified function. -*/ +/// Returns a list of all named arguments of the specified function. wcstring_list_t function_get_named_arguments(const wcstring &name); -/** - Returns a mapping of all variables of the specified function that were inherited - from the scope of the function definition to their values. - */ -std::map<wcstring,env_var_t> function_get_inherit_vars(const wcstring &name); +/// Returns a mapping of all variables of the specified function that were inherited from the scope +/// of the function definition to their values. +std::map<wcstring, env_var_t> function_get_inherit_vars(const wcstring &name); -/** - Creates a new function using the same definition as the specified function. - Returns true if copy is successful. -*/ +/// Creates a new function using the same definition as the specified function. Returns true if copy +/// is successful. bool function_copy(const wcstring &name, const wcstring &new_name); -/** - Returns whether this function shadows variables of the underlying function -*/ +/// Returns whether this function shadows variables of the underlying function. int function_get_shadows(const wcstring &name); -/** Prepares the environment for executing a function. -*/ -void function_prepare_environment(const wcstring &name, const wchar_t * const * argv, const std::map<wcstring, env_var_t> &inherited_vars); +/// Prepares the environment for executing a function. +void function_prepare_environment(const wcstring &name, const wchar_t *const *argv, + const std::map<wcstring, env_var_t> &inherited_vars); #endif |