[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: property based C++ API with Lunar?
- From: Michael Bauroth <Michael.Bauroth@...>
- Date: Wed, 12 Nov 2008 12:53:44 +0100
Hi,
can eventually someone point me to a short example for how to use
__index and __newIndex (eventually in context Lunar) to access C++
methods like properties?
Example:
class A
{
public:
static const char className[];
static Lunar< A >::RegType methods[];
public:
void SetValue( int v );
int GetValue() { return m_v; }
private:
int m_v;
}
const char A::className[] = "A";
Lunar< A >::RegType A::methods[] = {
method( A, SetValue ),
method( A, GetValue ),
{ 0, 0 }
};
default use in Lua:
a = A:new()
a:SetValue( 1 )
print( a:GetValue() )
expected use:
a = A:new()
a.value = 1
print( a.value )
Best Regards
Micha