refactor(build): don't use the preprocessor when generating headers

Using the preprocessor before generating prototypes provides some
"niceties" but the places that rely on these are pretty few.
Vastly simplifying the BUILD SYSTEM is a better trade-off.

Unbalancing { } blocks due to the preprocessor is cringe anyway (think
of the tree-sitter trees!), write these in a different way.

Add some workarounds for plattform specific features.

INCLUDE_GENERATED_DECLARATIONS flag is now technically redundant,
but will be cleaned up in a follow-up PR as it is a big mess.
This commit is contained in:
bfredl
2025-08-01 12:26:52 +02:00
parent b4c092a092
commit 79c8159f41
24 changed files with 74 additions and 143 deletions

View File

@@ -729,18 +729,11 @@ void nlua_push_Array(lua_State *lstate, const Array array, int flags)
}
}
#define GENERATE_INDEX_FUNCTION(type) \
void nlua_push_##type(lua_State *lstate, const type item, int flags) \
FUNC_ATTR_NONNULL_ALL \
{ \
lua_pushnumber(lstate, (lua_Number)(item)); \
}
GENERATE_INDEX_FUNCTION(Buffer)
GENERATE_INDEX_FUNCTION(Window)
GENERATE_INDEX_FUNCTION(Tabpage)
#undef GENERATE_INDEX_FUNCTION
void nlua_push_handle(lua_State *lstate, const handle_T item, int flags)
FUNC_ATTR_NONNULL_ALL
{
lua_pushnumber(lstate, (lua_Number)(item));
}
/// Convert given Object to Lua value
///

View File

@@ -9,6 +9,10 @@
#define nlua_pop_Window nlua_pop_handle
#define nlua_pop_Tabpage nlua_pop_handle
#define nlua_push_Buffer nlua_push_handle
#define nlua_push_Window nlua_push_handle
#define nlua_push_Tabpage nlua_push_handle
/// Flags for nlua_push_*() functions.
enum {
kNluaPushSpecial = 0x01, ///< Use lua-special-tbl when necessary

View File

@@ -1,6 +1,7 @@
#pragma once
#include <lua.h> // IWYU pragma: keep
#include <stdbool.h>
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "lua/stdlib.h.generated.h"