diff --git a/src/embind/embind.js b/src/embind/embind.js index b5be46024..d4d428ad9 100755 --- a/src/embind/embind.js +++ b/src/embind/embind.js @@ -834,39 +834,6 @@ function __embind_register_class_constructor( 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 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; diff --git a/system/include/emscripten/bind.h b/system/include/emscripten/bind.h index baa579c6f..15bbfc865 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::template ArgTypeList args; + typename WithPolicies::template ArgTypeList, Args...> args; _embind_register_class_constructor( TypeID::get(), args.count, @@ -643,15 +636,15 @@ namespace emscripten { return *this; } - template - class_& constructor(SmartPtr (*factory)(Args...)) { + template + class_& constructor(SmartPtr (*factory)(Args...), Policies...) { using namespace internal; - // todo: generate unique name + // TODO: generate unique name smart_ptr("SmartPtr"); - typename WithPolicies<>::template ArgTypeList args; - _embind_register_class_smart_ptr_constructor( + typename WithPolicies::template ArgTypeList args; + _embind_register_class_constructor( TypeID::get(), args.count, args.types,