aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJukka Jylänki <jujjyl@gmail.com>2013-04-16 22:39:50 +0300
committerJukka Jylänki <jujjyl@gmail.com>2013-04-18 20:08:34 +0300
commit11bcd19a9ceae940277ec9ef72bea663f2f50ed1 (patch)
tree1cb286fda0ef26d909b3ee4ec10b3a477f7ec840 /src
parent496b38f13f74e04af233d5ad7307be4f099b07e5 (diff)
Removed embind class member this pointer 'instanceof' check when serializing this to wire type, since instanceof was profiled to be slow. Instead, the correct instanceof enforcement is done in the upcastPointer function.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/embind/embind.js27
1 files changed, 11 insertions, 16 deletions
diff --git a/src/embind/embind.js b/src/embind/embind.js
index 2a484dea..b41137e7 100755
--- a/src/embind/embind.js
+++ b/src/embind/embind.js
@@ -820,12 +820,8 @@ var genericPointerToWireType = function(destructors, handle) {
}
}
- if (!(handle instanceof this.registeredClass.constructor)) {
- throwBindingError('Expected null or instance of ' + this.name + ', got ' + _embind_repr(handle));
- }
-
- if (!handle.$$.ptr) {
- throwBindingError('Cannot pass deleted object');
+ if (!handle.$$ || !handle.$$.ptr) {
+ throwBindingError('Cannot pass deleted or null object');
}
// TODO: this is not strictly true
@@ -884,11 +880,9 @@ var nonConstNoSmartPtrRawPointerToWireType = function(destructors, handle) {
}
return 0;
}
- if (!(handle instanceof this.registeredClass.constructor)) {
- throwBindingError('Expected null or instance of ' + this.name + ', got ' + _embind_repr(handle));
- }
- if (!handle.$$.ptr) {
- throwBindingError('Cannot pass deleted object');
+
+ if (!handle.$$ || !handle.$$.ptr) {
+ throwBindingError('Cannot pass deleted or null object');
}
if (handle.$$.ptrType.isConst) {
throwBindingError('Cannot convert argument of type ' + handle.$$.ptrType.name + ' to parameter type ' + this.name);
@@ -905,11 +899,9 @@ var constNoSmartPtrRawPointerToWireType = function(destructors, handle) {
}
return 0;
}
- if (!(handle instanceof this.registeredClass.constructor)) {
- throwBindingError('Expected null or instance of ' + this.name + ', got ' + _embind_repr(handle));
- }
- if (!handle.$$.ptr) {
- throwBindingError('Cannot pass deleted object');
+
+ if (!handle.$$ || !handle.$$.ptr) {
+ throwBindingError('Cannot pass deleted or null object');
}
var handleClass = handle.$$.ptrType.registeredClass;
var ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass);
@@ -1283,6 +1275,9 @@ function downcastPointer(ptr, ptrClass, desiredClass) {
function upcastPointer(ptr, ptrClass, desiredClass) {
while (ptrClass !== desiredClass) {
+ if (!ptrClass.upcast) {
+ throwBindingError("Expected null or instance of " + desiredClass.name + ", got an instance of " + ptrClass.name);
+ }
ptr = ptrClass.upcast(ptr);
ptrClass = ptrClass.baseClass;
}