Casting Upvalues to luabind specific objects?

Harakiri <[email protected]> Tue, 29 Jan 2013 07:03:14 -0800 (PST)
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <[email protected]>
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