aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/lua/executor.h
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2024-02-13 12:14:53 +0100
committerGitHub <noreply@github.com>2024-02-13 12:14:53 +0100
commitce5a9bfe7e537c81d34bd4a27fc6638f20114e67 (patch)
tree1eeeedcb0370d7c156f60ee53017149c8aac8c28 /src/nvim/lua/executor.h
parent89135cff030b06f60cd596a9ae81cd9583987517 (diff)
parent1a3a8d903e9705ce41867e1cbc629a85c7cb6252 (diff)
downloadrneovim-ce5a9bfe7e537c81d34bd4a27fc6638f20114e67.tar.gz
rneovim-ce5a9bfe7e537c81d34bd4a27fc6638f20114e67.tar.bz2
rneovim-ce5a9bfe7e537c81d34bd4a27fc6638f20114e67.zip
Merge pull request #27428 from bfredl/luarena
refactor(lua): use Arena when converting from lua stack to API args
Diffstat (limited to 'src/nvim/lua/executor.h')
-rw-r--r--src/nvim/lua/executor.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/nvim/lua/executor.h b/src/nvim/lua/executor.h
index 0b4623cbd3..ebcd62122f 100644
--- a/src/nvim/lua/executor.h
+++ b/src/nvim/lua/executor.h
@@ -24,7 +24,8 @@ typedef struct {
#endif
} nlua_ref_state_t;
-#define NLUA_EXEC_STATIC(cstr, arg, err) nlua_exec(STATIC_CSTR_AS_STRING(cstr), arg, err)
+#define NLUA_EXEC_STATIC(cstr, arg, mode, arena, err) \
+ nlua_exec(STATIC_CSTR_AS_STRING(cstr), arg, mode, arena, err)
#define NLUA_CLEAR_REF(x) \
do { \
@@ -35,6 +36,16 @@ typedef struct {
} \
} while (0)
+typedef enum {
+ kRetObject, ///< any object, but doesn't preserve nested luarefs
+ kRetNilBool, ///< NIL preserved as such, other values return their booleanness
+ ///< Should also be used when return value is ignored, as it is allocation-free
+ kRetLuaref, ///< return value becomes a single Luaref, regardless of type (except NIL)
+} LuaRetMode;
+
+/// To use with kRetNilBool for quick thuthyness check
+#define LUARET_TRUTHY(res) ((res).type == kObjectTypeBoolean && (res).data.boolean == true)
+
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "lua/executor.h.generated.h"
#endif