diff options
-rwxr-xr-x | src/embind/embind.js | 8 | ||||
-rwxr-xr-x | tests/embind/embind.test.js | 8 |
2 files changed, 10 insertions, 6 deletions
diff --git a/src/embind/embind.js b/src/embind/embind.js index 03af7010..b8bd5fcf 100755 --- a/src/embind/embind.js +++ b/src/embind/embind.js @@ -640,9 +640,15 @@ RegisteredPointer.prototype.toWireType = 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'); + } + // TODO: this is not strictly true // We could support BY_EMVAL conversions from raw pointers to smart pointers // because the smart pointer can hold a reference to the handle @@ -1079,8 +1085,6 @@ function __embind_register_class_function( throwBindingError(humanName + ' called with ' + arguments.length + ' arguments, expected ' + (argCount-2)); } - validateThis(this, classType, humanName); - var destructors = []; var args = new Array(argCount + 1); args[0] = context; diff --git a/tests/embind/embind.test.js b/tests/embind/embind.test.js index 82dbeb25..8155fd11 100755 --- a/tests/embind/embind.test.js +++ b/tests/embind/embind.test.js @@ -143,7 +143,7 @@ module({ var e = assert.throws(cm.BindingError, function() { cm.Derived.prototype.setMember.call(a, "foo"); }); - assert.equal('Derived.setMember incompatible with "this" of type HasTwoBases', e.message); + assert.equal('Expected null or instance of Derived*, got [object Object]', e.message); a.delete(); }); @@ -153,7 +153,7 @@ module({ }); if (typeof INVOKED_FROM_EMSCRIPTEN_TEST_RUNNER === "undefined") { // TODO: Enable this to work in Emscripten runner as well! // got Error: expected: Derived.setMember with invalid "this": undefined, actual: Derived.setMember incompatible with "this" of type Object - assert.equal('Derived.setMember with invalid "this": undefined', e.message); + assert.equal('Expected null or instance of Derived*, got undefined', e.message); } var e = assert.throws(cm.BindingError, function() { @@ -161,14 +161,14 @@ module({ }); if (typeof INVOKED_FROM_EMSCRIPTEN_TEST_RUNNER === "undefined") { // TODO: Enable this to work in Emscripten runner as well! // TODO got 'Derived.setMember incompatible with "this" of type Object' - assert.equal('Derived.setMember with invalid "this": this', e.message); + assert.equal('Expected null or instance of Derived*, got this', e.message); } var e = assert.throws(cm.BindingError, function() { cm.Derived.prototype.setMember.call({}, "foo"); }); if (typeof INVOKED_FROM_EMSCRIPTEN_TEST_RUNNER === "undefined") { // TODO: Enable this to work in Emscripten runner as well! - assert.equal('Derived.setMember incompatible with "this" of type Object', e.message); + assert.equal('Expected null or instance of Derived*, got [object Object]', e.message); } }); |