diff options
-rwxr-xr-x | src/embind/embind.js | 13 | ||||
-rwxr-xr-x | system/include/emscripten/bind.h | 4 |
2 files changed, 10 insertions, 7 deletions
diff --git a/src/embind/embind.js b/src/embind/embind.js index 3ecea3e0..b33ff223 100755 --- a/src/embind/embind.js +++ b/src/embind/embind.js @@ -42,7 +42,7 @@ function extendError(baseErrorType, errorName) { return this.name + ': ' + this.message; } }; - + return errorClass; } @@ -698,7 +698,7 @@ function __embind_register_smart_ptr( rawConstructor = FUNCTION_TABLE[rawConstructor]; rawDestructor = FUNCTION_TABLE[rawDestructor]; rawGetPointee = FUNCTION_TABLE[rawGetPointee]; - + var Handle = createNamedFunction(name, function(ptr) { Object.defineProperty(this, '$$', { value: { @@ -713,7 +713,7 @@ function __embind_register_smart_ptr( // TODO: test for SmartPtr.prototype.constructor property? // We likely want it distinct from pointeeType.prototype.constructor Handle.prototype = Object.create(pointeeType.Handle.prototype); - + Handle.prototype.clone = function() { if (!this.$$.ptr) { throwBindingError(pointeeType.name + ' instance already deleted'); @@ -727,16 +727,16 @@ function __embind_register_smart_ptr( ptr: this.$$.ptr, }, }); - + clone.$$.count.value += 1; return clone; }; - + Handle.prototype['delete'] = function() { if (!this.$$.ptr) { throwBindingError(pointeeType.name + ' instance already deleted'); } - + this.$$.count.value -= 1; if (0 === this.$$.count.value) { rawDestructor(this.$$.smartPtr); @@ -757,6 +757,7 @@ function __embind_register_class( rawType, rawPointerType, rawConstPointerType, + baseClassType, isPolymorphic, name, rawDestructor diff --git a/system/include/emscripten/bind.h b/system/include/emscripten/bind.h index ad11395b..cbc5cb8e 100755 --- a/system/include/emscripten/bind.h +++ b/system/include/emscripten/bind.h @@ -105,6 +105,7 @@ namespace emscripten { TYPEID classType, TYPEID pointerType, TYPEID constPointerType, + TYPEID baseClassType, bool isPolymorphic, const char* className, GenericFunction destructor); @@ -610,7 +611,7 @@ namespace emscripten { #define EMSCRIPTEN_WRAPPER(T) \ T(const ::emscripten::val& v): wrapper(v) {} - // TODO: support external class constructors + // TODO: support base class template<typename ClassType> class class_ { public: @@ -622,6 +623,7 @@ namespace emscripten { TypeID<ClassType>::get(), TypeID<AllowedRawPointer<ClassType>>::get(), TypeID<AllowedRawPointer<const ClassType>>::get(), + 0, std::is_polymorphic<ClassType>::value, name, reinterpret_cast<GenericFunction>(&raw_destructor<ClassType>)); |