aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad Austin <caustin@gmail.com>2013-02-26 01:20:43 -0800
committerJukka Jylänki <jujjyl@gmail.com>2013-04-12 14:24:18 +0300
commitd53d8001aaa3666eb6de40fec25dbec338a75c81 (patch)
treecd0f28942527a18b703c6ac3bcf3c153a94777fd
parentc776c8831f313adb61c1d0e749dc86fbddb9c632 (diff)
Disallow direct embind constructor calls.
-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 71da1108..742dbb94 100755
--- a/src/embind/embind.js
+++ b/src/embind/embind.js
@@ -769,6 +769,9 @@ function __embind_register_class(
registeredClass.pointeeType = type;
type.constructor = createNamedFunction(type.name, function() {
+ if (Object.getPrototypeOf(this) !== Handle.prototype) {
+ throw new BindingError("Use 'new' to construct " + name);
+ }
var body = type.constructor.body;
return body.apply(this, arguments);
});