diff options
-rwxr-xr-x | src/embind/embind.js | 33 | ||||
-rwxr-xr-x | system/include/emscripten/bind.h | 19 |
2 files changed, 6 insertions, 46 deletions
diff --git a/src/embind/embind.js b/src/embind/embind.js index b5be4602..d4d428ad 100755 --- a/src/embind/embind.js +++ b/src/embind/embind.js @@ -852,39 +852,6 @@ function __embind_register_class_constructor( var ptr = invoker.apply(null, args); runDestructors(destructors); - return classType.Handle.call(this, ptr); - }; - }); -} - -function __embind_register_class_smart_ptr_constructor( - rawClassType, - argCount, - rawArgTypesAddr, - invoker, - rawConstructor -) { - var rawArgTypes = heap32VectorToArray(argCount, rawArgTypesAddr); - invoker = FUNCTION_TABLE[invoker]; - - requestDeferredRegistration(function() { - var classType = requireRegisteredType(rawClassType, 'class'); - var humanName = 'constructor ' + classType.name; - var argTypes = requireArgumentTypes(rawArgTypes, humanName); - classType.constructor.body = function() { - if (arguments.length !== argCount - 1) { - throwBindingError(humanName + ' called with ' + arguments.length + ' arguments, expected ' + (argCount-1)); - } - var destructors = []; - var args = new Array(argCount); - args[0] = rawConstructor; - for (var i = 1; i < argCount; ++i) { - args[i] = argTypes[i].toWireType(destructors, arguments[i - 1]); - } - - var ptr = invoker.apply(null, args); - runDestructors(destructors); - return argTypes[0].fromWireType(ptr); }; }); diff --git a/system/include/emscripten/bind.h b/system/include/emscripten/bind.h index baa579c6..15bbfc86 100755 --- a/system/include/emscripten/bind.h +++ b/system/include/emscripten/bind.h @@ -116,13 +116,6 @@ namespace emscripten { GenericFunction invoker, GenericFunction constructor); - void _embind_register_class_smart_ptr_constructor( - TYPEID classType, - unsigned argCount, - TYPEID argTypes[], - GenericFunction invoker, - GenericFunction constructor); - void _embind_register_class_method( TYPEID classType, const char* methodName, @@ -633,7 +626,7 @@ namespace emscripten { class_& constructor(ClassType* (*factory)(Args...), Policies...) { using namespace internal; - typename WithPolicies<Policies...>::template ArgTypeList<void, Args...> args; + typename WithPolicies<Policies...>::template ArgTypeList<AllowedRawPointer<ClassType>, Args...> args; _embind_register_class_constructor( TypeID<ClassType>::get(), args.count, @@ -643,15 +636,15 @@ namespace emscripten { return *this; } - template<typename SmartPtr, typename... Args> - class_& constructor(SmartPtr (*factory)(Args...)) { + template<typename SmartPtr, typename... Args, typename... Policies> + class_& constructor(SmartPtr (*factory)(Args...), Policies...) { using namespace internal; - // todo: generate unique name + // TODO: generate unique name smart_ptr<SmartPtr>("SmartPtr"); - typename WithPolicies<>::template ArgTypeList<SmartPtr, Args...> args; - _embind_register_class_smart_ptr_constructor( + typename WithPolicies<Policies...>::template ArgTypeList<SmartPtr, Args...> args; + _embind_register_class_constructor( TypeID<ClassType>::get(), args.count, args.types, |