diff options
author | Chad Austin <chad@imvu.com> | 2013-05-03 01:11:08 -0700 |
---|---|---|
committer | Chad Austin <chad@imvu.com> | 2013-05-17 12:56:16 -0700 |
commit | 31d6f4e7bf3b20be1a64ee481398910239174122 (patch) | |
tree | 22a4872878c7af383e089170658cf390c643d5dd /src | |
parent | a7c47e66eed5c2db9aac373f9b0d043d9f048703 (diff) |
Checkpoint work towards making vtable->JS calls faster.
Diffstat (limited to 'src')
-rw-r--r-- | src/embind/embind.js | 4 | ||||
-rw-r--r-- | src/embind/emval.js | 44 |
2 files changed, 27 insertions, 21 deletions
diff --git a/src/embind/embind.js b/src/embind/embind.js index cadee700..dfe4c014 100644 --- a/src/embind/embind.js +++ b/src/embind/embind.js @@ -270,6 +270,10 @@ function __embind_register_void(rawType, name) { 'fromWireType': function() { return undefined; }, + 'toWireType': function(destructors, o) { + // TODO: assert if anything else is given? + return undefined; + }, }); } diff --git a/src/embind/emval.js b/src/embind/emval.js index c02ffa92..bfce63b6 100644 --- a/src/embind/emval.js +++ b/src/embind/emval.js @@ -1,4 +1,4 @@ -/*global Module*/ +/*global Module, Runtime*/ /*global HEAP32*/ /*global readLatin1String, writeStringToMemory*/ /*global requireRegisteredType, throwBindingError*/ @@ -201,29 +201,31 @@ function __emval_call(handle, argCount, argTypes) { return __emval_register(rv); } -function __emval_call_method(handle, name, argCount, argTypes) { - requireHandle(handle); - name = getStringOrSymbol(name); - - var args = parseParameters( - argCount, - argTypes, - Array.prototype.slice.call(arguments, 4)); - var obj = _emval_handle_array[handle].value; - var rv = obj[name].apply(obj, args); - return __emval_register(rv); +function lookupTypes(argCount, argTypes, argWireTypes) { + var a = new Array(argCount); + for (var i = 0; i < argCount; ++i) { + a[i] = requireRegisteredType( + HEAP32[(argTypes >> 2) + i], + "parameter " + i); + } + return a; } -function __emval_call_void_method(handle, name, argCount, argTypes) { - requireHandle(handle); - name = getStringOrSymbol(name); +function __emval_get_method_caller(argCount, argTypes) { + var types = lookupTypes(argCount, argTypes); - var args = parseParameters( - argCount, - argTypes, - Array.prototype.slice.call(arguments, 4)); - var obj = _emval_handle_array[handle].value; - obj[name].apply(obj, args); + return Runtime.addFunction(function(handle, name) { + requireHandle(handle); + name = getStringOrSymbol(name); + + var args = new Array(argCount - 1); + for (var i = 1; i < argCount; ++i) { + args[i - 1] = types[i].fromWireType(arguments[1 + i]); + } + + var obj = _emval_handle_array[handle].value; + return types[0].toWireType([], obj[name].apply(obj, args)); + }); } function __emval_has_function(handle, name) { |