diff options
-rwxr-xr-x | src/embind/embind.js | 8 | ||||
-rwxr-xr-x | system/include/emscripten/bind.h | 6 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/embind/embind.js b/src/embind/embind.js index 5d6e6c21..83c3841f 100755 --- a/src/embind/embind.js +++ b/src/embind/embind.js @@ -491,7 +491,13 @@ RegisteredPointer.prototype.isPolymorphic = function() { RegisteredPointer.prototype.toWireType = function(destructors, handle) { var fromRawType; if (handle === null) { - return 0; // todo: maybe this should return a zero-initialized smart pointer object + if (this.isSmartPointer) { + var ptr = this.rawConstructor(0, 0); + destructors.push(this.rawDestructor, ptr); + return ptr; + } else { + return 0; + } } if (!(handle instanceof ClassHandle)) { throwBindingError('Expected pointer or null, got ' + IMVU.repr(handle)); diff --git a/system/include/emscripten/bind.h b/system/include/emscripten/bind.h index e8a8dc1d..7dcfa61b 100755 --- a/system/include/emscripten/bind.h +++ b/system/include/emscripten/bind.h @@ -543,7 +543,11 @@ namespace emscripten { typename smart_ptr_trait<SmartPointerType>::element_type* ptr, SmartPointerType* basePtr ) { - return new SmartPointerType(smart_ptr_trait<SmartPointerType>::share(*basePtr, ptr)); + if (ptr) { + return new SmartPointerType(smart_ptr_trait<SmartPointerType>::share(*basePtr, ptr)); + } else { + return new SmartPointerType; + } } template<typename PointerType> |