Re: call_function causes my program to crash

Ilia Trendafilov <[email protected]>
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <[email protected]>
As far as I can understand from the source
(luabind/detail/call_function.hpp, lines 349-350)
luabind::call_function<...>(lua_State*, const char*, ...) only works
with functions at global scope. call_function would have to do rather
sophisticated parsing to reach inner "scopes" - sure,
"CNPC_Nurse.Update" doesn't look very complex, but if that one works,
then "Nurses['Jessie'].Arms.Left:Update" should also work, and parsing
the latter is not trivial. But the parser to do everything for you is
there, and you can invoke it - just call

luaL_dostring(L, "CNPC_Nurse:Update()"); // luaL_dostring is a macro
from the Lua aux library, not luabind

It gets more complex if you want to get return values though. Probably
better option would be something along the lines:

luabind::object self = luabind::globals(L)["CNPC_Nurse"];
luabind::object func = self["Update"];
luabind::call_function(L, func, self);

(I haven't compiled the above code, but you get the idea)

Hope this helps,
Ilia


On Mon, Aug 10, 2009 at 3:08 PM, Secretive Loon<[email protected]> wrote:
> No, he tried it and it didn't work (we're on the same dev team). Perhaps
> it's still not implemented correctly?:
> // c++ call
> luabind::call_function<void>( L ), "CNPC_Nurse.Update", this );
> -- Lua function
> function CNPC_Nurse.Update( self )
> Msg( "\nIn Nurse.Update" )
> end
> I checked through every Google result for call_function (13 pages) and
> didn't find a single one using scope the way I'm trying. Has LuaBind just
> not been designed with the capability?
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus
> on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> luabind-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/luabind-user
>
>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
luabind-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/luabind-user
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.