fix problem with instantiations of abstract classes in optional reference

This commit is contained in:
ThePhD 2016-09-10 20:59:12 -04:00
parent edb8eacac7
commit 5dface25fb
4 changed files with 30 additions and 8 deletions

@ -1 +1 @@
Subproject commit 45112c085a4ca75b5591dde3bf46faf4969c3026
Subproject commit 70ad908553b0bbac144452ce0dcc98d6dfe565a4

View File

@ -20,8 +20,8 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// This file was generated with a script.
// Generated 2016-09-04 15:42:29.271382 UTC
// This header was generated with sol v2.12.2 (revision cb0116a)
// Generated 2016-09-11 00:47:45.107316 UTC
// This header was generated with sol v2.12.3 (revision edb8eac)
// https://github.com/ThePhD/sol2
#ifndef SOL_SINGLE_INCLUDE_HPP
@ -1442,10 +1442,10 @@ public:
return ref != nullptr;
}
template <class V>
constexpr typename ::std::decay<T>::type value_or(V&& v) const
template <typename V>
constexpr T& value_or(V&& v) const
{
return *this ? **this : detail_::convert<typename ::std::decay<T>::type>(constexpr_forward<V>(v));
return *this ? **this : detail_::convert<T&>(constexpr_forward<V>(v));
}
};
@ -9382,7 +9382,7 @@ namespace sol {
namespace usertype_detail {
struct no_comp {
template <typename A, typename B>
bool operator()(A&&, B&&) {
bool operator()(A&&, B&&) const {
return false;
}
};

View File

@ -37,7 +37,7 @@ namespace sol {
namespace usertype_detail {
struct no_comp {
template <typename A, typename B>
bool operator()(A&&, B&&) {
bool operator()(A&&, B&&) const {
return false;
}
};

View File

@ -72,6 +72,18 @@ public:
}
};
class abstract_A {
public:
virtual void a() = 0;
};
class abstract_B : public abstract_A {
public:
virtual void a() override {
INFO("overridden a() in B : public A - BARK");
}
};
struct Vec {
float x, y, z;
Vec(float x, float y, float z) : x{ x }, y{ y }, z{ z } {}
@ -1405,3 +1417,13 @@ TEST_CASE("usertype/unique_usertype-check", "make sure unique usertypes don't ge
my_func(std::make_shared<Entity>());
});
}
TEST_CASE("usertype/abstract-base-class", "Ensure that abstract base classes and such can be registered") {
sol::state lua;
lua.new_usertype<abstract_A>("A", "a", &abstract_A::a);
lua.new_usertype<abstract_B>("B", sol::base_classes, sol::bases<abstract_A>());
lua.script(R"(local b = B.new()
b:a()
)");
}