Przeglądaj źródła

Make use of 'call' across the board

Ole 10 lat temu
rodzic
commit
d8f8bf223d
2 zmienionych plików z 24 dodań i 24 usunięć
  1. 21 20
      lib/luwra/methods.hpp
  2. 3 4
      lib/luwra/usertypes.hpp

+ 21 - 20
lib/luwra/methods.hpp

@@ -8,6 +8,7 @@
 #define LUWRA_METHODS_H_
 
 #include "common.hpp"
+#include "stack.hpp"
 #include "functions.hpp"
 
 LUWRA_NS_BEGIN
@@ -30,14 +31,14 @@ namespace internal {
 		using MethodPointerType = R (T::*)(A...) const volatile;
 		using FunctionSignature = R (const volatile T*, A...);
 
-		template <MethodPointerType method_pointer> static inline
-		R call(const volatile T* parent, A... args) {
-			return (parent->*method_pointer)(std::forward<A>(args)...);
+		template <MethodPointerType meth> static inline
+		R hook(const volatile T* parent, A&&... args) {
+			return (parent->*meth)(std::forward<A>(args)...);
 		}
 
-		template <MethodPointerType method_pointer> static inline
+		template <MethodPointerType meth> static inline
 		int invoke(State* state) {
-			return FunctionWrapper<FunctionSignature>::template invoke<call<method_pointer>>(state);
+			return call<FunctionSignature>(state, hook<meth>);
 		}
 	};
 
@@ -47,14 +48,14 @@ namespace internal {
 		using MethodPointerType = R (T::*)(A...) const;
 		using FunctionSignature = R (const T*, A...);
 
-		template <MethodPointerType method_pointer> static inline
-		R call(const T* parent, A... args) {
-			return (parent->*method_pointer)(std::forward<A>(args)...);
+		template <MethodPointerType meth> static inline
+		R hook(const T* parent, A... args) {
+			return (parent->*meth)(std::forward<A>(args)...);
 		}
 
-		template <MethodPointerType method_pointer> static inline
+		template <MethodPointerType meth> static inline
 		int invoke(State* state) {
-			return FunctionWrapper<FunctionSignature>::template invoke<call<method_pointer>>(state);
+			return call<FunctionSignature>(state, hook<meth>);
 		}
 	};
 
@@ -64,14 +65,14 @@ namespace internal {
 		using MethodPointerType = R (T::*)(A...) volatile;
 		using FunctionSignature = R (volatile T*, A...);
 
-		template <MethodPointerType method_pointer> static inline
-		R call(volatile T* parent, A... args) {
-			return (parent->*method_pointer)(std::forward<A>(args)...);
+		template <MethodPointerType meth> static inline
+		R hook(volatile T* parent, A... args) {
+			return (parent->*meth)(std::forward<A>(args)...);
 		}
 
-		template <MethodPointerType method_pointer> static inline
+		template <MethodPointerType meth> static inline
 		int invoke(State* state) {
-			return FunctionWrapper<FunctionSignature>::template invoke<call<method_pointer>>(state);
+			return call<FunctionSignature>(state, hook<meth>);
 		}
 	};
 
@@ -81,14 +82,14 @@ namespace internal {
 		using MethodPointerType = R (T::*)(A...);
 		using FunctionSignature = R (T*, A...);
 
-		template <MethodPointerType method_pointer> static inline
-		R call(T* parent, A... args) {
-			return (parent->*method_pointer)(std::forward<A>(args)...);
+		template <MethodPointerType meth> static inline
+		R hook(T* parent, A... args) {
+			return (parent->*meth)(std::forward<A>(args)...);
 		}
 
-		template <MethodPointerType method_pointer> static inline
+		template <MethodPointerType meth> static inline
 		int invoke(State* state) {
-			return FunctionWrapper<FunctionSignature>::template invoke<call<method_pointer>>(state);
+			return call<FunctionSignature>(state, hook<meth>);
 		}
 	};
 }

+ 3 - 4
lib/luwra/usertypes.hpp

@@ -70,9 +70,8 @@ namespace internal {
 	 */
 	template <typename U, typename... A> static inline
 	int construct_user_type(State* state) {
-		return internal::Layout<int(A...)>::direct(
+		return direct<int(A...)>(
 			state,
-			1,
 			&Value<StripUserType<U>&>::template push<A...>,
 			state
 		);
@@ -86,7 +85,7 @@ namespace internal {
 		using T = StripUserType<U>;
 
 		if (!lua_islightuserdata(state, 1))
-			Value<T&>::read(state, 1).~T();
+			read<T&>(state, 1).~T();
 
 		return 0;
 	}
@@ -98,7 +97,7 @@ namespace internal {
 	int stringify_user_type(State* state) {
 		using T = StripUserType<U>;
 
-		return Value<std::string>::push(
+		return push(
 			state,
 			internal::user_type_reg_name<T>
 				+ "@"