diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-07-09 12:33:01 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-07-09 12:33:01 -0300 |
commit | 7c519dfbd0c68b952f0849e01deaa3750e1f8153 (patch) | |
tree | dde3ddbba310877db725df37a0d9f2cbe4e2a8f9 /testes/libs/lib2.c | |
parent | f59e6a93c0ad38a27a420e51abf8f13d962446b5 (diff) | |
download | lua-7c519dfbd0c68b952f0849e01deaa3750e1f8153.tar.gz lua-7c519dfbd0c68b952f0849e01deaa3750e1f8153.tar.bz2 lua-7c519dfbd0c68b952f0849e01deaa3750e1f8153.zip |
Added manual and tests for version 5.4-w2
Diffstat (limited to 'testes/libs/lib2.c')
-rw-r--r-- | testes/libs/lib2.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/testes/libs/lib2.c b/testes/libs/lib2.c new file mode 100644 index 00000000..bc9651ee --- /dev/null +++ b/testes/libs/lib2.c | |||
@@ -0,0 +1,23 @@ | |||
1 | #include "lua.h" | ||
2 | #include "lauxlib.h" | ||
3 | |||
4 | static int id (lua_State *L) { | ||
5 | return lua_gettop(L); | ||
6 | } | ||
7 | |||
8 | |||
9 | static const struct luaL_Reg funcs[] = { | ||
10 | {"id", id}, | ||
11 | {NULL, NULL} | ||
12 | }; | ||
13 | |||
14 | |||
15 | LUAMOD_API int luaopen_lib2 (lua_State *L) { | ||
16 | lua_settop(L, 2); | ||
17 | lua_setglobal(L, "y"); /* y gets 2nd parameter */ | ||
18 | lua_setglobal(L, "x"); /* x gets 1st parameter */ | ||
19 | luaL_newlib(L, funcs); | ||
20 | return 1; | ||
21 | } | ||
22 | |||
23 | |||