From f87cd4435dbe20470b46ad9a7510da97435c0c73 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 31 May 2016 23:32:12 +0200 Subject: [PATCH] allow lua binding functions with up to 9 parameters e.g new_midi_track() --- libs/lua/LuaBridge/detail/FuncTraits.h | 91 ++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/libs/lua/LuaBridge/detail/FuncTraits.h b/libs/lua/LuaBridge/detail/FuncTraits.h index c99d028e86..5cece7b15c 100644 --- a/libs/lua/LuaBridge/detail/FuncTraits.h +++ b/libs/lua/LuaBridge/detail/FuncTraits.h @@ -178,6 +178,20 @@ struct FuncTraits } }; +template +struct FuncTraits +{ + static bool const isMemberFunction = false; + typedef D DeclType; + typedef R ReturnType; + typedef TypeList > > > > > > > > Params; + static R call (D fp, TypeListValues & tvl) + { + return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.tl.hd); + } +}; + + /* Non-const member function pointers. */ template @@ -315,6 +329,22 @@ struct FuncTraits } }; +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = false; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList > > > > > > > > Params; + static R call (T* obj, D fp, TypeListValues & tvl) + { + return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.tl.hd); + } +}; + + /* Const member function pointers. */ template @@ -453,6 +483,22 @@ struct FuncTraits } }; +template +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = true; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList > > > > > > > > Params; + static R call (T const* obj, D fp, TypeListValues & tvl) + { + return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.tl.hd); + } +}; + + #if defined (LUABRIDGE_THROWSPEC) /* Ordinary function pointers. */ @@ -574,6 +620,19 @@ struct FuncTraits +struct FuncTraits +{ + static bool const isMemberFunction = false; + typedef D DeclType; + typedef R ReturnType; + typedef TypeList > > > > > > > > Params; + static R call (D fp, TypeListValues & tvl) + { + return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.tl.hd); + } +}; + /* Non-const member function pointers with THROWSPEC. */ template @@ -711,6 +770,22 @@ struct FuncTraits +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = false; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList > > > > > > > > Params; + static R call (T* obj, D fp, TypeListValues & tvl) + { + return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.tl.hd); + } +}; + + /* Const member function pointers with THROWSPEC. */ template @@ -849,4 +924,20 @@ struct FuncTraits +struct FuncTraits +{ + static bool const isMemberFunction = true; + static bool const isConstMemberFunction = true; + typedef D DeclType; + typedef T ClassType; + typedef R ReturnType; + typedef TypeList > > > > > > > > Params; + static R call (T const* obj, D fp, TypeListValues & tvl) + { + return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.tl.hd); + } +}; + + #endif