[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: A C++ wrapper class
- From: "Joshua Jensen" <jjensen@...>
- Date: Wed, 13 Dec 2000 08:20:10 -0000
As I've used Lua over the years, I've always written a C++ wrapper to
simplify my life. It is extremely lightweight, but it does do some
useful functionality that is otherwise obscure.
The archive may be found at
The documentation (what little there is) is at
documentation was made through Doxygen (see the Links page of
The wrapper is a class called Script. What does Script do that is
special, besides providing a halfway object oriented approach to Lua?
* A nested class Script::Object represents an object on the Lua
stack. Encapsulates the stack index of the given object. (You can
refer to Lua objects by their C variable name, not by index.)
* Script::Object contains the parent script, making it possible to
pass Script::Object objects to functions and retrieve the script, if
* Script::Object provides a method of creating a named table through
a single function, CreateTable().
* Simple methods for setting a number, string, or user data into the
* Two methods in Script::Object for finding a particular table
element: GetByName() and GetByIndex() (for arrays).
* A nested class Script::AutoBlock represents a way of automatically
restoring the stack state when AutoBlock falls out of scope.
(Helpful for not leaving extraneous stuff on the stack.)
* Provides a Lua function, CopyTable(), that does a deep copy of a
* .ini file-like configuration function, Script::ConfigGet*() and
* Script::SaveText() dumps out the current Lua state to a file.
Originally modeled after the Lua test program. Has been reworked to
format everything in a "pretty" fashion.
The archive above contains a copy of the Lua source, the Script
class, some test code, and Visual C++ projects. The code should be
portable to other compilers.
Lua has been a great tool to work with, and in some cases, a life
saver. Thanks go to the authors for such a great product.
Author, Workspace Whiz! - A Visual Studio Add-in
Author, Script (A Lua Wrapper)