LuaPlus for Lua 5.01 Distribution
C++ Enhancements to Core Lua Functionality
http://wwhiz.com/LuaPlus/index.html
Author: Joshua Jensen (jjensen@workspacewhiz.com)
Build 1081 (3/4/04)
- LuaPlus Global:
- Corrects another couple bugs due to adding support for bitwise
operators in the last build.
- If a lookup is attempted on a value that is not a table (or for
other failing operators), a LuaPlus::LuaException is thrown.
- When LUA_REFCOUNT is on, building the default meta tables at state
startup would fail. Fixed.
- When LUA_REFCOUNT is in use, wide character strings would cause
crashes. Fixed.
- LuaObject:
- IsConvertibleToNumber() and IsConvertibleToInteger() were broken.
Fixed.
- ManagedLuaPlus:
- Iterator support for tables through LuaTableIterator.
for (LuaTableIterator it = new LuaTableIterator(theObject); it.IsValid();
++it)
{
// Reference through it.GetKey() and it.GetValue().
}
- foreach support for tables using LuaNode (see ManagedLuaPlusTest/Class1.cs
for an example).
foreach (LuaNode node in theObject)
{
// Reference through node.Key and node.Value.
}
- If a lookup is attempted on a value that is not a table (or for
other failing operators), a ManagedLuaPlus::LuaException is thrown.
Build 1080a (3/1/04)
- Build 1080a was released 3/1/04 with some bugs and missing files.
- Build 1080 was released 2/28/04 with some bugs and missing files.
- Please note: This build of LuaPlus contains significant changes from
previous builds in order to support some powerful new features. Move
forward with caution.
- LuaPlus Global:
- All wide character strings represented as lua_WChar instead of wchar_t.
- Upgraded to Lua 5.0.1.
- All LCD functionality moved to standalone LuaPlusLCD.h.
- LuaFunctorList removed since functor types are better fits now.
- Support for Pocket PC. In particular ARMV4 and the emulator has
been tested.
- The lexer understands both single byte and double byte streams.
- Better cross platform support thanks to Brian Sharon and Philip Jones.
- DLL and library binaries renamed to include an _1080 (the build number)
at the end of the file name.
- The garbage collection was broken for LUA_TTHREAD. Fixed.
- Lots of code cleanups for better portability.
- LuaObject:
- Compile time assertions in place to ensure LuaObject's size matches
lua_TObject.
- IsInteger() function added. Tests whether the type of the
LuaObject is an integer.
- IsConvertibleToInteger() function added.
- ToInteger() function added.
- Clone() function copies metatables now.
- Due to vararg functions not accepting POD data types, PCall() has been
removed. It has numerous issues that are not fixable, especially on
conforming C++ compilers.
- SetInteger() functions added, mirroring the other Set*() functions.
- AssignInteger() function added, mirroring the other Assign*() functions.
- All Register() functions accept upvalues now.
- The Register() functions for LuaFunctorLists have been removed.
- RegisterEx() renamed to RegisterObjectDirect() to accommodate the
addition of other Register*() functions.
- RegisterDirect() functions added.
- RegisterObjectFunctor() function added.
- LuaFunction<> (using the default void parameter) has been changed to
LuaFunctionVoid. Certain older compilers can't accept template
arguments of void. All other return argument types for LuaFunction<T>
work fine.
- The operator() has been removed due to compiler incompatibilities.
Instead, get access to the same functionality like this:
LuaCall call = theLuaObject;
call << 5 << LuaRun();
- Additional types to LuaCall can be added through global functions in
the form:
LuaCall& operator<<(LuaCall& call, float value);
- SetInteger() functions added.
- AssignInteger() function added.
- DoWString(), LoadWBuffer(), and DoWBuffer() added for the wide
string equivalents of the non 'W' functions.
- LuaStackObject:
- Added IsInteger(), GetInteger(), and SetInteger().
- Added another overload of SetLightUserData().
- Register() functions removed. Use the PushCClosure variants.
- Due to vararg functions not accepting POD data types, PCall() has been
removed. It has numerous issues that are not fixable, especially on
conforming C++ compilers.
- LuaState:
- PushInteger() added.
- DoWString(), LoadWBuffer(), and DoWBuffer() added. Works with
a wide character input buffer.
- Remote Lua Debugger:
- The remote debugger has an Output bar for output strings.
Thanks to Evan Wies.
- The remote debugger also has a Command bar to execute code in.
Thanks go to Evan Wies.
- Crash bug fixed.
- Wide character string support implemented.
- Preliminary support for multiple Lua states, although not working.
- Upgraded to latest Scintilla viewer/editor.
- LuaNetworkServer:
- Modules:
- Lua:
- Hex numbers understood in the form of 0x12345678.
- Integers:
- Operators for bitwise and (&), bitwise or (|), bitwise xor (^), bit shift
left (<<), and bit shift right (>>) added.
- LuaRemoteDebuggingServer:
- In preparation for the debugger being able to handle multiple Lua
states, a new RegisterState() function is available and the Initialize()
signature has changed so the LuaState* is not passed in. Use it
like:
LuaRemoteDebuggingServer::RegisterState("State", g_luaScript);
LuaRemoteDebuggingServer::Initialize();
- LuaPlus Debugger add-in for Visual Studio .NET:
- Tree expansion works properly for nested tables.
- Works with Visual Studio .NET 2002 and 2003.
- LuaWatchAddin:
- Supports wide character strings.
- Samples:
- TestScript:
- MultiObjectTest() added to demonstrate the various Register*()
functions.
- TestANSIFile() and TestUnicodeFile() added to test the ANSI and
Unicode file reading capabilities.
- Windows CE support.
Known Issues
- If a Lua function calls a C callback and the C callback calls a Lua
function that errors (or somebody calls lua_error()), LuaObject objects aren't
cleaned up, because setjmp() is not compatible with C++ exception handling.
This will be fixed in an upcoming build.
- Remote Lua Debugger:
- Some of the formatting in the Locals or Watch grid windows can be a little
large. This deals with tabbed spacing for expanded trees.
- During serialization, tables can't
currently be cyclic and metatables aren't currently written.
- LuaStackObject's API no longer matches LuaObject's API.
Build 1078 (11/7/03)
- LuaPlus Global:
- All LCD callback functionality now runs
luaL_argcheck
instead of an assert
for argument checking.
- The calling signature for LuaPlus callbacks has changed. I don't
like to make changes like this, and it affected a great deal of my code.
However, the reasons leading up to it were thought long and hard about.
The old signature was of the form:
int Callback(LuaState* state, LuaStackObject* args);
When in this form, it was very easy to access arguments on the Lua stack.
There were also limitations to this method. In fact, no more than 20
arguments could be accessed through the args
array. This was
sufficient for every case I ever heard of, but there was a memory cost, too.
As I've dived into coroutines, I realized I had bloated the LuaState class
by a significant amount. Most of the bloat has been removed.
Part of the bloat was the internal storage of the LuaStackObjects for the
arguments.
The new signature is of the form:
int Callback(LuaState* state);
The args parameter is missing. However, it is easily replaced in the
first line of the callback as:
LuaStack args(state);
Unless a reference was taken to one of the past args array indices, all code
will compile fine with the addition of the LuaStack line. It can still
be referenced as if it was an array.
- All projects have been upgraded to VS.NET 2003 form. If you don't
already have VS.NET 2003, get it. It's worth the upgrade for the
stability and the improved C++ compiler. If you or your company simply
can't migrate, consider moving the projects back to VS.NET 2002 form via the
tool:
http://jsp.mobikom.com/stoyan/vspc/vspc.html
- LuaObject:
- RegisterEx() now registers the callback in the LuaObject it is being
called through instead of as a global.
- operator[](const char*) is now much more memory efficient.
Whereas Lua, when looking up a table entry by key, requires insertion of
the lookup string into the string table, only to possibly be garbage
collected later, LuaObject's operator[] doesn't insert anything into the
Lua string table.
- LuaState:
- In an effort to save LuaState space, particularly when creating coroutines,
an array of LUA_MINSTACK LuaStackObjects is no longer kept around.
Instead, it is allocated on the fly on the stack before calling the callback
function.
- m_tweakMeToSeeStuff has been removed.
- The Stack() function now has an implementation.
- New helper functions:
- TypeError - Mirrors luaL_typerror.
- ArgError - Mirrors luaL_argerror.
- CheckLString - Mirrors luaL_checklstring.
- OptLString - Mirrors luaL_optlstring.
- CheckNumber - Mirrors luaL_checknumber.
- OptNumber - Mirrors luaL_optnumber.
- ArgCheck - Mirrors luaL_argcheck.
- CheckString - Mirrors luaL_checkstring.
- OptString - Mirrors luaL_optstring.
- CheckInt - Mirrors luaL_checkint.
- CheckLong - Mirrors luaL_checklong.
- OptInt - Mirrors luaL_optint.
- OptLong - Mirrors luaL_optlong.
- CheckStack - Mirrors luaL_checkstack.
- CheckType - Mirrors luaL_checktype.
- CheckAny - Mirrors luaL_checkany.
- CheckUData - Mirrors luaL_checkudata.
- Integration of Leszek Buczowski's break/continue code.
- LuaPlus Modules
- bit
- Added Bitwise Operations Library from Reuben Thomas.
- iox
- New library adds lots of Windows specific I/O functions.
- pipe
- Didn't work properly after the Lua 5.0 upgrade. Fixed.
- ManagedLuaPlus
- Operational but not as complete as the C++ LuaObject yet. In
particular, complete support for calling arbitrary .NET functions is
missing.
- .NET callbacks implemented.
- LuaWatchAddin:
- Upgraded the display of TStrings to include the LUA_TWSTRING format.
- A bunch of other stuff.
Build 1076 (5/17/03)
- Upgraded to Lua 5.0 Final.
- LuaPlus Global:
- Removed Rich Hickey's CALLBACK.HPP in favor of LuaPlus/LuaFunctor.h, which
is a LuaPlus specific functor dispatcher.
- Added new LuaFunctorList class to allow building of lists of functors,
similar to the Lua C mechanism.
- Namespace LuaPlus::LCD added for all related Lua Call Dispatcher
functionality.
- LuaFunction:
- Added this new class that enables Lua functions to be called as if they
were regular C++ functions.
- LuaObject:
- Added short documentation snippets above each function describing which
Lua C function is mirrored.
- GetTypeName() has been renamed to TypeName().
- GetType() has been renamed to Type().
- IsNumber()'s inline documentation update describes it doesn't behave the
same as lua_isnumber().
- IsString()'s inline documentation update describes it doesn't behave the
same as lua_isstring().
- Added IsConvertibleToNumber(), which mirrors lua_isnumber() behavior.
- Added IsConvertibleToString(), which mirrors lua_isstring() behavior.
- Added IsConvertibleToWString().
- Added ToNumber(), mirroring lua_tonumber().
- Added ToString(), mirroring lua_tostring().
- Added ToWString(), which converts a number or ANSI string to a wide
character string.
- Added ToStrLen(), mirroring lua_strlen() (which gives the string length of
the converted form).
- All Set*() functions return a reference to themselves, allowing simpler
specification of table manipulation. Example:
myTableObj.SetString("Key1", "Value").SetString("Key2", "Value2");
- All Assign*() functions take a LuaState* parameter now. This
complicates their usage, but it was awkward to, say, assign a table to a
LuaObject that wasn't assigned a state.
- The Register() function can take a LuaFunctorList pointer.
- The Register() function for functors no longer needs a call to the old
style makeFunctor(). It is capable of interpreting the parameters into a
functor without any further effort than to simply hand off the function
pointer and optionally, the this pointer.
- Added RegisterEx() function for handling the new-style LuaPlus Callback
Dispatcher mechanism, which can directly call C/C++ functions without writing
Lua callbacks.
- LuaState:
- The new loadlib library is registered as part of the standard library
initialization process when creating a state.
- Equal_Stack() renamed to Equal().
- Added RawEqual().
- LessThan_Stack() renamed to LessThan().
Builds 1071-1075
Build 1070 (2/17/03)
Build 1069 (2/12/03)
- LuaState:
- DumpObject() has been upgraded to handle key values that aren't perfectly
printable to a file. Instead, the same mechanism used to format the
values from the key/value pair to the file is used for the keys, too.
- DumpFile() has been renamed into DumpObject() for consistency.
- DumpObject() has overloads for LuaObject keys, in addition to the old
const char* name.
- DumpGlobals() can take either a const char* filename or a LuaStateOutFile&.
- All Dump*() calls can take any of the following flags:
DUMP_ALPHABETICAL
- Alphabetize the keys when writing to the file.
DUMP_WRITEALL
- Write all Lua objects out, including function and user
data information.
DUMP_WRITETABLEPOINTERS
- If
DUMP_WRITEALL
is specified, the actual memory addresses of tables are
written in comment form.
- For the filename versions of the Dump*() functions, passing an "@" as the
filename will log the serialization to OutputDebugString.
- Some code reorganization (moved LuaState functions from LuaPlus.cpp to
LuaState.cpp).
- New module, FileFind, added. It was made from some code previously
in LuaPlusFunctions.cpp.
- ManagedLuaPlus:
- Support for LuaState::DumpGlobals() has been added to the ManagedLuaPlus wrapper.
Build 1068 (1/29/03)
- If Lua thread states are created, LuaObjects from threads other than the
calling garbage collection thread won't be marked and will be cleaned up, even
though they are still in existence. This problem, stemming from the
upgrade for Lua 5.0, has now been fixed.
- Added a new multiple thread test case in the TestScript sample. See
function TestThreeThreads().
- Removed the auto linking of the LuaPlus library. The LuaPlus DLL
export library is still auto linked.
- In order to turn on LuaPlus namespace support, uncomment the line reading
#define LUAPLUS_USE_NAMESPACE
in LuaLink.h.
- #ifdef WIN32 segments added to a whole bunch of Windows specific parts of
the code. In theory, LuaPlus's core should compile on another OS.
- Non-wide character "\xff" strings were incorrectly read.
- LuaState:
- CreateThread() no longer asks for a parameter indicating whether the
standard libraries should be initialized.
- Fixed a bug when dumping a quoted binary string in ANSI form.
- Readded DumpGlobals().
- LuaState has no more virtual functions. This caused the DLL class
signature to change, so modules will have to be rebuilt.
- ManagedLuaPlus:
- Watch window support added. See the main LuaPlus documentation for
setup.
- LuaObject::AssignString() works now.
- LuaObject::AssignWString() works now.
- Visual Studio .NET LuaPlus Debugger add-in:
- Updated so the tools command is always available and never gets lost by
Visual Studio .NET.
- Tools menu command is grayed out if the debugger is not active.
- LuaRemoteDebuggingServer project:
- Reliance on ATL's CString has been removed. CStdString, compatible
with CString but built on std::string, is used in its stead.
Build 1067 (1/16/03)
- Fixed some parts of the Unicode text file support in liolib.c. In
particular, reading lines was broken.
- Fixed wide character string concatenation. It must have become
broken in the 5.0 Alpha upgrade, because it worked in LuaState 4.1 Alpha.
- Fixed quoted binary string formatting in both the single and wide
character libs.
- Forgot to initialize the wide string library.
Build 1066 (1/11/03)
- Fixed LuaObject::StrLen() to return the right string length for wide
character strings.
- Brought the LuaPlus Debugger VS .NET add-in back online.
- Added the capability to the specialized LuaObject function calling
convention to specify the number of return arguments through an argument to
LuaRun:
addFunction() << 5 << 10 << LuaRun(1);
- Also added the ability to the LuaObject << calling convention to handle
LuaStackObjects and LuaObjects.
- Changed LuaObject::GetN() so it mirrors Lua's table.getn().
- Added LuaObject::SetN(), mirroring Lua's table.setn().
- Added LuaObject::Insert(), mirroring Lua's table.insert().
- Added LuaObject::Remove(), mirroring Lua's table.remove().
- Added LuaObject::Sort(), mirroring Lua's table.sort().
- A bunch of documentation updates, particularly concerning LuaObjects.
Build 1065
- Upgraded to Lua 5.0 Beta.
- The LuaState object entirely creates itself under the memory allocation
routines set by lua_setdefaultmemoryfunctions().
- Although not mentioned previously, LuaPlus can exist side-by-side with
another Lua version. This works really well if the project you're
working on has lots of legacy Lua 3 or Lua 4 code. You can get the
benefits of LuaPlus and slowly migrate the other code as appropriate.
See LuaLink.h.
- lua_getdefaultreallocfunction() renamed to lua_getdefaultmemoryfunctions(),
because Lua 5.0 Beta expects a free() function in addition to realloc().
- lua_setdefaultreallocfunction() renamed to lua_setdefaultmemoryfunctions(),
because Lua 5.0 Beta expects a free() function in addition to realloc().
- New LuaState functions mirroring their lua_* counterparts: CPCall(),
Dump().
- The LuaPlus VS .NET "debugger" add-in (the one that just views tables
right now) has not been ported over to the new Lua build. That will
happen next time. The LuaWatchAddin, however, does work.
Build 1062
- Renamed LuaC.exe to LuaPlusC.exe.
- Renamed Lua.exe to LuaPlus.exe.
- Namespaced so Lua.h can be kept out of the include chain, if the client
desires. See LuaLink.h.
- Added the LuaObject versions of the LuaHelper functions.
- Began merging in the updated LuaCOM library from the original authors.
- Brought the Managed C++ wrapper back online. Classes exist for
LuaState, LuaObject, LuaStackObject, and LuaAutoBlock.
- Added the optional comma support back into the parser for tables.
MyTable = { 1 2 3 4 }
- An experimental new typesafe calling convention. This has not been
tested thoroughly yet and works something like:
state->DoString("function Add(x, y) return x + y end");
LuaObject funcObj = state->GetGlobal("Add");
LuaStackObject retObj = funcObj() << 2 << 5 << LuaRun();
- HelperLuaFunctions.lua CopyTable() and GetN() functions have been removed.
- Scintilla source directory removed. It shouldn't have been there in
the first place.
Build 1061
- LuaObject::Clone() function added. Clones any LuaObject, including
tables. This results in a deep copy.
- LuaObject::GetCount() is synonymous to LuaObject::GetN().
- Added LuaObject::GetTableCount() which counts the total elements in the
table.
- Added LuaObject::operator< which will compare two LuaObjects and determine
if one is less than the other.
- Removed outputting of the semicolon in LuaState::DumpObject().
- Fixed LuaState::DumpObject() to dump the correct table value in a
non-alphabetical list.
- Renamed LuaState::Object() to LuaState::Stack().
- Added LuaState::LessThan_Stack.
Build 1060