|
QLua
Lua-Qt bindings
|
Lua context. Creates or wraps an existing Lua state. More...
#include <LuaContext.h>

Classes | |
| struct | Method |
| Stores information used at method invocation time. | |
Public Types | |
| enum | ObjectDeleteMode { QOBJ_NO_DELETE, QOBJ_IMMEDIATE_DELETE, QOBJ_DELETE_LATER } |
| Delete mode: Specify how/if object shall be garbage collected. More... | |
Public Member Functions | |
| LuaContext (lua_State *L=0) | |
| lua_State * | LuaState () const |
| Return Lua state. | |
| void | Eval (const char *code) |
| Evaluate Lua code. | |
| void | AddQVariantMap (const QVariantMap &vm, const char *name=0) |
| Add QVariantMap: Either push it on the stack or set it as global. | |
| void | AddQVariantList (const QVariantList &vl, const char *name=0) |
| Add QVariantList: Either push it on the stack or set it as global. | |
| void | AddQStringList (const QStringList &sl, const char *name=0) |
| Add QStringList: Either push it on the stack or set it as global. | |
| template<typename T > | |
| void | AddQList (const QList< T > &l, const char *name=0) |
| Add QList of numeric values: Either push it on the stack or set it as global. | |
| void | AddQObject (QObject *obj, const char *tableName=0, bool cache=false, ObjectDeleteMode deleteMode=QOBJ_NO_DELETE, const ILuaSignatureMapper &mapper=LuaDefaultSignatureMapper(), const QStringList &methodNames=QStringList(), const QList< QMetaMethod::MethodType > &methodTypes=QList< QMetaMethod::MethodType >()) |
| Add QObject to Lua context as a Lua table. | |
| bool | OwnQObjects () const |
| Return value of global garbage collection policy. | |
| ~LuaContext () | |
| Destructor: Destroys Lua state if owned by this object. | |
Lua context. Creates or wraps an existing Lua state.
This class is the interface exposed by QLua to client code. Use the provided method to add QObjects and other types the Lua context and to evaluate Lua code. LuaContext is also used internally by other classes to add QObjects returned by methods or received from signals to the Lua context.
| qlua::LuaContext::LuaContext | ( | lua_State * | L = 0 | ) |
Constructor: Create qlua table with QLua interface.
| L | if not null the passed Lua state is used, otherwise a new one is created. |
| void qlua::LuaContext::AddQList | ( | const QList< T > & | l, |
| const char * | name = 0 |
||
| ) | [inline] |
Add QList of numeric values: Either push it on the stack or set it as global.
| l | QList |
| name | global name; if null value is left on the Lua stack. |
| void qlua::LuaContext::AddQObject | ( | QObject * | obj, |
| const char * | tableName = 0, |
||
| bool | cache = false, |
||
| ObjectDeleteMode | deleteMode = QOBJ_NO_DELETE, |
||
| const ILuaSignatureMapper & | mapper = LuaDefaultSignatureMapper(), |
||
| const QStringList & | methodNames = QStringList(), |
||
| const QList< QMetaMethod::MethodType > & | methodTypes = QList< QMetaMethod::MethodType >() |
||
| ) |
Add QObject to Lua context as a Lua table.
When a new QObject is added this method:
| obj | QObject |
| tableName | global name of Lua table wrapping object; if null object is left on stack |
| cache | if true object won't be re-added to LuaContext. If tableName is not null a new global variable pointing at the previoulsy added object will be added. |
| mapper | maps signature string to Lua method name; this allows to convert overloaed methods to different Lua functions. |
| deleteMode | choose how/if object shall be garbage collected; |
| methodNames | if not empty only the methods with the names in this list are added to the Lua table |
| methodTypes | if not empty only the methods of the required types are added to the Lua table |
| void qlua::LuaContext::AddQStringList | ( | const QStringList & | sl, |
| const char * | name = 0 |
||
| ) | [inline] |
Add QStringList: Either push it on the stack or set it as global.
| sl | QStringList |
| name | global name; if null value is left on the Lua stack. |
| void qlua::LuaContext::AddQVariantList | ( | const QVariantList & | vl, |
| const char * | name = 0 |
||
| ) | [inline] |
Add QVariantList: Either push it on the stack or set it as global.
| vl | QVariantList |
| name | global name; if null value is left on the Lua stack. |
| void qlua::LuaContext::AddQVariantMap | ( | const QVariantMap & | vm, |
| const char * | name = 0 |
||
| ) | [inline] |
Add QVariantMap: Either push it on the stack or set it as global.
| vm | QVariantMap |
| name | global name; if null value is left on the Lua stack. |
| bool qlua::LuaContext::OwnQObjects | ( | ) | const [inline] |
Return value of global garbage collection policy.
The global object ownership policy is set from Lua through a call to qlua.ownQObjects(). The ownership policy affects the QObjects returned by QObject methods only.
1.7.4