[ci skip] update single

This commit is contained in:
ThePhD 2016-08-25 12:51:36 -04:00
parent 354c26772a
commit 0aca322f3f

View File

@ -20,8 +20,8 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// This file was generated with a script. // This file was generated with a script.
// Generated 2016-08-24 16:24:16.873107 UTC // Generated 2016-08-25 16:51:18.743349 UTC
// This header was generated with sol v2.12.0 (revision 16cd699) // This header was generated with sol v2.12.1 (revision 354c267)
// https://github.com/ThePhD/sol2 // https://github.com/ThePhD/sol2
#ifndef SOL_SINGLE_INCLUDE_HPP #ifndef SOL_SINGLE_INCLUDE_HPP
@ -590,11 +590,6 @@ namespace sol {
static const bool value = sizeof(test<Derived>(0)) == sizeof(yes); static const bool value = sizeof(test<Derived>(0)) == sizeof(yes);
}; };
} // meta_detail
template<typename T>
struct is_callable : boolean<meta_detail::is_callable<T>::value> {};
struct has_begin_end_impl { struct has_begin_end_impl {
template<typename T, typename U = unqualified_t<T>, template<typename T, typename U = unqualified_t<T>,
typename B = decltype(std::declval<U&>().begin()), typename B = decltype(std::declval<U&>().begin()),
@ -605,9 +600,6 @@ namespace sol {
static std::false_type test(...); static std::false_type test(...);
}; };
template<typename T>
struct has_begin_end : decltype(has_begin_end_impl::test<T>(0)) {};
struct has_key_value_pair_impl { struct has_key_value_pair_impl {
template<typename T, typename U = unqualified_t<T>, template<typename T, typename U = unqualified_t<T>,
typename V = typename U::value_type, typename V = typename U::value_type,
@ -619,8 +611,33 @@ namespace sol {
static std::false_type test(...); static std::false_type test(...);
}; };
template <typename T, typename U = T, typename = decltype(std::declval<T&>() < std::declval<U&>())>
std::true_type supports_op_less_test(const T&);
std::false_type supports_op_less_test(...);
template <typename T, typename U = T, typename = decltype(std::declval<T&>() == std::declval<U&>())>
std::true_type supports_op_equal_test(const T&);
std::false_type supports_op_equal_test(...);
template <typename T, typename U = T, typename = decltype(std::declval<T&>() <= std::declval<U&>())>
std::true_type supports_op_less_equal_test(const T&);
std::false_type supports_op_less_equal_test(...);
} // meta_detail
template <typename T> template <typename T>
struct has_key_value_pair : decltype(has_key_value_pair_impl::test<T>(0)) {}; using supports_op_less = decltype(meta_detail::supports_op_less_test(std::declval<T&>()));
template <typename T>
using supports_op_equal = decltype(meta_detail::supports_op_equal_test(std::declval<T&>()));
template <typename T>
using supports_op_less_equal = decltype(meta_detail::supports_op_less_equal_test(std::declval<T&>()));
template<typename T>
struct is_callable : boolean<meta_detail::is_callable<T>::value> {};
template<typename T>
struct has_begin_end : decltype(meta_detail::has_begin_end_impl::test<T>(0)) {};
template<typename T>
struct has_key_value_pair : decltype(meta_detail::has_key_value_pair_impl::test<T>(0)) {};
template <typename T> template <typename T>
using is_string_constructible = any<std::is_same<unqualified_t<T>, const char*>, std::is_same<unqualified_t<T>, char>, std::is_same<unqualified_t<T>, std::string>, std::is_same<unqualified_t<T>, std::initializer_list<char>>>; using is_string_constructible = any<std::is_same<unqualified_t<T>, const char*>, std::is_same<unqualified_t<T>, char>, std::is_same<unqualified_t<T>, std::string>, std::is_same<unqualified_t<T>, std::initializer_list<char>>>;
@ -9353,8 +9370,14 @@ namespace sol {
// end of sol/deprecate.hpp // end of sol/deprecate.hpp
namespace sol { namespace sol {
namespace usertype_detail { namespace usertype_detail {
struct no_comp {
template <typename A, typename B>
bool operator()(A&&, B&&) {
return false;
}
};
inline bool is_indexer(string_detail::string_shim s) { inline bool is_indexer(string_detail::string_shim s) {
return s == name_of(meta_function::index) || s == name_of(meta_function::new_index); return s == name_of(meta_function::index) || s == name_of(meta_function::new_index);
} }
@ -9408,6 +9431,37 @@ namespace sol {
return luaL_error(L, "sol: attempt to index (set) nil value \"%s\" on userdata (bad (misspelled?) key name or does not exist)", accessor.data()); return luaL_error(L, "sol: attempt to index (set) nil value \"%s\" on userdata (bad (misspelled?) key name or does not exist)", accessor.data());
} }
template <typename T, typename Op>
inline int operator_wrap(lua_State* L) {
auto maybel = stack::check_get<T>(L, 1);
if (maybel) {
auto mayber = stack::check_get<T>(L, 2);
if (mayber) {
auto& l = *maybel;
auto& r = *mayber;
if (std::is_same<no_comp, Op>::value) {
return stack::push(L, detail::ptr(l) == detail::ptr(r));
}
else {
Op op;
return stack::push(L, (detail::ptr(l) == detail::ptr(r)) || op(detail::deref(l), detail::deref(r)));
}
}
}
return stack::push(L, false);
}
template <typename T, typename Op, typename Supports, typename Regs, meta::enable<Supports> = meta::enabler>
inline void make_reg_op(Regs& l, int& index, const char* name) {
l[index] = { name, &operator_wrap<T, Op> };
++index;
}
template <typename T, typename Op, typename Supports, typename Regs, meta::disable<Supports> = meta::enabler>
inline void make_reg_op(Regs&, int&, const char*) {
// Do nothing if there's no support
}
struct add_destructor_tag {}; struct add_destructor_tag {};
struct check_destructor_tag {}; struct check_destructor_tag {};
struct verified_tag {} const verified{}; struct verified_tag {} const verified{};
@ -9456,7 +9510,7 @@ namespace sol {
struct usertype_metatable<T, std::index_sequence<I...>, Tn...> : usertype_detail::registrar { struct usertype_metatable<T, std::index_sequence<I...>, Tn...> : usertype_detail::registrar {
typedef std::make_index_sequence<sizeof...(I) * 2> indices; typedef std::make_index_sequence<sizeof...(I) * 2> indices;
typedef std::index_sequence<I...> half_indices; typedef std::index_sequence<I...> half_indices;
typedef std::array<luaL_Reg, sizeof...(Tn) / 2 + 1> regs_t; typedef std::array<luaL_Reg, sizeof...(Tn) / 2 + 1 + 3> regs_t;
typedef std::tuple<Tn...> RawTuple; typedef std::tuple<Tn...> RawTuple;
typedef std::tuple<clean_type_t<Tn> ...> Tuple; typedef std::tuple<clean_type_t<Tn> ...> Tuple;
template <std::size_t Idx> template <std::size_t Idx>
@ -9475,6 +9529,9 @@ namespace sol {
void* baseclasscast; void* baseclasscast;
bool mustindex; bool mustindex;
bool secondarymeta; bool secondarymeta;
bool hasequals;
bool hasless;
bool haslessequals;
template <std::size_t Idx, meta::enable<std::is_same<lua_CFunction, meta::unqualified_tuple_element<Idx + 1, RawTuple>>> = meta::enabler> template <std::size_t Idx, meta::enable<std::is_same<lua_CFunction, meta::unqualified_tuple_element<Idx + 1, RawTuple>>> = meta::enabler>
inline lua_CFunction make_func() { inline lua_CFunction make_func() {
@ -9498,6 +9555,18 @@ namespace sol {
} }
int finish_regs(regs_t& l, int& index) { int finish_regs(regs_t& l, int& index) {
if (!hasless) {
const char* name = name_of(meta_function::less_than).c_str();
usertype_detail::make_reg_op<T, std::less<>, meta::supports_op_less<T>>(l, index, name);
}
if (!haslessequals) {
const char* name = name_of(meta_function::less_than_or_equal_to).c_str();
usertype_detail::make_reg_op<T, std::less_equal<>, meta::supports_op_less_equal<T>>(l, index, name);
}
if (!hasequals) {
const char* name = name_of(meta_function::equal_to).c_str();
usertype_detail::make_reg_op<T, std::conditional_t<meta::supports_op_equal<T>::value, std::equal_to<>, usertype_detail::no_comp>, std::true_type>(l, index, name);
}
if (destructfunc != nullptr) { if (destructfunc != nullptr) {
l[index] = { name_of(meta_function::garbage_collect).c_str(), destructfunc }; l[index] = { name_of(meta_function::garbage_collect).c_str(), destructfunc };
++index; ++index;
@ -9536,6 +9605,15 @@ namespace sol {
// Returnable scope // Returnable scope
// That would be a neat keyword for C++ // That would be a neat keyword for C++
// returnable { ... }; // returnable { ... };
if (reg.name == name_of(meta_function::equal_to)) {
hasequals = true;
}
if (reg.name == name_of(meta_function::less_than)) {
hasless = true;
}
if (reg.name == name_of(meta_function::less_than_or_equal_to)) {
haslessequals = true;
}
if (reg.name == name_of(meta_function::garbage_collect)) { if (reg.name == name_of(meta_function::garbage_collect)) {
destructfunc = reg.func; destructfunc = reg.func;
return; return;
@ -9561,7 +9639,8 @@ namespace sol {
indexbase(&core_indexing_call<true>), newindexbase(&core_indexing_call<false>), indexbase(&core_indexing_call<true>), newindexbase(&core_indexing_call<false>),
indexbaseclasspropogation(walk_all_bases<true>), newindexbaseclasspropogation(walk_all_bases<false>), indexbaseclasspropogation(walk_all_bases<true>), newindexbaseclasspropogation(walk_all_bases<false>),
baseclasscheck(nullptr), baseclasscast(nullptr), baseclasscheck(nullptr), baseclasscast(nullptr),
mustindex(contains_variable() || contains_index()), secondarymeta(contains_variable()) { mustindex(contains_variable() || contains_index()), secondarymeta(contains_variable()),
hasequals(false), hasless(false), haslessequals(false) {
} }
template <std::size_t I0, std::size_t I1, bool is_index> template <std::size_t I0, std::size_t I1, bool is_index>
@ -9734,9 +9813,9 @@ namespace sol {
(void)detail::swallow{ 0, (um.template make_regs<(I * 2)>(value_table, lastreg, std::get<(I * 2)>(um.functions), std::get<(I * 2 + 1)>(um.functions)), 0)... }; (void)detail::swallow{ 0, (um.template make_regs<(I * 2)>(value_table, lastreg, std::get<(I * 2)>(um.functions), std::get<(I * 2 + 1)>(um.functions)), 0)... };
um.finish_regs(value_table, lastreg); um.finish_regs(value_table, lastreg);
value_table[lastreg] = { nullptr, nullptr }; value_table[lastreg] = { nullptr, nullptr };
bool hasdestructor = !value_table.empty() && name_of(meta_function::garbage_collect) == value_table[lastreg - 1].name;
regs_t ref_table = value_table; regs_t ref_table = value_table;
regs_t unique_table = value_table; regs_t unique_table = value_table;
bool hasdestructor = !value_table.empty() && name_of(meta_function::garbage_collect) == value_table[lastreg - 1].name;
if (hasdestructor) { if (hasdestructor) {
ref_table[lastreg - 1] = { nullptr, nullptr }; ref_table[lastreg - 1] = { nullptr, nullptr };
unique_table[lastreg - 1] = { value_table[lastreg - 1].name, detail::unique_destruct<T> }; unique_table[lastreg - 1] = { value_table[lastreg - 1].name, detail::unique_destruct<T> };
@ -9909,6 +9988,9 @@ namespace sol {
typedef simple_usertype_metatable<T> umt_t; typedef simple_usertype_metatable<T> umt_t;
static int push(lua_State* L, umt_t&& umx) { static int push(lua_State* L, umt_t&& umx) {
bool hasequals = false;
bool hasless = false;
bool haslessequals = false;
for (std::size_t i = 0; i < 3; ++i) { for (std::size_t i = 0; i < 3; ++i) {
// Pointer types, AKA "references" from C++ // Pointer types, AKA "references" from C++
const char* metakey = nullptr; const char* metakey = nullptr;
@ -9927,14 +10009,25 @@ namespace sol {
luaL_newmetatable(L, metakey); luaL_newmetatable(L, metakey);
stack_reference t(L, -1); stack_reference t(L, -1);
for (auto& kvp : umx.registrations) { for (auto& kvp : umx.registrations) {
if (kvp.first.template is<std::string>()) {
std::string regname = kvp.first.template as<std::string>();
if (regname == name_of(meta_function::equal_to)) {
hasequals = true;
}
else if (regname == name_of(meta_function::less_than)) {
hasless = true;
}
else if (regname == name_of(meta_function::less_than_or_equal_to)) {
haslessequals = true;
}
switch (i) { switch (i) {
case 0: case 0:
if (kvp.first.template is<std::string>() && kvp.first.template as<std::string>() == "__gc") { if (regname == name_of(meta_function::garbage_collect)) {
continue; continue;
} }
break; break;
case 1: case 1:
if (kvp.first.template is<std::string>() && kvp.first.template as<std::string>() == "__gc") { if (regname == name_of(meta_function::garbage_collect)) {
stack::set_field(L, kvp.first, detail::unique_destruct<T>, t.stack_index()); stack::set_field(L, kvp.first, detail::unique_destruct<T>, t.stack_index());
continue; continue;
} }
@ -9943,9 +10036,26 @@ namespace sol {
default: default:
break; break;
} }
}
stack::set_field(L, kvp.first, kvp.second, t.stack_index()); stack::set_field(L, kvp.first, kvp.second, t.stack_index());
} }
luaL_Reg opregs[4]{};
int opregsindex = 0;
if (!hasless) {
const char* name = name_of(meta_function::less_than).c_str();
usertype_detail::make_reg_op<T, std::less<>, meta::supports_op_less<T>>(opregs, opregsindex, name);
}
if (!haslessequals) {
const char* name = name_of(meta_function::less_than_or_equal_to).c_str();
usertype_detail::make_reg_op<T, std::less_equal<>, meta::supports_op_less_equal<T>>(opregs, opregsindex, name);
}
if (!hasequals) {
const char* name = name_of(meta_function::equal_to).c_str();
usertype_detail::make_reg_op<T, std::conditional_t<meta::supports_op_equal<T>::value, std::equal_to<>, usertype_detail::no_comp>, std::true_type>(opregs, opregsindex, name);
}
t.push();
luaL_setfuncs(L, opregs, 0);
t.pop();
// Metatable indexes itself // Metatable indexes itself
stack::set_field(L, meta_function::index, t, t.stack_index()); stack::set_field(L, meta_function::index, t, t.stack_index());
@ -10015,17 +10125,17 @@ namespace sol {
} }
template <typename T, typename C = void> template <typename Raw, typename C = void>
struct container_usertype_metatable { struct container_usertype_metatable {
typedef meta::unqualified_t<T> U; typedef meta::unqualified_t<Raw> T;
typedef std::size_t K; typedef std::size_t K;
typedef typename U::value_type V; typedef typename T::value_type V;
typedef typename U::iterator I; typedef typename T::iterator I;
struct iter { struct iter {
U& source; T& source;
I it; I it;
iter(U& source, I it) : source(source), it(std::move(it)) {} iter(T& source, I it) : source(source), it(std::move(it)) {}
}; };
static auto& get_src(lua_State* L) { static auto& get_src(lua_State* L) {
@ -10172,18 +10282,18 @@ namespace sol {
} }
}; };
template <typename T> template <typename Raw>
struct container_usertype_metatable<T, std::enable_if_t<meta::has_key_value_pair<T>::value>> { struct container_usertype_metatable<Raw, std::enable_if_t<meta::has_key_value_pair<meta::unqualified_t<Raw>>::value>> {
typedef meta::unqualified_t<T> U; typedef meta::unqualified_t<Raw> T;
typedef typename U::value_type KV; typedef typename T::value_type KV;
typedef typename KV::first_type K; typedef typename KV::first_type K;
typedef typename KV::second_type V; typedef typename KV::second_type V;
typedef typename U::iterator I; typedef typename T::iterator I;
struct iter { struct iter {
U& source; T& source;
I it; I it;
iter(U& source, I it) : source(source), it(std::move(it)) {} iter(T& source, I it) : source(source), it(std::move(it)) {}
}; };
static auto& get_src(lua_State* L) { static auto& get_src(lua_State* L) {