[oolua] Re: Getting class info from instance in Lua

  • From: Sean Dunn <seanedunn@xxxxxxxxx>
  • To: "oolua@xxxxxxxxxxxxx" <oolua@xxxxxxxxxxxxx>
  • Date: Sun, 2 Mar 2014 09:43:26 -0800 (PST)

I didn't realize that the userdata wasn't just the pointer to the native 
instance, but that it uses the Lua_ud type to contain the instance and 
metadata. On further inspection it looks like my goal could be reached by 
exposing a call that uses OOLUA::INTERNAL::check_index<T> (which calls 
ud_is_type<T>()) through the proxy class's Lua table.

I'm going to try it out soon, but does that seem like a good direction to go 
in, or are there deeper issues with doing this that I'm not aware of? 

--



On Sunday, March 2, 2014 9:50 AM, Sean Dunn <seanedunn@xxxxxxxxx> wrote:
 
I think we're on the same page. Since Lua isn't a strongly typed language, it's 
useful to know what you're sending to an OOLua proxy. It seems like a good 
design decision of yours not to use RTTI in Oolua, but I need a basic way to, 
from Lua, to do the following:
>
>local inst
>-- some code, we don't know what inst is, but it's possibly from MyClass.new()
>if MyClass.isInstance(inst) then
>    -- do something
>end
>
>Do you have any ideas on how I could achieve this using OOLua, or is this 
>something I could only do by changing the library to store some intrusive data 
>as part of the instance (for example, via a mix-in)?
>
>
>> On Mar 2, 2014, at 6:55 AM, "Liam Devine" <liamdevine@xxxxxxxxx> wrote:
>> 
>>> On 02/03/14 05:17, Sean Dunn wrote:
>>> I'm trying to determine whether an instance is a member of a specific proxy 
>>> class, in Lua. I've looked through the documentation, and I don't see any 
>>> mention of what the API is on the Lua side, or whether this is possible. 
>>> Can someone point me to docs, or where in the source this is specified?
>>> 
>>> Thanks,
>>> Sean
>>> 
>>> --
>> Sean,
>> 
>> If I understand you correctly, the library does not store any
>> information about members of a class.
>> 
>> -- 
>> Liam
>> 
>
>
>

Other related posts: