41 static int LuaDatasetGC(
lua_State *luastate)
51 static int LuaDatasetGetRef(
lua_State *luastate)
59 const char *
name = lua_tostring(luastate, 2);
65 if (dataset == NULL) {
72 static int LuaDatasetAdd(
lua_State *luastate)
79 if (!lua_isstring(luastate, 2)) {
82 if (!lua_isnumber(luastate, 3)) {
86 const uint8_t *
str = (
const uint8_t *)lua_tostring(luastate, 2);
91 uint32_t str_len = lua_tonumber(luastate, 3);
95 lua_pushnumber(luastate, (lua_Number)r);
100 static int LuaDatasetNew(
lua_State *luastate)
107 luaL_getmetatable(luastate,
"dataset::metatable");
108 lua_setmetatable(luastate, -2);
114 static const luaL_Reg datasetlib[] = {
115 {
"new", LuaDatasetNew },
116 {
"get", LuaDatasetGetRef },
117 {
"add", LuaDatasetAdd },
118 {
"__gc", LuaDatasetGC },
125 luaL_newmetatable(luastate,
"dataset::metatable");
126 lua_pushvalue(luastate, -1);
127 lua_setfield(luastate, -2,
"__index");
128 luaL_setfuncs(luastate, datasetlib, 0);
129 luaL_newlib(luastate, datasetlib);