[luabind] Making "self" Apply to More Than Two Classes
Brought to you by:
arvidn,
daniel_wallin
From: Secretive L. <sec...@gm...> - 2009-08-20 18:01:12
|
I want my Lua class to be able to inherit from two different classes just so it can use the "self" keyword to access the second class's functions. I found that "self" only works for the first class from which the class inherits. Example: *class *'BaseClass1' *function *BaseClass1:B1Print() *print*( 'in B1 print' ) *end* *class *'BaseClass2' *function *BaseClass2:B2Print() *print*( 'in B2 print' ) *end* *class *'DerivedClass1' ( BaseClass1, BaseClass2 ) *function *DerivedClass1:__init() BaseClass1.__init( self ) BaseClass2.__init( self ) self:B1Print() -- works fine self:B2Print() -- nil. 'self' can't be used to access this classes functions BaseClass1.B1Print( self ) -- works fine BaseClass2.B2Print( self ) -- works fine *end* * * Is there another way around this? LuaBind docs didn't say it couldn't do this. If it can't be done using just the luabind 'class' method, is there another way like by appending the index table of BaseClass2 onto the index table for DerivedClass1? If that's possible, how might I go about doing it? Thanks. |