diff --git a/sol.hpp b/sol.hpp index 2534e646..1556728e 100644 --- a/sol.hpp +++ b/sol.hpp @@ -25,6 +25,9 @@ #include "sol/state.hpp" #include "sol/object.hpp" #include "sol/function.hpp" +#include "sol/protected_function.hpp" +#include "sol/state.hpp" #include "sol/coroutine.hpp" +#include "sol/variadic_args.hpp" #endif // SOL_HPP diff --git a/sol/demangle.hpp b/sol/demangle.hpp index 3f5e94f3..5cade575 100644 --- a/sol/demangle.hpp +++ b/sol/demangle.hpp @@ -39,11 +39,11 @@ inline std::string get_type_name(const std::type_info& id) { std::string realname = id.name(); const static std::array removals = { { "struct ", "class " } }; for (std::size_t r = 0; r < removals.size(); ++r) { - auto found = realname.find(removals[r]); - while (found != std::string::npos) { - realname.erase(found, removals[r].size()); - found = realname.find(removals[r]); - } + auto found = realname.find(removals[r]); + while (found != std::string::npos) { + realname.erase(found, removals[r].size()); + found = realname.find(removals[r]); + } } return realname; } @@ -143,8 +143,8 @@ inline std::string demangle() { template inline std::string short_demangle() { - static const std::string d = short_demangle_once(); - return d; + static const std::string d = short_demangle_once(); + return d; } } // detail } // sol diff --git a/sol/function.hpp b/sol/function.hpp index 3b31c53f..95c8db51 100644 --- a/sol/function.hpp +++ b/sol/function.hpp @@ -24,7 +24,6 @@ #include "reference.hpp" #include "stack.hpp" -#include "resolve.hpp" #include "function_result.hpp" #include "function_types.hpp" #include diff --git a/sol/function_result.hpp b/sol/function_result.hpp index f3c8765e..59a4fe52 100644 --- a/sol/function_result.hpp +++ b/sol/function_result.hpp @@ -25,7 +25,6 @@ #include "reference.hpp" #include "tuple.hpp" #include "stack.hpp" -#include "stack_proxy.hpp" #include "proxy_base.hpp" #include @@ -76,14 +75,6 @@ public: lua_pop(L, returncount); } }; - -template <> -struct bond_size : std::integral_constant {}; - -template -stack_proxy get(const function_result& fr) { - return stack_proxy(fr.lua_state(), static_cast(fr.stack_index() + I)); -} } // sol #endif // SOL_FUNCTION_RESULT_HPP diff --git a/sol/protected_function_result.hpp b/sol/protected_function_result.hpp index 86aa0a46..9957d25c 100644 --- a/sol/protected_function_result.hpp +++ b/sol/protected_function_result.hpp @@ -26,7 +26,6 @@ #include "tuple.hpp" #include "stack.hpp" #include "proxy_base.hpp" -#include "stack_proxy.hpp" #include namespace sol { @@ -126,14 +125,6 @@ public: stack::remove(L, index, popcount); } }; - -template <> -struct bond_size : std::integral_constant {}; - -template -stack_proxy get(const protected_function_result& fr) { - return stack_proxy(fr.lua_state(), static_cast(fr.stack_index() + I)); -} } // sol #endif // SOL_FUNCTION_RESULT_HPP diff --git a/sol/stack.hpp b/sol/stack.hpp index c2c11683..821e3fe5 100644 --- a/sol/stack.hpp +++ b/sol/stack.hpp @@ -24,7 +24,6 @@ #include "stack_core.hpp" #include "stack_reference.hpp" -#include "stack_proxy.hpp" #include "stack_check.hpp" #include "stack_get.hpp" #include "stack_check_get.hpp" diff --git a/sol/stack_proxy.hpp b/sol/stack_proxy.hpp index 47249954..005acb97 100644 --- a/sol/stack_proxy.hpp +++ b/sol/stack_proxy.hpp @@ -23,6 +23,8 @@ #define SOL_STACK_PROXY_HPP #include "stack.hpp" +#include "function.hpp" +#include "protected_function.hpp" #include "proxy_base.hpp" namespace sol { @@ -74,6 +76,22 @@ struct pusher { } }; } // stack + +template <> +struct bond_size : std::integral_constant {}; + +template +stack_proxy get(const function_result& fr) { + return stack_proxy(fr.lua_state(), static_cast(fr.stack_index() + I)); +} + +template <> +struct bond_size : std::integral_constant {}; + +template +stack_proxy get(const protected_function_result& fr) { + return stack_proxy(fr.lua_state(), static_cast(fr.stack_index() + I)); +} } // sol #endif // SOL_STACK_PROXY_HPP diff --git a/sol/state_view.hpp b/sol/state_view.hpp index 730727cc..89c6306d 100644 --- a/sol/state_view.hpp +++ b/sol/state_view.hpp @@ -24,7 +24,6 @@ #include "error.hpp" #include "table.hpp" -#include "stack_proxy.hpp" #include namespace sol { @@ -129,12 +128,12 @@ public: luaL_requiref(L, "debug", luaopen_debug, 1); lua_pop(L, 1); break; - case lib::ffi: + case lib::ffi: #ifdef SOL_LUAJIT luaL_requiref(L, "ffi", luaopen_ffi, 1); #endif break; - case lib::jit: + case lib::jit: #ifdef SOL_LUAJIT luaL_requiref(L, "jit", luaopen_jit, 1); #endif @@ -160,7 +159,7 @@ public: stack_proxy load(const std::string& code) { luaL_loadstring(L, code.c_str()); - return stack_proxy(L, -1); + return stack_proxy(L, -1); } stack_proxy load_file(const std::string& filename) { diff --git a/sol/variadic_args.hpp b/sol/variadic_args.hpp index 6d4aa654..9666ceb7 100644 --- a/sol/variadic_args.hpp +++ b/sol/variadic_args.hpp @@ -28,105 +28,105 @@ #include namespace sol { - struct va_iterator : std::iterator { - lua_State* L; - int index; - int stacktop; - stack_proxy sp; + struct va_iterator : std::iterator { + lua_State* L; + int index; + int stacktop; + stack_proxy sp; - va_iterator() : L(nullptr), index(std::numeric_limits::max()), stacktop(std::numeric_limits::max()) {} - va_iterator(lua_State* L, int index, int stacktop) : L(L), index(index), stacktop(stacktop), sp(L, index) {} + va_iterator() : L(nullptr), index(std::numeric_limits::max()), stacktop(std::numeric_limits::max()) {} + va_iterator(lua_State* L, int index, int stacktop) : L(L), index(index), stacktop(stacktop), sp(L, index) {} - stack_proxy operator*() { - sp = stack_proxy(L, index); - return sp; - } + stack_proxy operator*() { + sp = stack_proxy(L, index); + return sp; + } - stack_proxy* operator->() { - sp = stack_proxy(L, index); - return &sp; - } + stack_proxy* operator->() { + sp = stack_proxy(L, index); + return &sp; + } - va_iterator& operator++ () { - ++index; - return *this; - } + va_iterator& operator++ () { + ++index; + return *this; + } - va_iterator operator++ (int) { - auto r = *this; - this->operator ++(); - return r; - } + va_iterator operator++ (int) { + auto r = *this; + this->operator ++(); + return r; + } - va_iterator& operator-- () { - --index; - return *this; - } + va_iterator& operator-- () { + --index; + return *this; + } - va_iterator operator-- (int) { - auto r = *this; - this->operator --(); - return r; - } + va_iterator operator-- (int) { + auto r = *this; + this->operator --(); + return r; + } - va_iterator& operator+= (difference_type idx) { - index += static_cast(idx); - return *this; - } + va_iterator& operator+= (difference_type idx) { + index += static_cast(idx); + return *this; + } - va_iterator& operator-= (difference_type idx) { - index -= static_cast(idx); - return *this; - } + va_iterator& operator-= (difference_type idx) { + index -= static_cast(idx); + return *this; + } - difference_type operator- (const va_iterator& r) const { - return index - r.index; - } + difference_type operator- (const va_iterator& r) const { + return index - r.index; + } - va_iterator operator+ (difference_type idx) const { - va_iterator r = *this; - r += idx; - return r; - } + va_iterator operator+ (difference_type idx) const { + va_iterator r = *this; + r += idx; + return r; + } - stack_proxy operator[](difference_type idx) { - return stack_proxy(L, index + static_cast(idx)); - } + stack_proxy operator[](difference_type idx) { + return stack_proxy(L, index + static_cast(idx)); + } - bool operator==(const va_iterator& r) const { - if (stacktop == std::numeric_limits::max()) { - return r.index == r.stacktop; - } - else if (r.stacktop == std::numeric_limits::max()) { - return index == stacktop; - } - return index == r.index; - } + bool operator==(const va_iterator& r) const { + if (stacktop == std::numeric_limits::max()) { + return r.index == r.stacktop; + } + else if (r.stacktop == std::numeric_limits::max()) { + return index == stacktop; + } + return index == r.index; + } - bool operator != (const va_iterator& r) const { - return !(this->operator==(r)); - } + bool operator != (const va_iterator& r) const { + return !(this->operator==(r)); + } - bool operator < (const va_iterator& r) const { - return index < r.index; - } + bool operator < (const va_iterator& r) const { + return index < r.index; + } - bool operator > (const va_iterator& r) const { - return index > r.index; - } + bool operator > (const va_iterator& r) const { + return index > r.index; + } - bool operator <= (const va_iterator& r) const { - return index <= r.index; - } + bool operator <= (const va_iterator& r) const { + return index <= r.index; + } - bool operator >= (const va_iterator& r) const { - return index >= r.index; - } - }; + bool operator >= (const va_iterator& r) const { + return index >= r.index; + } + }; - inline va_iterator operator+(typename va_iterator::difference_type n, const va_iterator& r) { - return r + n; - } + inline va_iterator operator+(typename va_iterator::difference_type n, const va_iterator& r) { + return r + n; + } struct variadic_args { private: