diff options
author | Chad Austin <caustin@gmail.com> | 2014-04-12 21:06:54 -0700 |
---|---|---|
committer | Chad Austin <chad@chadaustin.me> | 2014-04-13 09:24:08 -0700 |
commit | 521216f211165e962664f49be3890e2fc22d8efd (patch) | |
tree | 74a00a3948b9e3fd7f71fb9191d765687c51130f /src | |
parent | 50bcf89f21c098aa54033733b33cb66c6c56d7ce (diff) |
checkpoint asm.js-style function lookup by signature string
Diffstat (limited to 'src')
-rw-r--r-- | src/embind/embind.js | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/embind/embind.js b/src/embind/embind.js index 6ec07cd9..23248335 100644 --- a/src/embind/embind.js +++ b/src/embind/embind.js @@ -1,4 +1,4 @@ -/*global Module*/ +/*global Module, asm*/ /*global _malloc, _free, _memcpy*/ /*global FUNCTION_TABLE, HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64*/ /*global readLatin1String*/ @@ -708,10 +708,27 @@ function craftInvokerFunction(humanName, argTypes, classType, cppInvokerFunc, cp return invokerFunction; } -function __embind_register_function(name, argCount, rawArgTypesAddr, rawInvoker, fn) { +function requireFunction(signature, rawFunction) { + signature = readLatin1String(signature); + var fp; + if (typeof FUNCTION_TABLE === "undefined") { + // asm.js style + fp = asm['FUNCTION_TABLE_' + signature](rawFunction); + } else { + fp = FUNCTION_TABLE[rawFunction]; + } + + if (typeof fp !== "function") { + throwBindingError("unknown function pointer with signature " + signature + ": " + rawFunction); + } + return fp; +} + +function __embind_register_function(name, argCount, rawArgTypesAddr, signature, rawInvoker, fn) { var argTypes = heap32VectorToArray(argCount, rawArgTypesAddr); name = readLatin1String(name); - rawInvoker = FUNCTION_TABLE[rawInvoker]; + + rawInvoker = requireFunction(signature, rawInvoker); exposePublicSymbol(name, function() { throwUnboundTypeError('Cannot call ' + name + ' due to unbound types', argTypes); |