Parcourir la Source

simplify: LUWRA_WRAP_FUNCTION

Ole il y a 10 ans
Parent
commit
6708318057
1 fichiers modifiés avec 11 ajouts et 18 suppressions
  1. 11 18
      lib/luwra/functions.hpp

+ 11 - 18
lib/luwra/functions.hpp

@@ -42,33 +42,26 @@ namespace internal {
 		}
 	};
 
-	template <typename T>
-	struct FunctionWrapperHelper {
-		static_assert(
-			sizeof(T) == -1,
-			"Parameter to FunctionWrapperHelper is not a function pointer"
-		);
-	};
-
 	template <typename R, typename... A>
-	struct FunctionWrapperHelper<R(*)(A...)> {
-		using Signature = R(A...);
-	};
+	struct FunctionWrapper<R(*)(A...)>: FunctionWrapper<R(A...)> {};
 }
 
+/**
+ * \deprecated
+ */
 template <
 	typename S,
-	S* function_pointer
+	S function_pointer
 >
 constexpr CFunction wrap_function =
 	&internal::FunctionWrapper<S>::template invoke<function_pointer>;
 
-#define LUWRA_WRAP_FUNCTION(fun) \
-	(luwra::wrap_function< \
-	     typename luwra::internal::FunctionWrapperHelper<decltype(&fun)>::Signature, \
-	     &fun \
-	 >)
-
 LUWRA_NS_END
 
+/**
+ * Generate a `lua_CFunction` wrapper for a function.
+ */
+#define LUWRA_WRAP_FUNCTION(fun) \
+	(&luwra::internal::FunctionWrapper<decltype(&fun)>::template invoke<&fun>)
+
 #endif