Lua Utils
Biblioteca utilitária para facilitar a integração de Lua com C++
Classes | Static Public Member Functions | List of all members
LuaProxy Class Reference

#include <luaProxy.h>

Classes

class  Base
 

Static Public Member Functions

static void pushObject (lua_State *L, Base *obj)
 
static void pushMetatable (lua_State *L, Base *obj)
 
static bool isObject (lua_State *L, int index)
 
static BasetoObject (lua_State *L, int index)
 
template<typename T >
static T * toObjectOfClass (lua_State *L, int index)
 
template<typename T >
static T * toObjectOfClass (const QVariant &v)
 
template<typename T >
static T * checkObjectOfClass (lua_State *L, int index)
 

Detailed Description

This class provides static methods to ease exporting Objects to Lua

Member Function Documentation

◆ checkObjectOfClass()

template<typename T >
static T* LuaProxy::checkObjectOfClass ( lua_State *  L,
int  index 
)
inlinestatic
        If the Lua value at index is a full userdata of type T, uses

toObjectOfClass<T>() to return the object converted to T. If not, emits an error in the same way as those emitted by luaL_checkxxxx()functions.

◆ isObject()

bool LuaProxy::isObject ( lua_State *  L,
int  index 
)
static

Objects that have been added to the Lua state with pushObject() can be identified with this method.

Returns
True if the Lua value at index is actually a LuaProxy::Base, false otherwise.

◆ pushMetatable()

void LuaProxy::pushMetatable ( lua_State *  L,
Base obj 
)
static
        Takes an object pointer and pushes it's metatable onto the Lua stack.

If the object does not have a metattable yet, create's one.

◆ pushObject()

void LuaProxy::pushObject ( lua_State *  L,
LuaProxy::Base obj 
)
static

Takes an object pointer and pushes it onto the Lua stack as a full userdata with a metatable associated.

See also
isObject(), toObject()

◆ toObject()

LuaProxy::Base * LuaProxy::toObject ( lua_State *  L,
int  index 
)
static

If the Lua value at index is a full userdata that was added with pushObject(), this method will convert it back into a C++ pointer.

Returns
A pointer to the LuaProxy::Base object, or NULL if the conversion is illegal.

◆ toObjectOfClass() [1/2]

template<typename T >
static T* LuaProxy::toObjectOfClass ( lua_State *  L,
int  index 
)
inlinestatic

If the Lua value at index is a full userdata that was added with pushObject(), this template method attempts to convert it back into a C++ pointer of the specified type.

Warning
Your compiler must support RTTI, and it must be enabled.
Returns
A pointer to the object of type T, or NULL if the conversion is illegal.

◆ toObjectOfClass() [2/2]

template<typename T >
static T* LuaProxy::toObjectOfClass ( const QVariant v)
inlinestatic

Converts a QVariant value that contains a LuaProxy::Base* to ano object of class T

Warning
Your compiler must support RTTI, and it must be enabled.
Returns
A pointer to the object of type T, or NULL if the conversion is illegal.

The documentation for this class was generated from the following files: