diff options
author | Chad Austin <chad@imvu.com> | 2013-03-14 00:50:18 -0700 |
---|---|---|
committer | Jukka Jylänki <jujjyl@gmail.com> | 2013-04-12 14:25:53 +0300 |
commit | ddb31f11310847b50e4e27f0d64390b55809eecd (patch) | |
tree | 924c79fa217e17ccb6e5e1f1eb9d2757935d8b9d /src/embind/embind.js | |
parent | c8cdc3f73c486cc4ac2ac5da0de01f6072a092af (diff) |
Implement a sane error message when passing an incompatible smart pointer type
Diffstat (limited to 'src/embind/embind.js')
-rwxr-xr-x | src/embind/embind.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/embind/embind.js b/src/embind/embind.js index 89669172..2f30750f 100755 --- a/src/embind/embind.js +++ b/src/embind/embind.js @@ -508,6 +508,11 @@ RegisteredPointer.prototype.isPolymorphic = function() { }; RegisteredPointer.prototype.toWireType = function(destructors, handle) { + var self = this; + function throwCannotConvert() { + throwBindingError('Cannot convert argument of type ' + handle.$$.registeredPointer.name + ' to parameter type ' + self.name); + } + if (handle === null) { if (this.isReference) { throwBindingError('null is not a valid ' + this.name); @@ -528,7 +533,7 @@ RegisteredPointer.prototype.toWireType = function(destructors, handle) { throwBindingError('Passing raw pointer to smart pointer is illegal'); } if (!this.isConst && handle.$$.registeredPointer.isConst) { - throwBindingError('Cannot pass argument of type ' + handle.$$.registeredPointer.name + ' to parameter of type ' + this.name); + throwCannotConvert(); } var handleClass = handle.$$.registeredPointer.registeredClass; var ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass); @@ -539,7 +544,7 @@ RegisteredPointer.prototype.toWireType = function(destructors, handle) { if (handle.$$.registeredPointer === this) { ptr = handle.$$.smartPtr; } else { - throwBindingError('NONE sharing policy not yet supported'); + throwCannotConvert(); } break; |