lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


----- Original Message -----
From: Tim Mensch
Date: 4/24/2009 2:39 PM
LuaPlus is pretty heavy, but you can grab just the LuaPlus Call Dispatcher (luapluscd.h) and use it on its own--that would at least allow you to trivially call C++ member functions from within Lua. I do that in Playground SDK.
I hear this often. Under Visual Studio 2008, the most minimal LuaPlus adds 4 kilobytes to the size of the executable. I'm not convinced it is even a full 4k; the size of the executable just grows by that much. There was once a Playground SDK forum posting about LuaPlus adding 100k to the image size. This occurred when the function to add the standard set of Lua libraries was in the same compilation unit as the function that just initialized the Lua state without standard libraries. When these two functions were separated, this problem went away.

In luaconf.h, there are a bunch of #defines to turn various features on and off, too.

I think the original article mentioned using Lua without accessing the stack (or the appearance of doing so). This is one of the places where LuaPlus shines. As an example of code I would never write for performance reasons:

for ( int i = 1; i < 1000; ++i )
printf( "%d", luaState->GetGlobals()[ "SomeBigArray" ][ "InnerStuff" ][ i ].GetInteger() );

LuaObject valueObj;
valueObj.AssignString( luaState, "hello" ); // This isn't on the Lua stack... it actually exists on the C stack.

LuaFunction<int> Add( luaState->GetGlobal( "Add" ) );
int returnValue = Add( 5, 10 );

The Lua stack is definitely confusing. I find myself writing comments next to every line that manipulates the stack so I understand what I am intending and can visually determine which stack indices to access.

In any case, make sure you access the latest code at svn://svn.luaplus.org/LuaPlus/work51.

Josh