From d502f35da4795cb38f6c0c49fd7915d7d37cf6b4 Mon Sep 17 00:00:00 2001 From: Ben Visness Date: Wed, 27 Sep 2023 15:53:15 -0500 Subject: [PATCH] Add oc_run_cmd --- .clang-format | 1 - samples/breakout/build.bat | 2 +- scripts/compile_commands.template.json | 74 ++++ scripts/dev.py | 22 +- src/orca.c | 3 + src/orca.h | 1 + src/platform/orca_subprocess.c | 11 + src/platform/platform_subprocess.h | 24 ++ src/platform/win32_subprocess.c | 135 ++++++++ src/runtime.c | 9 + src/runtime.h | 1 + src/runtime_subprocess.c | 29 ++ src/runtime_subprocess.h | 15 + src/wasmbind/core_api.json | 452 ++++++++++++++++++------- src/wasmbind/subprocess_api.json | 29 ++ 15 files changed, 673 insertions(+), 135 deletions(-) create mode 100644 scripts/compile_commands.template.json create mode 100644 src/platform/orca_subprocess.c create mode 100644 src/platform/platform_subprocess.h create mode 100644 src/platform/win32_subprocess.c create mode 100644 src/runtime_subprocess.c create mode 100644 src/runtime_subprocess.h create mode 100644 src/wasmbind/subprocess_api.json diff --git a/.clang-format b/.clang-format index 03bf57f..c149820 100644 --- a/.clang-format +++ b/.clang-format @@ -26,7 +26,6 @@ BraceWrapping: AfterNamespace: true AfterObjCDeclaration: true AfterStruct: true - AfterObjCDeclaration: true AfterUnion: true BeforeCatch: true BeforeElse: true diff --git a/samples/breakout/build.bat b/samples/breakout/build.bat index a63b8ae..2937090 100644 --- a/samples/breakout/build.bat +++ b/samples/breakout/build.bat @@ -19,7 +19,7 @@ set STDLIB_DIR=%ORCA_DIR%\src\libc-shim set wasmFlags=--target=wasm32^ --no-standard-libraries ^ -mbulk-memory ^ - -g -O2 ^ + -g ^ -D__ORCA__ ^ -Wl,--no-entry ^ -Wl,--export-dynamic ^ diff --git a/scripts/compile_commands.template.json b/scripts/compile_commands.template.json new file mode 100644 index 0000000..c40640d --- /dev/null +++ b/scripts/compile_commands.template.json @@ -0,0 +1,74 @@ +[ + { + "directory": "{{ORCAROOT}}", + "file": "src/orca.c", + "arguments": [ + "src/orca.c", + "-g", + "-D", + "OC_DEBUG", + "-D", + "OC_LOG_COMPILE_DEBUG", + "-c", + "-std=c11", + "-I", + "src", + "-I", + "src/util", + "-I", + "src/platform", + "-I", + "src/ext", + "-I", + "src/ext/angle/include" + ] + }, + { + "directory": "{{ORCAROOT}}", + "file": "src/orca.m", + "arguments": [ + "-xobjective-c", + "src/orca.m", + "-g", + "-D", + "OC_DEBUG", + "-D", + "OC_LOG_COMPILE_DEBUG", + "-c", + "-I", + "src", + "-I", + "src/util", + "-I", + "src/platform", + "-I", + "src/ext", + "-I", + "src/ext/angle/include" + ] + }, + { + "directory": "{{ORCAROOT}}", + "file": "src/runtime.c", + "arguments": [ + "src/runtime.c", + "-g", + "-D", + "OC_DEBUG", + "-D", + "OC_LOG_COMPILE_DEBUG", + "-I", + "src", + "-I", + "src/ext", + "-I", + "src/ext/angle/include", + "-I", + "src/ext/wasm3/source", + "-Lbuild/bin", + "-Lbuild/lib", + "-lorca", + "-lwasm3" + ] + } +] \ No newline at end of file diff --git a/scripts/dev.py b/scripts/dev.py index 464165a..1e81253 100644 --- a/scripts/dev.py +++ b/scripts/dev.py @@ -1,7 +1,7 @@ import glob +import json import os import platform -import re import urllib.request import shutil import subprocess @@ -63,6 +63,8 @@ def build_runtime(args): ensure_programs() ensure_angle() + plonk_compile_commands() + build_platform_layer("lib", args.release) build_wasm3(args.release) build_orca(args.release) @@ -90,6 +92,14 @@ def clean(args): yeetdir("scripts/__pycache__") +def plonk_compile_commands(): + os.makedirs("build", exist_ok=True) + with open("scripts/compile_commands.template.json") as infile: + out = infile.read().replace(r'"{{ORCAROOT}}"', json.dumps(os.getcwd())) + with open("build/compile_commands.json", "w") as outfile: + outfile.write(out) + + def build_platform_layer(target, release): print("Building Orca platform layer...") @@ -344,7 +354,7 @@ def build_orca_mac(release): "-Isrc/ext/wasm3/source" ] libs = ["-Lbuild/bin", "-Lbuild/lib", "-lorca", "-lwasm3"] - debug_flags = ["-O2"] if release else ["-g", "-DOC_DEBUG -DOC_LOG_COMPILE_DEBUG"] + debug_flags = ["-O2"] if release else ["-g", "-DOC_DEBUG", "-DOC_LOG_COMPILE_DEBUG"] flags = [ *debug_flags, "-mmacos-version-min=10.15.4"] @@ -376,22 +386,18 @@ def gen_all_bindings(): "src/wasmbind/gles_api.json", "src/graphics/orca_gl31.h" ) - bindgen("gles", "src/wasmbind/gles_api.json", wasm3_bindings="src/wasmbind/gles_api_bind_gen.c", ) - bindgen("core", "src/wasmbind/core_api.json", guest_stubs="src/wasmbind/core_api_stubs.c", wasm3_bindings="src/wasmbind/core_api_bind_gen.c", ) - bindgen("surface", "src/wasmbind/surface_api.json", guest_stubs="src/graphics/orca_surface_stubs.c", guest_include="graphics/graphics.h", wasm3_bindings="src/wasmbind/surface_api_bind_gen.c", ) - bindgen("clock", "src/wasmbind/clock_api.json", guest_include="platform/platform_clock.h", wasm3_bindings="src/wasmbind/clock_api_bind_gen.c", @@ -400,6 +406,10 @@ def gen_all_bindings(): guest_stubs="src/platform/orca_io_stubs.c", wasm3_bindings="src/wasmbind/io_api_bind_gen.c", ) + bindgen("subprocess", "src/wasmbind/subprocess_api.json", + guest_stubs="src/wasmbind/subprocess_api_stubs.c", + wasm3_bindings="src/wasmbind/subprocess_api_bind_gen.c", + ) def ensure_programs(): diff --git a/src/orca.c b/src/orca.c index a28ff15..0c7db8d 100644 --- a/src/orca.c +++ b/src/orca.c @@ -20,6 +20,7 @@ #include "platform/win32_io.c" #include "platform/win32_thread.c" #include "platform/win32_platform.c" + #include "platform/win32_subprocess.c" //TODO #elif OC_PLATFORM_MACOS #include "platform/native_debug.c" @@ -53,6 +54,7 @@ #include "platform/orca_io_stubs.c" #include "platform/orca_platform.c" #include "platform/platform_path.c" + #include "platform/orca_subprocess.c" #else #error "Unsupported platform" #endif @@ -98,6 +100,7 @@ #elif OC_PLATFORM_ORCA #include "app/orca_app.c" #include "wasmbind/core_api_stubs.c" + #include "wasmbind/subprocess_api_stubs.c" #include "graphics/graphics_common.c" #include "graphics/orca_surface_stubs.c" #else diff --git a/src/orca.h b/src/orca.h index c8f756c..e15bf39 100644 --- a/src/orca.h +++ b/src/orca.h @@ -23,6 +23,7 @@ #include "platform/platform_io.h" #include "platform/platform_io_dialog.h" #include "platform/platform_path.h" +#include "platform/platform_subprocess.h" #if !defined(OC_PLATFORM_ORCA) || !(OC_PLATFORM_ORCA) #include "platform/platform_thread.h" diff --git a/src/platform/orca_subprocess.c b/src/platform/orca_subprocess.c new file mode 100644 index 0000000..1afd74b --- /dev/null +++ b/src/platform/orca_subprocess.c @@ -0,0 +1,11 @@ +/************************************************************************* +* +* Orca +* Copyright 2023 Martin Fouilleul and the Orca project contributors +* See LICENSE.txt for licensing information +* +**************************************************************************/ +#include "platform_subprocess.h" +#include "util/typedefs.h" + +oc_str8 ORCA_IMPORT(oc_run_cmd)(oc_arena* arena, oc_str8 cmd); diff --git a/src/platform/platform_subprocess.h b/src/platform/platform_subprocess.h new file mode 100644 index 0000000..f2a10f7 --- /dev/null +++ b/src/platform/platform_subprocess.h @@ -0,0 +1,24 @@ +/************************************************************************* +* +* Orca +* Copyright 2023 Martin Fouilleul and the Orca project contributors +* See LICENSE.txt for licensing information +* +**************************************************************************/ +#ifndef __PLATFORM_SUBPROCESS_H +#define __PLATFORM_SUBPROCESS_H + +#include "platform.h" +#include "util/strings.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +ORCA_API oc_str8 oc_run_cmd(oc_arena* arena, oc_str8 cmd); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus + +#endif // __PLATFORM_SUBPROCESS_H diff --git a/src/platform/win32_subprocess.c b/src/platform/win32_subprocess.c new file mode 100644 index 0000000..4385971 --- /dev/null +++ b/src/platform/win32_subprocess.c @@ -0,0 +1,135 @@ +/************************************************************************* +* +* Orca +* Copyright 2023 Martin Fouilleul and the Orca project contributors +* See LICENSE.txt for licensing information +* +**************************************************************************/ +#include "platform_subprocess.h" + +#define WIN32_LEAN_AND_MEAN +#include +#include +#include +#include + +oc_str8 oc_run_cmd(oc_arena* arena, oc_str8 cmd) +{ + oc_arena_scope scratch = oc_scratch_begin(); + oc_str8 out = { 0 }; + + HANDLE childStdinRd = NULL; + HANDLE childStdinWr = NULL; + HANDLE childStdoutRd = NULL; + HANDLE childStdoutWr = NULL; + + // Create child process's stdin and stdout pipes + SECURITY_ATTRIBUTES saAttr; + saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); + saAttr.lpSecurityDescriptor = NULL; + saAttr.bInheritHandle = TRUE; + + if(!CreatePipe(&childStdinRd, &childStdinWr, + &saAttr, 0) + || !SetHandleInformation(childStdinWr, HANDLE_FLAG_INHERIT, 0)) + { + oc_log_error("failed to create child stdin\n"); + goto error; + } + if(!CreatePipe(&childStdoutRd, &childStdoutWr, + &saAttr, 0) + || !SetHandleInformation(childStdoutRd, HANDLE_FLAG_INHERIT, 0)) + { + oc_log_error("failed to create child stdout\n"); + goto error; + } + + // Create child process + char* cmdStr = oc_str8_to_cstring(scratch.arena, cmd); + PROCESS_INFORMATION procInfo; + STARTUPINFO startInfo; + + memset(&procInfo, 0, sizeof(PROCESS_INFORMATION)); + memset(&startInfo, 0, sizeof(STARTUPINFO)); + + startInfo.cb = sizeof(STARTUPINFO); + startInfo.hStdInput = childStdinRd; + startInfo.hStdOutput = childStdoutWr; + startInfo.hStdError = childStdoutWr; + startInfo.dwFlags |= STARTF_USESTDHANDLES; + + BOOL success = CreateProcess( + NULL, + cmdStr, + NULL, + NULL, + TRUE, + 0, + NULL, + NULL, + &startInfo, + &procInfo); + if(!success) + { + oc_log_error("failed to create child process\n"); + goto error; + } + CloseHandle(procInfo.hProcess); + CloseHandle(procInfo.hThread); + CloseHandle(childStdinRd); // the parent does not need these ends of the pipes + CloseHandle(childStdoutWr); + + // TODO: Optionally write to the child's stdin + if(!CloseHandle(childStdinWr)) + { + oc_log_error("failed to close child's stdin"); + goto error; + } + + // Read child's combined stdout/stderr + u64 outputLen = 0; + char* outputBuf = NULL; + while(true) + { + const int chunkSize = 1024; + char* chunk = oc_arena_push(arena, chunkSize); + if(outputBuf == NULL) + { + // Initialize output buffer to first allocated chunk + outputBuf = chunk; + } + + DWORD nRead; + BOOL success = ReadFile(childStdoutRd, chunk, chunkSize, &nRead, NULL); + if(!success || nRead == 0) + { + break; + } + + outputLen += nRead; + } + + out = oc_str8_from_buffer(outputLen, outputBuf); + CloseHandle(childStdinWr); + CloseHandle(childStdoutRd); + goto cleanup; + +error: + LPVOID msgBuf; + DWORD dw = GetLastError(); + + FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + dw, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPTSTR)&msgBuf, + 0, NULL); + oc_log_error("%s\n", msgBuf); + + LocalFree(msgBuf); +cleanup: + oc_scratch_end(scratch); + + return out; +} diff --git a/src/runtime.c b/src/runtime.c index 3aa59f6..46d93b0 100644 --- a/src/runtime.c +++ b/src/runtime.c @@ -15,6 +15,7 @@ #include "runtime.h" #include "runtime_clipboard.c" +#include "runtime_subprocess.c" #include "runtime_io.c" #include "runtime_memory.c" @@ -216,6 +217,12 @@ void oc_bridge_request_quit(void) __orcaApp.quit = true; } +// TODO: wait why do I have this bridge +oc_wasm_str8 oc_bridge_run_cmd(oc_wasm_addr wasmArena, oc_wasm_str8 cmd) +{ + return oc_runtime_run_cmd(wasmArena, cmd); +} + typedef struct orca_surface_create_data { oc_window window; @@ -403,6 +410,7 @@ void oc_wasm_env_init(oc_wasm_env* runtime) #include "wasmbind/io_api_bind_gen.c" #include "wasmbind/surface_api_bind_manual.c" #include "wasmbind/surface_api_bind_gen.c" +#include "wasmbind/subprocess_api_bind_gen.c" i32 orca_runloop(void* user) { @@ -461,6 +469,7 @@ i32 orca_runloop(void* user) err |= bindgen_link_clock_api(app->env.m3Module); err |= bindgen_link_io_api(app->env.m3Module); err |= bindgen_link_gles_api(app->env.m3Module); + err |= bindgen_link_subprocess_api(app->env.m3Module); err |= manual_link_gles_api(app->env.m3Module); if(err) diff --git a/src/runtime.h b/src/runtime.h index 46b20d5..976e009 100644 --- a/src/runtime.h +++ b/src/runtime.h @@ -11,6 +11,7 @@ #include "platform/platform_io_internal.h" #include "runtime_memory.h" #include "runtime_clipboard.h" +#include "runtime_subprocess.h" #include "m3_compile.h" #include "m3_env.h" diff --git a/src/runtime_subprocess.c b/src/runtime_subprocess.c new file mode 100644 index 0000000..ee6506a --- /dev/null +++ b/src/runtime_subprocess.c @@ -0,0 +1,29 @@ +/************************************************************************* +* +* Orca +* Copyright 2023 Martin Fouilleul and the Orca project contributors +* See LICENSE.txt for licensing information +* +**************************************************************************/ + +#include "runtime_subprocess.h" +// #include "memory.h" + +oc_arena cmdArena; + +oc_wasm_str8 oc_runtime_run_cmd(oc_wasm_addr wasmArena, oc_wasm_str8 cmd) +{ + if(!cmdArena.currentChunk) + { + oc_arena_init(&cmdArena); + } + + oc_arena_clear(&cmdArena); + oc_str8 nativeCmd = oc_wasm_str8_to_native(cmd); + oc_str8 out = oc_run_cmd(&cmdArena, nativeCmd); + oc_wasm_addr outAddr = oc_wasm_arena_push(wasmArena, out.len); + char* outPtr = (char*)oc_wasm_address_to_ptr(outAddr, out.len); + memcpy(outPtr, out.ptr, out.len); + return (oc_wasm_str8){ .ptr = outAddr, + .len = out.len }; +} diff --git a/src/runtime_subprocess.h b/src/runtime_subprocess.h new file mode 100644 index 0000000..da18ef8 --- /dev/null +++ b/src/runtime_subprocess.h @@ -0,0 +1,15 @@ +/************************************************************************* +* +* Orca +* Copyright 2023 Martin Fouilleul and the Orca project contributors +* See LICENSE.txt for licensing information +* +**************************************************************************/ +#ifndef __RUNTIME_SUBPROCESS_H_ +#define __RUNTIME_SUBPROCESS_H_ + +#include "runtime_memory.h" + +oc_wasm_str8 oc_runtime_run_cmd(oc_wasm_addr wasmArena, oc_wasm_str8 cmd); + +#endif // __RUNTIME_SUBPROCESS_H diff --git a/src/wasmbind/core_api.json b/src/wasmbind/core_api.json index b3a7471..2625cd2 100644 --- a/src/wasmbind/core_api.json +++ b/src/wasmbind/core_api.json @@ -1,128 +1,326 @@ [ -{ - "name": "oc_bridge_log", - "cname": "oc_bridge_log", - "ret": {"name": "void", "tag": "v"}, - "args": [ {"name": "level", - "type": {"name": "oc_log_level", "tag": "i"}}, - {"name": "functionLen", - "type": {"name": "int", "tag": "i"}}, - {"name": "function", - "type": {"name": "char*", "tag": "p"}, - "len": {"count": "functionLen"}}, - {"name": "fileLen", - "type": {"name": "int", "tag": "i"}}, - {"name": "file", - "type": {"name": "char*", "tag": "p"}, - "len": {"count": "fileLen"}}, - {"name": "line", - "type": {"name": "int", "tag": "i"}}, - {"name": "msgLen", - "type": {"name": "int", "tag": "i"}}, - {"name": "msg", - "type": {"name": "char*", "tag": "p"}, - "len": {"count": "msgLen"}} - ] -}, -{ - "name": "oc_mem_grow", - "cname": "oc_mem_grow", - "ret": {"name": "int", "tag": "i"}, - "args": [ {"name": "size", - "type": {"name": "u64", "tag": "I"}}] -}, -{ - "name": "oc_bridge_assert_fail", - "cname": "oc_assert_fail", - "ret": {"name": "void", "tag": "v"}, - "args": [ {"name": "file", - "type": {"name": "const char*", "tag": "p"}, - "len": {"proc": "orca_check_cstring", "args": ["file"]}}, - {"name": "function", - "type": {"name": "const char*", "tag": "p"}, - "len": {"proc": "orca_check_cstring", "args": ["function"]}}, - {"name": "line", - "type": {"name": "int", "tag": "i"}}, - {"name": "src", - "type": {"name": "const char*", "tag": "p"}, - "len": {"proc": "orca_check_cstring", "args": ["src"]}}, - {"name": "note", - "type": {"name": "const char*", "tag": "p"}, - "len": {"proc": "orca_check_cstring", "args": ["note"]}} - ] -}, -{ - "name": "oc_bridge_abort_ext", - "cname": "oc_abort_ext", - "ret": {"name": "void", "tag": "v"}, - "args": [ {"name": "file", - "type": {"name": "const char*", "tag": "p"}, - "len": {"proc": "orca_check_cstring", "args": ["file"]}}, - {"name": "function", - "type": {"name": "const char*", "tag": "p"}, - "len": {"proc": "orca_check_cstring", "args": ["function"]}}, - {"name": "line", - "type": {"name": "int", "tag": "i"}}, - {"name": "note", - "type": {"name": "const char*", "tag": "p"}, - "len": {"proc": "orca_check_cstring", "args": ["note"]}} - ] -}, -{ - "name": "oc_get_host_platform", - "cname": "oc_get_host_platform", - "ret": {"name": "int", "tag": "i"}, - "args": [] -}, -{ - "name": "oc_request_quit", - "cname": "oc_bridge_request_quit", - "ret": {"name": "void", "tag": "v"}, - "args": [] -}, -{ - "name": "oc_window_set_title", - "cname": "oc_bridge_window_set_title", - "ret": {"name": "void", "tag": "v"}, - "args": [ - { "name": "title", - "type": {"name": "oc_str8", "cname": "oc_wasm_str8", "tag": "S"}} - ] -}, -{ - "name": "oc_window_set_size", - "cname": "oc_bridge_window_set_size", - "ret": {"name": "void", "tag": "v"}, - "args": [ - { "name": "size", - "type": {"name": "oc_vec2", "tag": "S"}} - ] -}, -{ - "name": "oc_scancode_to_keycode", - "cname": "oc_scancode_to_keycode", - "ret": { "name": "oc_key_code", "tag": "i"}, - "args": [ - { "name": "scanCode", - "type": {"name": "oc_scan_code", "tag": "i"}} - ] -}, -{ - "name": "oc_clipboard_get_string", - "cname": "oc_bridge_clipboard_get_string", - "ret": { "name": "oc_str8", "cname": "oc_wasm_str8", "tag": "S"}, - "args": [ - {"name": "arena", - "type": {"name": "oc_arena*", "cname": "i32", "tag": "i"}} - ] -}, -{ - "name": "oc_clipboard_set_string", - "cname": "oc_bridge_clipboard_set_string", - "ret": {"name": "void", "tag": "v"}, - "args": [ - { "name": "value", - "type": {"name": "oc_str8", "cname": "oc_wasm_str8", "tag": "S"}} - ] -} -] + { + "name": "oc_bridge_log", + "cname": "oc_bridge_log", + "ret": { + "name": "void", + "tag": "v" + }, + "args": [ + { + "name": "level", + "type": { + "name": "oc_log_level", + "tag": "i" + } + }, + { + "name": "functionLen", + "type": { + "name": "int", + "tag": "i" + } + }, + { + "name": "function", + "type": { + "name": "char*", + "tag": "p" + }, + "len": { + "count": "functionLen" + } + }, + { + "name": "fileLen", + "type": { + "name": "int", + "tag": "i" + } + }, + { + "name": "file", + "type": { + "name": "char*", + "tag": "p" + }, + "len": { + "count": "fileLen" + } + }, + { + "name": "line", + "type": { + "name": "int", + "tag": "i" + } + }, + { + "name": "msgLen", + "type": { + "name": "int", + "tag": "i" + } + }, + { + "name": "msg", + "type": { + "name": "char*", + "tag": "p" + }, + "len": { + "count": "msgLen" + } + } + ] + }, + { + "name": "oc_mem_grow", + "cname": "oc_mem_grow", + "ret": { + "name": "int", + "tag": "i" + }, + "args": [ + { + "name": "size", + "type": { + "name": "u64", + "tag": "I" + } + } + ] + }, + { + "name": "oc_bridge_assert_fail", + "cname": "oc_assert_fail", + "ret": { + "name": "void", + "tag": "v" + }, + "args": [ + { + "name": "file", + "type": { + "name": "const char*", + "tag": "p" + }, + "len": { + "proc": "orca_check_cstring", + "args": [ + "file" + ] + } + }, + { + "name": "function", + "type": { + "name": "const char*", + "tag": "p" + }, + "len": { + "proc": "orca_check_cstring", + "args": [ + "function" + ] + } + }, + { + "name": "line", + "type": { + "name": "int", + "tag": "i" + } + }, + { + "name": "src", + "type": { + "name": "const char*", + "tag": "p" + }, + "len": { + "proc": "orca_check_cstring", + "args": [ + "src" + ] + } + }, + { + "name": "note", + "type": { + "name": "const char*", + "tag": "p" + }, + "len": { + "proc": "orca_check_cstring", + "args": [ + "note" + ] + } + } + ] + }, + { + "name": "oc_bridge_abort_ext", + "cname": "oc_abort_ext", + "ret": { + "name": "void", + "tag": "v" + }, + "args": [ + { + "name": "file", + "type": { + "name": "const char*", + "tag": "p" + }, + "len": { + "proc": "orca_check_cstring", + "args": [ + "file" + ] + } + }, + { + "name": "function", + "type": { + "name": "const char*", + "tag": "p" + }, + "len": { + "proc": "orca_check_cstring", + "args": [ + "function" + ] + } + }, + { + "name": "line", + "type": { + "name": "int", + "tag": "i" + } + }, + { + "name": "note", + "type": { + "name": "const char*", + "tag": "p" + }, + "len": { + "proc": "orca_check_cstring", + "args": [ + "note" + ] + } + } + ] + }, + { + "name": "oc_get_host_platform", + "cname": "oc_get_host_platform", + "ret": { + "name": "int", + "tag": "i" + }, + "args": [] + }, + { + "name": "oc_request_quit", + "cname": "oc_bridge_request_quit", + "ret": { + "name": "void", + "tag": "v" + }, + "args": [] + }, + { + "name": "oc_window_set_title", + "cname": "oc_bridge_window_set_title", + "ret": { + "name": "void", + "tag": "v" + }, + "args": [ + { + "name": "title", + "type": { + "name": "oc_str8", + "cname": "oc_wasm_str8", + "tag": "S" + } + } + ] + }, + { + "name": "oc_window_set_size", + "cname": "oc_bridge_window_set_size", + "ret": { + "name": "void", + "tag": "v" + }, + "args": [ + { + "name": "size", + "type": { + "name": "oc_vec2", + "tag": "S" + } + } + ] + }, + { + "name": "oc_scancode_to_keycode", + "cname": "oc_scancode_to_keycode", + "ret": { + "name": "oc_key_code", + "tag": "i" + }, + "args": [ + { + "name": "scanCode", + "type": { + "name": "oc_scan_code", + "tag": "i" + } + } + ] + }, + { + "name": "oc_clipboard_get_string", + "cname": "oc_bridge_clipboard_get_string", + "ret": { + "name": "oc_str8", + "cname": "oc_wasm_str8", + "tag": "S" + }, + "args": [ + { + "name": "arena", + "type": { + "name": "oc_arena*", + "cname": "i32", + "tag": "i" + } + } + ] + }, + { + "name": "oc_clipboard_set_string", + "cname": "oc_bridge_clipboard_set_string", + "ret": { + "name": "void", + "tag": "v" + }, + "args": [ + { + "name": "value", + "type": { + "name": "oc_str8", + "cname": "oc_wasm_str8", + "tag": "S" + } + } + ] + } +] \ No newline at end of file diff --git a/src/wasmbind/subprocess_api.json b/src/wasmbind/subprocess_api.json new file mode 100644 index 0000000..f71136b --- /dev/null +++ b/src/wasmbind/subprocess_api.json @@ -0,0 +1,29 @@ +[ + { + "name": "oc_run_cmd", + "cname": "oc_bridge_run_cmd", + "ret": { + "name": "oc_str8", + "cname": "oc_wasm_str8", + "tag": "S" + }, + "args": [ + { + "name": "arena", + "type": { + "name": "oc_arena*", + "cname": "i32", + "tag": "i" + } + }, + { + "name": "cmd", + "type": { + "name": "oc_str8", + "cname": "oc_wasm_str8", + "tag": "S" + } + } + ] + } +] \ No newline at end of file