aboutsummaryrefslogtreecommitdiff
path: root/src/embind/embind.js
diff options
context:
space:
mode:
authorChad Austin <chad@imvu.com>2013-04-30 15:01:08 -0700
committerChad Austin <chad@imvu.com>2013-05-02 18:55:07 -0700
commit9607e5be25f12ac986436622bdd3b710505a596c (patch)
treeabefc96801dca8f0579b28ea8e46a038a7449245 /src/embind/embind.js
parent54526667562b394f1c3673a48780b18000d798a6 (diff)
Add isAliasOf for seeing if two embind handles point to the same underlying object.
Conflicts: tests/embind/embind_test.cpp
Diffstat (limited to 'src/embind/embind.js')
-rwxr-xr-xsrc/embind/embind.js20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/embind/embind.js b/src/embind/embind.js
index 78f54e31..cadee700 100755
--- a/src/embind/embind.js
+++ b/src/embind/embind.js
@@ -1061,8 +1061,24 @@ ClassHandle.prototype.isAliasOf = function(other) {
if (!(other instanceof ClassHandle)) {
return false;
}
- return this.$$.ptr == other.$$.ptr;
-}
+
+ 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) {