lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Are you sure?






----- Original Message ----- From: Kenk
To: Lua list
Sent: Saturday, October 24, 2009 1:29 AM
Subject: Re: Metatables, C and Script...


Okay, getting closer...

Following  page 123...

Okay... I have AWindowClass defined in script. I set a field within that
table to be another table object with a metatable I've defined in C. I 've
__index AWindowClass. AWindowClass has a .new method which takes a table and
set's that objects metatable to that of AWindowClass.

So now O=AWindowClass.new{fields and stuff} ... When
0.FunctionInProtoTypeTable() is called, it won't find it in AWindowClass and
look in the prototype's table. which it finds...Problem is, the initial
'self' state isn't be passed through...as get's done when you reference a
method with anObject:AFunction();



----- Original Message ----- From: "Kenk" <kenk@heroesent.com>
To: "Lua list" <lua@bazar2.conectiva.com.br>
Sent: Friday, October 23, 2009 12:49 PM
Subject: Re: Metatables, C and Script...


Hmm.. I see... I think page 123 accomplishes what I'm looking to do. let me play with that...

Thanks,

Ken
----- Original Message ----- From: "Luiz Henrique de Figueiredo" <lhf@tecgraf.puc-rio.br>
To: "Lua list" <lua@bazar2.conectiva.com.br>
Sent: Friday, October 23, 2009 11:40 AM
Subject: Re: Metatables, C and Script...


Or once you define a metatable for an object, you can't extend it at all?

A metatable is just a plain ordinary table. You can do anything to it.
OTOH, you may choose to protect it from Lua code by adding __metatable=false
to it.