aboutsummaryrefslogtreecommitdiffstats
path: root/testing/lua5.2-llthreads/bindings-2.patch
blob: 226ba322c6332d39f13377324faa1a8298d135f8 (plain)
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
From 25687f0babcc2b3cdc8b42c7ecf8a34f751062d6 Mon Sep 17 00:00:00 2001
From: "Robert G. Jakabosky" <bobby@sharedrealm.com>
Date: Fri, 2 Mar 2012 17:34:04 -0800
Subject: [PATCH] Re-generate bindings.

---
 src/pre_generated-llthreads.nobj.c | 35 +++++++++++++++++++++++++++++------
 1 file changed, 29 insertions(+), 6 deletions(-)

diff --git a/src/pre_generated-llthreads.nobj.c b/src/pre_generated-llthreads.nobj.c
index b2d1185..d016651 100644
--- a/src/pre_generated-llthreads.nobj.c
+++ b/src/pre_generated-llthreads.nobj.c
@@ -56,7 +56,7 @@
 #define true 1
 #endif
 #ifndef false
-#define false 1
+#define false 0
 #endif
 
 #endif
@@ -250,7 +250,8 @@ static int nobj_check_ffi_support(lua_State *L) {
 	if(!lua_isnil(L, -1)) {
 		rc = lua_toboolean(L, -1);
 		lua_pop(L, 1);
-		return rc; /* return results of previous check. */
+		/* use results of previous check. */
+		goto finished;
 	}
 	lua_pop(L, 1); /* pop nil. */
 
@@ -276,6 +277,7 @@ static int nobj_check_ffi_support(lua_State *L) {
 	lua_pushboolean(L, rc);
 	lua_rawset(L, LUA_REGISTRYINDEX);
 
+finished:
 	/* turn-on hint that there is FFI code enabled. */
 	if(rc) {
 		nobj_ffi_support_enabled_hint = 1;
@@ -284,9 +286,29 @@ static int nobj_check_ffi_support(lua_State *L) {
 	return rc;
 }
 
+typedef struct {
+	const char **ffi_init_code;
+	int offset;
+} nobj_reader_state;
+
+static const char *nobj_lua_Reader(lua_State *L, void *data, size_t *size) {
+	nobj_reader_state *state = (nobj_reader_state *)data;
+	const char *ptr;
+
+	ptr = state->ffi_init_code[state->offset];
+	if(ptr != NULL) {
+		*size = strlen(ptr);
+		state->offset++;
+	} else {
+		*size = 0;
+	}
+	return ptr;
+}
+
 static int nobj_try_loading_ffi(lua_State *L, const char *ffi_mod_name,
-		const char *ffi_init_code, const ffi_export_symbol *ffi_exports, int priv_table)
+		const char *ffi_init_code[], const ffi_export_symbol *ffi_exports, int priv_table)
 {
+	nobj_reader_state state = { ffi_init_code, 0 };
 	int err;
 
 	/* export symbols to priv_table. */
@@ -296,7 +318,7 @@ static int nobj_try_loading_ffi(lua_State *L, const char *ffi_mod_name,
 		lua_settable(L, priv_table);
 		ffi_exports++;
 	}
-	err = luaL_loadbuffer(L, ffi_init_code, strlen(ffi_init_code), ffi_mod_name);
+	err = lua_load(L, nobj_lua_Reader, &state, ffi_mod_name);
 	if(0 == err) {
 		lua_pushvalue(L, -2); /* dup C module's table. */
 		lua_pushvalue(L, priv_table); /* move priv_table to top of stack. */
@@ -670,6 +692,7 @@ static FUNC_UNUSED void * obj_simple_udata_luadelete(lua_State *L, int _index, o
 
 static FUNC_UNUSED void *obj_simple_udata_luapush(lua_State *L, void *obj, int size, obj_type *type)
 {
+	void *ud;
 #if LUAJIT_FFI
 	lua_pushlightuserdata(L, type);
 	lua_rawget(L, LUA_REGISTRYINDEX); /* type's metatable. */
@@ -681,7 +704,7 @@ static FUNC_UNUSED void *obj_simple_udata_luapush(lua_State *L, void *obj, int s
 	}
 #endif
 	/* create new userdata. */
-	void *ud = lua_newuserdata(L, size);
+	ud = lua_newuserdata(L, size);
 	memcpy(ud, obj, size);
 	/* get obj_type metatable. */
 #if LUAJIT_FFI
@@ -1483,7 +1506,7 @@ static int llthreads__new__func(lua_State *L) {
 
 #if LUAJIT_FFI
 static const ffi_export_symbol llthreads_ffi_export[] = {
-  {NULL, { .data = NULL } }
+  {NULL, { NULL } }
 };
 #endif
 
-- 
1.8.1.6