[oolua] Re: Get derived class instead of base

  • From: "Liam Devine" <liamdevine@xxxxxxxxx>
  • To: oolua@xxxxxxxxxxxxx
  • Date: Wed, 28 May 2014 15:01:21 +0100

On 28/05/14 12:36, SteelRat wrote:
 What is normal behavior for such cases in OOLua?

What you are seeing is normal behaviour. OOLua keeps a userdata cache,
so if create and then store the instance in the container, from Lua, it
will know the derived class. This is until the instance in no longer
reachable in Lua and the gc has ran. When the gc is ran, the
corresponding userdata entry is removed from the cache. I imagine you
are, at this point, retrieving the instance from the container and the
method returns a base instance hence it is a base instance in Lua. In
C++, for the rare occasion you would need this, you would use a
dynamic_cast yet OOLua has no such cast.

-- 
Liam

Attachment: signature.asc
Description: OpenPGP digital signature

Other related posts: