Преглед на файлове

Clean up 'vs2105' branch

Ole преди 9 години
родител
ревизия
74ff2e2ca3
променени са 4 файла, в които са добавени 69 реда и са изтрити 51 реда
  1. 12 4
      lib/luwra/methods.hpp
  2. 8 4
      lib/luwra/tables.hpp
  3. 26 26
      lib/luwra/types.hpp
  4. 23 17
      lib/luwra/usertypes.hpp

+ 12 - 4
lib/luwra/methods.hpp

@@ -38,7 +38,9 @@ namespace internal {
 
 		template <MethodPointerType meth> static inline
 		int invoke(State* state) {
-			return static_cast<int>(map<FunctionSignature>(state, hook<meth>));
+			return static_cast<int>(
+				map<FunctionSignature>(state, hook<meth>)
+			);
 		}
 	};
 
@@ -55,7 +57,9 @@ namespace internal {
 
 		template <MethodPointerType meth> static inline
 		int invoke(State* state) {
-			return static_cast<int>(map<FunctionSignature>(state, hook<meth>));
+			return static_cast<int>(
+				map<FunctionSignature>(state, hook<meth>)
+			);
 		}
 	};
 
@@ -72,7 +76,9 @@ namespace internal {
 
 		template <MethodPointerType meth> static inline
 		int invoke(State* state) {
-			return map<FunctionSignature>(state, hook<meth>);
+			return static_cast<int>(
+				map<FunctionSignature>(state, hook<meth>)
+			);
 		}
 	};
 
@@ -89,7 +95,9 @@ namespace internal {
 
 		template <MethodPointerType meth> static inline
 		int invoke(State* state) {
-			return static_cast<int>(map<FunctionSignature>(state, hook<meth>));
+			return static_cast<int>(
+				map<FunctionSignature>(state, hook<meth>)
+			);
 		}
 	};
 }

+ 8 - 4
lib/luwra/tables.hpp

