diff options
author | Chad Austin <chad@imvu.com> | 2014-05-07 18:30:30 -0700 |
---|---|---|
committer | Bruce Mitchener <bruce.mitchener@gmail.com> | 2014-05-21 22:58:23 +0700 |
commit | 1f7d9ea73de5fccbedf642b68ff600a5b0285061 (patch) | |
tree | 01c309e4398f055c191c7cd60db436e2e09dbd3f /src | |
parent | 1bad0e2ae1038b9ae6ba362c73ca9d3fc8f17e11 (diff) |
Support deriving from abstract classes with constructors
Diffstat (limited to 'src')
-rw-r--r-- | src/embind/embind.js | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/embind/embind.js b/src/embind/embind.js index 43b67fbf..536d53fc 100644 --- a/src/embind/embind.js +++ b/src/embind/embind.js @@ -1743,6 +1743,8 @@ function __embind_create_inheriting_constructor(constructorName, wrapperType, pr wrapperType = requireRegisteredType(wrapperType, 'wrapper'); properties = requireHandle(properties); + var arraySlice = [].slice; + var registeredClass = wrapperType.registeredClass; var wrapperPrototype = registeredClass.instancePrototype; var baseClass = registeredClass.baseClass; @@ -1755,12 +1757,19 @@ function __embind_create_inheriting_constructor(constructorName, wrapperType, pr } }.bind(this)); - var inner = baseConstructor.__$implement(this); - this.$$ = inner.$$; - this.initialize.apply(this, Array.prototype.slice.call(arguments)); + this.__parent = wrapperPrototype; + this.initialize.apply(this, arraySlice.call(arguments)); }); + + // It's a little nasty that we're modifying the wrapper prototype here. + wrapperPrototype.initialize = function initialize() { + var inner = baseConstructor.__$implement.apply( + undefined, + [this].concat(arraySlice.call(arguments))); + this.$$ = inner.$$; + }; + ctor.prototype = Object.create(wrapperPrototype); - ctor.prototype.initialize = function initialize() {}; for (var p in properties) { ctor.prototype[p] = properties[p]; } |