aboutsummaryrefslogtreecommitdiff
path: root/src/embind/emval.js
diff options
context:
space:
mode:
authorChad Austin <chad@imvu.com>2013-05-03 18:20:26 -0700
committerChad Austin <chad@imvu.com>2013-05-17 12:56:48 -0700
commitfd8cbaa853ec9ea1f2c0c689e1729126c52368e4 (patch)
tree5359cad8a12b53f4d74dcd129945c6d08825a3c8 /src/embind/emval.js
parent7f83ab2926947fda7181a7e67e76425f02da19c4 (diff)
Add support for (fast?) memory_view objects. If C++ passes a memory_view to JS, it gets converted into a typed array object on the other side. Intended for WebGL.
Diffstat (limited to 'src/embind/emval.js')
-rw-r--r--src/embind/emval.js17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/embind/emval.js b/src/embind/emval.js
index bfce63b6..96024269 100644
--- a/src/embind/emval.js
+++ b/src/embind/emval.js
@@ -1,5 +1,6 @@
/*global Module, Runtime*/
/*global HEAP32*/
+/*global createNamedFunction*/
/*global readLatin1String, writeStringToMemory*/
/*global requireRegisteredType, throwBindingError*/
@@ -192,11 +193,14 @@ function parseParameters(argCount, argTypes, argWireTypes) {
function __emval_call(handle, argCount, argTypes) {
requireHandle(handle);
+ var types = lookupTypes(argCount, argTypes);
+
+ var args = new Array(argCount);
+ for (var i = 0; i < argCount; ++i) {
+ args[i] = types[i].fromWireType(arguments[3 + i]);
+ }
+
var fn = _emval_handle_array[handle].value;
- var args = parseParameters(
- argCount,
- argTypes,
- Array.prototype.slice.call(arguments, 3));
var rv = fn.apply(undefined, args);
return __emval_register(rv);
}
@@ -214,7 +218,8 @@ function lookupTypes(argCount, argTypes, argWireTypes) {
function __emval_get_method_caller(argCount, argTypes) {
var types = lookupTypes(argCount, argTypes);
- return Runtime.addFunction(function(handle, name) {
+ var signatureName = types[0].name + "_$" + types.slice(1).map(function(t){return t.name;}).join("_") + "$";
+ return Runtime.addFunction(createNamedFunction(signatureName, function(handle, name) {
requireHandle(handle);
name = getStringOrSymbol(name);
@@ -225,7 +230,7 @@ function __emval_get_method_caller(argCount, argTypes) {
var obj = _emval_handle_array[handle].value;
return types[0].toWireType([], obj[name].apply(obj, args));
- });
+ }));
}
function __emval_has_function(handle, name) {