|
@@ -20,7 +20,9 @@ static int l_store_new (lua_State *L)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-static int store_gc (lua_State *L)
|
|
|
|
|
|
+// This can be called automatically by te garbage collector, or manually.
|
|
|
|
+// It is idempotent.
|
|
|
|
+static int l_store_gc (lua_State *L)
|
|
{
|
|
{
|
|
VOLK_Store **sp = luaL_checkudata(L, 1, "VOLK.Store");
|
|
VOLK_Store **sp = luaL_checkudata(L, 1, "VOLK.Store");
|
|
LOG_DEBUG ("Garbage collecting store @%p.", *sp);
|
|
LOG_DEBUG ("Garbage collecting store @%p.", *sp);
|
|
@@ -32,6 +34,15 @@ static int store_gc (lua_State *L)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+static int l_store_size (lua_State *L)
|
|
|
|
+{
|
|
|
|
+ const VOLK_Store **store_p = luaL_checkudata (L, 1, "VOLK.Store");
|
|
|
|
+ lua_pushinteger (L, VOLK_store_size (*store_p));
|
|
|
|
+
|
|
|
|
+ return 1;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
static int l_store_tostring (lua_State *L)
|
|
static int l_store_tostring (lua_State *L)
|
|
{
|
|
{
|
|
const VOLK_Store *store = *(VOLK_Store **) luaL_checkudata (
|
|
const VOLK_Store *store = *(VOLK_Store **) luaL_checkudata (
|
|
@@ -57,9 +68,12 @@ static const luaL_Reg store_lib_fn [] = {
|
|
|
|
|
|
|
|
|
|
static const luaL_Reg store_lib_meth [] = {
|
|
static const luaL_Reg store_lib_meth [] = {
|
|
- {"__gc", store_gc},
|
|
|
|
|
|
+ {"__gc", l_store_gc},
|
|
|
|
+ {"__len", l_store_size},
|
|
{"__tostring", l_store_tostring},
|
|
{"__tostring", l_store_tostring},
|
|
|
|
|
|
|
|
+ {"close", l_store_gc},
|
|
|
|
+
|
|
{NULL}
|
|
{NULL}
|
|
};
|
|
};
|
|
|
|
|