Re: Error trying to export class
Tony Kostanjsek <[email protected]>
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
sorry, just saw those were the 2 + 3 params from the C++ call. If it isn't the constructor call, maybe you are using DLLs and the build is broken. Post some more details, OS, compiler, how you build. ________________________________ Von: Ferran Ferri <[email protected]> An: [email protected] Gesendet: Freitag, den 31. Dezember 2010, 17:48:17 Uhr Betreff: [luabind] Error trying to export class Hello all, I have a question. I'm a newbie: First, this is my c++ code #include <iostream> #include <cstdlib> extern "C" { #include "lua.h" #include "lualib.h" #include "lauxlib.h" } #include "luabind/luabind.hpp" using namespace std; class Point2D{ int _x,_y; public: Point2D():_x(0),_y(0){} void setXYPoint(int x, int y){_x = x; _y = y;} void printPoint(){std::cout << "X = "<<_x<<" Y = "<<_y<<"\n";} void publishAPI(const lua_State* L){} }; int main(){ lua_State *L = lua_open(); // Connect LuaBind to this lua state luabind::open(L); luaL_openlibs(L); luabind::module(L)[ luabind::class_<Point2D>("point2d") .def(luabind::constructor<>()) .def("print",&Point2D::printPoint) .def("setXY",&Point2D::setXYPoint) ]; // Define a lua function that we can call luaL_dofile(L,"main.lua"); try{ std::cout << "Result: " << luabind::call_function<int>(L, "func", 2, 3) << endl; lua_close(L); } catch(const std::exception& e){ std::cout << e.what() << std::endl; } return EXIT_SUCCESS; } And this is my lua script function func(first, second) MyPoint = point2d MyPoint:setXY(3,4) MyPoint:print() return first + second end The only result I always get is "lua runtime exception". But the program compiles fine and it seems legal. Could you help me please? This is very similar to others samples. Another question is: how do I get a more detailed error message? I always get "lua runtime exception" and I need a more comprehensive error Thanks in advance.Ferran ------------------------------------------------------------------------------ Learn how Oracle Real Application Clusters (RAC) One Node allows customers to consolidate database storage, standardize their database environment, and, should the need arise, upgrade to a full multi-node Oracle RAC database without downtime or disruption http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ luabind-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/luabind-user