2023-11-10 12:23:42 +01:00
|
|
|
#pragma once
|
2016-03-04 21:55:28 +03:00
|
|
|
|
2019-05-29 10:05:00 +02:00
|
|
|
#include <lauxlib.h>
|
2016-03-04 21:55:28 +03:00
|
|
|
#include <lua.h>
|
2022-09-11 17:12:44 +02:00
|
|
|
#include <stdbool.h>
|
2016-03-04 21:55:28 +03:00
|
|
|
|
2022-09-11 17:12:44 +02:00
|
|
|
#include "nvim/api/private/helpers.h"
|
2023-12-18 10:55:23 +01:00
|
|
|
#include "nvim/cmdexpand_defs.h" // IWYU pragma: keep
|
|
|
|
|
#include "nvim/ex_cmds_defs.h" // IWYU pragma: keep
|
2016-03-04 21:55:28 +03:00
|
|
|
#include "nvim/func_attr.h"
|
2023-11-28 20:31:00 +01:00
|
|
|
#include "nvim/macros_defs.h"
|
2023-11-27 20:27:32 +01:00
|
|
|
#include "nvim/types_defs.h"
|
2023-12-18 10:55:23 +01:00
|
|
|
#include "nvim/usercmd.h" // IWYU pragma: keep
|
2016-03-04 21:55:28 +03:00
|
|
|
|
2024-04-27 09:21:46 +02:00
|
|
|
// Generated by generators/gen_api_dispatch.lua
|
2016-03-04 21:55:28 +03:00
|
|
|
void nlua_add_api_functions(lua_State *lstate) REAL_FATTR_NONNULL_ALL;
|
|
|
|
|
|
2021-12-25 14:38:26 +01:00
|
|
|
typedef struct {
|
|
|
|
|
LuaRef nil_ref;
|
|
|
|
|
LuaRef empty_dict_ref;
|
|
|
|
|
int ref_count;
|
|
|
|
|
#if __has_feature(address_sanitizer)
|
2023-05-14 18:45:56 +02:00
|
|
|
PMap(int) ref_markers;
|
2021-12-25 14:38:26 +01:00
|
|
|
#endif
|
|
|
|
|
} nlua_ref_state_t;
|
|
|
|
|
|
2024-02-11 15:46:14 +01:00
|
|
|
#define NLUA_EXEC_STATIC(cstr, arg, mode, arena, err) \
|
|
|
|
|
nlua_exec(STATIC_CSTR_AS_STRING(cstr), arg, mode, arena, err)
|
2022-07-25 10:16:33 +02:00
|
|
|
|
2020-09-21 10:37:28 +02:00
|
|
|
#define NLUA_CLEAR_REF(x) \
|
|
|
|
|
do { \
|
|
|
|
|
/* Take the address to avoid double evaluation. #1375 */ \
|
|
|
|
|
if ((x) != LUA_NOREF) { \
|
|
|
|
|
api_free_luaref(x); \
|
|
|
|
|
(x) = LUA_NOREF; \
|
|
|
|
|
} \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
2024-02-11 15:46:14 +01:00
|
|
|
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;
|
|
|
|
|
|
2024-04-10 11:42:46 +02:00
|
|
|
/// To use with kRetNilBool for quick truthiness check
|
2024-02-11 15:46:14 +01:00
|
|
|
#define LUARET_TRUTHY(res) ((res).type == kObjectTypeBoolean && (res).data.boolean == true)
|
|
|
|
|
|
2016-03-04 21:55:28 +03:00
|
|
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
2017-04-11 01:09:36 +03:00
|
|
|
# include "lua/executor.h.generated.h"
|
2016-03-04 21:55:28 +03:00
|
|
|
#endif
|
2021-12-25 14:38:26 +01:00
|
|
|
|
2023-10-20 15:10:33 +02:00
|
|
|
EXTERN nlua_ref_state_t *nlua_global_refs INIT( = NULL);
|
|
|
|
|
EXTERN bool nlua_disable_preload INIT( = false);
|