-
Notifications
You must be signed in to change notification settings - Fork 0
/
aegisub-luabins.patch
201 lines (182 loc) · 5.57 KB
/
aegisub-luabins.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
From b78c14a0ad9773de18a040d6f8e57d3b04c0a82c Mon Sep 17 00:00:00 2001
From: scx <scx.mail@gmail.com>
Date: Sat, 7 Sep 2019 21:36:24 +0200
Subject: [PATCH] Fixes for lua
Fix build with luajit >= 2.1.0
---
libaegisub/lua/modules/lpeg.c | 4 ++--
vendor/luabins/AUTHORS | 1 +
vendor/luabins/README.md | 2 ++
vendor/luabins/src/luabins.c | 2 +-
vendor/luabins/src/luaheaders.h | 10 ++++++++++
vendor/luabins/src/luainternals.h | 19 +++++++++++++++++-
vendor/luabins/src/lualess.c | 32 +++++++++++++++++++++++++++++++
vendor/luabins/test/test.lua | 5 ++++-
8 files changed, 70 insertions(+), 5 deletions(-)
create mode 100644 vendor/luabins/src/lualess.c
diff --git a/libaegisub/lua/modules/lpeg.c b/libaegisub/lua/modules/lpeg.c
index 8d67335ab..5261c2061 100644
--- a/libaegisub/lua/modules/lpeg.c
+++ b/libaegisub/lua/modules/lpeg.c
@@ -2334,7 +2334,7 @@ static int matchl (lua_State *L) {
}
-static struct luaL_reg pattreg[] = {
+static struct luaL_Reg pattreg[] = {
{"match", matchl},
{"print", printpat_l},
{"locale", locale_l},
@@ -2360,7 +2360,7 @@ static struct luaL_reg pattreg[] = {
};
-static struct luaL_reg metapattreg[] = {
+static struct luaL_Reg metapattreg[] = {
{"__add", union_l},
{"__pow", star_l},
{"__sub", diff_l},
diff --git a/vendor/luabins/AUTHORS b/vendor/luabins/AUTHORS
index c5bde58ea..5ea52537e 100644
--- a/vendor/luabins/AUTHORS
+++ b/vendor/luabins/AUTHORS
@@ -2,3 +2,4 @@ Luabins authors:
----------------
Alexander Gladysh <agladysh@gmail.com>
+hanxi <hanxi@gmail.com>
diff --git a/vendor/luabins/README.md b/vendor/luabins/README.md
index 02b3b17b0..1333ded47 100644
--- a/vendor/luabins/README.md
+++ b/vendor/luabins/README.md
@@ -4,6 +4,8 @@ luabins — Lua Binary Serialization Library
Allows to save tuples of primitive Lua types into binary chunks
and to load saved data back.
+NB: You may be better off with luatexts: https://github.com/agladysh/luatexts.
+
On serialization
----------------
diff --git a/vendor/luabins/src/luabins.c b/vendor/luabins/src/luabins.c
index 60668213f..35b177629 100644
--- a/vendor/luabins/src/luabins.c
+++ b/vendor/luabins/src/luabins.c
@@ -54,7 +54,7 @@ static int l_load(lua_State * L)
}
/* luabins Lua module API */
-static const struct luaL_reg R[] =
+static const struct luaL_Reg R[] =
{
{ "save", l_save },
{ "load", l_load },
diff --git a/vendor/luabins/src/luaheaders.h b/vendor/luabins/src/luaheaders.h
index 5d1b4079b..db9e8f256 100644
--- a/vendor/luabins/src/luaheaders.h
+++ b/vendor/luabins/src/luaheaders.h
@@ -7,6 +7,16 @@ extern "C" {
#include <lua.h>
#include <lauxlib.h>
+
+#if !defined LUA_VERSION_NUM
+#define luaL_Reg luaL_reg
+#endif
+
+#if LUA_VERSION_NUM > 501
+#define luaL_register(L,n,R) (luaL_newlib(L,R))
+#define lua_objlen(L,i) lua_rawlen(L, (i))
+#endif
+
#if defined (__cplusplus) && !defined (LUABINS_LUABUILTASCPP)
}
#endif
diff --git a/vendor/luabins/src/luainternals.h b/vendor/luabins/src/luainternals.h
index 6d0639335..c4217c02c 100644
--- a/vendor/luabins/src/luainternals.h
+++ b/vendor/luabins/src/luainternals.h
@@ -7,6 +7,24 @@
#ifndef LUABINS_LUAINTERNALS_H_INCLUDED_
#define LUABINS_LUAINTERNALS_H_INCLUDED_
+#ifndef LUAI_BITSINT
+/*
+* LUAI_BITSINT defines the number of bits in an int.
+* CHANGE here if Lua cannot automatically detect the number of bits of
+* your machine. Probably you do not need to change this.
+*
+* avoid overflows in comparison */
+#if INT_MAX-20 < 32760
+#define LUAI_BITSINT 16
+#elif INT_MAX > 2147483640L
+/* int has at least 32 bits */
+#define LUAI_BITSINT 32
+#else
+#error "you must define LUA_BITSINT with number of bits in an integer"
+#endif
+
+#endif // ifndef LUAI_BITSINT
+
/*
* BEGIN COPY-PASTE FROM Lua 5.1.4 luaconf.h
* WARNING: If your Lua config differs, fix this!
@@ -38,7 +56,6 @@ int luaO_log2 (unsigned int x);
/*
** max size of array part is 2^MAXBITS
*/
-#define LUAI_BITSINT 32
#if LUAI_BITSINT > 26
#define MAXBITS 26
#else
diff --git a/vendor/luabins/src/lualess.c b/vendor/luabins/src/lualess.c
new file mode 100644
index 000000000..fefc0a135
--- /dev/null
+++ b/vendor/luabins/src/lualess.c
@@ -0,0 +1,32 @@
+/*
+* lualess.h
+* Lua-related definitions for lua-less builds (based on Lua manual)
+* See copyright notice in luabins.h
+*/
+
+#include <stdlib.h>
+
+/*
+* lua_Alloc-compatible allocator to use in Lua-less applications
+* with lbs_SaveBuffer. Based on sample code from Lua 5.1 manual.
+*/
+void * lbs_simplealloc(
+ void * ud,
+ void * ptr,
+ size_t osize,
+ size_t nsize
+ )
+{
+ (void) ud;
+ (void) osize; /* not used */
+
+ if (nsize == 0)
+ {
+ free(ptr);
+ return NULL;
+ }
+ else
+ {
+ return realloc(ptr, nsize);
+ }
+}
diff --git a/vendor/luabins/test/test.lua b/vendor/luabins/test/test.lua
index a5a42e976..76f866e63 100644
--- a/vendor/luabins/test/test.lua
+++ b/vendor/luabins/test/test.lua
@@ -6,6 +6,8 @@
package.cpath = "./?.so;"..package.cpath
+local pack = pack or table.pack
+local unpack = unpack or table.unpack
local randomseed = 1235134892
--local randomseed = os.time()
@@ -145,6 +147,7 @@ end
-- Test helper functions
-- ----------------------------------------------------------------------------
+luabins = require 'luabins'
local luabins_local = require 'luabins'
assert(luabins_local == luabins)
@@ -281,7 +284,7 @@ check_fail_save(
"can't save: unsupported type detected",
coroutine.create(function() end)
)
-check_fail_save("can't save: unsupported type detected", newproxy())
+check_fail_save("can't save: unsupported type detected", function()end)
print("---> basic table tests")