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

Chris Byrne <[email protected]> Thu, 4 Sep 2014 10:18:52 -0700
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <CABSAafFF2bOtTnvX+Aq2GJ4w52ECgKvysyRw6bjSZCBSsT1doQ@mail.gmail.com>
--===============7335425834942215496==
Content-Type: multipart/alternative; boundary=001a1134652ebd360a0502408d8c

--001a1134652ebd360a0502408d8c
Content-Type: text/plain; charset=UTF-8

I would second that approach.


If you really want to go down the path of binding functions with more than
10 arguments, then I think you need to define LUABIND_MAX_ARITY with a
value greater than 10.

10 being the default value if LUABIND_MAX_ARITY is not already defined:
 https://github.com/luabind/luabind/blob/master/luabind/config.hpp

This is used during pre-processing to expand out and provide the necessary
binding overloads (predating variadic templates).


I haven't tried this, so I can't promise that this is the only definition
(or even the correct one). There is likely a similar limitation/definition
within boost as well.


Kind Regards,
 CB


On Thu, Sep 4, 2014 at 9:51 AM, Andreas Grob <[email protected]>
wrote:

>  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
>  ====================================================================
>          _ _                              _           _ _        _
> __ _____| | |_ __ _ __ _ ___   __ ___ _ _| |_ _ _ ___| | |___ __| |
> \ V / _ \ |  _/ _` / _` / -_) / _/ _ \ ' \  _| '_/ _ \ | / -_) _` |
>  \_/\___/_|\__\__,_\__, \___| \__\___/_||_\__|_| \___/_|_\___\__,_|
>                    |___/
> ====================================================================
>
>
>
>
>
> ------------------------------------------------------------------------------
> Slashdot TV.
> Video for Nerds.  Stuff that matters.http://tv.slashdot.org/
>
>
>
> _______________________________________________
> luabind-user mailing [email protected]://lists.sourceforge.net/lists/listinfo/luabind-user
>
>
>

--001a1134652ebd360a0502408d8c
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I would second that approach.<div><br></div><div><br></div=
><div>If you really want to go down the path of binding functions with more=
 than 10 arguments, then I think you need to define LUABIND_MAX_ARITY with =
a value greater than 10.</div>

<div><br></div><div>10 being the default value if LUABIND_MAX_ARITY is not =
already defined:</div><div>=C2=A0<a href=3D"https://github.com/luabind/luab=
ind/blob/master/luabind/config.hpp">https://github.com/luabind/luabind/blob=
/master/luabind/config.hpp</a><br>

</div><div><br></div><div>This is used during pre-processing to expand out =
and provide the necessary binding overloads (predating variadic templates).=
</div><div><br></div><div><br></div><div>I haven&#39;t tried this, so I can=
&#39;t promise that this is the only definition (or even the correct one). =
There is likely a similar limitation/definition within boost as well.</div>

<div><br></div><div><br></div><div>Kind Regards,</div><div>=C2=A0CB</div><d=
iv class=3D"gmail_extra"><br></div><div class=3D"gmail_extra"><br><div clas=
s=3D"gmail_quote">On Thu, Sep 4, 2014 at 9:51 AM, Andreas Grob <span dir=3D=
"ltr">&lt;<a href=3D"mailto:[email protected]" target=3D"_blank">=
[email protected]</a>&gt;</span> wrote:<br>

<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;p=
adding-left:1ex">



<div bgcolor=3D"#FFFFFF">
<div>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 type=3D"cite"><div><div class=3D"h5">
<div dir=3D"ltr">
<div style=3D"font-family:&#39;courier new&#39;,monospace">Helo.<br>
<br>
I&#39;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 v=
ia 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&#39;s all working fi=
ne, until i hit a problem. Some of the methods in the original LookAndFeel =
class have more then 10 parameters,
 and i can&#39;t bind those methods using this approach.<br>
<br>
</div>
<div style=3D"font-family:&#39;courier new&#39;,monospace">One of the solut=
ions i found would be to change the parameters and wrap them in a structure=
, and that would be a good idea but i can&#39;t change the original LookAnd=
Feel class, and
 changing the class that derives from luabind::wrap_base - that i&#39;m imp=
lementing - so that it&#39;s methods take a structure as a parameter instea=
d of the actual parameters, makes those methods unusable (luabind never cal=
ls them, since the parameter count and type
 does not match the original LookAndFeel class).<br>
<br>
</div>
<div style=3D"font-family:&#39;courier new&#39;,monospace">Is there a way t=
o 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 style=3D"font-family:&#39;courier new&#39;,monospace">Any help is welc=
ome.<br>
<br>
</div>
<div style=3D"font-family:&#39;courier new&#39;,monospace">My class looks l=
ike:<br>
class LLookAndFeel : public LookAndFeel_V3, public luabind::wrap_base<br>
{<br>
=C2=A0=C2=A0=C2=A0=C2=A0 virtual void drawButtonBackground (Graphics &amp;g=
, Button &amp;b, const Colour &amp;c, bool over, bool down) override<br>
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 { call&lt;void&gt;=
(&quot;drawButtonBackground&quot;, boost::ref (g), boost::ref(b), c, over, =
down); }<br>
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 static void def_drawButtonBackground =
(LookAndFeel_V3 *ptr, Graphics &amp;g, Button &amp;b, const Colour &amp;c, =
bool over, bool down)<br>
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 { return (ptr-&gt;=
LookAndFeel_V3::drawButtonBackground (g,b,c,over,down)); }<br>
<br>
</div>
<div style=3D"font-family:&#39;courier new&#39;,monospace">/* More methods =
are needed that have more then 10 parameters */<br>
</div>
<div style=3D"font-family:&#39;courier new&#39;,monospace">}<br>
<br>
</div>
<div style=3D"font-family:&#39;courier new&#39;,monospace">Best regards.<br=
>
<br>
Roman Kubiak<br>
<a href=3D"http://ctrlr.org" target=3D"_blank">http://ctrlr.org</a><br clea=
r=3D"all">
</div>
<div><font size=3D"1">=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<br>
<span style=3D"font-family:&#39;courier new&#39;,monospace">=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 _ _=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 _=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 _ _=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 _</span><br style=3D"font-family:&#39;courier new&=
#39;,monospace">
<span style=3D"font-family:&#39;courier new&#39;,monospace">__ _____| | |_ =
__ _ __ _ ___=C2=A0=C2=A0 __ ___ _ _| |_ _ _ ___| | |___ __| |</span><br st=
yle=3D"font-family:&#39;courier new&#39;,monospace">
<span style=3D"font-family:&#39;courier new&#39;,monospace">\ V / _ \ |=C2=
=A0 _/ _` / _` / -_) / _/ _ \ &#39; \=C2=A0 _| &#39;_/ _ \ | / -_) _` |</sp=
an><br style=3D"font-family:&#39;courier new&#39;,monospace">
<span style=3D"font-family:&#39;courier new&#39;,monospace">=C2=A0\_/\___/_=
|\__\__,_\__, \___| \__\___/_||_\__|_| \___/_|_\___\__,_|</span><br style=
=3D"font-family:&#39;courier new&#39;,monospace">
<span style=3D"font-family:&#39;courier new&#39;,monospace">=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0 |___/</span><br>
=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<br style=3D"font-fam=
ily:&#39;courier new&#39;,monospace">
<br style=3D"font-family:&#39;courier new&#39;,monospace">
<br style=3D"font-family:&#39;courier new&#39;,monospace">
</font><br>
</div>
</div>
<br>
<fieldset></fieldset> <br>
</div></div><pre>----------------------------------------------------------=
--------------------
Slashdot TV. =20
Video for Nerds.  Stuff that matters.
<a href=3D"http://tv.slashdot.org/" target=3D"_blank">http://tv.slashdot.or=
g/</a></pre>
<br>
<fieldset></fieldset> <br>
<pre>_______________________________________________
luabind-user mailing list
<a href=3D"mailto:[email protected]" target=3D"_blank">lua=
[email protected]</a>
<a href=3D"https://lists.sourceforge.net/lists/listinfo/luabind-user" targe=
t=3D"_blank">https://lists.sourceforge.net/lists/listinfo/luabind-user</a>
</pre>
</blockquote>
<br>

</div>

</blockquote></div><br></div></div>

--001a1134652ebd360a0502408d8c--


--===============7335425834942215496==
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/
--===============7335425834942215496==
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

--===============7335425834942215496==--