diff options
author | Chad Austin <chad@imvu.com> | 2013-04-29 18:29:43 -0700 |
---|---|---|
committer | Chad Austin <chad@imvu.com> | 2013-05-02 18:55:00 -0700 |
commit | 54526667562b394f1c3673a48780b18000d798a6 (patch) | |
tree | 50f44dc0edcd0966b86fabb4682df1a4be63b87c | |
parent | 9b2cb58a355d4645fe2c7352a0408dc43e99d538 (diff) |
checkpoint object handle composition
-rwxr-xr-x | src/embind/embind.js | 10 | ||||
-rwxr-xr-x | tests/embind/embind.test.js | 20 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/embind/embind.js b/src/embind/embind.js index 988526b4..78f54e31 100755 --- a/src/embind/embind.js +++ b/src/embind/embind.js @@ -1054,6 +1054,16 @@ 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; + } + return this.$$.ptr == other.$$.ptr; +} + ClassHandle.prototype.clone = function() { if (!this.$$.ptr) { throwBindingError(getInstanceTypeName(this) + ' instance already deleted'); diff --git a/tests/embind/embind.test.js b/tests/embind/embind.test.js index 8ef46ad8..812c3b8b 100755 --- a/tests/embind/embind.test.js +++ b/tests/embind/embind.test.js @@ -1682,6 +1682,26 @@ 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("smart pointers compare with raw", function() { + // todo + }); + + BaseFixture.extend("derived-with-offset types compare with base", function() { + // todo + }); }); /* global run_all_tests */ |