aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xemscripten.py1
-rwxr-xr-xsrc/embind/embind.js26
-rwxr-xr-xsystem/include/emscripten/bind.h101
-rw-r--r--system/include/emscripten/val.h1
-rwxr-xr-xtests/embind/build_benchmark2
-rw-r--r--tests/embind/embind.benchmark.js26
-rwxr-xr-xtests/embind/embind.test.js46
-rw-r--r--tests/embind/embind_benchmark.cpp71
-rw-r--r--tests/embind/embind_test.cpp4290
9 files changed, 2363 insertions, 2201 deletions
diff --git a/emscripten.py b/emscripten.py
index f4bfed82..924012af 100755
--- a/emscripten.py
+++ b/emscripten.py
@@ -767,6 +767,7 @@ WARNING: You should normally never use this! Use emcc instead.
if keywords.temp_dir is None:
temp_files = get_configuration().get_temp_files()
+ temp_dir = get_configuration().TEMP_DIR
else:
temp_dir = os.path.abspath(keywords.temp_dir)
if not os.path.exists(temp_dir):
diff --git a/src/embind/embind.js b/src/embind/embind.js
index 988526b4..cadee700 100755
--- a/src/embind/embind.js
+++ b/src/embind/embind.js
@@ -1054,6 +1054,32 @@ function getInstanceTypeName(handle) {
return handle.$$.ptrType.registeredClass.name;
}
+ClassHandle.prototype.isAliasOf = function(other) {
+ if (!(this instanceof ClassHandle)) {
+ return false;
+ }
+ if (!(other instanceof ClassHandle)) {
+ return false;
+ }
+
+ var leftClass = this.$$.ptrType.registeredClass;
+ var left = this.$$.ptr;
+ var rightClass = other.$$.ptrType.registeredClass;
+ var right = other.$$.ptr;
+
+ while (leftClass.baseClass) {
+ left = leftClass.upcast(left);
+ leftClass = leftClass.baseClass;
+ }
+
+ while (rightClass.baseClass) {
+ right = rightClass.upcast(right);
+ rightClass = rightClass.baseClass;
+ }
+
+ return leftClass === rightClass && left === right;
+};
+
ClassHandle.prototype.clone = function() {
if (!this.$$.ptr) {
throwBindingError(getInstanceTypeName(this) + ' instance already deleted');
diff --git a/system/include/emscripten/bind.h b/system/include/emscripten/bind.h
index 4d2f4ac8..7aa2a55e 100755
--- a/system/include/emscripten/bind.h
+++ b/system/include/emscripten/bind.h
@@ -224,6 +224,10 @@ namespace emscripten {
struct allow_raw_pointer : public allow_raw_pointers {
};
+ ////////////////////////////////////////////////////////////////////////////////
+ // select_overload and select_const
+ ////////////////////////////////////////////////////////////////////////////////
+
template<typename Signature>
typename std::add_pointer<Signature>::type select_overload(typename std::add_pointer<Signature>::type fn) {
return fn;
@@ -241,6 +245,15 @@ namespace emscripten {
return fn;
}
+ template<typename ClassType, typename ReturnType, typename... Args>
+ auto select_const(ReturnType (ClassType::*method)(Args...) const) -> decltype(method) {
+ return method;
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // Invoker
+ ////////////////////////////////////////////////////////////////////////////////
+
namespace internal {
template<typename ReturnType, typename... Args>
struct Invoker {
@@ -1220,90 +1233,10 @@ namespace emscripten {
TypeID<const ConstantType&>::get(),
asGenericValue(BindingType<const ConstantType&>::toWireType(v)));
}
-
- namespace internal {
- template<typename T>
- class optional {
- public:
- optional()
- : initialized(false)
- {}
-
- ~optional() {
- if (initialized) {
- get()->~T();
- }
- }
-
- optional(const optional& rhs)
- : initialized(false)
- {
- *this = rhs;
- }
-
- T& operator*() {
- assert(initialized);
- return *get();
- }
-
- const T& operator*() const {
- assert(initialized);
- return *get();
- }
-
- explicit operator bool() const {
- return initialized;
- }
-
- optional& operator=(const T& v) {
- if (initialized) {
- get()->~T();
- }
- new(get()) T(v);
- initialized = true;
- return *this;
- }
-
- optional& operator=(const optional& o) {
- if (initialized) {
- get()->~T();
- }
- if (o.initialized) {
- new(get()) T(*o);
- }
- initialized = o.initialized;
- return *this;
- }
-
- private:
- T* get() {
- return reinterpret_cast<T*>(&data);
- }
-
- T const* get() const {
- return reinterpret_cast<T const*>(&data);
- }
-
- bool initialized;
- typename std::aligned_storage<sizeof(T)>::type data;
- };
- }
-}
-
-namespace emscripten {
- namespace internal {
- class BindingsDefinition {
- public:
- template<typename Function>
- BindingsDefinition(Function fn) {
- fn();
- }
- };
- }
}
#define EMSCRIPTEN_BINDINGS(name) \
- static struct BindingInitializer_##name { \
- BindingInitializer_##name(); \
- } BindingInitializer_##name##_instance; \
- BindingInitializer_##name::BindingInitializer_##name()
+ static struct EmscriptenBindingInitializer_##name { \
+ EmscriptenBindingInitializer_##name(); \
+ } EmscriptenBindingInitializer_##name##_instance; \
+ EmscriptenBindingInitializer_##name::EmscriptenBindingInitializer_##name()
diff --git a/system/include/emscripten/val.h b/system/include/emscripten/val.h
index 09cad80e..edd070e3 100644
--- a/system/include/emscripten/val.h
+++ b/system/include/emscripten/val.h
@@ -10,6 +10,7 @@ namespace emscripten {
extern "C" {
void _emval_register_symbol(const char*);
+ typedef struct _EM_SIG* EM_SIG;
typedef struct _EM_VAL* EM_VAL;
void _emval_incref(EM_VAL value);
diff --git a/tests/embind/build_benchmark b/tests/embind/build_benchmark
new file mode 100755
index 00000000..6faad18b
--- /dev/null
+++ b/tests/embind/build_benchmark
@@ -0,0 +1,2 @@
+#!/bin/bash
+EMCC_LLVM_TARGET=le32-unknown-nacl ~/projects/emscripten/emcc --minify 0 --bind --post-js embind.benchmark.js -O2 --shell-file shell.html -o embind_benchmark.html embind_benchmark.cpp
diff --git a/tests/embind/embind.benchmark.js b/tests/embind/embind.benchmark.js
index fcbd64ef..7b20db88 100644
--- a/tests/embind/embind.benchmark.js
+++ b/tests/embind/embind.benchmark.js
@@ -222,3 +222,29 @@ function _pass_gameobject_ptr_benchmark_embind_js() {
Module.print("JS embind pass_gameobject_ptr " + N + " iters: " + (b-a) + " msecs.");
}
+function _call_through_interface0() {
+ var N = 1000000;
+ var obj = Module['Interface'].implement({
+ call0: function() {
+ }
+ });
+ var start = _emscripten_get_now();
+ Module['callInterface0'](N, obj);
+ var elapsed = _emscripten_get_now() - start;
+ Module.print("C++ -> JS void through interface " + N + " iters: " + elapsed + " msecs.");
+ obj.delete();
+}
+
+function _call_through_interface1() {
+ var N = 1000000;
+ var obj = Module['Interface'].implement({
+ call1: function(s1, s2) {
+ return s1 + s2;
+ }
+ });
+ var start = _emscripten_get_now();
+ Module['callInterface1'](N, obj);
+ var elapsed = _emscripten_get_now() - start;
+ Module.print("C++ -> JS std::wstring through interface " + N + " iters: " + elapsed + " msecs.");
+ obj.delete();
+}
diff --git a/tests/embind/embind.test.js b/tests/embind/embind.test.js
index 8ef46ad8..52b2cad8 100755
--- a/tests/embind/embind.test.js
+++ b/tests/embind/embind.test.js
@@ -1558,6 +1558,31 @@ module({
assert.equal("optionalfoo", cm.callOptionalMethod(impl, "foo"));
impl.delete();
});
+
+ test("void methods work", function() {
+ var saved = {};
+ var impl = cm.AbstractClass.implement({
+ differentArguments: function(i, d, f, q, s) {
+ saved.i = i;
+ saved.d = d;
+ saved.f = f;
+ saved.q = q;
+ saved.s = s;
+ }
+ });
+
+ cm.callDifferentArguments(impl, 1, 2, 3, 4, "foo");
+
+ assert.deepEqual(saved, {
+ i: 1,
+ d: 2,
+ f: 3,
+ q: 4,
+ s: "foo",
+ });
+
+ impl.delete();
+ });
});
BaseFixture.extend("registration order", function() {
@@ -1682,6 +1707,27 @@ module({
assert.deepEqual([1, 2, 3, 4], cm.VALUE_TUPLE_CONSTANT);
assert.deepEqual({x:1,y:2,z:3,w:4}, cm.VALUE_STRUCT_CONSTANT);
});
+
+ BaseFixture.extend("object handle comparison", function() {
+ var e = new cm.ValHolder("foo");
+ var f = new cm.ValHolder("foo");
+ assert.false(e.isAliasOf(undefined));
+ assert.false(e.isAliasOf(10));
+ assert.true(e.isAliasOf(e));
+ assert.false(e.isAliasOf(f));
+ assert.false(f.isAliasOf(e));
+ e.delete();
+ f.delete();
+ });
+
+ BaseFixture.extend("derived-with-offset types compare with base", function() {
+ var e = new cm.DerivedWithOffset;
+ var f = cm.return_Base_from_DerivedWithOffset(e);
+ assert.true(e.isAliasOf(f));
+ assert.true(f.isAliasOf(e));
+ e.delete();
+ f.delete();
+ });
});
/* global run_all_tests */
diff --git a/tests/embind/embind_benchmark.cpp b/tests/embind/embind_benchmark.cpp
index cdfe998c..b6a834c9 100644
--- a/tests/embind/embind_benchmark.cpp
+++ b/tests/embind/embind_benchmark.cpp
@@ -5,8 +5,7 @@
int counter = 0;
-extern "C"
-{
+extern "C" {
int __attribute__((noinline)) get_counter()
{
@@ -48,6 +47,9 @@ extern void move_gameobjects_benchmark_embind_js();
extern void pass_gameobject_ptr_benchmark();
extern void pass_gameobject_ptr_benchmark_embind_js();
+
+extern void call_through_interface0();
+extern void call_through_interface1();
}
class Vec3
@@ -128,6 +130,56 @@ public:
int class_counter;
};
+class Interface
+{
+public:
+ virtual void call0() = 0;
+ virtual std::wstring call1(const std::wstring& str1, const std::wstring& str2) = 0;
+};
+
+class InterfaceWrapper : public emscripten::wrapper<Interface>
+{
+public:
+ EMSCRIPTEN_WRAPPER(InterfaceWrapper);
+
+ void call0() override {
+ return call<void>("call0");
+ }
+
+ std::wstring call1(const std::wstring& str1, const std::wstring& str2) {
+ return call<std::wstring>("call1", str1, str2);
+ }
+};
+
+void callInterface0(unsigned N, Interface& o) {
+ for (unsigned i = 0; i < N; i += 8) {
+ o.call0();
+ o.call0();
+ o.call0();
+ o.call0();
+ o.call0();
+ o.call0();
+ o.call0();
+ o.call0();
+ }
+}
+
+void callInterface1(unsigned N, Interface& o) {
+ static std::wstring foo(L"foo");
+ static std::wstring bar(L"bar");
+ static std::wstring baz(L"baz");
+ static std::wstring qux(L"qux");
+ for (unsigned i = 0; i < N; i += 7) {
+ o.call1(
+ o.call1(
+ o.call1(foo, bar),
+ o.call1(baz, qux)),
+ o.call1(
+ o.call1(qux, foo),
+ o.call1(bar, baz)));
+ }
+}
+
EMSCRIPTEN_BINDINGS(benchmark)
{
using namespace emscripten;
@@ -164,7 +216,15 @@ EMSCRIPTEN_BINDINGS(benchmark)
.constructor<>()
.function("incr_global_counter", &Foo::incr_global_counter)
.function("incr_class_counter", &Foo::incr_class_counter)
- .function("class_counter_val", &Foo::class_counter_val);
+ .function("class_counter_val", &Foo::class_counter_val)
+ ;
+
+ class_<Interface>("Interface")
+ .allow_subclass<InterfaceWrapper>()
+ ;
+
+ function("callInterface0", &callInterface0);
+ function("callInterface1", &callInterface1);
}
void __attribute__((noinline)) emscripten_get_now_benchmark(int N)
@@ -334,6 +394,7 @@ void __attribute__((noinline)) pass_gameobject_ptr_benchmark()
int main()
{
+ /*
for(int i = 1000; i <= 100000; i *= 10)
emscripten_get_now_benchmark(i);
@@ -370,4 +431,8 @@ int main()
printf("\n");
pass_gameobject_ptr_benchmark();
pass_gameobject_ptr_benchmark_embind_js();
+ */
+ emscripten_get_now();
+ call_through_interface0();
+ call_through_interface1();
}
diff --git a/tests/embind/embind_test.cpp b/tests/embind/embind_test.cpp
index f2359955..23761efc 100644
--- a/tests/embind/embind_test.cpp
+++ b/tests/embind/embind_test.cpp
@@ -1,2114 +1,2176 @@
-#include <string>
-#include <malloc.h>
-#include <functional>
-#include <emscripten/bind.h>
-
-using namespace emscripten;
-
-val emval_test_mallinfo() {
- const auto& i = mallinfo();
- val rv(val::object());
- rv.set("arena", val(i.arena));
- rv.set("ordblks", val(i.ordblks));
- rv.set("smblks", val(i.smblks));
- rv.set("hblks", val(i.hblks));
- rv.set("usmblks", val(i.usmblks));
- rv.set("fsmblks", val(i.fsmblks));
- rv.set("uordblks", val(i.uordblks));
- rv.set("fordblks", val(i.fordblks));
- rv.set("keepcost", val(i.keepcost));
- return rv;
-}
-
-val emval_test_new_integer() {
- return val(15);
-}
-
-val emval_test_new_string() {
- return val("Hello everyone");
-}
-
-std::string emval_test_get_string_from_val(val v) {
- return v["key"].as<std::string>();
-}
-
-val emval_test_new_object() {
- val rv(val::object());
- rv.set("foo", val("bar"));
- rv.set("baz", val(1));
- return rv;
-}
-
-unsigned emval_test_passthrough_unsigned(unsigned v) {
- return v;
-}
-
-val emval_test_passthrough(val v) {
- return v;
-}
-
-void emval_test_return_void() {
-}
-
-bool emval_test_not(bool b) {
- return !b;
-}
-
-unsigned emval_test_as_unsigned(val v) {
- return v.as<unsigned>();
-}
-
-unsigned emval_test_get_length(val v) {
- return v["length"].as<unsigned>();
-}
-
-double emval_test_add(char c, signed char sc, unsigned char uc, signed short ss, unsigned short us, signed int si, unsigned int ui, signed long sl, unsigned long ul, float f, double d) {
- return c + sc + uc + ss + us + si + ui + sl + ul + f + d;
-}
-
-float const_ref_adder(const int& i, const float& f) {
- return i + f;
-}
-
-unsigned emval_test_sum(val v) {
- unsigned length = v["length"].as<unsigned>();
- double rv = 0;
- for (unsigned i = 0; i < length; ++i) {
- rv += v[i].as<double>();
- }
- return rv;
-}
-
-std::string get_non_ascii_string() {
- char c[128 + 1];
- c[128] = 0;
- for (int i = 0; i < 128; ++i) {
- c[i] = 128 + i;
- }
- return c;
-}
-
-std::wstring get_non_ascii_wstring() {
- std::wstring ws(4, 0);
- ws[0] = 10;
- ws[1] = 1234;
- ws[2] = 2345;
- ws[3] = 65535;
- return ws;
-}
-
-std::string emval_test_take_and_return_const_char_star(const char* str) {
- return str;
-}
-
-std::string emval_test_take_and_return_std_string(std::string str) {
- return str;
-}
-
-std::string emval_test_take_and_return_std_string_const_ref(const std::string& str) {
- return str;
-}
-
-std::wstring take_and_return_std_wstring(std::wstring str) {
- return str;
-}
-
-std::function<std::string (std::string)> emval_test_get_function_ptr() {
- return emval_test_take_and_return_std_string;
-}
-
-std::string emval_test_take_and_call_functor(std::function<std::string(std::string)> func) {
- return func("asdf");
-}
-
-class ValHolder {
-public:
- ValHolder(val v)
- : v_(v)
- {}
-
- val getVal() const {
- return v_;
- }
-
- val getValNonConst() {
- return v_;
- }
-
- const val getConstVal() const {
- return v_;
- }
-
- const val& getValConstRef() const {
- return v_;
- }
-
- void setVal(val v) {
- this->v_ = v;
- }
-
- static int some_class_method(int i) {
- return i;
- }
-
- static const ValHolder* makeConst(val v) {
- return new ValHolder(v);
- }
-
- static ValHolder makeValHolder(val v) {
- return ValHolder(v);
- }
-
- static void set_via_raw_pointer(ValHolder* vh, val v) {
- vh->setVal(v);
- }
-
- static val get_via_raw_pointer(const ValHolder* vh) {
- return vh->getVal();
- }
-
- static void transfer_via_raw_pointer(ValHolder* target, const ValHolder* source) {
- target->setVal(source->getVal());
- }
-
- static val getValNonMember(const ValHolder& target) {
- return target.getVal();
- }
-
-private:
- val v_;
-};
-
-ValHolder emval_test_return_ValHolder() {
- return val::object();
-}
-
-void emval_test_set_ValHolder_to_empty_object(ValHolder& vh) {
- vh.setVal(val::object());
-}
-
-class StringHolder {
-public:
- StringHolder(const std::string& s)
- : str_(s)
- {}
-
- void set(const std::string& s) {
- str_ = s;
- }
-
- std::string get() const {
- return str_;
- }
-
- std::string& get_ref() {
- return str_;
- }
-
- const std::string& get_const_ref() const {
- return str_;
- }
-
-private:
- std::string str_;
-};
-
-class SharedPtrHolder {
-public:
- SharedPtrHolder()
- : ptr_(new StringHolder("a string"))
- {}
-
- std::shared_ptr<StringHolder> get() const {
- return ptr_;
- }
-
- void set(std::shared_ptr<StringHolder> p) {
- ptr_ = p;
- }
-private:
- std::shared_ptr<StringHolder> ptr_;
-};
-
-class VectorHolder {
-public:
- VectorHolder() {
- v_.push_back(StringHolder("string #1"));
- v_.push_back(StringHolder("string #2"));
- }
-
- std::vector<StringHolder> get() const {
- return v_;
- }
-
- void set(std::vector<StringHolder> vec) {
- v_ = vec;
- }
-
-private:
- std::vector<StringHolder> v_;
-};
-
-class SmallClass {
-public:
- SmallClass(): member(7) {};
- int member;
-};
-
-class BigClass {
-public:
- BigClass(): member(11) {};
- int member;
- int otherMember;
- int yetAnotherMember;
-
- int getMember() {
- return member;
- }
-};
-
-class ParentClass {
-public:
- ParentClass(): bigClass() {};
-
- BigClass bigClass;
-
- const BigClass& getBigClass() {
- return bigClass;
- };
-};
-
-template<typename T>
-class TemplateClass {
-public:
- TemplateClass(T a, T b, T c) {
- members[0] = a;
- members[1] = b;
- members[2] = c;
- };
-
- const T getMember(int n) {
- return members[n];
- }
-
-protected:
- T members[3];
-};
-
-class ContainsTemplatedMemberClass {
-public:
- ContainsTemplatedMemberClass(): testTemplate(86, 87, 88) {};
-
- TemplateClass<int> testTemplate;
-
- const TemplateClass<int>& getTestTemplate() {
- return testTemplate;
- };
-};
-
-// Begin Inheritance Hierarchy Class Definitions
-
-class Base {
-public:
- Base(): name("Base"),
- member(0),
- baseMember(0)
- {}
-
- std::string getClassName() const {
- return name;
- }
- std::string getClassNameFromBase() const {
- return name;
- }
- std::string getClassNameNotAvailableInDerivedClasses() {
- // but wait -- if you act now we will throw in a SECOND base class method ABSOLUTELY FREE!!
- return name;
- }
- void setMember(int value) {
- member = value;
- }
- int getMember() {
- return member;
- }
- void setBaseMember(int value) {
- baseMember = value;
- }
- int getBaseMember() {
- return baseMember;
- }
- std::string name;
- int member;
- int baseMember;
-};
-
-class SecondBase {
-public:
- SecondBase()
- : name("SecondBase"),
- member(0),
- secondBaseMember(0)
- {}
-
- std::string getClassName() const {
- return name;
- }
- std::string getClassNameNotAvailableInDerivedClasses() {
- return name;
- }
- std::string getClassNameFromSecondBase() const {
- return name;
- }
- void setMember(int value) {
- member = value;
- }
- int getMember() {
- return member;
- }
- void setSecondBaseMember(int value) {
- secondBaseMember = value;
- }
- int getSecondBaseMember() {
- return secondBaseMember;
- }
- std::string name;
- int member;
- int secondBaseMember;
-};
-
-class Derived : public Base{
-public:
- Derived()
- : Base()
- , member(0)
- , name_("Derived")
- {}
-
- std::string getClassName() const {
- return name_;
- }
- void setMember(int value) {
- member = value;
- }
- int getMember() {
- return member;
- }
- int member;
-private:
- std::string name_;
-};
-
-class DerivedHolder {
-public:
- DerivedHolder() {
- derived_.reset();
- }
- void newDerived() {
- deleteDerived();
- derived_ = std::shared_ptr<Derived>(new Derived());
- }
- void deleteDerived() {
- derived_.reset();
- }
- std::shared_ptr<Derived> getDerived() {
- return derived_;
- }
- std::string getDerivedClassName() {
- return derived_->getClassName();
- }
-private:
- std::shared_ptr<Derived> derived_;
-};
-
-class SiblingDerived : public Base {
-public:
- SiblingDerived()
- : Base(),
- name_("SiblingDerived")
- {}
-
- std::string getClassName() const {
- return name_;
- }
-
-private:
- std::string name_;
-};
-
-class MultiplyDerived : public Base, public SecondBase {
-public:
- MultiplyDerived()
- : Base(), SecondBase(),
- name_("MultiplyDerived")
- { instanceCount_ ++; }
-
- ~MultiplyDerived()
- { instanceCount_ --; }
-
- std::string getClassName() const {
- return name_;
- }
-
- static int getInstanceCount() {
- return instanceCount_;
- }
-private:
- std::string name_;
- static int instanceCount_;
-};
-int MultiplyDerived::instanceCount_ = 0;
-
-class DerivedTwice : public Derived {
-public:
- DerivedTwice()
- : Derived(),
- name_("DerivedTwice")
- {}
-
- std::string getClassName() const {
- return name_;
- }
-private:
- std::string name_;
-};
-
-class DerivedTwiceNotBound : public Derived {
-public:
- DerivedTwiceNotBound()
- : Derived(),
- name_("DerivedTwiceNotBound")
- {}
-
- std::string getClassName() const {
- return name_;
- }
-private:
- std::string name_;
-};
-
-class DerivedThrice: public DerivedTwiceNotBound {
-public:
- DerivedThrice()
- : DerivedTwiceNotBound(),
- name_("DerivedThrice")
- {}
-
- std::string getClassName() const {
- return name_;
- }
-private:
- std::string name_;
-};
-
-class DerivedFourTimesNotBound: public DerivedThrice {
-public:
- DerivedFourTimesNotBound()
- : DerivedThrice(),
- name_("DerivedFourTimesNotBound")
- {}
-
- std::string getClassName() const {
- return name_;
- }
-private:
- std::string name_;
-};
-
-class PolyBase {
-public:
- PolyBase(const std::string& s)
- : str_(s),
- name_("PolyBase")
- {}
-
- PolyBase(): name_("PolyBase") {}
-
- virtual ~PolyBase() {}
-
- virtual std::string virtualGetClassName() const {
- return name_;
- }
-
- std::string getClassName() const {
- return name_;
- }
-
-private:
- std::string str_;
- std::string name_;
-};
-
-class PolySecondBase {
-public:
- PolySecondBase(): name_("PolySecondBase")
- {}
-
- virtual ~PolySecondBase() {}
-
- std::string getClassName() const {
- return name_;
- }
-private:
- std::string name_;
-};
-
-class PolyDerived : public PolyBase{
-public:
- PolyDerived()
- : PolyBase("PolyDerived"),
- name_("PolyDerived")
- {}
-
- std::string virtualGetClassName() const {
- return name_;
- }
-
- std::string getClassName() const {
- return name_;
- }
-
- static void setPtrDerived() {
- ptr_ = std::shared_ptr<PolyDerived>(new PolyDerived());
- }
-
- static void releasePtr() {
- ptr_.reset();
- }
-
- static std::string getPtrClassName() {
- return ptr_->getClassName();
- }
-
- static std::shared_ptr<PolyBase> getPtr() {
- return ptr_;
- }
-
-private:
- std::string name_;
- static std::shared_ptr<PolyBase> ptr_;
-};
-std::shared_ptr<PolyBase> PolyDerived::ptr_;
-
-class PolySiblingDerived : public PolyBase {
-public:
- PolySiblingDerived()
- : PolyBase(),
- name_("PolySiblingDerived")
- {}
-
- std::string getClassName() const {
- return name_;
- }
-private:
- std::string name_;
-};
-
-class PolyMultiplyDerived : public PolyBase, public PolySecondBase {
-public:
- PolyMultiplyDerived()
- : PolyBase(), PolySecondBase(),
- name_("PolyMultiplyDerived")
- {}
-
- std::string getClassName() const {
- return name_;
- }
-private:
- std::string name_;
-};
-
-class PolyDerivedTwiceWithoutSmartPointer: public PolyDerived {
-public:
- PolyDerivedTwiceWithoutSmartPointer()
- : PolyDerived(),
- name_("PolyDerivedTwiceWithoutSmartPointer")
- {}
-
- std::string getClassName() const {
- return name_;
- }
-private:
- std::string name_;
-};
-
-class PolyDerivedTwiceNotBound : public PolyDerived {
-public:
- PolyDerivedTwiceNotBound()
- : PolyDerived(),
- name_("PolyDerivedTwiceNotBound")
- {}
-
- std::string getClassName() const {
- return name_;
- }
-private:
- std::string name_;
-};
-
-class PolyDerivedThrice: public PolyDerivedTwiceNotBound {
-public:
- PolyDerivedThrice()
- : PolyDerivedTwiceNotBound(),
- name_("PolyDerivedThrice")
- {}
-
- std::string getClassName() const {
- return name_;
- }
-private:
- std::string name_;
-};
-
-class PolyDerivedFourTimesNotBound: public PolyDerivedThrice {
-public:
- PolyDerivedFourTimesNotBound()
- : PolyDerivedThrice(),
- name_("PolyDerivedFourTimesNotBound")
- {}
-
- std::string getClassName() const {
- return name_;
- }
-private:
- std::string name_;
-};
-
-class PolyDiamondBase {
-public:
- PolyDiamondBase():
- name_("PolyBase")
- {}
- ~PolyDiamondBase() {}
-
- std::string getClassName() const {
- return name_;
- }
-private:
- std::string name_;
-};
-
-class PolyDiamondDerived: public PolyDiamondBase {
-public:
- PolyDiamondDerived()
- : PolyDiamondBase(),
- name_("PolyDiamondDerived")
- {}
-
- std::string getClassName() const {
- return name_;
- }
-private:
- std::string name_;
-};
-
-class PolyDiamondSiblingDerived: public PolyDiamondBase {
-public:
- PolyDiamondSiblingDerived()
- : PolyDiamondBase(),
- name_("PolyDiamondSiblingDerived")
- {}
-
- std::string getClassName() const {
- return name_;
- }
-private:
- std::string name_;
-};
-
-class PolyDiamondMultiplyDerived: public PolyDiamondDerived, public PolyDiamondSiblingDerived {
-public:
- PolyDiamondMultiplyDerived()
- : PolyDiamondDerived(), PolyDiamondSiblingDerived(),
- name_("PolyDiamondMultiplyDerived")
- {}
-
- std::string getClassName() const {
- return name_;
- }
-private:
- std::string name_;
-};
-
-// End Inheritance Hierarchy Class Definitions
-
-std::map<std::string, int> embind_test_get_string_int_map() {
- std::map<std::string, int> m;
-
- m["one"] = 1;
- m["two"] = 2;
-
- return m;
-};
-
-struct Vector {
- Vector() = delete;
-
- Vector(float x_, float y_, float z_, float w_)
- : x(x_)
- , y(y_)
- , z(z_)
- , w(w_)
- {}
-
- float x, y, z, w;
-
- float& operator[](int i) {
- return (&x)[i];
- }
-
- const float& operator[](int i) const {
- return (&x)[i];
- }
-
- float getY() const {
- return y;
- }
- void setY(float _y) {
- y = _y;
- }
-};
-
-struct DummyDataToTestPointerAdjustment {
- std::string dummy;
-};
-
-struct TupleVector : DummyDataToTestPointerAdjustment, Vector {
- TupleVector(): Vector(0, 0, 0,