binding reference to scalar types: shouldn't it work already?

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

binding reference to scalar types: shouldn't it work already?

Lorenzo Pistone
Hello,
I'm trying to bind a reference to a bool. This thing compiles:

     globals(L)["dotrap"] = boost::ref(dotrap);

but at compile time I get the following exception:

     terminate called after throwing an instance of 'std::runtime_error'
       what():  Trying to use unregistered class

It looks like that luabind is treating a reference to a bool as a user
defined type. So... it isn't able by default to bind references to
simple bools?
By the way, luabind does know about bool, in fact I can do

     globals(L)["dotrap"] = dotrap;

but here I create a copy of the value, which is not what I want to do.

Cheers.

------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: binding reference to scalar types: shouldn't it work already?

Szymon Gatner
boost::ref creates object of type boost::reference_wrapper<T> not T&. This type obviously isn't known to luabind.


2013/4/10 Lorenzo Pistone <[hidden email]>
Hello,
I'm trying to bind a reference to a bool. This thing compiles:

     globals(L)["dotrap"] = boost::ref(dotrap);

but at compile time I get the following exception:

     terminate called after throwing an instance of 'std::runtime_error'
       what():  Trying to use unregistered class

It looks like that luabind is treating a reference to a bool as a user
defined type. So... it isn't able by default to bind references to
simple bools?
By the way, luabind does know about bool, in fact I can do

     globals(L)["dotrap"] = dotrap;

but here I create a copy of the value, which is not what I want to do.

Cheers.

------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user



--
Szymon Gatner
The Lordz Games Studio
www.thelordzgamesstudio.com

------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: binding reference to scalar types: shouldn't it work already?

Lorenzo Pistone
well, is there any other suggested way to bind a reference to a scalar type? Being a very simple and common operation, I would think that this has been foreseen in the library.

On 04/18/2013 09:49 AM, Szymon Gatner wrote:
boost::ref creates object of type boost::reference_wrapper<T> not T&. This type obviously isn't known to luabind.


2013/4/10 Lorenzo Pistone <[hidden email]>
Hello,
I'm trying to bind a reference to a bool. This thing compiles:

     globals(L)["dotrap"] = boost::ref(dotrap);

but at compile time I get the following exception:

     terminate called after throwing an instance of 'std::runtime_error'
       what():  Trying to use unregistered class

It looks like that luabind is treating a reference to a bool as a user
defined type. So... it isn't able by default to bind references to
simple bools?
By the way, luabind does know about bool, in fact I can do

     globals(L)["dotrap"] = dotrap;

but here I create a copy of the value, which is not what I want to do.

Cheers.

------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user



--
Szymon Gatner
The Lordz Games Studio
www.thelordzgamesstudio.com


------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter


_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user


------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user