Re: Deriving in lua, more then 10 parameters for a method

Andreas Grob <[email protected]> Thu, 04 Sep 2014 18:51:04 +0200
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--===============1698306175657260791==
Content-Type: multipart/alternative;
	boundary="------------050408060304050206030205"

This is a multi-part message in MIME format.
--------------050408060304050206030205
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hi,

How about wrapping the whole L&F class to have a cleaner interface? You
could store the original L&F inside that wrapper using pimpl and have a
method to move it out.

Regards,
Andreas

Am 04.09.2014 16:12, schrieb Roman Kubiak:
> Helo.
>
> I'm using a third party library for my application (JUCE), this
> library has a large class called LookAndFeel, i want to expose that
> class to lua via luabind.
>
> I started to do the work following the documentation, and using the
> luabind::wrap_base approach, i got a few methods bound and it's all
> working fine, until i hit a problem. Some of the methods in the
> original LookAndFeel class have more then 10 parameters, and i can't
> bind those methods using this approach.
>
> One of the solutions i found would be to change the parameters and
> wrap them in a structure, and that would be a good idea but i can't
> change the original LookAndFeel class, and changing the class that
> derives from luabind::wrap_base - that i'm implementing - so that it's
> methods take a structure as a parameter instead of the actual
> parameters, makes those methods unusable (luabind never calls them,
> since the parameter count and type does not match the original
> LookAndFeel class).
>
> Is there a way to solve this somehow, can i increase the limit of 10
> parameters in luabind (trying to extend the ARITY macro over 10 causes
> loades of compile errors).
>
> Any help is welcome.
>
> My class looks like:
> class LLookAndFeel : public LookAndFeel_V3, public luabind::wrap_base
> {
>      virtual void drawButtonBackground (Graphics &g, Button &b, const
> Colour &c, bool over, bool down) override
>             { call<void>("drawButtonBackground", boost::ref (g),
> boost::ref(b), c, over, down); }
>         static void def_drawButtonBackground (LookAndFeel_V3 *ptr,
> Graphics &g, Button &b, const Colour &c, bool over, bool down)
>             { return (ptr->LookAndFeel_V3::drawButtonBackground
> (g,b,c,over,down)); }
>
> /* More methods are needed that have more then 10 parameters */
> }
>
> Best regards.
>
> Roman Kubiak
> http://ctrlr.org
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>          _ _                              _           _ _        _
> __ _____| | |_ __ _ __ _ ___   __ ___ _ _| |_ _ _ ___| | |___ __| |
> \ V / _ \ |  _/ _` / _` / -_) / _/ _ \ ' \  _| '_/ _ \ | / -_) _` |
>  \_/\___/_|\__\__,_\__, \___| \__\___/_||_\__|_| \___/_|_\___\__,_|
>                    |___/
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>
>
>
>
>
> -------------------------------------------------------------------------=
-----
> Slashdot TV.  
> Video for Nerds.  Stuff that matters.
> http://tv.slashdot.org/
>
>
> _______________________________________________
> luabind-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/luabind-user



---
Diese E-Mail ist frei von Viren und Malware, denn der avast! Antivirus Schu=
tz ist aktiv.
http://www.avast.com

--------------050408060304050206030205
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit

<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Hi,<br>
      <br>
      How about wrapping the whole L&amp;F class to have a cleaner
      interface? You could store the original L&amp;F inside that
      wrapper using pimpl and have a method to move it out.<br>
      <br>
      Regards,<br>
      Andreas<br>
      <br>
      Am 04.09.2014 16:12, schrieb Roman Kubiak:<br>
    </div>
    <blockquote
cite="mid:CACugK=YQhD+eqch7XKs9EM65wg95N-CVrZeiPGzZ2DZ7+5WTiw@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_default" style="font-family:courier
          new,monospace">Helo.<br>
          <br>
          I'm using a third party library for my application (JUCE),
          this library has a large class called LookAndFeel, i want to
          expose that class to lua via luabind.<br>
          <br>
          I started to do the work following the documentation, and
          using the luabind::wrap_base approach, i got a few methods
          bound and it's all working fine, until i hit a problem. Some
          of the methods in the original LookAndFeel class have more
          then 10 parameters, and i can't bind those methods using this
          approach.<br>
          <br>
        </div>
        <div class="gmail_default" style="font-family:courier
          new,monospace">One of the solutions i found would be to change
          the parameters and wrap them in a structure, and that would be
          a good idea but i can't change the original LookAndFeel class,
          and changing the class that derives from luabind::wrap_base -
          that i'm implementing - so that it's methods take a structure
          as a parameter instead of the actual parameters, makes those
          methods unusable (luabind never calls them, since the
          parameter count and type does not match the original
          LookAndFeel class).<br>
          <br>
        </div>
        <div class="gmail_default" style="font-family:courier
          new,monospace">Is there a way to solve this somehow, can i
          increase the limit of 10 parameters in luabind (trying to
          extend the ARITY macro over 10 causes loades of compile
          errors).<br>
          <br>
        </div>
        <div class="gmail_default" style="font-family:courier
          new,monospace">Any help is welcome.<br>
          <br>
        </div>
        <div class="gmail_default" style="font-family:courier
          new,monospace">My class looks like:<br>
          class LLookAndFeel : public LookAndFeel_V3, public
          luabind::wrap_base<br>
          {<br>
          &nbsp;&nbsp;&nbsp;&nbsp; virtual void drawButtonBackground (Graphics &amp;g,
          Button &amp;b, const Colour &amp;c, bool over, bool down)
          override<br>
          &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; { call&lt;void&gt;("drawButtonBackground",
          boost::ref (g), boost::ref(b), c, over, down); }<br>
          &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; static void def_drawButtonBackground (LookAndFeel_V3
          *ptr, Graphics &amp;g, Button &amp;b, const Colour &amp;c,
          bool over, bool down)<br>
          &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; { return
          (ptr-&gt;LookAndFeel_V3::drawButtonBackground
          (g,b,c,over,down)); }<br>
          <br>
        </div>
        <div class="gmail_default" style="font-family:courier
          new,monospace">/* More methods are needed that have more then
          10 parameters */<br>
        </div>
        <div class="gmail_default" style="font-family:courier
          new,monospace">
          }<br>
          <br>
        </div>
        <div class="gmail_default" style="font-family:courier
          new,monospace">Best regards.<br>
          <br>
          Roman Kubiak<br>
          <a moz-do-not-send="true" href="http://ctrlr.org">http://ctrlr.org</a><br
            clear="all">
        </div>
        <div><font size="1">====================================================================<br>
            <span style="font-family:courier new,monospace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _
              _&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _ _&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _</span><br
              style="font-family:courier new,monospace">
            <span style="font-family:courier new,monospace">__ _____| |
              |_ __ _ __ _ ___&nbsp;&nbsp; __ ___ _ _| |_ _ _ ___| | |___ __| |</span><br
              style="font-family:courier new,monospace">
            <span style="font-family:courier new,monospace">\ V / _ \ |&nbsp;
              _/ _` / _` / -_) / _/ _ \ ' \&nbsp; _| '_/ _ \ | / -_) _` |</span><br
              style="font-family:courier new,monospace">
            <span style="font-family:courier new,monospace">&nbsp;\_/\___/_|\__\__,_\__,
              \___| \__\___/_||_\__|_| \___/_|_\___\__,_|</span><br
              style="font-family:courier new,monospace">
            <span style="font-family:courier new,monospace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              |___/</span><br>
====================================================================<br
              style="font-family:courier new,monospace">
            <br style="font-family:courier new,monospace">
            <br style="font-family:courier new,monospace">
          </font><br>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
<a class="moz-txt-link-freetext" href="http://tv.slashdot.org/">http://tv.slashdot.org/</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>
  
<br /><br />
<hr style='border:none; color:#909090; background-color:#B0B0B0; height: 1px; width: 99%;' />
<table style='border-collapse:collapse;border:none;'>
	<tr>
		<td style='border:none;padding:0px 15px 0px 8px'>
			<a href="http://www.avast.com/">
				<img border=0 src="http://static.avast.com/emails/avast-mail-stamp.png" />
			</a>
		</td>
		<td>
			<p style='color:#3d4d5a; font-family:"Calibri","Verdana","Arial","Helvetica"; font-size:12pt;'>
				Diese E-Mail ist frei von Viren und Malware, denn der <a href="http://www.avast.com/">avast! Antivirus</a> Schutz ist aktiv.
			</p>
		</td>
	</tr>
</table>
<br />
</body>
</html>

--------------050408060304050206030205--


--===============1698306175657260791==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
--===============1698306175657260791==
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

--===============1698306175657260791==--