mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Let nullptr pass through, but we still can't do a conversion from lua_nil
to unique_usertype
s.
This commit is contained in:
parent
ea895b4338
commit
090c834f2c
|
@ -143,8 +143,6 @@ namespace sol {
|
||||||
|
|
||||||
template <typename Arg, meta::enable<std::is_base_of<Real, meta::unqualified_t<Arg>>> = meta::enabler>
|
template <typename Arg, meta::enable<std::is_base_of<Real, meta::unqualified_t<Arg>>> = meta::enabler>
|
||||||
static int push(lua_State* L, Arg&& arg) {
|
static int push(lua_State* L, Arg&& arg) {
|
||||||
if (unique_usertype_traits<T>::is_null(arg))
|
|
||||||
return stack::push(L, lua_nil);
|
|
||||||
return push_deep(L, std::forward<Arg>(arg));
|
return push_deep(L, std::forward<Arg>(arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -562,7 +562,7 @@ namespace sol {
|
||||||
return static_cast<type>(lua_type(L, index));
|
return static_cast<type>(lua_type(L, index));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int type_panic(lua_State* L, int index, type expected, type actual) {
|
inline int type_panic(lua_State* L, int index, type expected, type actual) noexcept(false) {
|
||||||
return luaL_error(L, "stack index %d, expected %s, received %s", index,
|
return luaL_error(L, "stack index %d, expected %s, received %s", index,
|
||||||
expected == type::poly ? "anything" : lua_typename(L, static_cast<int>(expected)),
|
expected == type::poly ? "anything" : lua_typename(L, static_cast<int>(expected)),
|
||||||
expected == type::poly ? "anything" : lua_typename(L, static_cast<int>(actual))
|
expected == type::poly ? "anything" : lua_typename(L, static_cast<int>(actual))
|
||||||
|
@ -574,15 +574,15 @@ namespace sol {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void type_error(lua_State* L, int expected, int actual) {
|
inline void type_error(lua_State* L, int expected, int actual) noexcept(false) {
|
||||||
luaL_error(L, "expected %s, received %s", lua_typename(L, expected), lua_typename(L, actual));
|
luaL_error(L, "expected %s, received %s", lua_typename(L, expected), lua_typename(L, actual));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void type_error(lua_State* L, type expected, type actual) {
|
inline void type_error(lua_State* L, type expected, type actual) noexcept(false) {
|
||||||
type_error(L, static_cast<int>(expected), static_cast<int>(actual));
|
type_error(L, static_cast<int>(expected), static_cast<int>(actual));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void type_assert(lua_State* L, int index, type expected, type actual) {
|
inline void type_assert(lua_State* L, int index, type expected, type actual) noexcept(false) {
|
||||||
if (expected != type::poly && expected != actual) {
|
if (expected != type::poly && expected != actual) {
|
||||||
type_panic(L, index, expected, actual);
|
type_panic(L, index, expected, actual);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user