Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/core
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2023-07-03 08:51:42 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2023-07-03 08:51:42 +1000
commit398a5655f42378176a1e596af6d399a180ffb733 (patch)
tree88b5d6a9c389a55f5f10a5243188cdf5de7c553a /source/core
parentd7ba1136883de9392bb929df5772dba7f8bf49df (diff)
Add Drawable <-> Lua conversion to LuaGameConverters
Diffstat (limited to 'source/core')
-rw-r--r--source/core/StarLua.cpp4
-rw-r--r--source/core/StarLua.hpp6
-rw-r--r--source/core/StarLuaConverters.hpp8
-rw-r--r--source/core/StarVector.hpp1
4 files changed, 9 insertions, 10 deletions
diff --git a/source/core/StarLua.cpp b/source/core/StarLua.cpp
index 93ed516..3b04fc8 100644
--- a/source/core/StarLua.cpp
+++ b/source/core/StarLua.cpp
@@ -464,10 +464,10 @@ LuaString LuaEngine::createString(char const* str) {
return LuaString(LuaDetail::LuaHandle(RefPtr<LuaEngine>(this), popHandle(m_state)));
}
-LuaTable LuaEngine::createTable() {
+LuaTable LuaEngine::createTable(int narr, int nrec) {
lua_checkstack(m_state, 1);
- lua_newtable(m_state);
+ lua_createtable(m_state, narr, nrec);
return LuaTable(LuaDetail::LuaHandle(RefPtr<LuaEngine>(this), popHandle(m_state)));
}
diff --git a/source/core/StarLua.hpp b/source/core/StarLua.hpp
index 2c108ef..41310a3 100644
--- a/source/core/StarLua.hpp
+++ b/source/core/StarLua.hpp
@@ -505,7 +505,7 @@ public:
LuaString createString(String const& str);
LuaString createString(char const* str);
- LuaTable createTable();
+ LuaTable createTable(int narr = 0, int nrec = 0);
template <typename Container>
LuaTable createTable(Container const& map);
@@ -1890,7 +1890,7 @@ T LuaEngine::luaTo(LuaValue const& v) {
template <typename Container>
LuaTable LuaEngine::createTable(Container const& map) {
- auto table = createTable();
+ auto table = createTable(0, map.size());
for (auto const& p : map)
table.set(p.first, p.second);
return table;
@@ -1898,7 +1898,7 @@ LuaTable LuaEngine::createTable(Container const& map) {
template <typename Container>
LuaTable LuaEngine::createArrayTable(Container const& array) {
- auto table = createTable();
+ auto table = createTable(array.size(), 0);
int i = 1;
for (auto const& elem : array) {
table.set(LuaInt(i), elem);
diff --git a/source/core/StarLuaConverters.hpp b/source/core/StarLuaConverters.hpp
index bf030cd..c20442f 100644
--- a/source/core/StarLuaConverters.hpp
+++ b/source/core/StarLuaConverters.hpp
@@ -63,10 +63,10 @@ struct LuaConverter<Vector<T, N>> {
template <typename T>
struct LuaConverter<Matrix3<T>> {
static LuaValue from(LuaEngine& engine, Matrix3<T> const& m) {
- auto table = engine.createTable();
- table.set(1, luaFrom(engine, m.row1));
- table.set(2, luaFrom(engine, m.row2));
- table.set(3, luaFrom(engine, m.row3));
+ auto table = engine.createTable(3, 0);
+ table.set(1, m[0]);
+ table.set(2, m[1]);
+ table.set(3, m[2]);
return table;
}
diff --git a/source/core/StarVector.hpp b/source/core/StarVector.hpp
index aaa5909..16d9d42 100644
--- a/source/core/StarVector.hpp
+++ b/source/core/StarVector.hpp
@@ -212,7 +212,6 @@ public:
template <size_t P = N>
Enable4DOrHigher<P> setW(T const& t);
-private:
using Base::size;
using Base::empty;
};