|
Luís Santos wrote:
I was wondering how to create a fast integration between C++ and Lua concerning the passing of tables from either side to the other.. My wonderings led me to create a set of C++ classes that reference tables on Lua.. the problem: all tables accessed by their C++ references would have either to:LuaPlus does exactly this, bypassing the Lua stack altogether. Bear in mind that LuaPlus modifies the core Lua code (adding some patching into the garbage collector). Regardless, I've often used LuaPlus to process recursive multi-megabyte data sets without giving a second thought to stack management, since LuaPlus's is handled through C++'s deterministic finalization for LuaObjects. For instance, a test in the LuaPlus test suite reads: ////////////////////////////////////////////////////////////////////////// TEST(LuaObject_LotsOTables) { std::list<LuaObject> lotsOTables; LuaStateOwner state; for (size_t i = 0; i < 100000; ++i) { LuaObject tableObj; tableObj.AssignNewTable(state); tableObj.SetNumber("SomeNumber", i); // Create newTable.SomeNumber = i; lotsOTables.push_back(tableObj); } size_t i = 0; for (std::list<LuaObject>::iterator it = lotsOTables.begin(); it != lotsOTables.end(); ++it, ++i) { LuaObject& tableObj = (*it); CHECK(tableObj.IsTable()); LuaObject someNumberObj = tableObj["SomeNumber"]; CHECK(someNumberObj.IsNumber()); CHECK(someNumberObj.GetNumber() == i); } } Josh |