summaryrefslogtreecommitdiff
path: root/zig-lua/lua-5.4.7/testes/libs
diff options
context:
space:
mode:
Diffstat (limited to 'zig-lua/lua-5.4.7/testes/libs')
-rw-r--r--zig-lua/lua-5.4.7/testes/libs/P1/dummy2
-rw-r--r--zig-lua/lua-5.4.7/testes/libs/lib1.c44
-rw-r--r--zig-lua/lua-5.4.7/testes/libs/lib11.c10
-rw-r--r--zig-lua/lua-5.4.7/testes/libs/lib2.c23
-rw-r--r--zig-lua/lua-5.4.7/testes/libs/lib21.c10
-rw-r--r--zig-lua/lua-5.4.7/testes/libs/lib22.c25
-rw-r--r--zig-lua/lua-5.4.7/testes/libs/makefile27
7 files changed, 141 insertions, 0 deletions
diff --git a/zig-lua/lua-5.4.7/testes/libs/P1/dummy b/zig-lua/lua-5.4.7/testes/libs/P1/dummy
new file mode 100644
index 0000000..b0468a0
--- /dev/null
+++ b/zig-lua/lua-5.4.7/testes/libs/P1/dummy
@@ -0,0 +1,2 @@
+# This is a dummy file just to make git keep the otherwise empty
+# directory 'P1' in the repository.
diff --git a/zig-lua/lua-5.4.7/testes/libs/lib1.c b/zig-lua/lua-5.4.7/testes/libs/lib1.c
new file mode 100644
index 0000000..56b6ef4
--- /dev/null
+++ b/zig-lua/lua-5.4.7/testes/libs/lib1.c
@@ -0,0 +1,44 @@
+#include "lua.h"
+#include "lauxlib.h"
+
+static int id (lua_State *L) {
+ return lua_gettop(L);
+}
+
+
+static const struct luaL_Reg funcs[] = {
+ {"id", id},
+ {NULL, NULL}
+};
+
+
+/* function used by lib11.c */
+LUAMOD_API int lib1_export (lua_State *L) {
+ lua_pushstring(L, "exported");
+ return 1;
+}
+
+
+LUAMOD_API int onefunction (lua_State *L) {
+ luaL_checkversion(L);
+ lua_settop(L, 2);
+ lua_pushvalue(L, 1);
+ return 2;
+}
+
+
+LUAMOD_API int anotherfunc (lua_State *L) {
+ luaL_checkversion(L);
+ lua_pushfstring(L, "%d%%%d\n", (int)lua_tointeger(L, 1),
+ (int)lua_tointeger(L, 2));
+ return 1;
+}
+
+
+LUAMOD_API int luaopen_lib1_sub (lua_State *L) {
+ lua_setglobal(L, "y"); /* 2nd arg: extra value (file name) */
+ lua_setglobal(L, "x"); /* 1st arg: module name */
+ luaL_newlib(L, funcs);
+ return 1;
+}
+
diff --git a/zig-lua/lua-5.4.7/testes/libs/lib11.c b/zig-lua/lua-5.4.7/testes/libs/lib11.c
new file mode 100644
index 0000000..377d0c4
--- /dev/null
+++ b/zig-lua/lua-5.4.7/testes/libs/lib11.c
@@ -0,0 +1,10 @@
+#include "lua.h"
+
+/* function from lib1.c */
+int lib1_export (lua_State *L);
+
+LUAMOD_API int luaopen_lib11 (lua_State *L) {
+ return lib1_export(L);
+}
+
+
diff --git a/zig-lua/lua-5.4.7/testes/libs/lib2.c b/zig-lua/lua-5.4.7/testes/libs/lib2.c
new file mode 100644
index 0000000..bc9651e
--- /dev/null
+++ b/zig-lua/lua-5.4.7/testes/libs/lib2.c
@@ -0,0 +1,23 @@
+#include "lua.h"
+#include "lauxlib.h"
+
+static int id (lua_State *L) {
+ return lua_gettop(L);
+}
+
+
+static const struct luaL_Reg funcs[] = {
+ {"id", id},
+ {NULL, NULL}
+};
+
+
+LUAMOD_API int luaopen_lib2 (lua_State *L) {
+ lua_settop(L, 2);
+ lua_setglobal(L, "y"); /* y gets 2nd parameter */
+ lua_setglobal(L, "x"); /* x gets 1st parameter */
+ luaL_newlib(L, funcs);
+ return 1;
+}
+
+
diff --git a/zig-lua/lua-5.4.7/testes/libs/lib21.c b/zig-lua/lua-5.4.7/testes/libs/lib21.c
new file mode 100644
index 0000000..a39b683
--- /dev/null
+++ b/zig-lua/lua-5.4.7/testes/libs/lib21.c
@@ -0,0 +1,10 @@
+#include "lua.h"
+
+
+int luaopen_lib2 (lua_State *L);
+
+LUAMOD_API int luaopen_lib21 (lua_State *L) {
+ return luaopen_lib2(L);
+}
+
+
diff --git a/zig-lua/lua-5.4.7/testes/libs/lib22.c b/zig-lua/lua-5.4.7/testes/libs/lib22.c
new file mode 100644
index 0000000..8e65650
--- /dev/null
+++ b/zig-lua/lua-5.4.7/testes/libs/lib22.c
@@ -0,0 +1,25 @@
+#include "lua.h"
+#include "lauxlib.h"
+
+static int id (lua_State *L) {
+ lua_pushboolean(L, 1);
+ lua_insert(L, 1);
+ return lua_gettop(L);
+}
+
+
+static const struct luaL_Reg funcs[] = {
+ {"id", id},
+ {NULL, NULL}
+};
+
+
+LUAMOD_API int luaopen_lib2 (lua_State *L) {
+ lua_settop(L, 2);
+ lua_setglobal(L, "y"); /* y gets 2nd parameter */
+ lua_setglobal(L, "x"); /* x gets 1st parameter */
+ luaL_newlib(L, funcs);
+ return 1;
+}
+
+
diff --git a/zig-lua/lua-5.4.7/testes/libs/makefile b/zig-lua/lua-5.4.7/testes/libs/makefile
new file mode 100644
index 0000000..9c0c4e3
--- /dev/null
+++ b/zig-lua/lua-5.4.7/testes/libs/makefile
@@ -0,0 +1,27 @@
+# change this variable to point to the directory with Lua headers
+# of the version being tested
+LUA_DIR = ../../
+
+CC = gcc
+
+# compilation should generate Dynamic-Link Libraries
+CFLAGS = -Wall -std=gnu99 -O2 -I$(LUA_DIR) -fPIC -shared
+
+# libraries used by the tests
+all: lib1.so lib11.so lib2.so lib21.so lib2-v2.so
+ touch all
+
+lib1.so: lib1.c $(LUA_DIR)/luaconf.h $(LUA_DIR)/lua.h
+ $(CC) $(CFLAGS) -o lib1.so lib1.c
+
+lib11.so: lib11.c $(LUA_DIR)/luaconf.h $(LUA_DIR)/lua.h
+ $(CC) $(CFLAGS) -o lib11.so lib11.c
+
+lib2.so: lib2.c $(LUA_DIR)/luaconf.h $(LUA_DIR)/lua.h
+ $(CC) $(CFLAGS) -o lib2.so lib2.c
+
+lib21.so: lib21.c $(LUA_DIR)/luaconf.h $(LUA_DIR)/lua.h
+ $(CC) $(CFLAGS) -o lib21.so lib21.c
+
+lib2-v2.so: lib21.c $(LUA_DIR)/luaconf.h $(LUA_DIR)/lua.h
+ $(CC) $(CFLAGS) -o lib2-v2.so lib22.c