33 lines
670 B
C
33 lines
670 B
C
#include<lua.h>
|
|
#include<lualib.h>
|
|
#include<lauxlib.h>
|
|
#include<stdint.h>
|
|
|
|
extern int glua_go_call_func(uint64_t);
|
|
extern int glua_go_remove_func(uint64_t);
|
|
|
|
int glua_metatable_call(lua_State *L) {
|
|
uint64_t id = *(uint64_t*) lua_touserdata(L, 1);
|
|
int result = glua_go_call_func(id);
|
|
if(result < 0) {
|
|
lua_error(L);
|
|
}
|
|
return result;
|
|
}
|
|
int glua_metatable_gc(lua_State *L) {
|
|
uint64_t id = *(uint64_t*) lua_touserdata(L, 1);
|
|
glua_go_remove_func(id);
|
|
return 0;
|
|
}
|
|
int glua_metatable_tostring(lua_State *L) {
|
|
uint64_t id = *(uint64_t*) lua_touserdata(L, 1);
|
|
|
|
char buf[64];
|
|
snprintf(buf, sizeof(buf), "gofunc: 0x%X", id);
|
|
|
|
lua_pushstring(L, buf);
|
|
|
|
return 1;
|
|
}
|
|
|