diff options
author | Chad Austin <chad@imvu.com> | 2013-04-30 15:01:08 -0700 |
---|---|---|
committer | Chad Austin <chad@imvu.com> | 2013-05-02 18:55:07 -0700 |
commit | 9607e5be25f12ac986436622bdd3b710505a596c (patch) | |
tree | abefc96801dca8f0579b28ea8e46a038a7449245 /tests/embind | |
parent | 54526667562b394f1c3673a48780b18000d798a6 (diff) |
Add isAliasOf for seeing if two embind handles point to the same underlying object.
Conflicts:
tests/embind/embind_test.cpp
Diffstat (limited to 'tests/embind')
-rwxr-xr-x | tests/embind/embind.test.js | 11 | ||||
-rw-r--r-- | tests/embind/embind_test.cpp | 15 |
2 files changed, 21 insertions, 5 deletions
diff --git a/tests/embind/embind.test.js b/tests/embind/embind.test.js index 812c3b8b..2f407471 100755 --- a/tests/embind/embind.test.js +++ b/tests/embind/embind.test.js @@ -1695,12 +1695,13 @@ module({ f.delete(); }); - BaseFixture.extend("smart pointers compare with raw", function() { - // todo - }); - BaseFixture.extend("derived-with-offset types compare with base", function() { - // todo + 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(); }); }); diff --git a/tests/embind/embind_test.cpp b/tests/embind/embind_test.cpp index 48da45b8..21fbee65 100644 --- a/tests/embind/embind_test.cpp +++ b/tests/embind/embind_test.cpp @@ -2141,3 +2141,18 @@ EMSCRIPTEN_BINDINGS(constants) { StructVector sv(1, 2, 3, 4); constant("VALUE_STRUCT_CONSTANT", sv); } + +class DerivedWithOffset : public DummyDataToTestPointerAdjustment, public Base { +}; + +std::shared_ptr<Base> return_Base_from_DerivedWithOffset(std::shared_ptr<DerivedWithOffset> ptr) { + return ptr; +} + +EMSCRIPTEN_BINDINGS(with_adjustment) { + class_<DerivedWithOffset, base<Base>>("DerivedWithOffset") + .smart_ptr_constructor(&std::make_shared<DerivedWithOffset>) + ; + + function("return_Base_from_DerivedWithOffset", &return_Base_from_DerivedWithOffset); +} |