41static int LuaDatasetGC(
lua_State *luastate)
51static int LuaDatasetGetRef(
lua_State *luastate)
59 const char *
name = lua_tostring(luastate, 2);
65 if (dataset == NULL) {
72static 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);
100static int LuaDatasetNew(
lua_State *luastate)
107 luaL_getmetatable(luastate,
"dataset::metatable");
108 lua_setmetatable(luastate, -2);
114static 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);
Dataset * DatasetFind(const char *name, enum DatasetTypes type)
look for set by name without creating it
int DatasetAdd(Dataset *set, const uint8_t *data, const uint32_t data_len)
char name[DATASET_NAME_MAX_LEN+1]
struct lua_State lua_State
int LuaLoadDatasetLib(lua_State *luastate)