Re: How to bind a static member variable
Lorenzo Pistone <[email protected]> Mon, 08 Apr 2013 21:00:41 +0200
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format. --===============2416202148274829638== Content-Type: multipart/alternative; boundary="------------050200090604040308010206" This is a multi-part message in MIME format. --------------050200090604040308010206 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit So how does one bind instances of objects in globally, or in a namespace? Possibly avoiding that the lua part will ever override or unreference them. On 04/08/2013 08:45 PM, Ryan Pavlik wrote: > > On Mon, Apr 8, 2013 at 6:33 AM, Lorenzo Pistone > <[email protected] <mailto:[email protected]>> wrote: > > #include <luabind/luabind.hpp> > struct A{ > static const A a; > }; > const A A::a; > int main(){ > luabind::scope sc = luabind::class_<A>("A") > .scope[luabind::def_readonly("a", &A::a)]; > } > > > It seems as though while functions can be registered "globally" (in a > namespace rather than a class member), no such provision was made for > variables/data. I've added a test here: > https://github.com/rpavlik/luabind/blob/static-members/test/test_static_member.cpp > - the version committed succeeds but uncommenting the data members > causes a compile failure just as you had noticed. (There is a > luabind::def function that mimics the .def member of luabind::class_, > but no such luabind::def_readonly...) I'm not sure if a workaround of > setting the variable would work - I've had a tough time trying to > figure out how to bind references to values/data to Lua with LuaBind. > > Ryan > > > -- > Ryan Pavlik > HCI Graduate Student > Virtual Reality Applications Center > Iowa State University > > [email protected] <mailto:[email protected]> > http://academic.cleardefinition.com > > > ------------------------------------------------------------------------------ > Minimize network downtime and maximize team effectiveness. > Reduce network management and security costs.Learn how to hire > the most talented Cisco Certified professionals. Visit the > Employer Resources Portal > http://www.cisco.com/web/learning/employer_resources/index.html > > > _______________________________________________ > luabind-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/luabind-user --------------050200090604040308010206 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit <html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type"> </head> <body bgcolor="#FFFFFF" text="#000000"> <div class="moz-cite-prefix"><tt>So how does one bind instances of objects in globally, or in a namespace? Possibly avoiding that the lua part will ever override or unreference them.</tt><br> <br> On 04/08/2013 08:45 PM, Ryan Pavlik wrote:<br> </div> <blockquote cite="mid:CABMFTE_=LUL2tLAT92EqOXQPZC4QGH3kdwjA4G68enyd9T+t8g@mail.gmail.com" type="cite"> <div dir="ltr"> <div class="gmail_extra"><br> <div class="gmail_quote">On Mon, Apr 8, 2013 at 6:33 AM, Lorenzo Pistone <span dir="ltr"><<a moz-do-not-send="true" href="mailto:[email protected]" target="_blank">[email protected]</a>></span> wrote:<br> <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><tt> #include <luabind/luabind.hpp><br> </tt><tt> struct A{</tt><tt><br> </tt><tt> static const A a;</tt><tt><br> </tt><tt> };</tt><tt><br> </tt><tt> const A A::a;</tt><tt><br> int main(){<br> luabind::scope sc = luabind::class_<A>("A")<br> .scope[luabind::def_readonly("a", &A::a)];<br> }</tt></blockquote> </div> <br> It seems as though while functions can be registered "globally" (in a namespace rather than a class member), no such provision was made for variables/data. I've added a test here: <a moz-do-not-send="true" href="https://github.com/rpavlik/luabind/blob/static-members/test/test_static_member.cpp">https://github.com/rpavlik/luabind/blob/static-members/test/test_static_member.cpp</a> - the version committed succeeds but uncommenting the data members causes a compile failure just as you had noticed. (There is a luabind::def function that mimics the .def member of luabind::class_, but no such luabind::def_readonly...) I'm not sure if a workaround of setting the variable would work - I've had a tough time trying to figure out how to bind references to values/data to Lua with LuaBind.</div> <div class="gmail_extra"><br> </div> <div class="gmail_extra">Ryan<br> <br clear="all"> <div><br> </div> -- <br> Ryan Pavlik<br> HCI Graduate Student<br> Virtual Reality Applications Center<br> Iowa State University<br> <br> <a moz-do-not-send="true" href="mailto:[email protected]" target="_blank">[email protected]</a><br> <a moz-do-not-send="true" href="http://academic.cleardefinition.com" target="_blank">http://academic.cleardefinition.com</a> </div> </div> <br> <fieldset class="mimeAttachmentHeader"></fieldset> <br> <pre wrap="">------------------------------------------------------------------------------ Minimize network downtime and maximize team effectiveness. Reduce network management and security costs.Learn how to hire the most talented Cisco Certified professionals. Visit the Employer Resources Portal <a class="moz-txt-link-freetext" href="http://www.cisco.com/web/learning/employer_resources/index.html">http://www.cisco.com/web/learning/employer_resources/index.html</a></pre> <br> <fieldset class="mimeAttachmentHeader"></fieldset> <br> <pre wrap="">_______________________________________________ luabind-user mailing list <a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a> <a class="moz-txt-link-freetext" href="https://lists.sourceforge.net/lists/listinfo/luabind-user">https://lists.sourceforge.net/lists/listinfo/luabind-user</a> </pre> </blockquote> <br> </body> </html> --------------050200090604040308010206-- --===============2416202148274829638== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------------ Minimize network downtime and maximize team effectiveness. Reduce network management and security costs.Learn how to hire the most talented Cisco Certified professionals. Visit the Employer Resources Portal http://www.cisco.com/web/learning/employer_resources/index.html --===============2416202148274829638== 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 --===============2416202148274829638==--