diff options
author | Chad Austin <chad@imvu.com> | 2014-05-09 13:20:58 -0700 |
---|---|---|
committer | Bruce Mitchener <bruce.mitchener@gmail.com> | 2014-05-21 22:59:16 +0700 |
commit | 09b00f5cd39dc986bc5797c5eb9920af04b4ac59 (patch) | |
tree | 3ef7f74426e0ce45b8211498b5145f26ac79521f /src | |
parent | e25a0f0af05a12705bacf35e4d94bcdc9cd334e9 (diff) |
Prevent some common mistakes when calling parent constructors and destructors
Diffstat (limited to 'src')
-rw-r--r-- | src/embind/embind.js | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/embind/embind.js b/src/embind/embind.js index 27dfa928..6f905d55 100644 --- a/src/embind/embind.js +++ b/src/embind/embind.js @@ -1823,6 +1823,10 @@ function __embind_create_inheriting_constructor(constructorName, wrapperType, pr // It's a little nasty that we're modifying the wrapper prototype here. wrapperPrototype.__construct = function __construct() { + if (this === wrapperPrototype) { + throwBindingError("Pass correct 'this' to __construct"); + } + var inner = baseConstructor.__$implement.apply( undefined, [this].concat(arraySlice.call(arguments))); @@ -1835,6 +1839,10 @@ function __embind_create_inheriting_constructor(constructorName, wrapperType, pr }; wrapperPrototype.__destruct = function __destruct() { + if (this === wrapperPrototype) { + throwBindingError("Pass correct 'this' to __destruct"); + } + unregisterInheritedInstance(registeredClass, this.$$.ptr); }; |