From 1357f5a3647aba1024afe8557695c1a07a81b129 Mon Sep 17 00:00:00 2001 From: Aaron Gyes Date: Sun, 5 Jun 2016 18:46:04 -0700 Subject: Repair various invalid HeaderDoc comments. Enable build setting to allow Xcode to complain about invalid comments. --- src/complete.cpp | 5 ++--- src/complete.h | 25 +++++++++++++------------ src/exec.cpp | 2 +- src/expand.h | 8 ++++---- src/highlight.h | 4 ++-- src/pager.cpp | 4 ++-- src/parse_util.h | 2 +- src/parser.h | 9 --------- src/postfork.cpp | 2 +- src/reader.cpp | 15 +++++++-------- src/screen.h | 2 +- 11 files changed, 34 insertions(+), 44 deletions(-) (limited to 'src') diff --git a/src/complete.cpp b/src/complete.cpp index f686ab31..e23e9ce1 100644 --- a/src/complete.cpp +++ b/src/complete.cpp @@ -652,8 +652,7 @@ static wcstring complete_function_desc(const wcstring &fn) { /// Complete the specified command name. Search for executables in the path, executables defined /// using an absolute path, functions, builtins and directories for implicit cd commands. /// -/// \param cmd the command string to find completions for -/// \param comp the list to add all completions to +/// \param str_cmd the command string to find completions for void completer_t::complete_cmd(const wcstring &str_cmd, bool use_function, bool use_builtin, bool use_command, bool use_implicit_cd) { if (str_cmd.empty()) return; @@ -704,7 +703,7 @@ void completer_t::complete_cmd(const wcstring &str_cmd, bool use_function, bool /// \param str The string to complete. /// \param args The list of option arguments to be evaluated. /// \param desc Description of the completion -/// \param comp_out The list into which the results will be inserted +/// \param flags The list into which the results will be inserted void completer_t::complete_from_args(const wcstring &str, const wcstring &args, const wcstring &desc, complete_flags_t flags) { bool is_autosuggest = (this->type() == COMPLETE_AUTOSUGGEST); diff --git a/src/complete.h b/src/complete.h index 57c743c0..d9203aaf 100644 --- a/src/complete.h +++ b/src/complete.h @@ -99,6 +99,13 @@ enum { }; typedef uint32_t completion_request_flags_t; +enum complete_option_type_t { + option_type_args_only, // no option + option_type_short, // -x + option_type_single_long, // -foo + option_type_double_long // --foo +}; + /// Add a completion. /// /// All supplied values are copied, they should be freed by or otherwise disposed by the caller. @@ -117,14 +124,12 @@ typedef uint32_t completion_request_flags_t; /// complete -c grep -s d -x -a "read skip recurse" /// /// \param cmd Command to complete. -/// \param cmd_type If cmd_type is PATH, cmd will be interpreted as the absolute +/// \param cmd_is_path If cmd_is_path is true, cmd will be interpreted as the absolute /// path of the program (optionally containing wildcards), otherwise it /// will be interpreted as the command name. -/// \param short_opt The single character name of an option. (-a is a short option, -/// --all and -funroll are long options) -/// \param long_opt The multi character name of an option. (-a is a short option, --all and -/// -funroll are long options) -/// \param long_mode Whether to use old style, single dash long options. +/// \param option The name of an option. +/// \param option_type The type of option: can be option_type_short (-x), +/// option_type_single_long (-foo), option_type_double_long (--bar). /// \param result_mode Whether to search further completions when this completion has been /// succesfully matched. If result_mode is SHARED, any other completions may also be used. If /// result_mode is NO_FILES, file completion should not be used, but other completions may be used. @@ -135,16 +140,12 @@ typedef uint32_t completion_request_flags_t; /// \param condition a command to be run to check it this completion should be used. If \c condition /// is empty, the completion is always used. /// \param flags A set of completion flags -enum complete_option_type_t { - option_type_args_only, // no option - option_type_short, // -x - option_type_single_long, // -foo - option_type_double_long // --foo -}; void complete_add(const wchar_t *cmd, bool cmd_is_path, const wcstring &option, complete_option_type_t option_type, int result_mode, const wchar_t *condition, const wchar_t *comp, const wchar_t *desc, int flags); + + /// Sets whether the completion list for this command is complete. If true, any options not matching /// one of the provided options will be flagged as an error by syntax highlighting. void complete_set_authoritative(const wchar_t *cmd, bool cmd_type, bool authoritative); diff --git a/src/exec.cpp b/src/exec.cpp index aefdbc12..a5bdbc0b 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -315,7 +315,7 @@ static bool io_transmogrify(const io_chain_t &in_chain, io_chain_t *out_chain, /// \param def the code to evaluate, or the empty string if none /// \param node_offset the offset of the node to evalute, or NODE_OFFSET_INVALID /// \param block_type the type of block to push on evaluation -/// \param io the io redirections to be performed on this block +/// \param ios the io redirections to be performed on this block static void internal_exec_helper(parser_t &parser, const wcstring &def, node_offset_t node_offset, enum block_type_t block_type, const io_chain_t &ios) { // If we have a valid node offset, then we must not have a string to execute. diff --git a/src/expand.h b/src/expand.h index 7c82d72e..2f1dd2a6 100644 --- a/src/expand.h +++ b/src/expand.h @@ -33,7 +33,7 @@ enum { /// Don't generate descriptions. EXPAND_NO_DESCRIPTIONS = 1 << 6, /// Don't expand jobs (but you can still expand processes). This is because - // job expansion is not thread safe. + /// job expansion is not thread safe. EXPAND_SKIP_JOBS = 1 << 7, /// Don't expand home directories. EXPAND_SKIP_HOME_DIRECTORIES = 1 << 8, @@ -46,7 +46,7 @@ enum { /// working directories. EXPAND_SPECIAL_FOR_CD = 1 << 11, /// Do expansions specifically to support external command completions. This means using PATH as - // a list of potential working directories. + /// a list of potential working directories. EXPAND_SPECIAL_FOR_COMMAND = 1 << 12 }; typedef int expand_flags_t; @@ -109,7 +109,7 @@ enum expand_error_t { /// /// \param input The parameter to expand /// \param output The list to which the result will be appended. -/// \param flag Specifies if any expansion pass should be skipped. Legal values are any combination +/// \param flags Specifies if any expansion pass should be skipped. Legal values are any combination /// of EXPAND_SKIP_CMDSUBST EXPAND_SKIP_VARIABLES and EXPAND_SKIP_WILDCARDS /// \param errors Resulting errors, or NULL to ignore /// @@ -123,7 +123,7 @@ __warn_unused expand_error_t expand_string(const wcstring &input, std::vectorcommand_line; long match_highlight_pos = (long)el->position + match_highlight_pos_adjust; diff --git a/src/screen.h b/src/screen.h index 43e256d1..74cda3be 100644 --- a/src/screen.h +++ b/src/screen.h @@ -149,7 +149,7 @@ class screen_t { /// \param indent the indent to use for the command line /// \param cursor_pos where the cursor is /// \param pager_data any pager data, to append to the screen -/// \param position_is_within_pager whether the position is within the pager line (first line) +/// \param cursor_is_within_pager whether the position is within the pager line (first line) void s_write(screen_t *s, const wcstring &left_prompt, const wcstring &right_prompt, const wcstring &commandline, size_t explicit_len, const highlight_spec_t *colors, const int *indent, size_t cursor_pos, const page_rendering_t &pager_data, -- cgit v1.2.3 From 90ee810c737d3492f38a45425e46e1d6b7cfa9d3 Mon Sep 17 00:00:00 2001 From: Aaron Gyes Date: Sun, 5 Jun 2016 19:24:23 -0700 Subject: These autoload comment should be HeaderDoc comments. --- src/autoload.h | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/autoload.h b/src/autoload.h index 1d6d4a61..ef55fd94 100644 --- a/src/autoload.h +++ b/src/autoload.h @@ -11,15 +11,19 @@ #include "common.h" #include "lru.h" -// A struct responsible for recording an attempt to access a file. +/// Recording an attempt to access a file. struct file_access_attempt_t { - time_t mod_time; // modification time of the file - time_t last_checked; // when we last checked the file - bool accessible; // whether we believe we could access this file - bool stale; // whether the access attempt is stale - int error; // if we could not access the file, the error code + /// modification time of the file + time_t mod_time; + /// when we last checked the file + time_t last_checked; + /// whether we believe we could access this file + bool accessible; + /// whether the access attempt is stale + bool stale; + /// if we could not access the file, the error code + int error; }; - file_access_attempt_t access_file(const wcstring &path, int mode); struct autoload_function_t : public lru_node_t { @@ -29,12 +33,14 @@ struct autoload_function_t : public lru_node_t { is_loaded(false), is_placeholder(false), is_internalized(false) {} - file_access_attempt_t access; // the last access attempt - bool is_loaded; // whether we have actually loaded this function - // Whether we are a placeholder that stands in for "no such function". If this is true, then - // is_loaded must be false. + /// the last access attempt + file_access_attempt_t access; + /// whether we have actually loaded this function + bool is_loaded; + /// Whether we are a placeholder that stands in for "no such function". If this is true, then + /// is_loaded must be false. bool is_placeholder; - // Whether this function came from a builtin "internalized" script. + /// Whether this function came from a builtin "internalized" script. bool is_internalized; }; @@ -45,7 +51,7 @@ struct builtin_script_t { class env_vars_snapshot_t; -// A class that represents a path from which we can autoload, and the autoloaded contents. +/// A class that represents a path from which we can autoload, and the autoloaded contents. class autoload_t : private lru_cache_t { private: // Lock for thread safety. -- cgit v1.2.3 From 2fafb13eaa30981754a8cd0ba8f3c082e3147fa8 Mon Sep 17 00:00:00 2001 From: Aaron Gyes Date: Sun, 5 Jun 2016 21:30:24 -0700 Subject: Be a bit more consistent and proper. --- fish.xcodeproj/project.pbxproj | 2 -- src/autoload.cpp | 19 ++++++------ src/autoload.h | 70 +++++++++++++++++++----------------------- src/wcstringutil.h | 14 ++++----- 4 files changed, 46 insertions(+), 59 deletions(-) (limited to 'src') diff --git a/fish.xcodeproj/project.pbxproj b/fish.xcodeproj/project.pbxproj index 4234a516..721b5a82 100644 --- a/fish.xcodeproj/project.pbxproj +++ b/fish.xcodeproj/project.pbxproj @@ -569,7 +569,6 @@ D0A0854B13B3ACEE0099B651 /* intern.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = intern.cpp; sourceTree = ""; }; D0A0854C13B3ACEE0099B651 /* io.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = io.cpp; sourceTree = ""; }; D0A0854D13B3ACEE0099B651 /* iothread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = iothread.cpp; sourceTree = ""; }; - D0A0854E13B3ACEE0099B651 /* key_reader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = key_reader.cpp; sourceTree = ""; }; D0A0854F13B3ACEE0099B651 /* kill.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = kill.cpp; sourceTree = ""; }; D0A0855113B3ACEE0099B651 /* output.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = output.cpp; sourceTree = ""; }; D0A0855213B3ACEE0099B651 /* parse_util.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = parse_util.cpp; sourceTree = ""; }; @@ -805,7 +804,6 @@ D0A0854D13B3ACEE0099B651 /* iothread.cpp */, D0A0851813B3ACEE0099B651 /* kill.h */, D0A0854F13B3ACEE0099B651 /* kill.cpp */, - D0A0854E13B3ACEE0099B651 /* key_reader.cpp */, D03EE83814DF88B200FC7150 /* lru.h */, D0A0851A13B3ACEE0099B651 /* output.h */, D0A0855113B3ACEE0099B651 /* output.cpp */, diff --git a/src/autoload.cpp b/src/autoload.cpp index 9a8ebf40..56292fc6 100644 --- a/src/autoload.cpp +++ b/src/autoload.cpp @@ -22,7 +22,7 @@ #include "exec.h" #include "wutil.h" // IWYU pragma: keep -// The time before we'll recheck an autoloaded file. +/// The time before we'll recheck an autoloaded file. static const int kAutoloadStalenessInterval = 15; file_access_attempt_t access_file(const wcstring &path, int mode) { @@ -135,8 +135,9 @@ bool autoload_t::has_tried_loading(const wcstring &cmd) { return func != NULL; } +/// @return Whether this function is stale. +/// Internalized functions can never be stale. static bool is_stale(const autoload_function_t *func) { - // Return whether this function is stale. Internalized functions can never be stale. return !func->is_internalized && time(NULL) - func->access.last_checked > kAutoloadStalenessInterval; } @@ -159,14 +160,12 @@ autoload_function_t *autoload_t::get_autoloaded_function_with_creation(const wcs /// This internal helper function does all the real work. By using two functions, the internal /// function can return on various places in the code, and the caller can take care of various /// cleanup work. -/// -/// cmd: the command name ('grep') -/// really_load: whether to actually parse it as a function, or just check it it exists -/// reload: whether to reload it if it's already loaded -/// path_list: the set of paths to check -/// -/// Result: if really_load is true, returns whether the function was loaded. Otherwise returns -/// whether the function existed. +/// @param cmd the command name ('grep') +/// @param really_load Whether to actually parse it as a function, or just check it it exists +/// @param reload Whether to reload it if it's already loaded +/// @param path_list The set of paths to check +/// @return If really_load is true, returns whether the function was loaded. Otherwise returns +/// whether the function existed. bool autoload_t::locate_file_and_maybe_load_it(const wcstring &cmd, bool really_load, bool reload, const wcstring_list_t &path_list) { // Note that we are NOT locked in this function! diff --git a/src/autoload.h b/src/autoload.h index ef55fd94..efa8c16d 100644 --- a/src/autoload.h +++ b/src/autoload.h @@ -11,17 +11,17 @@ #include "common.h" #include "lru.h" -/// Recording an attempt to access a file. +/// Record of an attempt to access a file. struct file_access_attempt_t { - /// modification time of the file + /// Modification time of the file time_t mod_time; - /// when we last checked the file + /// When we last checked the file time_t last_checked; - /// whether we believe we could access this file + /// Whether or not we believe we can access this file bool accessible; - /// whether the access attempt is stale + /// The access attempt is stale bool stale; - /// if we could not access the file, the error code + /// If we cannot access the file, the error code encountered. int error; }; file_access_attempt_t access_file(const wcstring &path, int mode); @@ -33,9 +33,10 @@ struct autoload_function_t : public lru_node_t { is_loaded(false), is_placeholder(false), is_internalized(false) {} - /// the last access attempt + + /// The last access attempt recorded file_access_attempt_t access; - /// whether we have actually loaded this function + /// Have we actually loaded this function? bool is_loaded; /// Whether we are a placeholder that stands in for "no such function". If this is true, then /// is_loaded must be false. @@ -51,24 +52,23 @@ struct builtin_script_t { class env_vars_snapshot_t; -/// A class that represents a path from which we can autoload, and the autoloaded contents. +/// Class representing a path from which we can autoload and the autoloaded contents. class autoload_t : private lru_cache_t { private: - // Lock for thread safety. + /// Lock for thread safety. pthread_mutex_t lock; - // The environment variable name. + /// The environment variable name. const wcstring env_var_name; - // Builtin script array. + /// Builtin script array. const struct builtin_script_t *const builtin_scripts; - // Builtin script count. + /// Builtin script count. const size_t builtin_script_count; - // The path from which we most recently autoloaded. + /// The path from which we most recently autoloaded. wcstring last_path; - // That path, tokenized (split on separators). + /// the most reecently autoloaded path, tokenized (split on separators). wcstring_list_t last_path_tokenized; - - // A table containing all the files that are currently being loaded. This is here to help - // prevent recursion. + /// A table containing all the files that are currently being loaded. + /// This is here to help prevent recursion. std::set is_loading_set; void remove_all_functions(void) { this->evict_all_nodes(); } @@ -82,39 +82,31 @@ class autoload_t : private lru_cache_t { bool allow_eviction); protected: - // Overridable callback for when a command is removed. + /// Overridable callback for when a command is removed. virtual void command_removed(const wcstring &cmd) {} public: - // Create an autoload_t for the given environment variable name. + /// Create an autoload_t for the given environment variable name. autoload_t(const wcstring &env_var_name_var, const builtin_script_t *scripts, size_t script_count); - virtual ~autoload_t(); // destructor - - // Autoload the specified file, if it exists in the specified path. Do not load it multiple - // times unless its timestamp changes or parse_util_unload is called. - // - // Autoloading one file may unload another. - // - // \param cmd the filename to search for. The suffix '.fish' is always added to this name - // \param on_unload a callback function to run if a suitable file is found, which has not - // already been run. unload will also be called for old files which are unloaded. - // \param reload wheter to recheck file timestamps on already loaded files + virtual ~autoload_t(); + + /// Autoload the specified file, if it exists in the specified path. Do not load it multiple + /// times unless its timestamp changes or parse_util_unload is called. + /// Autoloading one file may unload another. + /// @param cmd the filename to search for. The suffix '.fish' is always added to this name + /// @param reload wheter to recheck file timestamps on already loaded files int load(const wcstring &cmd, bool reload); - // Check whether we have tried loading the given command. Does not do any I/O. + /// Check whether we have tried loading the given command. Does not do any I/O. bool has_tried_loading(const wcstring &cmd); - // Tell the autoloader that the specified file, in the specified path, is no longer loaded. - // - // \param cmd the filename to search for. The suffix '.fish' is always added to this name - // \param on_unload a callback function which will be called before (re)loading a file, may be - // used to unload the previous file. - // \return non-zero if the file was removed, zero if the file had not yet been loaded + /// Tell the autoloader that the specified file, in the specified path, is no longer loaded. + /// Returns non-zero if the file was removed, zero if the file had not yet been loaded int unload(const wcstring &cmd); - // Check whether the given command could be loaded, but do not load it. + /// Check whether the given command could be loaded, but do not load it. bool can_load(const wcstring &cmd, const env_vars_snapshot_t &vars); }; #endif diff --git a/src/wcstringutil.h b/src/wcstringutil.h index ea4489e7..4a86f86e 100644 --- a/src/wcstringutil.h +++ b/src/wcstringutil.h @@ -7,18 +7,16 @@ #include "common.h" -/// Typedef that represents a range in a wcstring. The first element is the location, the second is -/// the count. +/// @typedef wcstring_range represents a range in a wcstring. +/// The first element is the location, the second is the count. typedef std::pair wcstring_range; /// wcstring equivalent of wcstok(). Supports NUL. For convenience and wcstok() compatibility, the /// first character of each token separator is replaced with NUL. -/// -/// Returns a pair of (pos, count). -/// Returns (npos, npos) when it's done. -/// Returns (pos, npos) when the token is already known to be the final token. -/// -/// Note that the final token may not necessarily return (pos, npos). +/// @return Returns a pair of (pos, count). +/// This will be (npos, npos) when it's done. In the form of (pos, npos) +/// when the token is already known to be the final token. +/// @note The final token may not necessarily return (pos, npos). wcstring_range wcstring_tok(wcstring& str, const wcstring& needle, wcstring_range last = wcstring_range(0, 0)); -- cgit v1.2.3