diff options
| author | jacqueline <me@jacqueline.id.au> | 2024-01-15 12:31:20 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2024-01-15 12:31:20 +1100 |
| commit | 7cdcd44e0ca10ebdc796638190ed1d9b45d99ef0 (patch) | |
| tree | 637b43848d17c9dbdc1688cb4733eb235f223e37 /src/lua/lua_database.cpp | |
| parent | 0e04eb918ec976017276306181282769d8896c83 (diff) | |
| download | tangara-fw-7cdcd44e0ca10ebdc796638190ed1d9b45d99ef0.tar.gz | |
Begin migration of remaining screens to Lua
Diffstat (limited to 'src/lua/lua_database.cpp')
| -rw-r--r-- | src/lua/lua_database.cpp | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/src/lua/lua_database.cpp b/src/lua/lua_database.cpp index 82b22343..ac7d711b 100644 --- a/src/lua/lua_database.cpp +++ b/src/lua/lua_database.cpp @@ -73,8 +73,38 @@ static auto indexes(lua_State* state) -> int { return 1; } -static const struct luaL_Reg kDatabaseFuncs[] = {{"indexes", indexes}, - {NULL, NULL}}; +static auto version(lua_State* L) -> int { + Bridge* instance = Bridge::Get(L); + auto db = instance->services().database().lock(); + if (!db) { + return 0; + } + auto res = db->schemaVersion(); + lua_pushlstring(L, res.data(), res.size()); + return 1; +} + +static auto size(lua_State* L) -> int { + Bridge* instance = Bridge::Get(L); + auto db = instance->services().database().lock(); + if (!db) { + return 0; + } + lua_pushinteger(L, db->sizeOnDiskBytes()); + return 1; +} + +static auto recreate(lua_State* L) -> int { + return 0; +} + +static auto update(lua_State* L) -> int { + return 0; +} + +static const struct luaL_Reg kDatabaseFuncs[] = { + {"indexes", indexes}, {"version", version}, {"size", size}, + {"recreate", recreate}, {"update", update}, {NULL, NULL}}; /* * Struct to be used as userdata for the Lua representation of database records. |