@@ -56,7 +56,8 @@ struct Table {
 		push(state, ref);
 
 		size_t pushedKeys = push(state, key);
-		if (pushedKeys > 1) lua_pop(state, pushedKeys - 1);
+		if (pushedKeys > 1)
+			lua_pop(state, static_cast<int>(pushedKeys - 1));
 
 		lua_rawget(state, -2);
 		bool isNil = lua_isnil(state, -1);
@@ -71,10 +72,12 @@ struct Table {
 		push(state, ref);
 
 		size_t pushedKeys = push(state, key);
-		if (pushedKeys > 1) lua_pop(state, static_cast<int>(pushedKeys - 1));
+		if (pushedKeys > 1)
+			lua_pop(state, static_cast<int>(pushedKeys - 1));
 
 		size_t pushedValues = push(state, value);
-		if (pushedValues > 1) lua_pop(state, static_cast<int>(pushedValues - 1));
+		if (pushedValues > 1)
+			lua_pop(state, static_cast<int>(pushedValues - 1));
 
 		lua_rawset(state, -3);
 		lua_pop(state, 1);
@@ -87,7 +90,8 @@ struct Table {
 		push(state, ref);
 
 		size_t pushedKeys = push(state, key);
-		if (pushedKeys > 1) lua_pop(state, static_cast<int>(pushedKeys - 1));
+		if (pushedKeys > 1)
+			lua_pop(state, static_cast<int>(pushedKeys - 1));
 
 		lua_rawget(state, -2);
 		V ret = read<V>(state, -1);

+ 26 - 26
lib/luwra/types.hpp

@@ -96,34 +96,34 @@ T read(State* state, int index) {
  * extracts it from the stack and a `pushf(State*, type)` which pushes the value on the stack again.
  * This assumes that only one value will be pushed onto the stack.
  */
-#define LUWRA_DEF_VALUE(type, retrf, pushf)                            \
-	template <>                                                       \
-	struct Value<type> {                                              \
-		static inline                                                \
-		type read(State* state, int n) {                             \
-			return static_cast<type>(retrf(state, n));              \
-		}                                                            \
-                                                                       \
-		static inline                                                \
-		size_t push(State* state, type value) {                      \
-			pushf(state, value);                                    \
-			return 1;                                               \
-		}                                                            \
+#define LUWRA_DEF_VALUE(type, retrf, pushf)             \
+	template <>                                         \
+	struct Value<type> {                                \
+		static inline                                   \
+		type read(State* state, int n) {                \
+			return static_cast<type>(retrf(state, n));  \
+		}                                               \
+		                                                \
+		static inline                                   \
+		size_t push(State* state, type value) {         \
+			pushf(state, value);                        \
+			return 1;                                   \
+		}                                               \
 	}
 
-#define LUWRA_DEF_VALUE_BOOL(type, retrf, pushf)                       \
-	template <>                                                       \
-	struct Value<type> {                                              \
-		static inline                                                \
-		type read(State* state, int n) {                             \
-			return retrf(state, n) == 1;              \
-		}                                                            \
-                                                                       \
-		static inline                                                \
-		size_t push(State* state, type value) {                      \
-			pushf(state, value);                                    \
-			return 1;                                               \
-		}                                                            \
+#define LUWRA_DEF_VALUE_BOOL(type, retrf, pushf)        \
+	template <>                                         \
+	struct Value<type> {                                \
+		static inline                                   \
+		type read(State* state, int n) {                \
+			return retrf(state, n) == 1;                \
+		}                                               \
+		                                                \
+		static inline                                   \
+		size_t push(State* state, type value) {         \
+			pushf(state, value);                        \
+			return 1;                                   \
+		}                                               \
 	}
 
 #ifndef luaL_checkboolean

+ 23 - 17
lib/luwra/usertypes.hpp

@@ -47,7 +47,8 @@ namespace internal {
 	#endif
 
 	template <typename T>
-	const std::string UserTypeReg<T>::name = LUWRA_REGISTRY_PREFIX + std::to_string(uintptr_t(&id));
+	const std::string UserTypeReg<T>::name =
+		LUWRA_REGISTRY_PREFIX + std::to_string(uintptr_t(&id));
 
 	/**
 	 * Register a new metatable for a user type T.
@@ -64,7 +65,9 @@ namespace internal {
 	template <typename U> static inline
 	StripUserType<U>* check_user_type(State* state, int index) {
 		using T = StripUserType<U>;
-		return static_cast<T*>(luaL_checkudata(state, index, UserTypeReg<T>::name.c_str()));
+		return static_cast<T*>(
+			luaL_checkudata(state, index, UserTypeReg<T>::name.c_str())
+		);
 	}
 
 	/**
@@ -80,11 +83,13 @@ namespace internal {
 	 */
 	template <typename U, typename... A> static inline
 	int construct_user_type(State* state) {
-		return static_cast<int>(direct<size_t (A...)>(
-			state,
-			&Value<StripUserType<U>&>::template push<A...>,
-			state
-		));
+		return static_cast<int>(
+			direct<size_t (A...)>(
+				state,
+				&Value<StripUserType<U>&>::template push<A...>,
+				state
+			)
+		);
 	}
 
 	/**
@@ -105,12 +110,14 @@ namespace internal {
 	int stringify_user_type(State* state) {
 		using T = StripUserType<U>;
 
-		return static_cast<int>(push(
-			state,
-			internal::UserTypeReg<T>::name
-				+ "@"
-				+ std::to_string(uintptr_t(Value<T*>::read(state, 1)))
-		));
+		return static_cast<int>(
+			push(
+				state,
+				internal::UserTypeReg<T>::name
+					+ "@"
+					+ std::to_string(uintptr_t(Value<T*>::read(state, 1)))
+			)
+		);
 	}
 }
 
@@ -119,9 +126,8 @@ namespace internal {
  */
 template <typename U>
 struct Value<U&> {
-	using X = internal::StripUserType<U>;
-	using T = typename std::conditional<std::is_function<U>::value && !std::is_pointer<U>::value, U*, U>::type;
-	
+	using T = internal::StripUserType<U>;
+
 	/**
 	 * Reference a user type value on the stack.
 	 * \param state Lua state
@@ -218,7 +224,7 @@ struct Value<U*> {
 	 * \returns Number of values that have been pushed
 	 */
 	static inline
-	size_t push(State* state, T* ptr) {
+	size_t push(State* state, const T* ptr) {
 		return Value<T&>::push(state, *ptr);
 	}
 };