115 explicit LuaTable(lua_State *l,
int array_s,
int hash_s) :
118 lua_createtable(
m_lua, array_s, hash_s);
132 template <
class Value,
class Key>
133 Value
Get(
const Key &key)
const;
136 template <
class Value,
class Key>
137 Value
Get(
const Key &key, Value default_value)
const;
138 template <
class Value,
class Key>
139 LuaTable Set(
const Key &key,
const Value &value)
const;
141 template <
class Value>
144 template <
typename... Values>
147 template <
class Ret,
class Key,
class... Args>
148 Ret
Call(
const Key &key,
const Args &... args)
const;
149 template <
class Key,
class... Args>
150 void Call(
const Key &key,
const Args &... args)
const
152 Call<bool>(key, args...);
154 template <
class Ret1,
class Ret2,
class... Ret,
class Key,
class... Args>
155 std::tuple<Ret1, Ret2, Ret...>
Call(
const Key &key,
const Args &... args)
const;
157 template <
class Key,
class... Args>
160 Call<bool>(key, *
this, args...);
162 template <
class Ret,
class Key,
class... Args>
165 return Call<Ret>(key, *
this, args...);
167 template <
class Ret1,
class Ret2,
class... Ret,
class Key,
class... Args>
168 std::tuple<Ret1, Ret2, Ret...>
CallMethod(
const Key &key,
const Args &... args)
const
170 return Call<Ret1, Ret2, Ret...>(key, *
this, args...);
173 template <
class PairIterator>
175 template <
class ValueIterator>
178 template <
class Key,
class Value>
179 std::map<Key, Value>
GetMap()
const;
194 template <
class Value>
209 m_dirtyCache(true) {}
213 m_currentIndex(currentIndex),
215 m_dirtyCache(true) {}
217 m_table(copy.m_table),
218 m_currentIndex(copy.m_currentIndex),
220 m_dirtyCache(true) {}
224 m_table = copy.m_table;
225 m_currentIndex = copy.m_currentIndex;
247 if (m_table) --m_currentIndex;
253 if (m_table) --m_currentIndex;
257 bool operator==(
const VecIter &other)
const {
return (m_table == other.m_table && m_currentIndex == other.m_currentIndex); }
258 bool operator!=(
const VecIter &other)
const {
return (m_table != other.m_table || m_currentIndex != other.m_currentIndex); }
271 void CleanCache() { m_dirtyCache =
true; }
275 m_cache = m_table->
Get<Value>(m_currentIndex);
276 m_dirtyCache =
false;
285 template <
class Value>
287 template <
class Value>
344template <
class Value,
class Key>
354template <
class Value,
class Key>
358 if (!(lua_isnil(
m_lua, -1)))
361 return default_value;
364template <
class Value,
class Key>
373template <
class Value>
382template <
typename... Values>
385 (..., PushBack<Values>(values));
389template <
class Key,
class Value>
393 std::map<Key, Value> ret;
409template <
class PairIterator>
412 for (PairIterator it = beg; it != end; ++it)
413 Set(it->first, it->second);
417template <
class ValueIterator>
421 int i = lua_tointeger(
m_lua, -1) + 1;
423 for (ValueIterator it = beg; it != end; ++it, ++i)
428template <
class Ret,
class Key,
class... Args>
434 lua_checkstack(
m_lua,
sizeof...(args) + 3);
444template <
class Ret1,
class Ret2,
class... Ret,
class Key,
class... Args>
445std::tuple<Ret1, Ret2, Ret...>
LuaTable::Call(
const Key &key,
const Args &... args)
const
448 lua_checkstack(
m_lua,
sizeof...(args) + 3);
453 lua_pop(
m_lua,
static_cast<int>(
sizeof...(Ret)) + 2);
455 return return_values;
462 m_cache = m_table->Sub(m_currentIndex);
463 m_dirtyCache =
false;
469 if (!m_dirtyCache && m_cache.GetLua()) {
470 lua_remove(m_cache.GetLua(), m_cache.GetIndex());
void pi_lua_generic_pull(lua_State *l, int index, ObjectType &objectType)
Definition: LuaBody.cpp:865
bool pi_lua_strict_pull(lua_State *l, int index, Color4ub &out)
Definition: LuaColor.h:27
void pi_lua_multiple_push(lua_State *l, Types... args)
Definition: LuaPushPull.h:137
std::tuple< std::remove_reference_t< Types >... > pi_lua_multiple_pull(lua_State *l, int beg)
Definition: LuaPushPull.h:148
void pi_lua_generic_push(lua_State *l, const LuaTable &value)
Definition: LuaTable.h:475
#define LUA_DEBUG_START(luaptr)
Definition: LuaUtils.h:105
#define LUA_DEBUG_END(luaptr, expectedStackDiff)
Definition: LuaUtils.h:106
void pi_lua_protected_call(lua_State *L, int nargs, int nresults)
Definition: Sandbox.cpp:283
lua_State * GetLua() const
Definition: LuaRef.h:26
void PushCopyToStack() const
Definition: LuaRef.cpp:89
Definition: LuaTable.h:195
VecIter operator--()
Definition: LuaTable.h:245
Value value_type
Definition: LuaTable.h:199
VecIter(const VecIter ©)
Definition: LuaTable.h:216
VecIter operator++(int)
Definition: LuaTable.h:236
Value operator*()
Definition: LuaTable.h:259
VecIter operator--(int)
Definition: LuaTable.h:250
bool operator!=(const VecIter &other) const
Definition: LuaTable.h:258
std::ptrdiff_t difference_type
Definition: LuaTable.h:198
void operator=(const VecIter ©)
Definition: LuaTable.h:221
std::input_iterator_tag iterator_category
Definition: LuaTable.h:202
~VecIter()
Definition: LuaTable.h:210
VecIter()
Definition: LuaTable.h:205
bool operator==(const VecIter &other) const
Definition: LuaTable.h:257
VecIter(LuaTable *t, int currentIndex)
Definition: LuaTable.h:211
Value & reference
Definition: LuaTable.h:201
Value * pointer
Definition: LuaTable.h:200
VecIter operator++()
Definition: LuaTable.h:228
const Value * operator->()
Definition: LuaTable.h:264
Definition: LuaTable.h:99
Value Get(const Key &key) const
Definition: LuaTable.h:345
lua_State * m_lua
Definition: LuaTable.h:294
LuaTable PushValueToStack(const Key &key) const
Definition: LuaTable.h:330
int GetIndex() const
Definition: LuaTable.h:182
LuaTable(const LuaTable &ref)
Definition: LuaTable.h:102
void Call(const Key &key, const Args &... args) const
Definition: LuaTable.h:150
std::tuple< Ret1, Ret2, Ret... > CallMethod(const Key &key, const Args &... args) const
Definition: LuaTable.h:168
LuaTable Set(const Key &key, const Value &value) const
Definition: LuaTable.h:365
VecIter< Value > End()
Definition: LuaTable.h:288
~LuaTable()
Definition: LuaTable.h:122
std::map< Key, Value > GetMap() const
Definition: LuaTable.h:390
LuaTable LoadVector(ValueIterator beg, ValueIterator end) const
Definition: LuaTable.h:418
LuaTable & PushMultiple(Values &... value)
Definition: LuaTable.h:383
LuaTable(lua_State *l)
Definition: LuaTable.h:108
Ret Call(const Key &key, const Args &... args) const
Definition: LuaTable.h:429
Ret CallMethod(const Key &key, const Args &... args) const
Definition: LuaTable.h:163
LuaTable(lua_State *l, int index)
Definition: LuaTable.h:105
int m_index
Definition: LuaTable.h:295
VecIter< Value > Begin()
Definition: LuaTable.h:286
LuaTable(lua_State *l, int array_s, int hash_s)
Definition: LuaTable.h:115
lua_State * GetLua() const
Definition: LuaTable.h:181
size_t Size() const
Definition: LuaTable.h:183
LuaTable & PushBack(Value &value)
Definition: LuaTable.h:374
LuaTable()
Definition: LuaTable.h:291
LuaTable LoadMap(PairIterator beg, PairIterator end) const
Definition: LuaTable.h:410
const LuaTable & operator=(const LuaTable &ref)
Definition: LuaTable.h:124
LuaTable Sub(const Key &key) const
Definition: LuaTable.h:338
void CallMethod(const Key &key, const Args &... args) const
Definition: LuaTable.h:158
Definition: LuaTable.h:298
ScopedTable & operator=(const ScopedTable &)=delete
ScopedTable(const ScopedTable &)=delete
ScopedTable(lua_State *l)
Definition: LuaTable.h:308
ScopedTable(const LuaTable &t)
Definition: LuaTable.h:300
ScopedTable(const LuaRef &r)
Definition: LuaTable.h:310
~ScopedTable()
Definition: LuaTable.h:322
IMGUI_API void Value(const char *prefix, const std::string &str)
Definition: PerfInfo.cpp:188