NuriaProject Framework  0.1
The NuriaProject Framework
Public Member Functions | Static Public Member Functions | Friends | List of all members
Nuria::LuaObject Class Reference

Stores a C++ object with an associated Nuria::MetaObject. More...

#include <luaobject.hpp>

Public Member Functions

 LuaObject ()
 
 LuaObject (const LuaObject &other)
 
 ~LuaObject ()
 
QVariant copy () const
 
bool isValid () const
 
MetaObjectmetaObject () const
 
void * object () const
 
LuaObjectoperator= (const LuaObject &other)
 
int reference () const
 
LuaRuntimeruntime () const
 
QVariant toVariant () const
 

Static Public Member Functions

static LuaObject fromStructure (void *object, MetaObject *metaObject, LuaRuntime *runtime, bool takeOwnership=false)
 
static LuaObject fromVariant (const QVariant &variant, LuaRuntime *runtime, bool takeOwnership=false)
 

Friends

class LuaMetaObjectWrapper
 
class LuaRuntime
 
class LuaStackUtils
 
class LuaValue
 

Detailed Description

Stores a C++ object with an associated Nuria::MetaObject.

LuaObject encapsulates a Lua "user data" item, exposing a C++ object through Lua's meta table with the help of MetaObject.

All accesses to it from Lua are redirected to the C++ object.

Constructor & Destructor Documentation

Nuria::LuaObject::LuaObject ( )

Constructor for a invalid instance.

Nuria::LuaObject::LuaObject ( const LuaObject other)

Copy constructor.

Nuria::LuaObject::~LuaObject ( )

Destructor

Member Function Documentation

QVariant Nuria::LuaObject::copy ( ) const

Like toVariant(), but the referenced object is copied using its copy constructor and the resulting pointer put into a QVariant.

If copy'ing fails, the resulting QVariant is invalid.

See also
toVariant()
static LuaObject Nuria::LuaObject::fromStructure ( void *  object,
MetaObject metaObject,
LuaRuntime runtime,
bool  takeOwnership = false 
)
static

Creates a object from object which is defiend by metaObject. The resulting LuaObject is bound to runtime.

If takeOwnership is true, then ownership of object is transferred to the LUA runtime.

static LuaObject Nuria::LuaObject::fromVariant ( const QVariant &  variant,
LuaRuntime runtime,
bool  takeOwnership = false 
)
static

Creates a object from variant. If conversion is not possible, the resulting LuaObject will be invalid. The resulting LuaObject is bound to runtime.

If variant contains a pointer type and takeOwnership is true then ownership of the object inside variant is transferred to the LUA runtime.

See also
LuaValue(LuaRuntime *runtime, const QVariant &variant) isValid
bool Nuria::LuaObject::isValid ( ) const

Returns true if this instance is valid.

MetaObject* Nuria::LuaObject::metaObject ( ) const

Returns the associated MetaObject.

void* Nuria::LuaObject::object ( ) const

Returns the wrapped C++ structure. Returns nullptr if there's no associated object.

See also
toVariant(), copy()
LuaObject& Nuria::LuaObject::operator= ( const LuaObject other)

Assignment operator.

int Nuria::LuaObject::reference ( ) const

Returns the internal LUA reference.

LuaRuntime* Nuria::LuaObject::runtime ( ) const

Returns the associated LuaRuntime.

QVariant Nuria::LuaObject::toVariant ( ) const

Puts the result of object() into a QVariant and returns it. If object() returned nullptr, the resulting QVariant is invalid.

See also
copy()

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