tolua: Bring in patches from Freeciv

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
This commit is contained in:
Marko Lindqvist
2022-12-19 04:10:07 +02:00
parent 95d965c075
commit 36b8c16a41
6 changed files with 91 additions and 2 deletions

View File

@@ -0,0 +1,21 @@
diff -Nurd tolua-5.2/src/bin/tolua.c tolua-5.2/src/bin/tolua.c
--- tolua-5.2/src/bin/tolua.c 2022-09-26 18:11:41.769267668 +0300
+++ tolua-5.2/src/bin/tolua.c 2020-02-22 14:33:47.775736302 +0200
@@ -22,6 +22,9 @@
#include <stdlib.h>
#include <string.h>
+#ifndef LUA_SOURCE
+int tolua_tolua_open(lua_State *L);
+#endif
static void help (void)
{
@@ -106,7 +109,6 @@
#ifndef LUA_SOURCE
{
- int tolua_tolua_open (lua_State* L);
tolua_tolua_open(L);
}
#else

View File

@@ -0,0 +1,13 @@
diff -Nurd tolua-5.2/src/lib/tolua_event.c tolua-5.2/src/lib/tolua_event.c
--- tolua-5.2/src/lib/tolua_event.c 2022-09-26 18:17:40.544835582 +0300
+++ tolua-5.2/src/lib/tolua_event.c 2022-08-29 15:10:32.145383356 +0300
@@ -393,8 +393,8 @@
}
else if (lua_isuserdata(L,-1) && *((void**)lua_touserdata(L,-1))==NULL) {
/* free object */
- free(u);
tolua_release(L,u); /* unmap from tolua tables */
+ free(u);
}
}
lua_settop(L,top);

View File

@@ -0,0 +1,11 @@
diff -Nurd tolua-5.2/src/lib/tolua_map.c tolua-5.2/src/lib/tolua_map.c
--- tolua-5.2/src/lib/tolua_map.c 2022-09-26 18:19:26.145867532 +0300
+++ tolua-5.2/src/lib/tolua_map.c 2020-02-22 14:33:47.779735894 +0200
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <math.h>
+int tolua_bnd_takeownership(lua_State *L);
static char toluaname[128] = "tolua.";
static const char* TOLUANAME (const char* n)

View File

@@ -0,0 +1,12 @@
diff -Nurd tolua-5.2/src/lib/tolua_event.c tolua-5.2/src/lib/tolua_event.c
--- tolua-5.2/src/lib/tolua_event.c 2022-09-26 18:20:52.710709210 +0300
+++ tolua-5.2/src/lib/tolua_event.c 2022-09-26 18:18:49.593511033 +0300
@@ -18,6 +18,8 @@
#include "tolua.h"
+#include "tolua_event.h"
+
/* Store at peer
* It stores, creating the corresponding table if needed,
* the pair key/value in the corresponding peer table

View File

@@ -0,0 +1,27 @@
diff -Nurd tolua-5.2/src/bin/lua/variable.lua tolua-5.2/src/bin/lua/variable.lua
--- tolua-5.2/src/bin/lua/variable.lua 2022-09-26 18:23:47.772402128 +0300
+++ tolua-5.2/src/bin/lua/variable.lua 2022-08-29 15:10:32.145383356 +0300
@@ -116,7 +116,10 @@
-- check self value
if class and static==nil then
output('#ifndef TOLUA_RELEASE\n')
- output(' if (!self) tolua_error(tolua_S,"invalid \'self\' in accessing variable \''..self.name..'\'",NULL);');
+ output(' if (!self) {\n')
+ output(' tolua_error(tolua_S,"invalid \'self\' in accessing variable \''..self.name..'\'",NULL);\n')
+ output(' return 0;\n')
+ output(' }\n')
output('#endif\n')
end
@@ -163,7 +166,10 @@
output('#ifndef TOLUA_RELEASE\n')
output(' tolua_Error tolua_err;')
if class and static==nil then
- output(' if (!self) tolua_error(tolua_S,"invalid \'self\' in accessing variable \''..self.name..'\'",NULL);');
+ output(' if (!self) {\n')
+ output(' tolua_error(tolua_S,"invalid \'self\' in accessing variable \''..self.name..'\'",NULL);\n')
+ output(' return 0;\n')
+ output(' }\n')
elseif static then
_,_,self.mod = strfind(self.mod,'^%s*static%s%s*(.*)')
end

View File

@@ -1,5 +1,5 @@
SUMMARY = "Lua binding generator for C/C++"
DESCRIPTION = " tolua is a tool that greatly simplifies the integration of \
DESCRIPTION = "Tolua is a tool that greatly simplifies the integration of \
C/C++ code with Lua. Based on a cleaned header file, tolua automatically \
generates the binding code to access C/C++ features from Lua. Using Lua API \
and tag method facilities, tolua maps C/C++ constants, external variables, \
@@ -13,15 +13,20 @@ BBCLASSEXTEND = "native"
LICENSE = "GPL-2.0-or-later"
LIC_FILES_CHKSUM = "file://include/tolua.h;beginline=9;endline=12;md5=4a3fbc0759a4b8318d99f3d71a773105"
# 0?- patches are from freeciv source tree. https://www.freeciv.org/
SRC_URI = "\
http://webserver2.tecgraf.puc-rio.br/~celes/tolua/tolua-${PV}.tar.gz \
file://MakefileFix.patch \
file://AllLuaPath.patch \
file://01-tolua_tolua_open-proto-before-need.patch \
file://02-fix-use-after-free.patch \
file://03-tolua_bnd_takeownership-prototype.patch \
file://04-include-tolua_event.patch \
file://05-gen-code-fix-null-dereferences.patch \
"
B = "${S}"
SRC_URI[md5sum] = "c8dcf13555df45bdcd792981d7356997"
SRC_URI[sha256sum] = "c5a6b701b3ced9a66e7a9881c9d94430f8612040827650abe1aa3c5c3fc95bf2"
EXTRA_OEMAKE = "STAGING_DIR_NATIVE=${STAGING_DIR_NATIVE}"