Re: Casting Upvalues to luabind specific objects? [SOLVED]

Harakiri <[email protected]> Tue, 29 Jan 2013 12:46:00 -0800 (PST)
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <[email protected]>
I actually found what i need in the mailling list archive:

http://sourceforge.net/mailarchive/message.php?msg_id=27550158

onst std::pair<void*, int> Instance1 =
        pObj1->get_instance(pObj1->crep()->classes().get(pObj1->crep()->type()));

Instance1.first --> is the raw pointer to my interface

--- On Tue, 1/29/13, Harakiri <[email protected]> wrote:

> From: Harakiri <[email protected]>
> Subject: Re: [luabind] Casting Upvalues to luabind specific objects?
> To: [email protected]
> Date: Tuesday, January 29, 2013, 3:13 PM
> I got a bit further - i now know the
> luabind object at least
> 
> luabind::detail::object_rep* obj =
> static_cast<luabind::detail::object_rep*>(lua_touserdata(fn.interpreter(),2));
>            
>              
>       luabind::detail::class_rep* rep =
> obj->crep(); 
>            
>            
>         if (rep != NULL)
> {           
>            
>             
>            
>            
>            
> printf("My Class Name is %s \n",rep->name());
>            
>            
>         }
> 
> So - how do i get my original class object form object_rep
> ?
> 
> Why does rep->name() gives me the implemented class name
> and not the abstract interface i exposed (which my
> implemented class extends) e.g. IActor exposed to lua with
> luabind, MyActor is my actual class which implements it
> 
> 
> --- On Tue, 1/29/13, Harakiri <[email protected]>
> wrote:
> 
> > From: Harakiri <[email protected]>
> > Subject: [luabind] Casting Upvalues to luabind specific
> objects?
> > To: [email protected]
> > Date: Tuesday, January 29, 2013, 10:03 AM
> > Before executing a lua function i
> > like to see/modify the upvalues (basically
> globally/locally
> > accessible vars)
> > 
> > I'm able to retrieve and print them from C++
> > 
> > // lua func to call is on stack of luastate
> > const char* name = NULL;
> >                 int
> > j = 1;
> >                
> > while((name = lua_getupvalue(fn.interpreter(), -1, j))
> !=
> > NULL) {
> >                
> >         std::cout << name <<
> > std::endl;             
> >              
> >                
> >         std::cout <<  " "
> > << lua_typename(fn.interpreter(),
> > lua_type(fn.interpreter(),2)) << std::endl;
> >                
> >            
> >                
> >         if(lua_type(fn.interpreter(),2)
> > == LUA_TUSERDATA) {
> >                
> >                 //
> > lua_touserdata(fn.interpreter(),2);
> >                
> >            
> >    
> >                
> >         }
> > 
> >                
> >        
> >                
> >         lua_pop(fn.interpreter(),
> > 1);           
> >                
> >         j++;
> >                
> >        
> >                 }
> > 
> > 
> > Now what object type is my userdata here ? It is
> luabind
> > specific - because i printed the address from C and in
> lua i
> > did a toString() which i implemented in my exposed
> Class to
> > print the this ptr value.
> > 
> > I know there is a luabind specific upvalue handler but
> i
> > have no idea how to use it. And the documentation is
> > lacking
> > 
> > Questions:
> > 
> > What is the userdata object class that luabind uses to
> > expose objects in scripts?
> > 
> > How can i retrieve the classname from the original
> object
> > from that luabind object? So that i know how to cast
> the
> > luabind object to my own object type.
> > 
> > Anyone able to modify the above code to set some
> upvalues
> > for a function to NIL ? I tried lua_setupvalue but
> there is
> > no good documentation about it - i was able todo it
> just
> > fine from lua with 
> > local func = debug.getinfo(2, "f").func
> > debug.setupvalue(func, <idxofupvalue>,
> > <newvalue>);
> > 
> > Thanks
> > 
> > 
> > 
> > 
> >
> ------------------------------------------------------------------------------
> > Master Visual Studio, SharePoint, SQL, ASP.NET, C#
> 2012,
> > HTML5, CSS,
> > MVC, Windows 8 Apps, JavaScript and much more. Keep
> your
> > skills current
> > with LearnDevNow - 3,200 step-by-step video tutorials
> by
> > Microsoft
> > MVPs and experts. ON SALE this month only -- learn more
> at:
> > http://p.sf.net/sfu/learnnow-d2d
> > _______________________________________________
> > luabind-user mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/luabind-user
> > 
> 
> ------------------------------------------------------------------------------
> Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012,
> HTML5, CSS,
> MVC, Windows 8 Apps, JavaScript and much more. Keep your
> skills current
> with LearnDevNow - 3,200 step-by-step video tutorials by
> Microsoft
> MVPs and experts. ON SALE this month only -- learn more at:
> http://p.sf.net/sfu/learnnow-d2d
> _______________________________________________
> luabind-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/luabind-user
> 

------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d