Error trying to export class

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Error trying to export class

Ferran Ferri-2
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Error trying to export class

Tony Kostanjsek
"MyPoint = point2d" should probably be "MyPoint = point2d()" if this is the original lua script.
You should get a descriptive error if you call a missing static function on a class, I just tried that. Maybe something else is wrong?What types exactly are "first + second" that you try to add in the last line of the function?


Von: Ferran Ferri <[hidden email]>
An: [hidden email]
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Error trying to export class

Tony Kostanjsek
In reply to this post by Ferran Ferri-2
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 <[hidden email]>
An: [hidden email]
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Error trying to export class

Ferran Ferri-2
I'm programming in Visual C++ 2008 and luabind 0.9.1. System is Win7 64bits.

The part that is annoying me is that this works fine:
    luabind::module(L)
        [
            luabind::class_<testclass>("testclass")
            .def(luabind::constructor<const std::string&>())
            .def("print_string", &testclass::print_string)
        ];

And script:
function func(first, second)
    a = testclass('a string')
    a:print_string()
  return 0
end

In addition I can say that program fails after the constructor is callled. In script, this line works ok:
     MyPoint = Point2D()
(and even      MyPoint = Point2D )
But
    MyPoint:setXY(3,4)
and
    MyPoint:printXY()
fails, enven independently called.

Thanks
Ferran


On Fri, Dec 31, 2010 at 6:53 PM, Tony Kostanjsek <[hidden email]> wrote:
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 <[hidden email]>
An: [hidden email]
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user



------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Error trying to export class

Ali Hajiabadi
In reply to this post by Ferran Ferri-2
Hi,
I'm not sure about your first question, I think you should use something like this :
MyPoint = point2d()

but about your second question I use this :

    luaL_dostring(LuaState,"func(2,3)");
    if (lua_isstring(LuaState, lua_gettop(LuaState))) {
        std::cout << lua_tostring(LuaState,lua_gettop(LuaState)) << "\n";
        lua_pop(LuaState, 1);
    }

----------------------------

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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Error trying to export class

Tony Kostanjsek
In reply to this post by Ferran Ferri-2
How do you Link against luabind and Lua? Static or dlls? I've only used static builds and there are some things you have to take care of when you Link dynamically. There were quite a few posts regarding this topic in the List. If you can Build a testcase within a Single cpp file that fails then others could try it easier.




On 31.12.2010, at 21:25, Ferran Ferri <[hidden email]> wrote:

I'm programming in Visual C++ 2008 and luabind 0.9.1. System is Win7 64bits.

The part that is annoying me is that this works fine:
    luabind::module(L)
        [
            luabind::class_<testclass>("testclass")
            .def(luabind::constructor<const std::string&>())
            .def("print_string", &testclass::print_string)
        ];

And script:
function func(first, second)
    a = testclass('a string')
    a:print_string()
  return 0
end

In addition I can say that program fails after the constructor is callled. In script, this line works ok:
     MyPoint = Point2D()
(and even      MyPoint = Point2D )
But
    MyPoint:setXY(3,4)
and
    MyPoint:printXY()
fails, enven independently called.

Thanks
Ferran


On Fri, Dec 31, 2010 at 6:53 PM, Tony Kostanjsek <[hidden email]> wrote:
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 <[hidden email]>
An: [hidden email]
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user


------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user

------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Error trying to export class

Ferran Ferri-2
Hmmmm,
It is very strange. I've replaced this:
=============================================================
    luaL_dofile(L,"main.lua");
    try{
        luabind::call_function<int>(L, "func", 2, 3);

    }
=============================================================
By this:
===============================================================
    try{
        luaL_dofile(L,"main.lua");
        if (lua_isstring(L, lua_gettop(L))) {
            std::cout << lua_tostring(L,lua_gettop(L)) << "\n";
            lua_pop(L, 1);
        }
     }
===============================================================
All the rest is the same (including the catch clause) and it works. But replacind the code by the old one
luaL_dofile(L,"main.lua");
    try{
        luaL_dofile(L,"main.lua");
        luabind::call_function<int>(L, "func", 2, 3);

    }
works!!!
May visual studio block some file or DLL that causes the error?

Thanks to all
Ferran


