Update bindings to support newer Lua versions.

master v1.3
Robert G. Jakabosky 2 years ago
parent 8dcf3871d4
commit 018023c6c2
No known key found for this signature in database
GPG Key ID: 0C38AF433FE0B1C0

@ -1,7 +1,7 @@
# #
# A simple low-level Lua wrapper for pthreads. # A simple low-level Lua wrapper for pthreads.
# #
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 3.18)
project(lua-llthreads C) project(lua-llthreads C)
@ -9,18 +9,18 @@ set(BUILD_SHARED_LIBS TRUE)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
set(INSTALL_CMOD ${CMAKE_INSTALL_PREFIX}/lib/lua/5.1 CACHE PATH set(INSTALL_CMOD share/lua/cmod CACHE PATH "Directory to install Lua binary modules (configure lua via LUA_CPATH)")
"Directory to install Lua binary modules (configure lua via LUA_CPATH)")
set(COMMON_CFLAGS "${CFLAGS}") set(COMMON_CFLAGS "${CFLAGS}")
set(COMMON_LDFLAGS) set(COMMON_LDFLAGS)
set(COMMON_LIBS) set(COMMON_LIBS)
## Lua 5.1.x ## Lua 5.x
include(FindLua51) include(FindLua)
if(NOT ${LUA51_FOUND}) if(NOT ${LUA_FOUND})
message(FATAL_ERROR "The FindLua51 module could not find lua :-(") message(FATAL_ERROR "The FindLua module could not find lua :-(")
endif() endif()
set(COMMON_LIBS "${COMMON_LIBS};${LUA_LIBRARIES}")
if(WIN32) if(WIN32)
set(COMMON_CFLAGS "${COMMON_CFLAGS} -I${LUA_INCLUDE_DIR}") set(COMMON_CFLAGS "${COMMON_CFLAGS} -I${LUA_INCLUDE_DIR}")
set(COMMON_LDFLAGS "${COMMON_LDFLAGS} ${LUA_LIBRARY}") set(COMMON_LDFLAGS "${COMMON_LDFLAGS} ${LUA_LIBRARY}")

