Re: call_function causes my program to crash
Tom McCubbin <[email protected]>
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
I'd guess its the lua syntactic sugar of <class:method> v. <class.method> . When you use the ':'(colon) operator in lua it infers the object to act on is the first arg passed to the method, just like 'this' in c++ is passed by the compiler. When you call it, it would appear that you are not passing the object that Update() should act on. When it tries, I'd bet you get a SEGV or other nasty because the stack in lua holds some random address pointing to a whose-i-jigger. I could be completely off here...but I'm others will chime in w/ the solution. -tom On Sun, Aug 9, 2009 at 5:34 PM, Secretive Loon <[email protected]>wrote: > I've successfully used call_function to call Lua functions before and > didn't have a problem. I think it's because they were of global scope like:int > sum = luabind::call_function<int>( L, "add", 2, 3 ); > > but the one I'm trying to do now is like this, with a different scope: > luabind::call_function<void>( L, "CNPC_Nurse:Update" ); > > -- Here's the Lua code that I'm trying to call (in a different file from > the C++, of course) > function CNPC_Nurse:Update() > Msg( "\nIn Nurse:Update" ) > end > > // these came earlier in the file as the above C++ code > luabind::module( L ) [ > luabind::class_<CNPC_Nurse>( "CNPC_Nurse" ) > ]; > > When I run it, it crashes the application without a message. I've narrowed > it down to the call_function line causes the problem. Any idea why the > "CNPC_Nurse:Update" call breaks it? > > Thanks :) > > > ------------------------------------------------------------------------------ > 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