MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / create_em_js

Function create_em_js

tools/emscripten.py:778–802  ·  view source on GitHub ↗
(metadata)

Source from the content-addressed store, hash-verified

776
777
778def create_em_js(metadata):
779 em_js_funcs = []
780 separator = '<::>'
781 for name, raw in metadata.em_js_funcs.items():
782 assert separator in raw
783 args, body = raw.split(separator, 1)
784 args = args[1:-1].strip()
785 if not args or args == 'void':
786 args = []
787 else:
788 args = args.split(',')
789 arg_names = [arg.split()[-1].replace('*', '') for arg in args if arg]
790 args = ','.join(arg_names)
791 func = f'function {name}({args}) {body}'
792 if settings.WASM_ESM_INTEGRATION:
793 # Like JS library function EM_JS functions are exported at the point of
794 # declaration in WASM_ESM_INTEGRATION node.
795 func = f'export {func}'
796 em_js_funcs.append(func)
797 if (settings.MAIN_MODULE or settings.ASYNCIFY == 2) and name in metadata.em_js_func_types:
798 sig = func_type_to_sig(metadata.em_js_func_types[name])
799 sig = f'{name}.sig = \'{sig}\';'
800 em_js_funcs.append(sig)
801
802 return em_js_funcs
803
804
805def add_standard_wasm_imports(send_items_map):

Callers 1

emscriptFunction · 0.85

Calls 4

func_type_to_sigFunction · 0.85
splitMethod · 0.80
appendMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected