mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Inclusion argument order sorting
This commit is contained in:
parent
fdefa46ddc
commit
2497567897
3
sol.hpp
3
sol.hpp
@ -25,6 +25,9 @@
|
|||||||
#include "sol/state.hpp"
|
#include "sol/state.hpp"
|
||||||
#include "sol/object.hpp"
|
#include "sol/object.hpp"
|
||||||
#include "sol/function.hpp"
|
#include "sol/function.hpp"
|
||||||
|
#include "sol/protected_function.hpp"
|
||||||
|
#include "sol/state.hpp"
|
||||||
#include "sol/coroutine.hpp"
|
#include "sol/coroutine.hpp"
|
||||||
|
#include "sol/variadic_args.hpp"
|
||||||
|
|
||||||
#endif // SOL_HPP
|
#endif // SOL_HPP
|
||||||
|
@ -39,11 +39,11 @@ inline std::string get_type_name(const std::type_info& id) {
|
|||||||
std::string realname = id.name();
|
std::string realname = id.name();
|
||||||
const static std::array<std::string, 2> removals = { { "struct ", "class " } };
|
const static std::array<std::string, 2> removals = { { "struct ", "class " } };
|
||||||
for (std::size_t r = 0; r < removals.size(); ++r) {
|
for (std::size_t r = 0; r < removals.size(); ++r) {
|
||||||
auto found = realname.find(removals[r]);
|
auto found = realname.find(removals[r]);
|
||||||
while (found != std::string::npos) {
|
while (found != std::string::npos) {
|
||||||
realname.erase(found, removals[r].size());
|
realname.erase(found, removals[r].size());
|
||||||
found = realname.find(removals[r]);
|
found = realname.find(removals[r]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return realname;
|
return realname;
|
||||||
}
|
}
|
||||||
@ -143,8 +143,8 @@ inline std::string demangle() {
|
|||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline std::string short_demangle() {
|
inline std::string short_demangle() {
|
||||||
static const std::string d = short_demangle_once<T>();
|
static const std::string d = short_demangle_once<T>();
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
} // detail
|
} // detail
|
||||||
} // sol
|
} // sol
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
|
|
||||||
#include "reference.hpp"
|
#include "reference.hpp"
|
||||||
#include "stack.hpp"
|
#include "stack.hpp"
|
||||||
#include "resolve.hpp"
|
|
||||||
#include "function_result.hpp"
|
#include "function_result.hpp"
|
||||||
#include "function_types.hpp"
|
#include "function_types.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
#include "reference.hpp"
|
#include "reference.hpp"
|
||||||
#include "tuple.hpp"
|
#include "tuple.hpp"
|
||||||
#include "stack.hpp"
|
#include "stack.hpp"
|
||||||
#include "stack_proxy.hpp"
|
|
||||||
#include "proxy_base.hpp"
|
#include "proxy_base.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
@ -76,14 +75,6 @@ public:
|
|||||||
lua_pop(L, returncount);
|
lua_pop(L, returncount);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
|
||||||
struct bond_size<function_result> : std::integral_constant<std::size_t, SIZE_MAX> {};
|
|
||||||
|
|
||||||
template <std::size_t I>
|
|
||||||
stack_proxy get(const function_result& fr) {
|
|
||||||
return stack_proxy(fr.lua_state(), static_cast<int>(fr.stack_index() + I));
|
|
||||||
}
|
|
||||||
} // sol
|
} // sol
|
||||||
|
|
||||||
#endif // SOL_FUNCTION_RESULT_HPP
|
#endif // SOL_FUNCTION_RESULT_HPP
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
#include "tuple.hpp"
|
#include "tuple.hpp"
|
||||||
#include "stack.hpp"
|
#include "stack.hpp"
|
||||||
#include "proxy_base.hpp"
|
#include "proxy_base.hpp"
|
||||||
#include "stack_proxy.hpp"
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
namespace sol {
|
namespace sol {
|
||||||
@ -126,14 +125,6 @@ public:
|
|||||||
stack::remove(L, index, popcount);
|
stack::remove(L, index, popcount);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
|
||||||
struct bond_size<protected_function_result> : std::integral_constant<std::size_t, SIZE_MAX> {};
|
|
||||||
|
|
||||||
template <std::size_t I>
|
|
||||||
stack_proxy get(const protected_function_result& fr) {
|
|
||||||
return stack_proxy(fr.lua_state(), static_cast<int>(fr.stack_index() + I));
|
|
||||||
}
|
|
||||||
} // sol
|
} // sol
|
||||||
|
|
||||||
#endif // SOL_FUNCTION_RESULT_HPP
|
#endif // SOL_FUNCTION_RESULT_HPP
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
|
|
||||||
#include "stack_core.hpp"
|
#include "stack_core.hpp"
|
||||||
#include "stack_reference.hpp"
|
#include "stack_reference.hpp"
|
||||||
#include "stack_proxy.hpp"
|
|
||||||
#include "stack_check.hpp"
|
#include "stack_check.hpp"
|
||||||
#include "stack_get.hpp"
|
#include "stack_get.hpp"
|
||||||
#include "stack_check_get.hpp"
|
#include "stack_check_get.hpp"
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
#define SOL_STACK_PROXY_HPP
|
#define SOL_STACK_PROXY_HPP
|
||||||
|
|
||||||
#include "stack.hpp"
|
#include "stack.hpp"
|
||||||
|
#include "function.hpp"
|
||||||
|
#include "protected_function.hpp"
|
||||||
#include "proxy_base.hpp"
|
#include "proxy_base.hpp"
|
||||||
|
|
||||||
namespace sol {
|
namespace sol {
|
||||||
@ -74,6 +76,22 @@ struct pusher<stack_proxy> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // stack
|
} // stack
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct bond_size<function_result> : std::integral_constant<std::size_t, SIZE_MAX> {};
|
||||||
|
|
||||||
|
template <std::size_t I>
|
||||||
|
stack_proxy get(const function_result& fr) {
|
||||||
|
return stack_proxy(fr.lua_state(), static_cast<int>(fr.stack_index() + I));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct bond_size<protected_function_result> : std::integral_constant<std::size_t, SIZE_MAX> {};
|
||||||
|
|
||||||
|
template <std::size_t I>
|
||||||
|
stack_proxy get(const protected_function_result& fr) {
|
||||||
|
return stack_proxy(fr.lua_state(), static_cast<int>(fr.stack_index() + I));
|
||||||
|
}
|
||||||
} // sol
|
} // sol
|
||||||
|
|
||||||
#endif // SOL_STACK_PROXY_HPP
|
#endif // SOL_STACK_PROXY_HPP
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
|
|
||||||
#include "error.hpp"
|
#include "error.hpp"
|
||||||
#include "table.hpp"
|
#include "table.hpp"
|
||||||
#include "stack_proxy.hpp"
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace sol {
|
namespace sol {
|
||||||
@ -129,12 +128,12 @@ public:
|
|||||||
luaL_requiref(L, "debug", luaopen_debug, 1);
|
luaL_requiref(L, "debug", luaopen_debug, 1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
break;
|
break;
|
||||||
case lib::ffi:
|
case lib::ffi:
|
||||||
#ifdef SOL_LUAJIT
|
#ifdef SOL_LUAJIT
|
||||||
luaL_requiref(L, "ffi", luaopen_ffi, 1);
|
luaL_requiref(L, "ffi", luaopen_ffi, 1);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case lib::jit:
|
case lib::jit:
|
||||||
#ifdef SOL_LUAJIT
|
#ifdef SOL_LUAJIT
|
||||||
luaL_requiref(L, "jit", luaopen_jit, 1);
|
luaL_requiref(L, "jit", luaopen_jit, 1);
|
||||||
#endif
|
#endif
|
||||||
@ -160,7 +159,7 @@ public:
|
|||||||
|
|
||||||
stack_proxy load(const std::string& code) {
|
stack_proxy load(const std::string& code) {
|
||||||
luaL_loadstring(L, code.c_str());
|
luaL_loadstring(L, code.c_str());
|
||||||
return stack_proxy(L, -1);
|
return stack_proxy(L, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
stack_proxy load_file(const std::string& filename) {
|
stack_proxy load_file(const std::string& filename) {
|
||||||
|
@ -28,105 +28,105 @@
|
|||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
namespace sol {
|
namespace sol {
|
||||||
struct va_iterator : std::iterator<std::random_access_iterator_tag, stack_proxy, std::ptrdiff_t, stack_proxy*, stack_proxy> {
|
struct va_iterator : std::iterator<std::random_access_iterator_tag, stack_proxy, std::ptrdiff_t, stack_proxy*, stack_proxy> {
|
||||||
lua_State* L;
|
lua_State* L;
|
||||||
int index;
|
int index;
|
||||||
int stacktop;
|
int stacktop;
|
||||||
stack_proxy sp;
|
stack_proxy sp;
|
||||||
|
|
||||||
va_iterator() : L(nullptr), index(std::numeric_limits<int>::max()), stacktop(std::numeric_limits<int>::max()) {}
|
va_iterator() : L(nullptr), index(std::numeric_limits<int>::max()), stacktop(std::numeric_limits<int>::max()) {}
|
||||||
va_iterator(lua_State* L, int index, int stacktop) : L(L), index(index), stacktop(stacktop), sp(L, index) {}
|
va_iterator(lua_State* L, int index, int stacktop) : L(L), index(index), stacktop(stacktop), sp(L, index) {}
|
||||||
|
|
||||||
stack_proxy operator*() {
|
stack_proxy operator*() {
|
||||||
sp = stack_proxy(L, index);
|
sp = stack_proxy(L, index);
|
||||||
return sp;
|
return sp;
|
||||||
}
|
}
|
||||||
|
|
||||||
stack_proxy* operator->() {
|
stack_proxy* operator->() {
|
||||||
sp = stack_proxy(L, index);
|
sp = stack_proxy(L, index);
|
||||||
return &sp;
|
return &sp;
|
||||||
}
|
}
|
||||||
|
|
||||||
va_iterator& operator++ () {
|
va_iterator& operator++ () {
|
||||||
++index;
|
++index;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
va_iterator operator++ (int) {
|
va_iterator operator++ (int) {
|
||||||
auto r = *this;
|
auto r = *this;
|
||||||
this->operator ++();
|
this->operator ++();
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
va_iterator& operator-- () {
|
va_iterator& operator-- () {
|
||||||
--index;
|
--index;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
va_iterator operator-- (int) {
|
va_iterator operator-- (int) {
|
||||||
auto r = *this;
|
auto r = *this;
|
||||||
this->operator --();
|
this->operator --();
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
va_iterator& operator+= (difference_type idx) {
|
va_iterator& operator+= (difference_type idx) {
|
||||||
index += static_cast<int>(idx);
|
index += static_cast<int>(idx);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
va_iterator& operator-= (difference_type idx) {
|
va_iterator& operator-= (difference_type idx) {
|
||||||
index -= static_cast<int>(idx);
|
index -= static_cast<int>(idx);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
difference_type operator- (const va_iterator& r) const {
|
difference_type operator- (const va_iterator& r) const {
|
||||||
return index - r.index;
|
return index - r.index;
|
||||||
}
|
}
|
||||||
|
|
||||||
va_iterator operator+ (difference_type idx) const {
|
va_iterator operator+ (difference_type idx) const {
|
||||||
va_iterator r = *this;
|
va_iterator r = *this;
|
||||||
r += idx;
|
r += idx;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
stack_proxy operator[](difference_type idx) {
|
stack_proxy operator[](difference_type idx) {
|
||||||
return stack_proxy(L, index + static_cast<int>(idx));
|
return stack_proxy(L, index + static_cast<int>(idx));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const va_iterator& r) const {
|
bool operator==(const va_iterator& r) const {
|
||||||
if (stacktop == std::numeric_limits<int>::max()) {
|
if (stacktop == std::numeric_limits<int>::max()) {
|
||||||
return r.index == r.stacktop;
|
return r.index == r.stacktop;
|
||||||
}
|
}
|
||||||
else if (r.stacktop == std::numeric_limits<int>::max()) {
|
else if (r.stacktop == std::numeric_limits<int>::max()) {
|
||||||
return index == stacktop;
|
return index == stacktop;
|
||||||
}
|
}
|
||||||
return index == r.index;
|
return index == r.index;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator != (const va_iterator& r) const {
|
bool operator != (const va_iterator& r) const {
|
||||||
return !(this->operator==(r));
|
return !(this->operator==(r));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator < (const va_iterator& r) const {
|
bool operator < (const va_iterator& r) const {
|
||||||
return index < r.index;
|
return index < r.index;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator > (const va_iterator& r) const {
|
bool operator > (const va_iterator& r) const {
|
||||||
return index > r.index;
|
return index > r.index;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator <= (const va_iterator& r) const {
|
bool operator <= (const va_iterator& r) const {
|
||||||
return index <= r.index;
|
return index <= r.index;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator >= (const va_iterator& r) const {
|
bool operator >= (const va_iterator& r) const {
|
||||||
return index >= r.index;
|
return index >= r.index;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
inline va_iterator operator+(typename va_iterator::difference_type n, const va_iterator& r) {
|
inline va_iterator operator+(typename va_iterator::difference_type n, const va_iterator& r) {
|
||||||
return r + n;
|
return r + n;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct variadic_args {
|
struct variadic_args {
|
||||||
private:
|
private:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user