blob: adde214ca42ed0995d498cd61ed150be920f83ef (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#include <xmi.h>
static int add(lua_State *lua) {
int a = lua_tointeger(lua, 1);
int b = lua_tointeger(lua, 2);
lua_pushinteger(lua, a + b);
return 1;
}
static int sub(lua_State *lua) {
int a = lua_tointeger(lua, 1);
int b = lua_tointeger(lua, 2);
lua_pushinteger(lua, a - b);
return 1;
}
int luaopen(foo, lua_State *lua) {
static const luaL_Reg funcs[] = { { "add", add }, { "sub", sub }, { NULL, NULL } };
lua_newtable(lua);
luaL_setfuncs(lua, funcs, 0);
return 1;
}
|