mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Oh boy, more simplicity functions...!
This commit is contained in:
parent
edeb81a7e1
commit
f4f3bffe2f
|
@ -80,6 +80,8 @@ namespace sol {
|
||||||
coroutine(lua_nil_t r) : reference(r) {}
|
coroutine(lua_nil_t r) : reference(r) {}
|
||||||
coroutine(const stack_reference& r) noexcept : coroutine(r.lua_state(), r.stack_index()) {}
|
coroutine(const stack_reference& r) noexcept : coroutine(r.lua_state(), r.stack_index()) {}
|
||||||
coroutine(stack_reference&& r) noexcept : coroutine(r.lua_state(), r.stack_index()) {}
|
coroutine(stack_reference&& r) noexcept : coroutine(r.lua_state(), r.stack_index()) {}
|
||||||
|
template <typename T, meta::enable<meta::neg<std::is_integral<meta::unqualified_t<T>>>, meta::neg<std::is_same<T, ref_index>>> = meta::enabler>
|
||||||
|
coroutine(lua_State* L, T&& r) : coroutine(L, sol::ref_index(r.registry_index())) {}
|
||||||
coroutine(lua_State* L, int index = -1) : reference(L, index) {
|
coroutine(lua_State* L, int index = -1) : reference(L, index) {
|
||||||
#ifdef SOL_CHECK_ARGUMENTS
|
#ifdef SOL_CHECK_ARGUMENTS
|
||||||
stack::check<coroutine>(L, index, type_panic);
|
stack::check<coroutine>(L, index, type_panic);
|
||||||
|
|
|
@ -81,6 +81,8 @@ namespace sol {
|
||||||
basic_function& operator=(basic_function&&) = default;
|
basic_function& operator=(basic_function&&) = default;
|
||||||
basic_function(const stack_reference& r) : basic_function(r.lua_state(), r.stack_index()) {}
|
basic_function(const stack_reference& r) : basic_function(r.lua_state(), r.stack_index()) {}
|
||||||
basic_function(stack_reference&& r) : basic_function(r.lua_state(), r.stack_index()) {}
|
basic_function(stack_reference&& r) : basic_function(r.lua_state(), r.stack_index()) {}
|
||||||
|
template <typename T, meta::enable<meta::neg<std::is_integral<meta::unqualified_t<T>>>, meta::neg<std::is_same<T, ref_index>>> = meta::enabler>
|
||||||
|
basic_function(lua_State* L, T&& r) : basic_function(L, sol::ref_index(r.registry_index())) {}
|
||||||
basic_function(lua_State* L, int index = -1) : base_t(L, index) {
|
basic_function(lua_State* L, int index = -1) : base_t(L, index) {
|
||||||
#ifdef SOL_CHECK_ARGUMENTS
|
#ifdef SOL_CHECK_ARGUMENTS
|
||||||
stack::check<basic_function>(L, index, type_panic);
|
stack::check<basic_function>(L, index, type_panic);
|
||||||
|
|
|
@ -161,6 +161,8 @@ namespace sol {
|
||||||
basic_protected_function(proxy_base<Super>&& p, reference eh = get_default_handler()) : basic_protected_function(p.operator basic_function<base_t>(), std::move(eh)) {}
|
basic_protected_function(proxy_base<Super>&& p, reference eh = get_default_handler()) : basic_protected_function(p.operator basic_function<base_t>(), std::move(eh)) {}
|
||||||
template <typename Super>
|
template <typename Super>
|
||||||
basic_protected_function(const proxy_base<Super>& p, reference eh = get_default_handler()) : basic_protected_function(static_cast<basic_function<base_t>>(p), std::move(eh)) {}
|
basic_protected_function(const proxy_base<Super>& p, reference eh = get_default_handler()) : basic_protected_function(static_cast<basic_function<base_t>>(p), std::move(eh)) {}
|
||||||
|
template <typename T, meta::enable<meta::neg<std::is_integral<meta::unqualified_t<T>>>, meta::neg<std::is_same<T, ref_index>>> = meta::enabler>
|
||||||
|
basic_protected_function(lua_State* L, T&& r, reference eh) : basic_protected_function(L, sol::ref_index(r.registry_index()), std::move(eh)) {}
|
||||||
basic_protected_function(lua_State* L, int index = -1, reference eh = get_default_handler()) : base_t(L, index), error_handler(std::move(eh)) {
|
basic_protected_function(lua_State* L, int index = -1, reference eh = get_default_handler()) : base_t(L, index), error_handler(std::move(eh)) {
|
||||||
#ifdef SOL_CHECK_ARGUMENTS
|
#ifdef SOL_CHECK_ARGUMENTS
|
||||||
stack::check<basic_protected_function>(L, index, type_panic);
|
stack::check<basic_protected_function>(L, index, type_panic);
|
||||||
|
|
|
@ -174,6 +174,8 @@ namespace sol {
|
||||||
basic_table_core& operator=(basic_table_core&&) = default;
|
basic_table_core& operator=(basic_table_core&&) = default;
|
||||||
basic_table_core(const stack_reference& r) : basic_table_core(r.lua_state(), r.stack_index()) {}
|
basic_table_core(const stack_reference& r) : basic_table_core(r.lua_state(), r.stack_index()) {}
|
||||||
basic_table_core(stack_reference&& r) : basic_table_core(r.lua_state(), r.stack_index()) {}
|
basic_table_core(stack_reference&& r) : basic_table_core(r.lua_state(), r.stack_index()) {}
|
||||||
|
template <typename T, meta::enable<meta::neg<std::is_integral<meta::unqualified_t<T>>>, meta::neg<std::is_same<T, ref_index>>> = meta::enabler>
|
||||||
|
basic_table_core(lua_State* L, T&& r) : basic_table_core(L, sol::ref_index(r.registry_index())) {}
|
||||||
basic_table_core(lua_State* L, int index = -1) : base_t(L, index) {
|
basic_table_core(lua_State* L, int index = -1) : base_t(L, index) {
|
||||||
#ifdef SOL_CHECK_ARGUMENTS
|
#ifdef SOL_CHECK_ARGUMENTS
|
||||||
stack::check<basic_table_core>(L, index, type_panic);
|
stack::check<basic_table_core>(L, index, type_panic);
|
||||||
|
|
|
@ -94,6 +94,8 @@ namespace sol {
|
||||||
thread(stack_reference&& r) : thread(r.lua_state(), r.stack_index()) {};
|
thread(stack_reference&& r) : thread(r.lua_state(), r.stack_index()) {};
|
||||||
thread& operator=(const thread&) = default;
|
thread& operator=(const thread&) = default;
|
||||||
thread& operator=(thread&&) = default;
|
thread& operator=(thread&&) = default;
|
||||||
|
template <typename T, meta::enable<meta::neg<std::is_integral<meta::unqualified_t<T>>>, meta::neg<std::is_same<T, ref_index>>> = meta::enabler>
|
||||||
|
thread(lua_State* L, T&& r) : thread(L, sol::ref_index(r.registry_index())) {}
|
||||||
thread(lua_State* L, int index = -1) : reference(L, index) {
|
thread(lua_State* L, int index = -1) : reference(L, index) {
|
||||||
#ifdef SOL_CHECK_ARGUMENTS
|
#ifdef SOL_CHECK_ARGUMENTS
|
||||||
type_assert(L, index, type::thread);
|
type_assert(L, index, type::thread);
|
||||||
|
|
|
@ -44,6 +44,8 @@ namespace sol {
|
||||||
basic_userdata& operator=(basic_userdata&&) = default;
|
basic_userdata& operator=(basic_userdata&&) = default;
|
||||||
basic_userdata(const stack_reference& r) : basic_userdata(r.lua_state(), r.stack_index()) {}
|
basic_userdata(const stack_reference& r) : basic_userdata(r.lua_state(), r.stack_index()) {}
|
||||||
basic_userdata(stack_reference&& r) : basic_userdata(r.lua_state(), r.stack_index()) {}
|
basic_userdata(stack_reference&& r) : basic_userdata(r.lua_state(), r.stack_index()) {}
|
||||||
|
template <typename T, meta::enable<meta::neg<std::is_integral<meta::unqualified_t<T>>>, meta::neg<std::is_same<T, ref_index>>> = meta::enabler>
|
||||||
|
basic_userdata(lua_State* L, T&& r) : basic_userdata(L, sol::ref_index(r.registry_index())) {}
|
||||||
basic_userdata(lua_State* L, int index = -1) : base_t(L, index) {
|
basic_userdata(lua_State* L, int index = -1) : base_t(L, index) {
|
||||||
#ifdef SOL_CHECK_ARGUMENTS
|
#ifdef SOL_CHECK_ARGUMENTS
|
||||||
type_assert(L, index, type::userdata);
|
type_assert(L, index, type::userdata);
|
||||||
|
@ -76,6 +78,8 @@ namespace sol {
|
||||||
basic_lightuserdata& operator=(basic_lightuserdata&&) = default;
|
basic_lightuserdata& operator=(basic_lightuserdata&&) = default;
|
||||||
basic_lightuserdata(const stack_reference& r) : basic_lightuserdata(r.lua_state(), r.stack_index()) {}
|
basic_lightuserdata(const stack_reference& r) : basic_lightuserdata(r.lua_state(), r.stack_index()) {}
|
||||||
basic_lightuserdata(stack_reference&& r) : basic_lightuserdata(r.lua_state(), r.stack_index()) {}
|
basic_lightuserdata(stack_reference&& r) : basic_lightuserdata(r.lua_state(), r.stack_index()) {}
|
||||||
|
template <typename T, meta::enable<meta::neg<std::is_integral<meta::unqualified_t<T>>>, meta::neg<std::is_same<T, ref_index>>> = meta::enabler>
|
||||||
|
basic_lightuserdata(lua_State* L, T&& r) : basic_lightuserdata(L, sol::ref_index(r.registry_index())) {}
|
||||||
basic_lightuserdata(lua_State* L, int index = -1) : base_t(L, index) {
|
basic_lightuserdata(lua_State* L, int index = -1) : base_t(L, index) {
|
||||||
#ifdef SOL_CHECK_ARGUMENTS
|
#ifdef SOL_CHECK_ARGUMENTS
|
||||||
type_assert(L, index, type::lightuserdata);
|
type_assert(L, index, type::lightuserdata);
|
||||||
|
|
|
@ -13,7 +13,7 @@ end
|
||||||
sol::state lua;
|
sol::state lua;
|
||||||
sol::function f = lua["f"];
|
sol::function f = lua["f"];
|
||||||
sol::reference r = lua["f"];
|
sol::reference r = lua["f"];
|
||||||
sol::function regf(lua, sol::ref_index(f.registry_index()));
|
sol::function regf(lua, f);
|
||||||
sol::reference regr(lua, sol::ref_index(f.registry_index()));
|
sol::reference regr(lua, sol::ref_index(f.registry_index()));
|
||||||
bool isequal = f == r;
|
bool isequal = f == r;
|
||||||
REQUIRE(isequal);
|
REQUIRE(isequal);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user