Re: How to bind a static member variable

Lorenzo Pistone <[email protected]> Mon, 08 Apr 2013 13:33:26 +0200
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--===============3196452986186504706==
Content-Type: multipart/alternative;
	boundary="------------090300030102050706020003"

This is a multi-part message in MIME format.
--------------090300030102050706020003
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

still the same. This is a chopped down version of my code:

     #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)];
     }


On 04/08/2013 01:17 PM, Timo Boll wrote:
> Did you try .def_readonly? Maybe the error is a result of trying to 
> bind a const type with .def
>
> Am 08.04.2013 um 12:32 schrieb Lorenzo Pistone:
>
>> I've tried to do so, but I'm getting "def_readwrite is not a member 
>> of luabind". I have successfully bound a static member _function_ 
>> though (with .def).
>>
>> On 04/08/2013 08:40 AM, Iliya Trendafilov wrote:
>>> Hi,
>>>
>>> In the (rather old) docs, there's an example binding static 
>>> function: 
>>> http://www.rasterbar.com/products/luabind/docs.html#nested-scopes-and-static-functions
>>> Binding static members should be obvious from there
>>>
>>>
>>>
>>> On Sun, Apr 7, 2013 at 1:52 PM, Lorenzo Pistone 
>>> <[email protected] <mailto:[email protected]>> wrote:
>>>
>>>     Hello,
>>>     I cannot find any reference on how to bind a static member
>>>     variable, so
>>>     that I can access it from lua as myclass.staticmember.
>>>
>>>     Cheers.
>>>
>
>
>
> ------------------------------------------------------------------------------
> 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


--------------090300030102050706020003
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>still the same. This is a chopped
        down version of my code:</tt><tt><br>
      </tt><tt><br>
        &nbsp;&nbsp;&nbsp; #include &lt;luabind/luabind.hpp&gt;<br>
      </tt><tt>&nbsp;&nbsp;&nbsp; struct A{</tt><tt><br>
      </tt><tt>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; static const A a;</tt><tt><br>
      </tt><tt>&nbsp;&nbsp;&nbsp; };</tt><tt><br>
      </tt><tt>&nbsp;&nbsp;&nbsp; const A A::a;</tt><tt><br>
        &nbsp;&nbsp;&nbsp; int main(){<br>
        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; luabind::scope sc = luabind::class_&lt;A&gt;("A")<br>
        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .scope[luabind::def_readonly("a", &amp;A::a)];<br>
        &nbsp;&nbsp;&nbsp; }<br>
      </tt><br>
      <br>
      On 04/08/2013 01:17 PM, Timo Boll wrote:<br>
    </div>
    <blockquote cite="mid:[email protected]"
      type="cite">Did you try .def_readonly? Maybe the error is a result
      of trying to bind a const type with .def
      <div><br>
        <div>
          <div>Am 08.04.2013 um 12:32 schrieb Lorenzo Pistone:</div>
          <br class="Apple-interchange-newline">
          <blockquote type="cite">
            <meta content="text/html; charset=ISO-8859-1"
              http-equiv="Content-Type">
            <div bgcolor="#FFFFFF" text="#000000">
              <div class="moz-cite-prefix">I've tried to do so, but I'm
                getting "def_readwrite is not a member of luabind". I
                have successfully bound a static member _function_
                though (with .def).<br>
                <br>
                On 04/08/2013 08:40 AM, Iliya Trendafilov wrote:<br>
              </div>
              <blockquote
cite="mid:CAA9zKUsLNscELZhS2yEueh2_z+KEup0b5hgiv8Ts=ZTV+svNFA@mail.gmail.com"
                type="cite">
                <div dir="ltr">
                  <div>
                    <div>Hi,<br>
                      <br>
                    </div>
                    In the (rather old) docs, there's an example binding
                    static function: <a moz-do-not-send="true"
href="http://www.rasterbar.com/products/luabind/docs.html#nested-scopes-and-static-functions">http://www.rasterbar.com/products/luabind/docs.html#nested-scopes-and-static-functions</a><br>
                  </div>
                  Binding static members should be obvious from there<br>
                  <br>
                </div>
                <div class="gmail_extra"><br>
                  <br>
                  <div class="gmail_quote">On Sun, Apr 7, 2013 at 1:52
                    PM, Lorenzo Pistone <span dir="ltr">&lt;<a
                        moz-do-not-send="true"
                        href="mailto:[email protected]"
                        target="_blank">[email protected]</a>&gt;</span>
                    wrote:<br>
                    <blockquote class="gmail_quote" style="margin-top:
                      0px; margin-right: 0px; margin-bottom: 0px;
                      margin-left: 0.8ex; border-left-width: 1px;
                      border-left-color: rgb(204, 204, 204);
                      border-left-style: solid; padding-left: 1ex;
                      position: static; z-index: auto; ">Hello,<br>
                      I cannot find any reference on how to bind a
                      static member variable, so<br>
                      that I can access it from lua as
                      myclass.staticmember.<br>
                      <br>
                      Cheers.<br>
                    </blockquote>
                  </div>
                </div>
              </blockquote>
            </div>
          </blockquote>
        </div>
        <br>
      </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>

--------------090300030102050706020003--


--===============3196452986186504706==
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
--===============3196452986186504706==
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

--===============3196452986186504706==--