aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/embind/embind.js10
-rwxr-xr-xtests/embind/embind.test.js20
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 */