Re: [luabind] Deriving in lua, more then 10 parameters for a method
Brought to you by:
arvidn,
daniel_wallin
From: Chris B. <Chr...@ba...> - 2014-09-04 22:01:11
|
ok, I missed that last bit in your email. When changing LUABIND_MAX_ARITY to 20 there are indeed boost related compile errors. 2>s:\lib\luabind-0.9\luabind/detail/object_call.hpp(38): error C2977: 'boost::tuples::tuple' : too many template arguments 2> s:\lib\boost_1_46_1\boost/tuple/detail/tuple_basic.hpp(470) : see declaration of 'boost::tuples::tuple' 2> s:\lib\luabind-0.9\luabind/object.hpp(336) : see reference to class template instantiation 'luabind::adl::object_interface<T>' being compiled (excuse my super old versions of boost & luabind) Per: http://www.boost.org/doc/libs/1_56_0/libs/tuple/doc/tuple_users_guide.html *"The current version supports tuples with 0-10 elements"* and there's http://stackoverflow.com/questions/6425178/boost-tuple-increasing-maximum-number-of-elements which suggests a couple of options. i) Hack up tuple_basic.hpp and extend declarations out to the number of arguments you need ii) If your compiler(s) support variadic templates could consider changing luabind to use std::tuple iii) Changing luabind over to use boost::fusion::tuple which has a FUSION_MAX_VECTOR_SIZE definition Hard to know which is least effort. Sticking with boost (options i & iii) would be the most cross platform friendly (at least for now). Hacking up tuplic_basic.hpp is somewhat tedious and a quick search wasn't able to find someone who has already done this. Essentially involves extending out the number of template parameters: template < class T0 = null_type, class T1 = null_type, class T2 = null_type, class T3 = null_type, class T4 = null_type, class T5 = null_type, class T6 = null_type, class T7 = null_type, class T8 = null_type, class T9 = null_type, class T10 = null_type, class T11 = null_type, class T12 = null_type, class T13 = null_type, class T14 = null_type> class tuple; along with the several supporting classes: // Tuple to cons mapper -------------------------------------------------- template <class T0, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class T11, class T12, class T13, class T14> struct map_tuple_to_cons - I would still recommend using a facade and avoid the need for more arguments. Kind Regards, CB On Thu, Sep 4, 2014 at 12:41 PM, Roman Kubiak <kub...@gm...> wrote: > Like i wrote, increasing that constant above 10 is impossible, you'll > get flooded with compile errors, if that constant goes above 10 something > needs to change in boost to handle that. My question what and how, i'm not > a big boost expert, i use it only for luabind so i was wondering if there > was a ready solution to get this working. > > cheers. > > ==================================================================== > _ _ _ _ _ _ > __ _____| | |_ __ _ __ _ ___ __ ___ _ _| |_ _ _ ___| | |___ __| | > \ V / _ \ | _/ _` / _` / -_) / _/ _ \ ' \ _| '_/ _ \ | / -_) _` | > \_/\___/_|\__\__,_\__, \___| \__\___/_||_\__|_| \___/_|_\___\__,_| > |___/ > ==================================================================== > > > > > > On Thu, Sep 4, 2014 at 7:18 PM, Chris Byrne <Chr...@ba...> wrote: > >> 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 < >> And...@tu...> 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 lis...@li...https://lists.sourceforge.net/lists/listinfo/luabind-user >>> >>> >>> >> >> >> ------------------------------------------------------------------------------ >> Slashdot TV. >> Video for Nerds. Stuff that matters. >> http://tv.slashdot.org/ >> _______________________________________________ >> luabind-user mailing list >> lua...@li... >> https://lists.sourceforge.net/lists/listinfo/luabind-user >> >> > |