On Fri, Dec 31, 2010 at 11:09 PM, Tony Kostanjsek <[hidden email]> wrote:
How do you Link against luabind and Lua? Static or dlls? I've only used static builds and there are some things you have to take care of when you Link dynamically. There were quite a few posts regarding this topic in the List. If you can Build a testcase within a Single cpp file that fails then others could try it easier.




On 31.12.2010, at 21:25, Ferran Ferri <[hidden email]> wrote:

I'm programming in Visual C++ 2008 and luabind 0.9.1. System is Win7 64bits.

The part that is annoying me is that this works fine:
    luabind::module(L)
        [
            luabind::class_<testclass>("testclass")
            .def(luabind::constructor<const std::string&>())
            .def("print_string", &testclass::print_string)
        ];

And script:
function func(first, second)
    a = testclass('a string')
    a:print_string()
  return 0
end

In addition I can say that program fails after the constructor is callled. In script, this line works ok:
     MyPoint = Point2D()
(and even      MyPoint = Point2D )
But
    MyPoint:setXY(3,4)
and
    MyPoint:printXY()
fails, enven independently called.

Thanks
Ferran


On Fri, Dec 31, 2010 at 6:53 PM, Tony Kostanjsek <[hidden email][hidden email]> wrote:
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 <[hidden email][hidden email]>
An: [hidden email][hidden email]
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
[hidden email][hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user


------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user

------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user



------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Pushing C++ objects onto stack

Josh Klint
In reply to this post by Ferran Ferri-2

I need to push a C++ object into the Lua stack and have it recognized the same as other objects in LuaBind, and I don't think lightuserdata is the same. I can't seem to find search results for this. Any answers on this? It should be a simple thing.

 

 

Best Regards,

 

Josh Klint

CEO

Leadwerks Software

www.leadwerks.com

 


------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its
next-generation tools to help Windows* and Linux* C/C++ and Fortran
developers boost performance applications - including clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Pushing C++ objects onto stack

Iliya Trendafilov
http://www.rasterbar.com/products/luabind/docs.html#object

Construct a luabind::object with the `template<class T> object(lua_State*, T const& value)` constructor, then call the object's push() method.


On Wed, May 18, 2011 at 4:14 AM, Josh Klint <[hidden email]> wrote:

I need to push a C++ object into the Lua stack and have it recognized the same as other objects in LuaBind, and I don't think lightuserdata is the same. I can't seem to find search results for this. Any answers on this? It should be a simple thing.

 

 

Best Regards,

 

Josh Klint

CEO

Leadwerks Software

www.leadwerks.com

 


------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its
next-generation tools to help Windows* and Linux* C/C++ and Fortran
developers boost performance applications - including clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user



------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its
next-generation tools to help Windows* and Linux* C/C++ and Fortran
developers boost performance applications - including clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Pushing C++ objects onto stack

Josh Klint

Thank you, it werks!:

 

void Interpreter::PushObject(const Object* object)

{

      luabind::object o = luabind::object(L,object);

      o.push(L);

}

 

 

Best Regards,

 

Josh Klint

CEO

Leadwerks Software

www.leadwerks.com

 

From: Iliya Trendafilov [mailto:[hidden email]]
Sent: Tuesday, May 17, 2011 7:46 PM
To: [hidden email]
Subject: Re: [luabind] Pushing C++ objects onto stack

 

http://www.rasterbar.com/products/luabind/docs.html#object

Construct a luabind::object with the `template<class T> object(lua_State*, T const& value)` constructor, then call the object's push() method.

On Wed, May 18, 2011 at 4:14 AM, Josh Klint <[hidden email]> wrote:

I need to push a C++ object into the Lua stack and have it recognized the same as other objects in LuaBind, and I don't think lightuserdata is the same. I can't seem to find search results for this. Any answers on this? It should be a simple thing.

 

 

Best Regards,

 

Josh Klint

CEO

Leadwerks Software

www.leadwerks.com

 


------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its
next-generation tools to help Windows* and Linux* C/C++ and Fortran
developers boost performance applications - including clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user

 


------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its
next-generation tools to help Windows* and Linux* C/C++ and Fortran
developers boost performance applications - including clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user