Lua Utils
Biblioteca utilitária para facilitar a integração de Lua com C++
Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
LuaSimplePtrProxy< T > Class Template Reference

#include <luaProxy.h>

Inheritance diagram for LuaSimplePtrProxy< T >:
Inheritance graph
[legend]
Collaboration diagram for LuaSimplePtrProxy< T >:
Collaboration graph
[legend]

Public Member Functions

 LuaSimplePtrProxy (T *obj)
 
virtual ~LuaSimplePtrProxy ()
 Destructor.
 
T * get ()
 
void release ()
 Deletes the object stored by this proxy. Further calls to get will return NULL.
 
void * getClassMetatableID ()
 
void populateMetatable (lua_State *L, int index)
 

Static Private Member Functions

static int l___gc (lua_State *L)
 Método de coleta de lixo. Deleta o proxy.
 

Private Attributes

T * _obj
 Objeto encapsulado.
 

Detailed Description

template<typename T>
class LuaSimplePtrProxy< T >

A class with simmilar semantics as LuaSimpleProxy but storing a pointer to an object that will be DELETED when the Lua object is garbage collected.

Constructor & Destructor Documentation

◆ LuaSimplePtrProxy()

template<typename T>
LuaSimplePtrProxy< T >::LuaSimplePtrProxy ( T *  obj)
inline

Encapsulates the supplied object in a Lua proxy.

Member Function Documentation

◆ get()

template<typename T>
T* LuaSimplePtrProxy< T >::get ( )
inline
Returns
The object represented by this proxy.

◆ getClassMetatableID()

template<typename T>
void* LuaSimplePtrProxy< T >::getClassMetatableID ( )
inlinevirtual

A scriptable object should return here a unique ID for its class. This will be used to identify the class's metatable once it has been created.

Warning
Objects of the same most-derived class must return the same ID! Objects of different most-derived classes must return different IDs!

Implements LuaProxy::Base.

◆ populateMetatable()

template<typename T>
void LuaSimplePtrProxy< T >::populateMetatable ( lua_State *  L,
int  index 
)
inlinevirtual

The value at index in the Lua stack is guaranteed to be a table (which may or may not be empty; see below). This method must fill it with events/metamethods (set functions and tables in the table using strings as keys) so that userdata representing objects of this class will behave appropriately.

For convenience, the metatable will already have an "__index" event set to an empty table, so you can start filling that out immediately.

Hint: Design your classes so that the first thing in the method's body being an invocation of __super::populateMetatable() ensures proper inheritance.

Implements LuaProxy::Base.

Reimplemented in LuaSimpleTypedPtrProxy< T, typeName >.


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