diff options
-rwxr-xr-x | src/embind/embind.js | 57 | ||||
-rwxr-xr-x | system/include/emscripten/bind.h | 18 |
2 files changed, 6 insertions, 69 deletions
diff --git a/src/embind/embind.js b/src/embind/embind.js index b823e281..21eca35e 100755 --- a/src/embind/embind.js +++ b/src/embind/embind.js @@ -711,24 +711,10 @@ function __embind_register_class( rawDestructor = FUNCTION_TABLE[rawDestructor]; var Handle = createNamedFunction(name, function(ptr) { - var h = function() { - if(h.operator_call !== undefined) { - return h.operator_call.apply(h, arguments); - } else { - throw new BindingError(name + ' does not define call operator'); - } - }; - h.$$ = {}; - h.$$.count = {value: 1, ptr: ptr }; - h.$$.ptr = ptr; - h.$$.pointeeType = type; // set below - - for(var prop in Handle.prototype) { - var dp = Object.getOwnPropertyDescriptor(Handle.prototype, prop); - Object.defineProperty(h, prop, dp); - } - - return h; + this.$$ = {}; + this.$$.count = {value: 1, ptr: ptr }; + this.$$.ptr = ptr; + this.$$.pointeeType = type; // set below }); Handle.prototype.clone = function() { @@ -877,41 +863,6 @@ function __embind_register_class_classmethod( }); } -function __embind_register_class_operator_call( - rawClassType, - argCount, - rawArgTypesAddr, - rawInvoker -) { - var rawArgTypes = heap32VectorToArray(argCount, rawArgTypesAddr); - rawInvoker = FUNCTION_TABLE[rawInvoker]; - requestDeferredRegistration(function() { - var classType = requireRegisteredType(rawClassType, 'class'); - var humanName = classType.name + '.' + 'operator_call'; - var argTypes = requireArgumentTypes(rawArgTypes, 'method ' + humanName); - - classType.Handle.prototype.operator_call = function() { - if (!this.$$.ptr) { - throw new BindingError('cannot call emscripten binding method ' + humanName + ' on deleted object'); - } - if (arguments.length !== argCount - 1) { - throw new BindingError('emscripten binding method ' + humanName + ' called with ' + arguments.length + ' arguments, expected ' + (argCount-1)); - } - - var destructors = []; - var args = new Array(argCount); - args[0] = this.$$.ptr; - for (var i = 1; i < argCount; ++i) { - args[i] = argTypes[i].toWireType(destructors, arguments[i - 1]); - } - - var rv = argTypes[0].fromWireType(rawInvoker.apply(null, args)); - runDestructors(destructors); - return rv; - }; - }); -} - function __embind_register_class_operator_array_get( rawClassType, elementType, diff --git a/system/include/emscripten/bind.h b/system/include/emscripten/bind.h index 1ef462bc..5806d57f 100755 --- a/system/include/emscripten/bind.h +++ b/system/include/emscripten/bind.h @@ -141,12 +141,6 @@ namespace emscripten { GenericFunction invoker, GenericFunction method); - void _embind_register_class_operator_call( - TYPEID classType, - unsigned argCount, - TYPEID argTypes[], - GenericFunction invoker); - void _embind_register_class_operator_array_get( TYPEID classType, TYPEID elementType, @@ -754,16 +748,8 @@ namespace emscripten { } template<typename ReturnType, typename... Args, typename... Policies> - class_& calloperator(Policies...) { - using namespace internal; - - typename WithPolicies<Policies...>::template ArgTypeList<ReturnType, Args...> args; - _embind_register_class_operator_call( - TypeID<ClassType>::get(), - args.count, - args.types, - reinterpret_cast<internal::GenericFunction>(&internal::FunctorInvoker<ClassType, ReturnType, Args...>::invoke)); - return *this; + class_& calloperator(const char* methodName, Policies... policies) { + return method(methodName, &ClassType::operator(), policies...); } template<typename ElementType, typename IndexType> |