summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorailurux <ailuruxx@gmail.com>2024-05-10 13:27:01 +1000
committerailurux <ailuruxx@gmail.com>2024-05-10 13:27:01 +1000
commite06610f3a6d2bf034a20cc1b59fb25dc5efdda0a (patch)
treef01b8f0308824667fa5d8f4238159313b7b6e4ad /src
parent0062eb9a9ea265c7802d3c4bc8c1cd043cefbea3 (diff)
downloadtangara-fw-e06610f3a6d2bf034a20cc1b59fb25dc5efdda0a.tar.gz
Minor fixes before PR
Diffstat (limited to 'src')
-rw-r--r--src/tangara/lua/file_iterator.cpp4
-rw-r--r--src/tangara/lua/file_iterator.hpp4
-rw-r--r--src/tangara/lua/lua_filesystem.cpp30
-rw-r--r--src/tangara/lua/lua_filesystem.hpp2
4 files changed, 20 insertions, 20 deletions
diff --git a/src/tangara/lua/file_iterator.cpp b/src/tangara/lua/file_iterator.cpp
index 3afc57aa..d0eb0bae 100644
--- a/src/tangara/lua/file_iterator.cpp
+++ b/src/tangara/lua/file_iterator.cpp
@@ -11,7 +11,7 @@
#include "ff.h"
#include "drivers/spi.hpp"
-namespace database {
+namespace lua {
[[maybe_unused]] static const char* kTag = "FileIterator";
@@ -84,4 +84,4 @@ auto FileIterator::iterate(bool reverse) -> bool {
return true;
}
-} // namespace database \ No newline at end of file
+} // namespace lua \ No newline at end of file
diff --git a/src/tangara/lua/file_iterator.hpp b/src/tangara/lua/file_iterator.hpp
index 82d6f397..b803062c 100644
--- a/src/tangara/lua/file_iterator.hpp
+++ b/src/tangara/lua/file_iterator.hpp
@@ -11,7 +11,7 @@
#include "ff.h"
-namespace database {
+namespace lua {
// Note for when reading FILINFO, that we are in LFN mode:
// http://elm-chan.org/fsw/ff/doc/sfileinfo.html
@@ -42,4 +42,4 @@ class FileIterator {
auto iterate(bool reverse = false) -> bool;
};
-} // namespace database \ No newline at end of file
+} // namespace lua \ No newline at end of file
diff --git a/src/tangara/lua/lua_filesystem.cpp b/src/tangara/lua/lua_filesystem.cpp
index ea08ca48..de51f555 100644
--- a/src/tangara/lua/lua_filesystem.cpp
+++ b/src/tangara/lua/lua_filesystem.cpp
@@ -28,7 +28,7 @@ struct LuaFileEntry {
static_assert(std::is_trivially_destructible<LuaFileEntry>());
static_assert(std::is_trivially_copy_assignable<LuaFileEntry>());
-static auto push_lua_file_entry(lua_State* L, const database::FileEntry& r) -> void {
+static auto push_lua_file_entry(lua_State* L, const lua::FileEntry& r) -> void {
// Create and init the userdata.
LuaFileEntry* file_entry = reinterpret_cast<LuaFileEntry*>(
lua_newuserdata(L, sizeof(LuaFileEntry) + r.filepath.size()));
@@ -46,24 +46,24 @@ static auto push_lua_file_entry(lua_State* L, const database::FileEntry& r) -> v
std::memcpy(file_entry->path, r.filepath.data(), r.filepath.size());
}
-auto check_file_iterator(lua_State* L, int stack_pos) -> database::FileIterator* {
- database::FileIterator* it = *reinterpret_cast<database::FileIterator**>(
+auto check_file_iterator(lua_State* L, int stack_pos) -> lua::FileIterator* {
+ lua::FileIterator* it = *reinterpret_cast<lua::FileIterator**>(
luaL_checkudata(L, stack_pos, kFileIteratorMetatable));
return it;
}
-static auto push_iterator(lua_State* state, const database::FileIterator& it)
+static auto push_iterator(lua_State* state, const lua::FileIterator& it)
-> void {
- database::FileIterator** data = reinterpret_cast<database::FileIterator**>(
+ lua::FileIterator** data = reinterpret_cast<lua::FileIterator**>(
lua_newuserdata(state, sizeof(uintptr_t)));
- *data = new database::FileIterator(it); // TODO...
+ *data = new lua::FileIterator(it); // TODO...
luaL_setmetatable(state, kFileIteratorMetatable);
}
static auto fs_iterate_prev(lua_State* state) -> int {
- database::FileIterator* it = check_file_iterator(state, 1);
+ lua::FileIterator* it = check_file_iterator(state, 1);
it->prev();
- std::optional<database::FileEntry> res = it->value();
+ std::optional<lua::FileEntry> res = it->value();
if (res) {
push_lua_file_entry(state, *res);
@@ -75,9 +75,9 @@ static auto fs_iterate_prev(lua_State* state) -> int {
}
static auto fs_iterate(lua_State* state) -> int {
- database::FileIterator* it = check_file_iterator(state, 1);
+ lua::FileIterator* it = check_file_iterator(state, 1);
it->next();
- std::optional<database::FileEntry> res = it->value();
+ std::optional<lua::FileEntry> res = it->value();
if (res) {
push_lua_file_entry(state, *res);
@@ -89,13 +89,13 @@ static auto fs_iterate(lua_State* state) -> int {
}
static auto fs_iterator_clone(lua_State* state) -> int {
- database::FileIterator* it = check_file_iterator(state, 1);
+ lua::FileIterator* it = check_file_iterator(state, 1);
push_iterator(state, *it);
return 1;
}
static auto fs_iterator_gc(lua_State* state) -> int {
- database::FileIterator* it = check_file_iterator(state, 1);
+ lua::FileIterator* it = check_file_iterator(state, 1);
delete it;
return 0;
}
@@ -146,12 +146,12 @@ static auto fs_new_iterator(lua_State* state) -> int {
// Takes a filepath as a string and returns a new FileIterator
// on that directory
std::string filepath = luaL_checkstring(state, -1);
- database::FileIterator iter(filepath);
+ lua::FileIterator iter(filepath);
push_iterator(state, iter);
return 1;
}
-static const struct luaL_Reg kDatabaseFuncs[] = {{"iterator", fs_new_iterator},
+static const struct luaL_Reg kFilesystemFuncs[] = {{"iterator", fs_new_iterator},
{NULL, NULL}};
static auto lua_filesystem(lua_State* state) -> int {
@@ -167,7 +167,7 @@ static auto lua_filesystem(lua_State* state) -> int {
lua_settable(state, -3); // metatable.__index = metatable
luaL_setfuncs(state, kFileEntryFuncs, 0);
- luaL_newlib(state, kDatabaseFuncs);
+ luaL_newlib(state, kFilesystemFuncs);
return 1;
}
diff --git a/src/tangara/lua/lua_filesystem.hpp b/src/tangara/lua/lua_filesystem.hpp
index cb7170bd..d0f51498 100644
--- a/src/tangara/lua/lua_filesystem.hpp
+++ b/src/tangara/lua/lua_filesystem.hpp
@@ -10,7 +10,7 @@
namespace lua {
-auto check_file_iterator(lua_State*, int stack_pos) -> database::FileIterator*;
+auto check_file_iterator(lua_State*, int stack_pos) -> lua::FileIterator*;
auto RegisterFileSystemModule(lua_State*) -> void;