]> de.git.xonotic.org Git - xonotic/netradiant.git/commitdiff
Callback: work at any arity
authorTimePath <andrew.hardaker1995@gmail.com>
Sun, 31 Dec 2017 15:16:35 +0000 (02:16 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Sun, 31 Dec 2017 15:16:35 +0000 (02:16 +1100)
23 files changed:
include/icamera.h
include/ifilesystem.h
include/irender.h
include/iselection.h
include/ishaders.h
include/iundo.h
include/mapfile.h
include/modelskin.h
include/nameable.h
include/namespace.h
include/preferencesystem.h
include/selectable.h
libs/generic/CMakeLists.txt
libs/generic/callback.h
libs/generic/callbackfwd.h [deleted file]
libs/generic/functional.h
libs/gtkutil/button.h
libs/gtkutil/menu.h
libs/gtkutil/toolbar.h
radiant/brushmanip.h
radiant/selection.h
radiant/textures.h
radiant/texwindow.h

index e9becbae6f82748b4771d811e276275d7931e004..36cc24f11f0dce22b4158cd419ff1e8190ed1e62 100644 (file)
@@ -29,7 +29,7 @@
 #define INCLUDED_ICAMERA_H
 
 #include "generic/constant.h"
 #define INCLUDED_ICAMERA_H
 
 #include "generic/constant.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
 
 class Matrix4;
 
 
 class Matrix4;
 
index f497528f42a086b118124f46be938618ee04668c..605aba29810eb9d5c522ad65e8ed4e27c6bac0c7 100644 (file)
@@ -24,7 +24,7 @@
 
 #include <cstddef>
 #include "generic/constant.h"
 
 #include <cstddef>
 #include "generic/constant.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
 
 typedef Callback1<const char*> ArchiveNameCallback;
 typedef Callback1<const char*> FileNameCallback;
 
 typedef Callback1<const char*> ArchiveNameCallback;
 typedef Callback1<const char*> FileNameCallback;
index 8b0c3ec6b999507b594f646d89282c91b237f8ec..fbba51db007a51c3284bb47ae6188b10218cffc4 100644 (file)
@@ -23,7 +23,7 @@
 #define INCLUDED_IRENDER_H
 
 #include "generic/constant.h"
 #define INCLUDED_IRENDER_H
 
 #include "generic/constant.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
 
 
 // Rendering states to sort by.
 
 
 // Rendering states to sort by.
index a5951f9a78a031a6d1dc53fcf76296378641c9da..898a9aa1cf2daf464344db52819d327770567312 100644 (file)
@@ -24,7 +24,7 @@
 
 #include <cstddef>
 #include "generic/constant.h"
 
 #include <cstddef>
 #include "generic/constant.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
 #include "signal/signalfwd.h"
 
 class Renderer;
 #include "signal/signalfwd.h"
 
 class Renderer;
index ac447090cbd99fb9cde9aeade1cf8d833113e375..e66c9c7be887cb34cbc8cf0feb4693682a454358 100644 (file)
@@ -23,7 +23,7 @@
 #define INCLUDED_ISHADERS_H
 
 #include "generic/constant.h"
 #define INCLUDED_ISHADERS_H
 
 #include "generic/constant.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
 
 enum
 {
 
 enum
 {
index eb1e8681c9c16a7882d240306dc20bff43daafb0..25fa14899672b3a115f6c74ebeb72b4f3cb5da1d 100644 (file)
@@ -27,7 +27,7 @@
 
 #include <cstddef>
 #include "generic/constant.h"
 
 #include <cstddef>
 #include "generic/constant.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
 
 class UndoMemento
 {
 
 class UndoMemento
 {
index df1ab36fd7f44388a2d73447bc89bfc105a01495..7d61f6ed7e5472ba7e1d31129413df1eb563c5a8 100644 (file)
@@ -25,7 +25,7 @@
 #include <limits>
 
 #include "iscenegraph.h"
 #include <limits>
 
 #include "iscenegraph.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
 
 const std::size_t MAPFILE_MAX_CHANGES = std::numeric_limits<std::size_t>::max();
 
 
 const std::size_t MAPFILE_MAX_CHANGES = std::numeric_limits<std::size_t>::max();
 
index a2c219e6be1ca48c85d53e58b28ea3cacf1a5ff4..90fef9452a7d387a54272c7a627f18ec17eb87c8 100644 (file)
@@ -23,7 +23,7 @@
 #define INCLUDED_MODELSKIN_H
 
 #include "generic/constant.h"
 #define INCLUDED_MODELSKIN_H
 
 #include "generic/constant.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
 
 class SkinRemap
 {
 
 class SkinRemap
 {
index bbc6f899250891667cda4361fc0d56189d536df5..e295e5c66c322768de6dd41c35206dfe7ca6a5b6 100644 (file)
@@ -23,7 +23,7 @@
 #define INCLUDED_NAMEABLE_H
 
 #include "generic/constant.h"
 #define INCLUDED_NAMEABLE_H
 
 #include "generic/constant.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
 
 typedef Callback1<const char*> NameCallback;
 
 
 typedef Callback1<const char*> NameCallback;
 
index 9a00793c07a99350d9cabd2317130f63c90a78b0..f87a2e0604c720cf8b4cdafe3beaebe7ee90e8c7 100644 (file)
@@ -23,7 +23,7 @@
 #define INCLUDED_NAMESPACE_H
 
 #include "generic/constant.h"
 #define INCLUDED_NAMESPACE_H
 
 #include "generic/constant.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
 
 typedef Callback1<const char*> NameCallback;
 typedef Callback1<const NameCallback&> NameCallbackCallback;
 
 typedef Callback1<const char*> NameCallback;
 typedef Callback1<const NameCallback&> NameCallbackCallback;
index 45678024ffd8ec0a6df23e509a7d708fc8ed5369..bbc838ad11d5ae55f984ec5190ee9c7b4af61375 100644 (file)
@@ -23,7 +23,7 @@
 #define INCLUDED_PREFERENCESYSTEM_H
 
 #include "generic/constant.h"
 #define INCLUDED_PREFERENCESYSTEM_H
 
 #include "generic/constant.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
 
 typedef Callback1<const char*> StringImportCallback;
 typedef Callback1<const StringImportCallback&> StringExportCallback;
 
 typedef Callback1<const char*> StringImportCallback;
 typedef Callback1<const StringImportCallback&> StringExportCallback;
index 2b8eab073c24de63358749f01081885c7e7efbe1..1cea909f1a1cf4cdac6e6548d497b46daee79158 100644 (file)
@@ -26,7 +26,7 @@
 
 #include "generic/vector.h"
 #include "scenelib.h"
 
 #include "generic/vector.h"
 #include "scenelib.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
 
 class SelectionIntersection
 {
 
 class SelectionIntersection
 {
index b872d8740a4a405c17c9767ff586800ff6a59c2b..d89f57438b40966d7ce6a41003a3b4a27196f30a 100644 (file)
@@ -2,7 +2,6 @@ add_library(generic
         arrayrange.h
         bitfield.h
         callback.cpp callback.h
         arrayrange.h
         bitfield.h
         callback.cpp callback.h
-        callbackfwd.h
         constant.cpp constant.h
         enumeration.h
         functional.h
         constant.cpp constant.h
         enumeration.h
         functional.h
index 4110691e03b6b672ed8bc0917edbc2474c0e1dc9..1e8cd46d5be4a944e39218d2df10adcb37be7ac5 100644 (file)
@@ -27,7 +27,6 @@
 
 #include <cstddef>
 #include "functional.h"
 
 #include <cstddef>
 #include "functional.h"
-#include "callbackfwd.h"
 
 template<typename Type>
 inline void* convertToOpaque( Type* t ){
 
 template<typename Type>
 inline void* convertToOpaque( Type* t ){
@@ -150,6 +149,9 @@ public:
 template<class Caller>
 using BindFirstOpaque = BindFirstOpaqueN<Caller, get_func<Caller>>;
 
 template<class Caller>
 using BindFirstOpaque = BindFirstOpaqueN<Caller, get_func<Caller>>;
 
+/// \brief Combines a void pointer with a pointer to a function which operates on a void pointer.
+///
+/// Use with the callback constructors MemberCaller, ConstMemberCaller, ReferenceCaller, ConstReferenceCaller, PointerCaller, ConstPointerCaller and FreeCaller.
 template<class F>
 class CallbackN;
 
 template<class F>
 class CallbackN;
 
@@ -178,226 +180,205 @@ public:
        }
 };
 
        }
 };
 
-/// \brief Combines a void pointer with a pointer to a function which operates on a void pointer.
-///
-/// Use with the callback constructors MemberCaller, ConstMemberCaller, ReferenceCaller, ConstReferenceCaller, PointerCaller, ConstPointerCaller and FreeCaller.
-template<class Result>
-class Callback0 : public CallbackN<Result()> {
-public:
-       using CallbackN<Result()>::CallbackN;
-};
+namespace detail {
+       template<class F>
+       struct Arglist;
 
 
-template<typename Caller>
-inline Callback0<get_result_type<Caller>> makeCallback0(const Caller &caller, get_argument<Caller, 0> callee) {
-       return Callback0<get_result_type<Caller>>(BindFirstOpaque<Caller>(callee));
-}
-template<typename Caller>
-inline Callback0<get_result_type<Caller>> makeStatelessCallback0(const Caller &caller) {
-       return makeCallback0( Caller0To1<Caller>(), 0 );
-}
+       template<class R, class Head, class... Ts>
+       struct Arglist<R(Head, Ts...)> {
+               using type = R(Head, Ts...);
 
 
-typedef Callback0<void> Callback;
+               template <class Unshift>
+               using unshift = Arglist<R(Unshift, Head, Ts...)>;
 
 
+               using shift = Arglist<R(Ts...)>;
+       };
 
 
+       template<class R, class... Ts>
+       struct Arglist<R(Ts...)> {
+               using type = R(Ts...);
 
 
-/// \brief Combines a void pointer with a pointer to a function which operates on a void pointer and one other argument.
-///
-/// Use with the callback constructors MemberCaller1, ConstMemberCaller1, ReferenceCaller1, ConstReferenceCaller1, PointerCaller1, ConstPointerCaller1 and FreeCaller1.
-template<class FirstArgument, class Result>
-class Callback1 : public CallbackN<Result(FirstArgument)> {
-public:
-       using CallbackN<Result(FirstArgument)>::CallbackN;
-};
-
-template<typename Caller>
-inline Callback1<get_argument<Caller, 1>, get_result_type<Caller>>
-makeCallback1(const Caller &caller, get_argument<Caller, 0> callee) {
-       return Callback1<get_argument<Caller, 1>, get_result_type<Caller>>(BindFirstOpaque<Caller>(callee));
+               template <class Unshift>
+               using unshift = Arglist<R(Unshift, Ts...)>;
+       };
 }
 }
-template<typename Caller>
-inline Callback1<get_argument<Caller, 1>, get_result_type<Caller>> makeStatelessCallback1(const Caller &caller) {
-       return makeCallback1( Caller1To2<Caller>(), 0 );
-}
-
-
-/// \brief Combines a void pointer with a pointer to a function which operates on a void pointer and two other arguments.
-///
-template<typename FirstArgument, typename SecondArgument, typename Result>
-class Callback2 : public CallbackN<Result(FirstArgument, SecondArgument)> {
-public:
-       using CallbackN<Result(FirstArgument, SecondArgument)>::CallbackN;
-};
 
 template<typename Caller>
 
 template<typename Caller>
-inline Callback2<
-               get_argument<Caller, 1>,
-               get_argument<Caller, 2>,
-               get_result_type<Caller>
-> makeCallback2(const Caller &caller, get_argument<Caller, 0> callee) {
-       return Callback2<
-                       get_argument<Caller, 1>,
-                       get_argument<Caller, 2>,
-                       get_result_type<Caller>
-       >(BindFirstOpaque<Caller>(callee));
+inline CallbackN<typename detail::Arglist<get_func<Caller>>::shift::type> makeCallbackN(const Caller &caller, get_argument<Caller, 0> callee) {
+       return CallbackN<typename detail::Arglist<get_func<Caller>>::shift::type>(BindFirstOpaque<Caller>(callee));
 }
 }
+
 template<typename Caller>
 template<typename Caller>
-inline Callback2<
-               get_argument<Caller, 0>,
-               get_argument<Caller, 1>,
-               get_result_type<Caller>
-> makeStatelessCallback2(const Caller &caller) {
-       return makeCallback2( Caller2To3<Caller>(), 0 );
+inline CallbackN<get_func<Caller>> makeStatelessCallbackN(const Caller &caller) {
+       return makeCallbackN(CallerShiftFirst<Caller, typename detail::Arglist<get_func<Caller>>::template unshift<void *>::type>(), nullptr);
 }
 
 }
 
+namespace detail {
+       template<class Object, class F>
+       struct MemberFunction;
 
 
-/// \brief Combines a void pointer with a pointer to a function which operates on a void pointer and three other arguments.
-///
-template<typename FirstArgument, typename SecondArgument, typename ThirdArgument, typename Result>
-class Callback3 : public CallbackN<Result(FirstArgument, SecondArgument, ThirdArgument)> {
-public:
-       using CallbackN<Result(FirstArgument, SecondArgument, ThirdArgument)>::CallbackN;
-};
-
-template<typename Caller>
-inline Callback3<
-               get_argument<Caller, 1>,
-               get_argument<Caller, 2>,
-               get_argument<Caller, 3>,
-               get_result_type<Caller>
-> makeCallback3(const Caller &caller, get_argument<Caller, 0> callee) {
-       return Callback3<
-                       get_argument<Caller, 1>,
-                       get_argument<Caller, 2>,
-                       get_argument<Caller, 3>,
-                       get_result_type<Caller>
-       >(BindFirstOpaque<Caller>(callee));
-}
-template<typename Caller>
-inline Callback3<
-               get_argument<Caller, 0>,
-               get_argument<Caller, 1>,
-               get_argument<Caller, 2>,
-               get_result_type<Caller>
-> makeStatelessCallback3(const Caller &caller) {
-       return makeCallback3( Caller3To4<Caller>(), 0 );
+       template<class Object, class R, class... Ts>
+       struct MemberFunction<Object, R(Ts...)> {
+               using type = R(Object::*)(Ts...);
+               using type_const = R(Object::*)(Ts...) const;
+       };
 }
 
 }
 
+template<class Object, class F>
+using MemberFunction = typename detail::MemberFunction<Object, F>::type;
+
+template<class Object, class F>
+using ConstMemberFunction = typename detail::MemberFunction<Object, F>::type_const;
 
 /// \brief Forms a Callback from a non-const Environment reference and a non-const Environment member-function.
 ///
 /// \dontinclude generic/callback.cpp
 /// \skipline MemberCaller example
 /// \until end example
 
 /// \brief Forms a Callback from a non-const Environment reference and a non-const Environment member-function.
 ///
 /// \dontinclude generic/callback.cpp
 /// \skipline MemberCaller example
 /// \until end example
-template<class Environment, void(Environment::*member)()>
-using MemberCaller = BindFirstOpaque<Member<Environment, void, member>>;
+
+template<class Environment, class F, MemberFunction<Environment, F> member>
+using MemberCallerN = BindFirstOpaque<typename MemberN<Environment, F>::template instance<member>>;
 
 /// \brief Forms a Callback from a const Environment reference and a const Environment member-function.
 ///
 /// \dontinclude generic/callback.cpp
 /// \skipline MemberCaller example
 /// \until end example
 
 /// \brief Forms a Callback from a const Environment reference and a const Environment member-function.
 ///
 /// \dontinclude generic/callback.cpp
 /// \skipline MemberCaller example
 /// \until end example
-template<class Environment, void(Environment::*member)() const>
-using ConstMemberCaller = BindFirstOpaque<ConstMember<Environment, void, member>>;
-
-/// \brief Forms a Callback from a non-const Environment reference and a const Environment member-function which takes one argument.
-template<class Environment, class FirstArgument, void(Environment::*member)(FirstArgument)>
-using MemberCaller1 = BindFirstOpaque<Member1<Environment, FirstArgument, void, member>>;
-
-/// \brief Forms a Callback from a const Environment reference and a const Environment member-function which takes one argument.
-template<class Environment, class FirstArgument, void(Environment::*member)(FirstArgument) const>
-using ConstMemberCaller1 = BindFirstOpaque<ConstMember1<Environment, FirstArgument, void, member>>;
+template<class Environment, class F, ConstMemberFunction<Environment, F> member>
+using ConstMemberCallerN = BindFirstOpaque<typename ConstMemberN<Environment, F>::template instance<member>>;
 
 /// \brief Forms a Callback from a non-const Environment reference and a free function which operates on a non-const Environment reference.
 ///
 /// \dontinclude generic/callback.cpp
 /// \skipline ReferenceCaller example
 /// \until end example
 
 /// \brief Forms a Callback from a non-const Environment reference and a free function which operates on a non-const Environment reference.
 ///
 /// \dontinclude generic/callback.cpp
 /// \skipline ReferenceCaller example
 /// \until end example
-template<class Environment, void(*func)(Environment &)>
-using ReferenceCaller = BindFirstOpaque<Function1<Environment &, void, func>>;
+template<class Environment, class F, typename detail::Arglist<F>::template unshift<Environment &>::type *func>
+using ReferenceCallerN = BindFirstOpaque<typename FunctionN<typename detail::Arglist<F>::template unshift<Environment &>::type>::template instance<func>>;
 
 /// \brief Forms a Callback from a const Environment reference and a free function which operates on a const Environment reference.
 ///
 /// \dontinclude generic/callback.cpp
 /// \skipline ReferenceCaller example
 /// \until end example
 
 /// \brief Forms a Callback from a const Environment reference and a free function which operates on a const Environment reference.
 ///
 /// \dontinclude generic/callback.cpp
 /// \skipline ReferenceCaller example
 /// \until end example
+template<class Environment, class F, typename detail::Arglist<F>::template unshift<const Environment &>::type *func>
+using ConstReferenceCallerN = BindFirstOpaque<typename FunctionN<typename detail::Arglist<F>::template unshift<const Environment &>::type>::template instance<func>>;
+
+/// \brief Forms a Callback from a non-const Environment pointer and a free function which operates on a non-const Environment pointer.
+template<class Environment, class F, typename detail::Arglist<F>::template unshift<Environment *>::type *func>
+using PointerCallerN = BindFirstOpaque<typename FunctionN<typename detail::Arglist<F>::template unshift<Environment *>::type>::template instance<func>>;
+
+/// \brief Forms a Callback from a const Environment pointer and a free function which operates on a const Environment pointer.
+template<class Environment, class F, typename detail::Arglist<F>::template unshift<const Environment *>::type *func>
+using ConstPointerCallerN = BindFirstOpaque<typename FunctionN<typename detail::Arglist<F>::template unshift<const Environment *>::type>::template instance<func>>;
+
+/// \brief Forms a Callback from a free function
+template<class F, F *func>
+class FreeCallerN : public BindFirstOpaque<CallerShiftFirst<
+        typename FunctionN<F>::template instance<func>,
+        typename detail::Arglist<F>::template unshift<void *>::type
+>> {
+public:
+    FreeCallerN()
+            : BindFirstOpaque<CallerShiftFirst<
+            typename FunctionN<F>::template instance<func>,
+            typename detail::Arglist<F>::template unshift<void *>::type
+    >>(nullptr) {
+    }
+};
+
+/// \brief  Constructs a Callback1 from a non-const \p functor
+///
+/// \param Functor Must define \c first_argument_type and \c operator()(first_argument_type).
+template<typename Functor>
+inline CallbackN<get_func<Functor>> makeCallbackN(Functor &functor) {
+       return CallbackN<get_func<Functor>>(MemberCallerN<Functor, get_func<Functor>, &Functor::operator()>(functor));
+}
+
+/// \brief  Constructs a Callback1 from a const \p functor
+///
+/// \param Functor Must define \c first_argument_type and const \c operator()(first_argument_type).
+template<typename Functor>
+inline CallbackN<get_func<Functor>> makeCallbackN(const Functor &functor) {
+       return CallbackN<get_func<Functor>>(ConstMemberCallerN<Functor, get_func<Functor>, &Functor::operator()>(functor));
+}
+
+// todo: inline
+
+#define makeCallback makeCallbackN
+
+using Callback = CallbackN<void()>;
+
+template<class Result>
+using Callback0 = CallbackN<Result()>;
+
+template<class FirstArgument, class Result = void>
+using Callback1 = CallbackN<Result(FirstArgument)>;
+
+template<typename FirstArgument, typename SecondArgument, typename Result = void>
+using Callback2 = CallbackN<Result(FirstArgument, SecondArgument)>;
+
+template<typename FirstArgument, typename SecondArgument, typename ThirdArgument, typename Result = void>
+using Callback3 = CallbackN<Result(FirstArgument, SecondArgument, ThirdArgument)>;
+
+#define makeCallback0 makeCallbackN
+#define makeStatelessCallback0 makeStatelessCallbackN
+
+#define makeCallback1 makeCallbackN
+#define makeStatelessCallback1 makeStatelessCallbackN
+
+#define makeCallback2 makeCallbackN
+#define makeStatelessCallback2 makeStatelessCallbackN
+
+#define makeCallback3 makeCallbackN
+#define makeStatelessCallback3 makeStatelessCallbackN
+
+template<class Environment, void(Environment::*member)()>
+using MemberCaller = MemberCallerN<Environment, void(), member>;
+
+template<class Environment, void(Environment::*member)() const>
+using ConstMemberCaller = ConstMemberCallerN<Environment, void(), member>;
+
+template<class Environment, class FirstArgument, void(Environment::*member)(FirstArgument)>
+using MemberCaller1 = MemberCallerN<Environment, void(FirstArgument), member>;
+
+template<class Environment, class FirstArgument, void(Environment::*member)(FirstArgument) const>
+using ConstMemberCaller1 = ConstMemberCallerN<Environment, void(FirstArgument), member>;
+
+template<class Environment, void(*func)(Environment &)>
+using ReferenceCaller = ReferenceCallerN<Environment, void(), func>;
+
 template<class Environment, void(*func)(const Environment &)>
 template<class Environment, void(*func)(const Environment &)>
-using ConstReferenceCaller = BindFirstOpaque<Function1<const Environment &, void, func>>;
+using ConstReferenceCaller = ConstReferenceCallerN<Environment, void(), func>;
 
 /// \brief Forms a Callback from a non-const Environment reference and a free function which operates on a non-const Environment reference and one other argument.
 template<class Environment, class FirstArgument, void(*func)(Environment &, FirstArgument)>
 
 /// \brief Forms a Callback from a non-const Environment reference and a free function which operates on a non-const Environment reference and one other argument.
 template<class Environment, class FirstArgument, void(*func)(Environment &, FirstArgument)>
-using ReferenceCaller1 = BindFirstOpaque<Function2<Environment &, FirstArgument, void, func>>;
+using ReferenceCaller1 = ReferenceCallerN<Environment, void(FirstArgument), func>;
 
 /// \brief Forms a Callback from a const Environment reference and a free function which operates on a const Environment reference and one other argument.
 template<class Environment, class FirstArgument, void(*func)(const Environment &, FirstArgument)>
 
 /// \brief Forms a Callback from a const Environment reference and a free function which operates on a const Environment reference and one other argument.
 template<class Environment, class FirstArgument, void(*func)(const Environment &, FirstArgument)>
-using ConstReferenceCaller1 = BindFirstOpaque<Function2<const Environment &, FirstArgument, void, func>>;
+using ConstReferenceCaller1 = ConstReferenceCallerN<Environment, void(FirstArgument), func>;
 
 /// \brief Forms a Callback from a non-const Environment pointer and a free function which operates on a non-const Environment pointer.
 template<class Environment, void(*func)(Environment *)>
 
 /// \brief Forms a Callback from a non-const Environment pointer and a free function which operates on a non-const Environment pointer.
 template<class Environment, void(*func)(Environment *)>
-using PointerCaller = BindFirstOpaque<Function1<Environment *, void, func>>;
+using PointerCaller = PointerCallerN<Environment, void(), func>;
 
 /// \brief Forms a Callback from a const Environment pointer and a free function which operates on a const Environment pointer.
 template<class Environment, void(*func)(const Environment *)>
 
 /// \brief Forms a Callback from a const Environment pointer and a free function which operates on a const Environment pointer.
 template<class Environment, void(*func)(const Environment *)>
-using ConstPointerCaller = BindFirstOpaque<Function1<const Environment *, void, func>>;
+using ConstPointerCaller = ConstPointerCallerN<Environment, void(), func>;
 
 /// \brief Forms a Callback from a non-const Environment pointer and a free function which operates on a non-const Environment pointer and one other argument.
 template<class Environment, class FirstArgument, void(*func)(Environment *, FirstArgument)>
 
 /// \brief Forms a Callback from a non-const Environment pointer and a free function which operates on a non-const Environment pointer and one other argument.
 template<class Environment, class FirstArgument, void(*func)(Environment *, FirstArgument)>
-using PointerCaller1 = BindFirstOpaque<Function2<Environment *, FirstArgument, void, func>>;
+using PointerCaller1 = PointerCallerN<Environment, void(FirstArgument), func>;
 
 /// \brief Forms a Callback from a const Environment pointer and a free function which operates on a const Environment pointer and one other argument.
 template<class Environment, class FirstArgument, void(*func)(const Environment *, FirstArgument)>
 
 /// \brief Forms a Callback from a const Environment pointer and a free function which operates on a const Environment pointer and one other argument.
 template<class Environment, class FirstArgument, void(*func)(const Environment *, FirstArgument)>
-using ConstPointerCaller1 = BindFirstOpaque<Function2<const Environment *, FirstArgument, void, func>>;
+using ConstPointerCaller1 = ConstPointerCallerN<Environment, void(FirstArgument), func>;
 
 
-/// \brief Forms a Callback from a free function which takes no arguments.
 template<void(*func)()>
 template<void(*func)()>
-class FreeCaller : public BindFirstOpaque<Caller0To1<Function0<void, func>>> {
-public:
-       FreeCaller() : BindFirstOpaque<Caller0To1<Function0<void, func>>>(0) {
-       }
-};
+using FreeCaller = FreeCallerN<void(), func>;
 
 
-/// \brief Forms a Callback from a free function which takes a single argument.
 template<class FirstArgument, void(*func)(FirstArgument)>
 template<class FirstArgument, void(*func)(FirstArgument)>
-class FreeCaller1 : public BindFirstOpaque<Caller1To2<Function1<FirstArgument, void, func>>> {
-public:
-       FreeCaller1() : BindFirstOpaque<Caller1To2<Function1<FirstArgument, void, func>>>(0) {
-       }
-};
-
-
-/// \brief Constructs a Callback from a non-const \p functor with zero arguments.
-///
-/// \param Functor Must define \c operator()().
-template<typename Functor>
-inline Callback makeCallback( Functor& functor ){
-       return Callback( MemberCaller<Functor, &Functor::operator()>( functor ) );
-}
-
-/// \brief  Constructs a Callback from a const \p functor with zero arguments.
-///
-/// \param Functor Must define const \c operator()().
-template<typename Functor>
-inline Callback makeCallback( const Functor& functor ){
-       return Callback( ConstMemberCaller<Functor, &Functor::operator()>( functor ) );
-}
-
-/// \brief  Constructs a Callback1 from a non-const \p functor with one argument.
-///
-/// \param Functor Must define \c first_argument_type and \c operator()(first_argument_type).
-template<typename Functor>
-inline Callback1<get_argument<Functor, 0>> makeCallback1(Functor &functor) {
-       typedef get_argument<Functor, 0> FirstArgument;
-       return Callback1<FirstArgument>( MemberCaller1<Functor, FirstArgument, &Functor::operator()>( functor ) );
-}
-
-/// \brief  Constructs a Callback1 from a const \p functor with one argument.
-///
-/// \param Functor Must define \c first_argument_type and const \c operator()(first_argument_type).
-template<typename Functor>
-inline Callback1<get_argument<Functor, 0>> makeCallback1(const Functor &functor) {
-       typedef get_argument<Functor, 0> FirstArgument;
-       return Callback1<FirstArgument>( ConstMemberCaller1<Functor, FirstArgument, &Functor::operator()>( functor ) );
-}
-
+using FreeCaller1 = FreeCallerN<void(FirstArgument), func>;
 
 typedef Callback1<bool> BoolImportCallback;
 typedef Callback1<const BoolImportCallback&> BoolExportCallback;
 
 typedef Callback1<bool> BoolImportCallback;
 typedef Callback1<const BoolImportCallback&> BoolExportCallback;
@@ -414,5 +395,4 @@ typedef Callback1<const StringImportCallback&> StringExportCallback;
 typedef Callback1<std::size_t> SizeImportCallback;
 typedef Callback1<const SizeImportCallback&> SizeExportCallback;
 
 typedef Callback1<std::size_t> SizeImportCallback;
 typedef Callback1<const SizeImportCallback&> SizeExportCallback;
 
-
 #endif
 #endif
diff --git a/libs/generic/callbackfwd.h b/libs/generic/callbackfwd.h
deleted file mode 100644 (file)
index 48c01d3..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-
-#if !defined( INCLUDED_CALLBACKFWD_H )
-#define INCLUDED_CALLBACKFWD_H
-
-template<typename Return>
-class Callback0;
-typedef Callback0<void> Callback;
-
-template<typename FirstArgument, typename Result = void>
-class Callback1;
-
-template<typename FirstArgument, typename SecondArgument, typename Result = void>
-class Callback2;
-
-template<typename FirstArgument, typename SecondArgument, typename ThirdArgument, typename Result = void>
-class Callback3;
-
-#endif
index 8843e363b8325fd4c870249941bc5049573e6db9..ecbf6c7d938e285d93169b061a46db4c12fcc755 100644 (file)
@@ -184,6 +184,8 @@ public:
 template<class Functor>
 using FunctorInvoke = FunctorNInvoke<Functor, get_func<Functor>>;
 
 template<class Functor>
 using FunctorInvoke = FunctorNInvoke<Functor, get_func<Functor>>;
 
+// todo: inline
+
 template<class Object, class R, R(Object::*member)()>
 using Member = typename MemberN<Object, R()>::template instance<member>;
 
 template<class Object, class R, R(Object::*member)()>
 using Member = typename MemberN<Object, R()>::template instance<member>;
 
@@ -223,30 +225,4 @@ using Function3 = typename FunctionN<R(A1, A2, A3)>::template instance<func>;
 template<class A1, class A2, class A3, class A4, class R, R(*func)(A1, A2, A3, A4)>
 using Function4 = typename FunctionN<R(A1, A2, A3, A4)>::template instance<func>;
 
 template<class A1, class A2, class A3, class A4, class R, R(*func)(A1, A2, A3, A4)>
 using Function4 = typename FunctionN<R(A1, A2, A3, A4)>::template instance<func>;
 
-template<class Caller, class FirstArgument = void *>
-using Caller0To1 = CallerShiftFirst<Caller, get_result_type<Caller>(
-        FirstArgument
-)>;
-
-template<class Caller, class FirstArgument = void *>
-using Caller1To2 = CallerShiftFirst<Caller, get_result_type<Caller>(
-        FirstArgument,
-        get_argument<Caller, 0>
-)>;
-
-template<class Caller, class FirstArgument = void *>
-using Caller2To3 = CallerShiftFirst<Caller, get_result_type<Caller>(
-        FirstArgument,
-        get_argument<Caller, 0>,
-        get_argument<Caller, 1>
-)>;
-
-template<class Caller, class FirstArgument = void *>
-using Caller3To4 = CallerShiftFirst<Caller, get_result_type<Caller>(
-        FirstArgument,
-        get_argument<Caller, 0>,
-        get_argument<Caller, 1>,
-        get_argument<Caller, 2>
-)>;
-
 #endif
 #endif
index b7aa4127b4ccef9a48f79e2600d92f52f6c16d56..cec03b2fd719a0a82b3aa75c6f430e6ba8bbf827 100644 (file)
@@ -23,7 +23,7 @@
 #define INCLUDED_GTKUTIL_BUTTON_H
 
 #include <uilib/uilib.h>
 #define INCLUDED_GTKUTIL_BUTTON_H
 
 #include <uilib/uilib.h>
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
 
 typedef int gint;
 typedef gint gboolean;
 
 typedef int gint;
 typedef gint gboolean;
index 9b040450c8c5a582c49685d165be16efb4d31bc3..5d361f298c09923fb314d1fc26266beab06c96de 100644 (file)
@@ -23,7 +23,7 @@
 #define INCLUDED_GTKUTIL_MENU_H
 
 #include <uilib/uilib.h>
 #define INCLUDED_GTKUTIL_MENU_H
 
 #include <uilib/uilib.h>
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
 
 typedef int gint;
 typedef gint gboolean;
 
 typedef int gint;
 typedef gint gboolean;
index 66f38805896bc3a1a7894e44592368ecc02ab870..60515019e876a13fc12220bb0495291ade0c9b76 100644 (file)
@@ -23,7 +23,7 @@
 #define INCLUDED_GTKUTIL_TOOLBAR_H
 
 #include <uilib/uilib.h>
 #define INCLUDED_GTKUTIL_TOOLBAR_H
 
 #include <uilib/uilib.h>
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
 
 class Command;
 class Toggle;
 
 class Command;
 class Toggle;
index 8795bf4ef1fe36409e5111c70e863b924f80a69f..0654fd89d815e6d44b03410295883b55cdc63509 100644 (file)
@@ -25,7 +25,7 @@
 #include <cstddef>
 #include <uilib/uilib.h>
 #include "string/stringfwd.h"
 #include <cstddef>
 #include <uilib/uilib.h>
 #include "string/stringfwd.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
 
 enum EBrushPrefab
 {
 
 enum EBrushPrefab
 {
index 1082c002d5f2ac6962db55ff06c8dee6a8f867a6..b8f4fcfbf4c6c8420e9986292eab6f0375d5fc70 100644 (file)
@@ -23,7 +23,7 @@
 #define INCLUDED_SELECTION_H
 
 #include "windowobserver.h"
 #define INCLUDED_SELECTION_H
 
 #include "windowobserver.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
 
 struct rect_t
 {
 
 struct rect_t
 {
index 297ebc998359841d6cd7a590f0c80d73c545d3cb..cdd1a9b1e8f114ff11fd885ac4c3228495de40c9 100644 (file)
@@ -22,7 +22,7 @@
 #if !defined ( INCLUDED_TEXTURES_H )
 #define INCLUDED_TEXTURES_H
 
 #if !defined ( INCLUDED_TEXTURES_H )
 #define INCLUDED_TEXTURES_H
 
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
 
 void Textures_Realise();
 void Textures_Unrealise();
 
 void Textures_Realise();
 void Textures_Unrealise();
index 15ec907c5da1dcaf6e53328bcd793e9d62a7572a..9a153c44802ca3ca371678b30902701a7b66d176 100644 (file)
@@ -24,7 +24,7 @@
 
 #include <uilib/uilib.h>
 #include "math/vector.h"
 
 #include <uilib/uilib.h>
 #include "math/vector.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
 #include "signal/signalfwd.h"
 #include "xml/xmltextags.h"
 
 #include "signal/signalfwd.h"
 #include "xml/xmltextags.h"
 
@@ -44,8 +44,6 @@ void TextureBrowser_Construct();
 void TextureBrowser_Destroy();
 
 typedef Callback1<const char*> StringImportCallback;
 void TextureBrowser_Destroy();
 
 typedef Callback1<const char*> StringImportCallback;
-template<typename FirstArgument, void( *func ) (FirstArgument)>
-class FreeCaller1;
 
 extern ui::Widget g_page_textures;
 void TextureBrowser_exportTitle( const StringImportCallback& importer );
 
 extern ui::Widget g_page_textures;
 void TextureBrowser_exportTitle( const StringImportCallback& importer );