diff options
author | TJ DeVries <devries.timothyj@gmail.com> | 2020-10-22 14:32:19 -0400 |
---|---|---|
committer | TJ DeVries <devries.timothyj@gmail.com> | 2020-10-22 16:08:32 -0400 |
commit | 7fca3ddccad2130e75c68e94b5bf4db925b1911b (patch) | |
tree | c832cdaf71a064867dea0e6448386e8680fe6b33 /src/nvim/api/private/helpers.c | |
parent | 1afe6dd2f4578fa7e6758565db36fa36db72b236 (diff) | |
download | rneovim-7fca3ddccad2130e75c68e94b5bf4db925b1911b.tar.gz rneovim-7fca3ddccad2130e75c68e94b5bf4db925b1911b.tar.bz2 rneovim-7fca3ddccad2130e75c68e94b5bf4db925b1911b.zip |
fixup: some small nit picks
Diffstat (limited to 'src/nvim/api/private/helpers.c')
-rw-r--r-- | src/nvim/api/private/helpers.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index dbc4e16d09..41b0f8ae1d 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -1621,14 +1621,18 @@ free_exit: /// Force obj to bool. /// If it fails, returns false and sets err -bool api_coerce_to_bool(Object obj, const char *what, bool nil_truthy, Error *err) +/// @param obj The object to coerce to a boolean +/// @param what The name of the object, used for error message +/// @param if_nil What to return if the type is nil. +/// @param err Set if there was an error in converting to a bool +bool api_coerce_to_bool(Object obj, const char *what, bool if_nil, Error *err) { if (obj.type == kObjectTypeBoolean) { return obj.data.boolean; } else if (obj.type == kObjectTypeInteger) { return obj.data.integer; // C semantics: non-zero int is true } else if (obj.type == kObjectTypeNil) { - return nil_truthy; // caller decides what NIL (missing retval in lua) means + return if_nil; // caller decides what NIL (missing retval in lua) means } else { api_set_error(err, kErrorTypeValidation, "%s is not an boolean", what); return false; |