aboutsummaryrefslogtreecommitdiff
path: root/tests/embind/embind_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/embind/embind_test.cpp')
-rw-r--r--tests/embind/embind_test.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/embind/embind_test.cpp b/tests/embind/embind_test.cpp
index 30267994..7ac321a8 100644
--- a/tests/embind/embind_test.cpp
+++ b/tests/embind/embind_test.cpp
@@ -856,6 +856,32 @@ void emval_test_call_function(val v, int i, float f, TupleVector tv, StructVecto
v(i, f, tv, sv);
}
+class UniquePtrToConstructor {
+public:
+ UniquePtrToConstructor(std::unique_ptr<int> p)
+ : value(*p)
+ {}
+
+ int getValue() const {
+ return value;
+ }
+
+private:
+ int value;
+};
+
+std::unique_ptr<int> embind_test_return_unique_ptr(int v) {
+ return std::unique_ptr<int>(new int(v));
+}
+
+UniquePtrToConstructor* embind_test_construct_class_with_unique_ptr(int v) {
+ return new UniquePtrToConstructor(embind_test_return_unique_ptr(v));
+}
+
+int embind_test_accept_unique_ptr(std::unique_ptr<int> p) {
+ return *p.get();
+}
+
std::unique_ptr<ValHolder> emval_test_return_unique_ptr() {
return std::unique_ptr<ValHolder>(new ValHolder(val::object()));
}
@@ -1175,6 +1201,8 @@ struct AbstractClassWithConstructor {
: s(s)
{}
+ virtual ~AbstractClassWithConstructor() {};
+
virtual std::string abstractMethod() = 0;
std::string concreteMethod() {
return s;
@@ -1818,6 +1846,15 @@ EMSCRIPTEN_BINDINGS(tests) {
function("embind_test_accept_small_class_instance", &embind_test_accept_small_class_instance);
function("embind_test_accept_big_class_instance", &embind_test_accept_big_class_instance);
+ class_<UniquePtrToConstructor>("UniquePtrToConstructor")
+ .constructor<std::unique_ptr<int>>()
+ .function("getValue", &UniquePtrToConstructor::getValue)
+ ;
+
+ function("embind_test_construct_class_with_unique_ptr", embind_test_construct_class_with_unique_ptr, allow_raw_pointer<ret_val>());
+ function("embind_test_return_unique_ptr", embind_test_return_unique_ptr);
+ function("embind_test_accept_unique_ptr", embind_test_accept_unique_ptr);
+
function("embind_test_return_raw_base_ptr", embind_test_return_raw_base_ptr, allow_raw_pointer<ret_val>());
function("embind_test_return_raw_derived_ptr_as_base", embind_test_return_raw_derived_ptr_as_base, allow_raw_pointer<ret_val>());
function("embind_test_return_raw_sibling_derived_ptr_as_base", embind_test_return_raw_sibling_derived_ptr_as_base, allow_raw_pointer<ret_val>());