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.cpp31
1 files changed, 29 insertions, 2 deletions
diff --git a/tests/embind/embind_test.cpp b/tests/embind/embind_test.cpp
index 72506346..3561b8a1 100644
--- a/tests/embind/embind_test.cpp
+++ b/tests/embind/embind_test.cpp
@@ -1865,7 +1865,7 @@ int overloaded_function(int i, int j) {
class MultipleCtors {
public:
- int value;
+ int value = 0;
MultipleCtors(int i) {
value = 1;
@@ -1888,6 +1888,25 @@ public:
}
};
+class MultipleSmartCtors {
+public:
+ int value = 0;
+
+ MultipleSmartCtors(int i) {
+ value = 1;
+ assert(i == 10);
+ }
+ MultipleSmartCtors(int i, int j) {
+ value = 2;
+ assert(i == 20);
+ assert(j == 20);
+ }
+
+ int WhichCtorCalled() const {
+ return value;
+ }
+};
+
class MultipleOverloads {
public:
MultipleOverloads() {}
@@ -1994,7 +2013,15 @@ EMSCRIPTEN_BINDINGS(overloads) {
.constructor<int>()
.constructor<int, int>()
.constructor<int, int, int>()
- .function("WhichCtorCalled", &MultipleCtors::WhichCtorCalled);
+ .function("WhichCtorCalled", &MultipleCtors::WhichCtorCalled)
+ ;
+
+ class_<MultipleSmartCtors>("MultipleSmartCtors")
+ .smart_ptr<std::shared_ptr<MultipleSmartCtors>>()
+ .constructor(&std::make_shared<MultipleSmartCtors, int>)
+ .constructor(&std::make_shared<MultipleSmartCtors, int, int>)
+ .function("WhichCtorCalled", &MultipleSmartCtors::WhichCtorCalled)
+ ;
class_<MultipleOverloads>("MultipleOverloads")
.constructor<>()