mirror of
https://github.com/lua/lua
synced 2024-11-29 08:03:13 +03:00
01bded3d8c
Instead of being a copy of 'lib2.so', 'lib2-v2.so' has its own source file ('lib22.c'), so that the test can distinguish both libraries.
26 lines
430 B
C
26 lines
430 B
C
#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;
|
|
}
|
|
|
|
|