summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad Austin <chad@imvu.com>2013-03-07 17:50:53 -0800
committerJukka Jylänki <jujjyl@gmail.com>2013-04-12 14:25:18 +0300
commit29425235762674d01013f73f669918df989fc311 (patch)
tree7b0209449e5bcfaced99cebd262f13fd5d0f6d11
parent6a14788d73acac51770fd68d63cb8c5531efdfb2 (diff)
methods now give sensible error messages when passing incompatible objects as 'this'
-rwxr-xr-xsrc/embind/embind.js3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/embind/embind.js b/src/embind/embind.js
index ed659a2b..470b03f7 100755
--- a/src/embind/embind.js
+++ b/src/embind/embind.js
@@ -887,6 +887,9 @@ function __embind_register_class_method(
argTypes = argTypes.slice(1);
var humanName = classType.name + '.' + methodName;
classType.Handle.prototype[methodName] = function() {
+ if (!(this instanceof classType.constructor)) {
+ throwBindingError(humanName + ' incompatible with object of type ' + this.constructor.name);
+ }
if (!this.$$.ptr) {
throwBindingError('cannot call emscripten binding method ' + humanName + ' on deleted object');
}