QLua
Lua-Qt bindings
Public Member Functions
qlua::LuaCallbackDispatcher Class Reference

Manages Lua function invocation through Qt signals. And connection of Qt signals to Lua functions or QObject methods. More...

#include <LuaCallbackDispatcher.h>

Collaboration diagram for qlua::LuaCallbackDispatcher:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 LuaCallbackDispatcher (QObject *parent=0)
 Standard QObject constructor.
 LuaCallbackDispatcher (LuaContext *lc)
 Constructor, bind dispatcher to Lua context.
int qt_metacall (QMetaObject::Call c, int id, void **arguments)
bool Connect (QObject *obj, int signalIdx, const CBackParameterTypes &paramTypes, int luaCBackRef)
bool Disconnect (QObject *obj, int signalIdx, int cbackStackIndex)
void SetLuaContext (LuaContext *lc)
 Set LuaContext.
virtual ~LuaCallbackDispatcher ()
 Destructor: Clear method database.

Detailed Description

Manages Lua function invocation through Qt signals. And connection of Qt signals to Lua functions or QObject methods.

Offers methods to connect Qt signals emitted from QObjects to Lua functions or other QObject methods. Whenever a new signal -> Lua connection is requested a new proxy method is generated and the signal is routed to the new method which in turn takes care of invoking the Lua function. Note that when disconnecting a signal the associated method is not currently removed from the method array because signals are connected to methods through the method's position in the method array, thus removing a method from the array invalidates all the signal to method connections for which the method index is greater than the one of the removed method.


Member Function Documentation

bool qlua::LuaCallbackDispatcher::Connect ( QObject *  obj,
int  signalIdx,
const CBackParameterTypes &  paramTypes,
int  luaCBackRef 
)

Connect signal to Lua function

Parameters:
objsource QObject
signalIdxsignal index
paramTypessignal signature
luaCBackRefreference to Lua target function created through luaL_ref
bool qlua::LuaCallbackDispatcher::Disconnect ( QObject *  obj,
int  signalIdx,
int  cbackStackIndex 
)

Disconnect signal from Lua function; function must be already on the stack

Parameters:
objsource QObject
signalIdxsignal index
cbackStackIndexposition of Lua function in Lua stack
int qlua::LuaCallbackDispatcher::qt_metacall ( QMetaObject::Call  c,
int  id,
void **  arguments 
)

Overridden method: This is what makes it possible to bind a signal to a Lua function through the index of a proxy method.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Enumerations Enumerator