mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Allow creation of tables
This commit is contained in:
parent
12aac41b9e
commit
294e37f822
|
@ -145,6 +145,34 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
table create_table(T&& key, int narr = 0, int nrec = 0) {
|
||||
if(narr == 0 && nrec == 0) {
|
||||
lua_newtable(L.get());
|
||||
}
|
||||
else {
|
||||
lua_createtable(L.get(), narr, nrec);
|
||||
}
|
||||
|
||||
table result(L.get());
|
||||
lua_pop(L.get(), 1);
|
||||
global.set(std::forward<T>(key), result);
|
||||
return result;
|
||||
}
|
||||
|
||||
table create_table(int narr = 0, int nrec = 0) {
|
||||
if(narr == 0 && nrec == 0) {
|
||||
lua_newtable(L.get());
|
||||
}
|
||||
else {
|
||||
lua_createtable(L.get(), narr, nrec);
|
||||
}
|
||||
|
||||
table result(L.get());
|
||||
lua_pop(L.get(), 1);
|
||||
return result;
|
||||
}
|
||||
|
||||
table global_table() const {
|
||||
return global;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user