diff options
Diffstat (limited to 'testes/libs/lib22.c')
-rw-r--r-- | testes/libs/lib22.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/testes/libs/lib22.c b/testes/libs/lib22.c new file mode 100644 index 00000000..8e656502 --- /dev/null +++ b/testes/libs/lib22.c | |||
@@ -0,0 +1,25 @@ | |||
1 | #include "lua.h" | ||
2 | #include "lauxlib.h" | ||
3 | |||
4 | static int id (lua_State *L) { | ||
5 | lua_pushboolean(L, 1); | ||
6 | lua_insert(L, 1); | ||
7 | return lua_gettop(L); | ||
8 | } | ||
9 | |||
10 | |||
11 | static const struct luaL_Reg funcs[] = { | ||
12 | {"id", id}, | ||
13 | {NULL, NULL} | ||
14 | }; | ||
15 | |||
16 | |||
17 | LUAMOD_API int luaopen_lib2 (lua_State *L) { | ||
18 | lua_settop(L, 2); | ||
19 | lua_setglobal(L, "y"); /* y gets 2nd parameter */ | ||
20 | lua_setglobal(L, "x"); /* x gets 1st parameter */ | ||
21 | luaL_newlib(L, funcs); | ||
22 | return 1; | ||
23 | } | ||
24 | |||
25 | |||