Re: Trivial pointers result in unregistered class
rod haxton <[email protected]> Tue, 18 Jun 2013 12:17:23 -0400
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <CALz8gR-4Wa6O-qZN571WCWz1NyNabXeQKJ0tcayF1AGaG6Wevw@mail.gmail.com> |
--===============2715919496577741608== Content-Type: multipart/alternative; boundary=047d7b5da3d562a17e04df700c25 --047d7b5da3d562a17e04df700c25 Content-Type: text/plain; charset=ISO-8859-1 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]> 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] > https://lists.sourceforge.net/lists/listinfo/luabind-user > --047d7b5da3d562a17e04df700c25 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">give boost:ref a try...<div><br></div><div><span style=3D"= font-family:arial,sans-serif;font-size:12.800000190734863px">luabind::globa= ls(L)["x"] =3D boost::ref(x);</span><br></div></div><div class=3D= "gmail_extra"> <br><br><div class=3D"gmail_quote">On Tue, Jun 18, 2013 at 10:41 AM, Daniel= Walter <span dir=3D"ltr"><<a href=3D"mailto:daniel.walter@helmundwalter= .de" target=3D"_blank">[email protected]</a>></span> wrote:= <br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex">Hi folks,<br> <br> I have a struct with some pointers to trivial datatypes like this:<br> <br> struct A {<br> =A0 =A0 =A0int* x;<br> =A0 =A0 =A0int* y;<br> };<br> <br> I bound it to lua like this:<br> <br> luabind::module(L)<br> [<br> =A0 =A0 =A0 luabind::class_<A>("A")<br> =A0 =A0 =A0.def_readonly("x", &A::x)<br> =A0 =A0 =A0.def_readonly("y", &A::y)<br> ];<br> <br> If I am using this class in my lua script the runtime throws this<br> exception: "Trying to use unregistered class"<br> I managed this using a getter function returning the dereferenced<br> pointer, but there must be a better way.<br> <br> The same exception happens when i am using such an trivial pointer directly= :<br> <br> int* x =3D new int(42);<br> luabind::globals(L)["x"] =3D x;<br> <br> How to handle this? What i am missing?<br> <br> Thanks in advance,<br> Daniel<br> <br> ---------------------------------------------------------------------------= ---<br> This SF.net email is sponsored by Windows:<br> <br> Build for Windows Store.<br> <br> <a href=3D"http://p.sf.net/sfu/windows-dev2dev" target=3D"_blank">http://p.= sf.net/sfu/windows-dev2dev</a><br> _______________________________________________<br> luabind-user mailing list<br> <a href=3D"mailto:[email protected]">[email protected]= urceforge.net</a><br> <a href=3D"https://lists.sourceforge.net/lists/listinfo/luabind-user" targe= t=3D"_blank">https://lists.sourceforge.net/lists/listinfo/luabind-user</a><= br> </blockquote></div><br></div> --047d7b5da3d562a17e04df700c25-- --===============2715919496577741608== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev --===============2715919496577741608== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ luabind-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/luabind-user --===============2715919496577741608==--