@ -2,11 +2,11 @@
# Lua Native Objects # Lua Native Objects
# #
set(LUA_NATIVE_OBJECTS_PATH ${CMAKE_SOURCE_DIR}/../LuaNativeObjects CACHE PATH find_program(LUA_NATIVE_OBJECTS_EXECUTABLE native_objects.lua
"Directory to LuaNativeObjects bindings generator.") PATHS ${CMAKE_SOURCE_DIR}/../LuaNativeObjects
DOC "LuaNativeObjects executable path")
set(USE_PRE_GENERATED_BINDINGS TRUE CACHE BOOL set(USE_PRE_GENERATED_BINDINGS TRUE CACHE BOOL
"Set this to FALSE to re-generate bindings using LuaNativeObjects") "Set this to FALSE to re-generate bindings using LuaNativeObjects")
set(GENERATE_LUADOCS TRUE CACHE BOOL set(GENERATE_LUADOCS TRUE CACHE BOOL
"Set this to FALSE to avoid generation of docs using LuaDoc") "Set this to FALSE to avoid generation of docs using LuaDoc")
@ -17,7 +17,7 @@ macro(GenLuaNativeObjects _src_files_var)
string(REGEX REPLACE ".nobj.lua" ".nobj.c" _src_file_out ${_src_file}) string(REGEX REPLACE ".nobj.lua" ".nobj.c" _src_file_out ${_src_file})
string(REGEX REPLACE ".nobj.lua" ".nobj.ffi.lua" _ffi_file_out ${_src_file}) string(REGEX REPLACE ".nobj.lua" ".nobj.ffi.lua" _ffi_file_out ${_src_file})
add_custom_command(OUTPUT ${_src_file_out} ${_ffi_file_out} add_custom_command(OUTPUT ${_src_file_out} ${_ffi_file_out}
COMMAND lua ${LUA_NATIVE_OBJECTS_PATH}/native_objects.lua -outpath ${CMAKE_CURRENT_BINARY_DIR} -gen lua ${_src_file} COMMAND ${LUA_NATIVE_OBJECTS_EXECUTABLE} -outpath ${CMAKE_CURRENT_BINARY_DIR} -gen lua ${_src_file}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${_src_file} DEPENDS ${_src_file}
) )
@ -27,7 +27,7 @@ macro(GenLuaNativeObjects _src_files_var)
string(REGEX REPLACE ".nobj.lua" "" _doc_base ${_src_file}) string(REGEX REPLACE ".nobj.lua" "" _doc_base ${_src_file})
string(REGEX REPLACE ".nobj.lua" ".luadoc" _doc_file_out ${_src_file}) string(REGEX REPLACE ".nobj.lua" ".luadoc" _doc_file_out ${_src_file})
add_custom_target(${_doc_file_out} ALL add_custom_target(${_doc_file_out} ALL
COMMAND lua ${LUA_NATIVE_OBJECTS_PATH}/native_objects.lua -outpath docs -gen luadoc ${_src_file} COMMAND ${LUA_NATIVE_OBJECTS_EXECUTABLE} -outpath docs -gen luadoc ${_src_file}
COMMAND luadoc -nofiles -d docs docs COMMAND luadoc -nofiles -d docs docs
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${_src_file} DEPENDS ${_src_file}

@ -0,0 +1,23 @@
package = "lua-llthreads"
version = "1.3-1"
source = {
url = "git://github.com/Neopallium/lua-llthreads.git",
branch = "v1.3",
}
description = {
summary = "Low-Level threads for Lua",
homepage = "http://github.com/Neopallium/lua-llthreads",
license = "MIT/X11",
}
dependencies = {
"lua >= 5.1, < 5.5",
}
build = {
type = "builtin",
modules = {
llthreads = {
sources = {"src/pre_generated-llthreads.nobj.c"},
libraries = {"pthread"},
}
}
}

@ -10,7 +10,7 @@ description = {
license = "MIT/X11", license = "MIT/X11",
} }
dependencies = { dependencies = {
"lua >= 5.1, < 5.3", "lua >= 5.1, < 5.5",
} }
build = { build = {
type = "builtin", type = "builtin",

@ -20,12 +20,10 @@
#define luaL_Reg luaL_reg #define luaL_Reg luaL_reg
#endif #endif
/* some Lua 5.1 compatibility support. */
#if !defined(LUA_VERSION_NUM) || (LUA_VERSION_NUM == 501)
/* /*
** Adapted from Lua 5.2.0 ** Adapted from Lua 5.2.0 luaL_setfuncs.
*/ */
static void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) { static void nobj_setfuncs (lua_State *L, const luaL_Reg *l, int nup) {
luaL_checkstack(L, nup, "too many upvalues"); luaL_checkstack(L, nup, "too many upvalues");
for (; l->name != NULL; l++) { /* fill the table with given functions */ for (; l->name != NULL; l++) { /* fill the table with given functions */
int i; int i;
@ -38,6 +36,9 @@ static void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) {
lua_pop(L, nup); /* remove upvalues */ lua_pop(L, nup); /* remove upvalues */
} }
/* some Lua 5.1 compatibility support. */
#if !defined(LUA_VERSION_NUM) || (LUA_VERSION_NUM == 501)
#define lua_load_no_mode(L, reader, data, source) \ #define lua_load_no_mode(L, reader, data, source) \
lua_load(L, reader, data, source) lua_load(L, reader, data, source)
@ -45,7 +46,7 @@ static void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) {
#endif #endif
#if LUA_VERSION_NUM == 502 #if LUA_VERSION_NUM >= 502
#define lua_load_no_mode(L, reader, data, source) \ #define lua_load_no_mode(L, reader, data, source) \
lua_load(L, reader, data, source, NULL) lua_load(L, reader, data, source, NULL)
@ -1147,7 +1148,7 @@ static void obj_type_register_package(lua_State *L, const reg_sub_module *type_r
/* create public functions table. */ /* create public functions table. */
if(reg_list != NULL && reg_list[0].name != NULL) { if(reg_list != NULL && reg_list[0].name != NULL) {
/* register functions */ /* register functions */
luaL_setfuncs(L, reg_list, 0); nobj_setfuncs(L, reg_list, 0);
} }
obj_type_register_constants(L, type_reg->constants, -1, type_reg->bidirectional_consts); obj_type_register_constants(L, type_reg->constants, -1, type_reg->bidirectional_consts);
@ -1162,17 +1163,17 @@ static void obj_type_register_meta(lua_State *L, const reg_sub_module *type_reg)
reg_list = type_reg->pub_funcs; reg_list = type_reg->pub_funcs;
if(reg_list != NULL && reg_list[0].name != NULL) { if(reg_list != NULL && reg_list[0].name != NULL) {
/* register functions */ /* register functions */
luaL_setfuncs(L, reg_list, 0); nobj_setfuncs(L, reg_list, 0);
} }
obj_type_register_constants(L, type_reg->constants, -1, type_reg->bidirectional_consts); obj_type_register_constants(L, type_reg->constants, -1, type_reg->bidirectional_consts);
/* register methods. */ /* register methods. */
luaL_setfuncs(L, type_reg->methods, 0); nobj_setfuncs(L, type_reg->methods, 0);
/* create metatable table. */ /* create metatable table. */
lua_newtable(L); lua_newtable(L);
luaL_setfuncs(L, type_reg->metas, 0); /* fill metatable */ nobj_setfuncs(L, type_reg->metas, 0); /* fill metatable */
/* setmetatable on meta-object. */ /* setmetatable on meta-object. */
lua_setmetatable(L, -2); lua_setmetatable(L, -2);
@ -1197,7 +1198,7 @@ static void obj_type_register(lua_State *L, const reg_sub_module *type_reg, int
reg_list = type_reg->pub_funcs; reg_list = type_reg->pub_funcs;
if(reg_list != NULL && reg_list[0].name != NULL) { if(reg_list != NULL && reg_list[0].name != NULL) {
/* register "constructors" as to object's public API */ /* register "constructors" as to object's public API */
luaL_setfuncs(L, reg_list, 0); /* fill public API table. */ nobj_setfuncs(L, reg_list, 0); /* fill public API table. */
/* make public API table callable as the default constructor. */ /* make public API table callable as the default constructor. */
lua_newtable(L); /* create metatable */ lua_newtable(L); /* create metatable */
@ -1227,7 +1228,7 @@ static void obj_type_register(lua_State *L, const reg_sub_module *type_reg, int
#endif #endif
} }
luaL_setfuncs(L, type_reg->methods, 0); /* fill methods table. */ nobj_setfuncs(L, type_reg->methods, 0); /* fill methods table. */
luaL_newmetatable(L, type->name); /* create metatable */ luaL_newmetatable(L, type->name); /* create metatable */
lua_pushliteral(L, ".name"); lua_pushliteral(L, ".name");
@ -1245,7 +1246,7 @@ static void obj_type_register(lua_State *L, const reg_sub_module *type_reg, int
lua_pushvalue(L, -2); /* dup metatable. */ lua_pushvalue(L, -2); /* dup metatable. */
lua_rawset(L, priv_table); /* priv_table["<object_name>"] = metatable */ lua_rawset(L, priv_table); /* priv_table["<object_name>"] = metatable */
luaL_setfuncs(L, type_reg->metas, 0); /* fill metatable */ nobj_setfuncs(L, type_reg->metas, 0); /* fill metatable */
/* add obj_bases to metatable. */ /* add obj_bases to metatable. */
while(base->id >= 0) { while(base->id >= 0) {
@ -2010,7 +2011,7 @@ LUA_NOBJ_API int luaopen_llthreads(lua_State *L) {
luaL_register(L, "llthreads", llthreads_function); luaL_register(L, "llthreads", llthreads_function);
#else #else
lua_newtable(L); lua_newtable(L);
luaL_setfuncs(L, llthreads_function, 0); nobj_setfuncs(L, llthreads_function, 0);
#endif #endif
/* register module constants. */ /* register module constants. */

Loading…
Cancel
Save