From e2e901d6bfb153019d41999d47545e6922df2369 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 28 Jan 2015 14:05:56 -0800 Subject: [PATCH] cleanup and standardize indentation in emscripten.py output --- emscripten.py | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/emscripten.py b/emscripten.py index ae8d786a7..800045e42 100755 --- a/emscripten.py +++ b/emscripten.py @@ -985,8 +985,6 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None, return '' funcs_js[1] = re.sub(r'/\* PRE_ASM \*/(.*)\n', lambda m: move_preasm(m), funcs_js[1]) - funcs_js += ['\n// EMSCRIPTEN_END_FUNCS\n'] - class Counter: i = 0 j = 0 @@ -1088,7 +1086,7 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None, infos = [make_table(sig, raw) for sig, raw in last_forwarded_json['Functions']['tables'].iteritems()] Counter.pre = [] - function_tables_defs = '\n'.join([info[0] for info in infos]) + '\n// EMSCRIPTEN_END_FUNCS\n' + '\n'.join([info[1] for info in infos]) + function_tables_defs = '\n'.join([info[0] for info in infos]) + '\n\n// EMSCRIPTEN_END_FUNCS\n' + '\n'.join([info[1] for info in infos]) asm_setup = '' maths = ['Math.' + func for func in ['floor', 'abs', 'sqrt', 'pow', 'cos', 'sin', 'tan', 'acos', 'asin', 'atan', 'atan2', 'exp', 'log', 'ceil', 'imul', 'min', 'clz32']] @@ -1193,21 +1191,21 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None, coerced_args = ','.join([shared.JS.make_coercion('a' + str(i), sig[i], settings) for i in range(1, len(sig))]) ret = ('return ' if sig[0] != 'v' else '') + shared.JS.make_coercion('FUNCTION_TABLE_%s[index&{{{ FTM_%s }}}](%s)' % (sig, sig, coerced_args), sig[0], settings) function_tables_impls.append(''' - function dynCall_%s(index%s%s) { - index = index|0; - %s - %s; - } +function dynCall_%s(index%s%s) { + index = index|0; + %s + %s; +} ''' % (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 ffi_args else '', ffi_args), sig[0], settings, ffi_result=True) function_tables_impls.append(''' - function jsCall_%s_%s(%s) { - %s - %s; - } +function jsCall_%s_%s(%s) { + %s + %s; +} ''' % (sig, i, args, arg_coercions, jsret)) shared.Settings.copy(settings) @@ -1453,7 +1451,7 @@ function getTempRet0() { // EMSCRIPTEN_END_ASM (%s, %s, buffer); %s; -''' % (pre_tables + '\n'.join(function_tables_impls) + '\n' + function_tables_defs.replace('\n', '\n '), exports, +''' % (pre_tables + '\n'.join(function_tables_impls) + '\n' + function_tables_defs, exports, 'Module' + access_quote('asmGlobalArg'), 'Module' + access_quote('asmLibraryArg'), receiving)]