Call a lua function and pass a C++ Class object

Beric Holt <[email protected]>
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <9E82C0C42B538E4A9DEECB54EAE2AC3D05F7F52B93@CHCEX1v.intergen.org.nz>
I have a function declared in Lua
I want to be able to call that function from C++ and pass in a C++ class object, but I'm struggling how to do it.

The lua function looks like this:
--------AI.Lua starts----------
function UpdateActor(pActor)
                local pActorName = pActor.Name;
--             etc etc
                Return 0;
end
--------AI.Lua ends----------


CActor is declared in my luabinder:
---------Luabinding Code starts------
module(L)
                [
                                class_<CActor>("CActor")
                                                .property("Name",                                                                                         &CActor::GetActorName, &CActor::SetActorName)
//            etc etc
                                ,
                                def("Ptr2Actor",                                                                                                               &Ptr2Actor),
                ];
---------Luabinding Code starts------

I get an error when I call the lua function like this
---------C++ calling code starts----------
                CActor *actor = GetMyActor();
int ret = luabind::call_function<int>(luaVM, "UpdateActor", actor);
---------C++ calling code ends----------


This method works fine if I'm calling a C++ method through luabind.

Can anyone offer me any suggestions on how I should be doing this.  One possibility is that I need to somehow derive a lua function from a C++ function, but I haven't yet figured out how to do that.

Thanks for any help that you can offer.

Cheers
Beric
http://buzzrick.true.geek.nz




Beric Holt
Solution Delivery


INTERGEN: LEVEL 1, CONSULTANCY HOUSE, 7 BOND STREET, PO BOX 205, DUNEDIN 9054, NEW ZEALAND.
TEL +64 3 477 5648 DDI 3255 FAX +64 3 477 5649 MOB +64 21 242 7420 WWW.INTERGEN.CO.NZ<http://www.intergen.co.nz/>


        New Zealand Microsoft Partner Awards 2008 - Partner of the Year

Want me to do something? Send me an action item: www.actionthis.com<http://www.actionthis.com/>
Catch the latest on our blog: www.intergen.co.nz/blog<http://www.intergen.co.nz/blog>
Be kind to the planet: Do you really need to print this?
________________________________
This electronic message together with any attachments is confidential. If you are not the intended recipient: (i) do not copy, disclose or use the contents in any way (ii) please let us know by return e-mail immediately and then destroy the message. Intergen is not responsible for any changes made to this message and/or any attachments after sending by Intergen.

------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com

_______________________________________________
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.