diff options
-rwxr-xr-x | emscripten.py | 3 | ||||
-rw-r--r-- | tools/shared.py | 9 |
2 files changed, 9 insertions, 3 deletions
diff --git a/emscripten.py b/emscripten.py index 835b1ec9..bf55ee43 100755 --- a/emscripten.py +++ b/emscripten.py @@ -1076,8 +1076,9 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None, } ''' % (sig, ',' if len(sig) > 1 else '', args, arg_coercions, ret)) + ffi_args = ','.join([shared.JS.make_coercion('a' + str(i), sig[i], settings, ffi_arg=True) for i in range(1, len(sig))]) for i in range(settings['RESERVED_FUNCTION_POINTERS']): - jsret = ('return ' if sig[0] != 'v' else '') + shared.JS.make_coercion('jsCall(%d%s%s)' % (i, ',' if coerced_args else '', coerced_args), sig[0], settings) + jsret = ('return ' if sig[0] != 'v' else '') + shared.JS.make_coercion('jsCall(%d%s%s)' % (i, ',' if ffi_args else '', ffi_args), sig[0], settings, ffi_result=True) function_tables_impls.append(''' function jsCall_%s_%s(%s) { %s diff --git a/tools/shared.py b/tools/shared.py index 82bdd98b..826baa83 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -1650,12 +1650,17 @@ class JS: return '+0' @staticmethod - def make_coercion(value, sig, settings=None): + def make_coercion(value, sig, settings=None, ffi_arg=False, ffi_result=False): settings = settings or Settings if sig == 'i': return value + '|0' elif sig == 'f' and settings.get('PRECISE_F32'): - return 'Math_fround(' + value + ')' + if ffi_arg: + return '+Math_fround(' + value + ')' + elif ffi_result: + return 'Math_fround(+(' + value + '))' + else: + return 'Math_fround(' + value + ')' elif sig == 'd' or sig == 'f': return '+' + value else: |