sometimes, I have a dumb. Othertimes, the lua docs are sneaky and have subtle maybe-behaviors when other parts of their API never do. Sneaky, sneaky API...

This commit is contained in:
ThePhD 2016-10-02 13:37:52 -04:00
parent 23c2c6dedc
commit 4ac35aa8f4
2 changed files with 13 additions and 1 deletions

View File

@ -95,6 +95,14 @@ namespace sol {
basic_object& operator=(base_t&& b) { base_t::operator=(std::move(b)); return *this; }
basic_object(const stack_reference& r) noexcept : basic_object(r.lua_state(), r.stack_index()) {}
basic_object(stack_reference&& r) noexcept : basic_object(r.lua_state(), r.stack_index()) {}
template <typename Super>
basic_object(const proxy_base<Super>& r) noexcept : basic_object(r.operator basic_object()) {}
template <typename Super>
basic_object(proxy_base<Super>&& r) noexcept : basic_object(r.operator basic_object()) {}
template <typename Super>
basic_object& operator=(const proxy_base<Super>& r) { this->operator=(r.operator basic_object()); return *this; }
template <typename Super>
basic_object& operator=(proxy_base<Super>&& r) { this->operator=(r.operator basic_object()); return *this; }
basic_object(lua_State* L, int index = -1) noexcept : base_t(L, index) {}
template <typename T, typename... Args>
basic_object(lua_State* L, in_place_type_t<T>, Args&&... args) noexcept : basic_object(std::integral_constant<bool, !std::is_base_of<stack_reference, base_t>::value>(), L, -stack::push<T>(L, std::forward<Args>(args)...)) {}

View File

@ -199,7 +199,11 @@ namespace sol {
}
// Do advanced check for call-style userdata?
static const auto& callkey = name_of(meta_function::call);
lua_getmetatable(L, index);
if (lua_getmetatable(L, index) == 0) {
// No metatable, no __call key possible
handler(L, index, type::function, t);
return false;
}
if (lua_isnoneornil(L, -1)) {
lua_pop(L, 1);
handler(L, index, type::function, t);