Re: Trivial pointers result in unregistered class

Daniel Walter <[email protected]> Tue, 18 Jun 2013 18:42:31 +0200
Newsgroups gmane.comp.lang.lua.bind.user
Organization Helm & Walter IT-Solutions
Message-ID <[email protected]>
hi rod,
thank you for your answer.
what about the struct "A" in my example? In my project I can not change 
struct "A" to use boost::ref or any getters. Of course, I could write a 
wrapper class, but this hurts.

Is there any other way?


On 18.06.2013 18:17, rod haxton wrote:
> give boost:ref a try...
>
> luabind::globals(L)["x"] = boost::ref(x);
>
>
> On Tue, Jun 18, 2013 at 10:41 AM, Daniel Walter
> <[email protected] <mailto:[email protected]>>
> wrote:
>
>     Hi folks,
>
>     I have a struct with some pointers to trivial datatypes like this:
>
>     struct A {
>           int* x;
>           int* y;
>     };
>
>     I bound it to lua like this:
>
>     luabind::module(L)
>     [
>            luabind::class_<A>("A")
>           .def_readonly("x", &A::x)
>           .def_readonly("y", &A::y)
>     ];
>
>     If I am using this class in my lua script the runtime throws this
>     exception: "Trying to use unregistered class"
>     I managed this using a getter function returning the dereferenced
>     pointer, but there must be a better way.
>
>     The same exception happens when i am using such an trivial pointer
>     directly:
>
>     int* x = new int(42);
>     luabind::globals(L)["x"] = x;
>
>     How to handle this? What i am missing?
>
>     Thanks in advance,
>     Daniel
>
>     ------------------------------------------------------------------------------
>     This SF.net email is sponsored by Windows:
>
>     Build for Windows Store.
>
>     http://p.sf.net/sfu/windows-dev2dev
>     _______________________________________________
>     luabind-user mailing list
>     [email protected]
>     <mailto:[email protected]>
>     https://lists.sourceforge.net/lists/listinfo/luabind-user
>
>
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Windows:
>
> Build for Windows Store.
>
> http://p.sf.net/sfu/windows-dev2dev
>
>
>
> _______________________________________________
> luabind-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/luabind-user
>

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev