From 54f030873f220197e6b7569253c8fbbd164d1316 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Thu, 29 May 2014 01:26:46 -0400 Subject: [PATCH 1/3] Remove reference when creating new reference types on the stack --- sol/stack.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sol/stack.hpp b/sol/stack.hpp index 1322ed45..307fec34 100644 --- a/sol/stack.hpp +++ b/sol/stack.hpp @@ -68,9 +68,9 @@ inline T& get(types>, lua_State* L, int index = -1) { return *obj; } -template -inline T get(types, lua_State* L, int index = -1) { - return T(L, index); +template ::type> +inline U get(types, lua_State* L, int index = -1) { + return U(L, index); } template From accfd0f7a73930451574eb56a9302b4a16445ab7 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Thu, 29 May 2014 01:28:13 -0400 Subject: [PATCH 2/3] Add explicit operator bool for sol::object for even easier nil checking --- sol/object.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sol/object.hpp b/sol/object.hpp index 9aee1b52..0889a37f 100644 --- a/sol/object.hpp +++ b/sol/object.hpp @@ -45,6 +45,10 @@ public: auto actual = lua_type(state(), -1); return (static_cast(expected) == actual) || (expected == type::poly); } + + explicit operator bool() const { + return is(); + } }; inline bool operator==(const object& lhs, const nil_t&) { From f9b6cf15953dd6ec21fe73abed2ea8932cef4121 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Thu, 29 May 2014 01:47:27 -0400 Subject: [PATCH 3/3] Add a newline to every sol file missing one --- sol.hpp | 2 +- sol/demangle.hpp | 2 +- sol/deprecate.hpp | 2 +- sol/error.hpp | 2 +- sol/function.hpp | 4 ++-- sol/function_types.hpp | 6 +++--- sol/object.hpp | 2 +- sol/proxy.hpp | 2 +- sol/reference.hpp | 2 +- sol/stack.hpp | 2 +- sol/state.hpp | 2 +- sol/table.hpp | 2 +- sol/traits.hpp | 2 +- sol/tuple.hpp | 2 +- sol/types.hpp | 2 +- 15 files changed, 18 insertions(+), 18 deletions(-) diff --git a/sol.hpp b/sol.hpp index fbf44a8f..ce093f66 100644 --- a/sol.hpp +++ b/sol.hpp @@ -26,4 +26,4 @@ #include "sol/object.hpp" #include "sol/function.hpp" -#endif // SOL_HPP \ No newline at end of file +#endif // SOL_HPP diff --git a/sol/demangle.hpp b/sol/demangle.hpp index 963782e7..09a32c29 100644 --- a/sol/demangle.hpp +++ b/sol/demangle.hpp @@ -68,4 +68,4 @@ std::string demangle(const std::type_info& id) { } // detail } // sol -#endif // SOL_DEMANGLE_HPP \ No newline at end of file +#endif // SOL_DEMANGLE_HPP diff --git a/sol/deprecate.hpp b/sol/deprecate.hpp index 59b23729..f00a6e12 100644 --- a/sol/deprecate.hpp +++ b/sol/deprecate.hpp @@ -32,4 +32,4 @@ #endif // compilers #endif // SOL_DEPRECATED -#endif // SOL_DEPRECATE_HPP \ No newline at end of file +#endif // SOL_DEPRECATE_HPP diff --git a/sol/error.hpp b/sol/error.hpp index e2eaa15c..d18398ea 100644 --- a/sol/error.hpp +++ b/sol/error.hpp @@ -32,4 +32,4 @@ public: }; } // sol -#endif // SOL_ERROR_HPP \ No newline at end of file +#endif // SOL_ERROR_HPP diff --git a/sol/function.hpp b/sol/function.hpp index a4055d09..5e6d0595 100644 --- a/sol/function.hpp +++ b/sol/function.hpp @@ -36,7 +36,7 @@ private: template std::tuple invoke(types, std::size_t n) { - luacall(n, sizeof...(Ret)); + luacall(n, sizeof...(Ret)); return stack::pop_reverse_call(state(), std::make_tuple, types()); } @@ -71,7 +71,7 @@ public: typename return_type::type operator()(types, Args&&... args) { return call(std::forward(args)...); } - + template typename return_type::type call(Args&&... args) { push(); diff --git a/sol/function_types.hpp b/sol/function_types.hpp index 23a02ce3..8729e457 100644 --- a/sol/function_types.hpp +++ b/sol/function_types.hpp @@ -19,8 +19,8 @@ // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -#ifndef SOL_LUA_FUNC_HPP -#define SOL_LUA_FUNC_HPP +#ifndef SOL_FUNCTION_TYPES_HPP +#define SOL_FUNCTION_TYPES_HPP #include "stack.hpp" #include @@ -283,4 +283,4 @@ struct userdata_function : public base_function { } // sol -#endif // SOL_LUA_FUNC_HPP +#endif // SOL_FUNCTION_TYPES_HPP diff --git a/sol/object.hpp b/sol/object.hpp index 0889a37f..92da9ecf 100644 --- a/sol/object.hpp +++ b/sol/object.hpp @@ -68,4 +68,4 @@ inline bool operator!=(const nil_t&, const object& rhs) { } } // sol -#endif // SOL_OBJECT_HPP \ No newline at end of file +#endif // SOL_OBJECT_HPP diff --git a/sol/proxy.hpp b/sol/proxy.hpp index 00f641d1..e2bd8572 100644 --- a/sol/proxy.hpp +++ b/sol/proxy.hpp @@ -126,4 +126,4 @@ inline bool operator!= (const proxy& right, T&& left) { return right.template get>() != left; } -} // sol \ No newline at end of file +} // sol diff --git a/sol/reference.hpp b/sol/reference.hpp index 9acc75ed..8ccdad50 100644 --- a/sol/reference.hpp +++ b/sol/reference.hpp @@ -92,4 +92,4 @@ public: }; } // sol -#endif // SOL_REFERENCE_HPP \ No newline at end of file +#endif // SOL_REFERENCE_HPP diff --git a/sol/stack.hpp b/sol/stack.hpp index 307fec34..067db106 100644 --- a/sol/stack.hpp +++ b/sol/stack.hpp @@ -351,4 +351,4 @@ struct get_return { } // stack } // sol -#endif // SOL_STACK_HPP \ No newline at end of file +#endif // SOL_STACK_HPP diff --git a/sol/state.hpp b/sol/state.hpp index a3fd5a57..63f18713 100644 --- a/sol/state.hpp +++ b/sol/state.hpp @@ -208,4 +208,4 @@ public: }; } // sol -#endif // SOL_STATE_HPP \ No newline at end of file +#endif // SOL_STATE_HPP diff --git a/sol/table.hpp b/sol/table.hpp index 0cde0b83..bd67cfb2 100644 --- a/sol/table.hpp +++ b/sol/table.hpp @@ -261,4 +261,4 @@ private: }; } // sol -#endif // SOL_TABLE_HPP \ No newline at end of file +#endif // SOL_TABLE_HPP diff --git a/sol/traits.hpp b/sol/traits.hpp index acf8d55d..72c8de36 100644 --- a/sol/traits.hpp +++ b/sol/traits.hpp @@ -147,4 +147,4 @@ struct function_traits { }; } // sol -#endif // SOL_TRAITS_HPP \ No newline at end of file +#endif // SOL_TRAITS_HPP diff --git a/sol/tuple.hpp b/sol/tuple.hpp index 81240bb3..d73783cb 100644 --- a/sol/tuple.hpp +++ b/sol/tuple.hpp @@ -81,4 +81,4 @@ const auto default_constructor = constructors>{}; } // sol -#endif // SOL_TUPLE_HPP \ No newline at end of file +#endif // SOL_TUPLE_HPP diff --git a/sol/types.hpp b/sol/types.hpp index 6d17468b..987f8ce7 100644 --- a/sol/types.hpp +++ b/sol/types.hpp @@ -160,4 +160,4 @@ inline bool operator==(nil_t, nil_t) { return true; } inline bool operator!=(nil_t, nil_t) { return false; } } // sol -#endif // SOL_TYPES_HPP \ No newline at end of file +#endif // SOL_TYPES_HPP