diff options
author | Chad Austin <chad@imvu.com> | 2013-03-18 18:57:21 -0700 |
---|---|---|
committer | Jukka Jylänki <jujjyl@gmail.com> | 2013-04-12 14:26:09 +0300 |
commit | d235d3e4958154f8d6fdaea098e86b8495ee407e (patch) | |
tree | 2d6df10c3b5da8cbb77c549c28477dac399671e1 | |
parent | ecab6656e88f9399410f651c8fe4300dec103712 (diff) |
Simplify RegisteredPointer#fromWireType some
-rwxr-xr-x | src/embind/embind.js | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/embind/embind.js b/src/embind/embind.js index f6c926b7..520ca269 100755 --- a/src/embind/embind.js +++ b/src/embind/embind.js @@ -583,14 +583,6 @@ RegisteredPointer.prototype.destructor = function(ptr) { } }; -RegisteredPointer.prototype._fromWireType = function(ptr) { - if (!this.getPointee(ptr)) { - this.destructor(ptr); - return null; - } - return new this.Handle(this, ptr); -}; - RegisteredPointer.prototype.getDynamicRawPointerType = function(ptr) { var type = null; if (this.isPolymorphic()) { @@ -620,6 +612,10 @@ RegisteredPointer.prototype.getDynamicDowncastType = function(ptr) { }; RegisteredPointer.prototype.fromWireType = function(ptr) { // ptr is a raw pointer (or a raw smartpointer) + function makeHandle(registeredType, ptr) { + return new registeredType.Handle(registeredType, ptr); + } + var handle; if (!this.getPointee(ptr)) { this.destructor(ptr); @@ -628,13 +624,13 @@ RegisteredPointer.prototype.fromWireType = function(ptr) { // ptr is a raw point var toType = this.getDynamicDowncastType(ptr); if (toType) { if (this.isSmartPointer) { - handle = toType.smartPointerType._fromWireType(ptr); + handle = makeHandle(toType.smartPointerType, ptr); } else { - handle = toType._fromWireType(ptr); + handle = makeHandle(toType, ptr); } handle.$$.ptr = staticPointerCast(handle.$$.ptr, this.registeredClass.rawType, toType.rawType); } else { - handle = this._fromWireType(ptr); + handle = makeHandle(this, ptr); } return handle; }; |