aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/private/helpers.c
diff options
context:
space:
mode:
authorTJ DeVries <devries.timothyj@gmail.com>2020-10-22 16:21:35 -0400
committerTJ DeVries <devries.timothyj@gmail.com>2020-10-22 16:21:35 -0400
commita83b76790b82c8f9e74b82c8b0061682b66ddd0d (patch)
treebc9c86e689edec91082828734b1b15ce8b5fdc0d /src/nvim/api/private/helpers.c
parent7fca3ddccad2130e75c68e94b5bf4db925b1911b (diff)
downloadrneovim-a83b76790b82c8f9e74b82c8b0061682b66ddd0d.tar.gz
rneovim-a83b76790b82c8f9e74b82c8b0061682b66ddd0d.tar.bz2
rneovim-a83b76790b82c8f9e74b82c8b0061682b66ddd0d.zip
fixup: fixup: fixup: fixup:
Diffstat (limited to 'src/nvim/api/private/helpers.c')
-rw-r--r--src/nvim/api/private/helpers.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c
index 41b0f8ae1d..981d41ae6e 100644
--- a/src/nvim/api/private/helpers.c
+++ b/src/nvim/api/private/helpers.c
@@ -1621,18 +1621,22 @@ free_exit:
/// Force obj to bool.
/// If it fails, returns false and sets 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)
+/// @param obj The object to coerce to a boolean
+/// @param what The name of the object, used for error message
+/// @param nil_value 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 nil_value,
+ 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 if_nil; // caller decides what NIL (missing retval in lua) means
+ return nil_value; // caller decides what NIL (missing retval in lua) means
} else {
api_set_error(err, kErrorTypeValidation, "%s is not an boolean", what);
return false;