expose oc_request_quit() to wasm runtime

This commit is contained in:
Reuben Dunnington 2023-08-22 13:44:04 -07:00 committed by MartinFouilleul
parent 9d1d8e5306
commit 0973e26150
5 changed files with 25 additions and 3 deletions

View File

@ -274,6 +274,8 @@ extern "C"
} oc_event;
ORCA_API void oc_request_quit(void);
//NOTE: these APIs are not directly available to Orca apps
#if !defined(OC_PLATFORM_ORCA) || !(OC_PLATFORM_ORCA)
//--------------------------------------------------------------------
@ -285,7 +287,6 @@ extern "C"
ORCA_API bool oc_should_quit(void);
ORCA_API void oc_cancel_quit(void);
ORCA_API void oc_request_quit(void);
ORCA_API void oc_set_cursor(oc_mouse_cursor cursor);

View File

@ -2,3 +2,10 @@
//This is used to pass raw events from the runtime
ORCA_EXPORT oc_event oc_rawEvent;
void ORCA_IMPORT(oc_request_quit_stub)(void);
void oc_request_quit()
{
oc_request_quit_stub();
}

View File

@ -796,6 +796,15 @@ i32 orca_runloop(void* user)
oc_arena_clear(oc_scratch());
}
if(exports[OC_EXPORT_TERMINATE])
{
M3Result res = m3_Call(exports[OC_EXPORT_TERMINATE], 0, 0);
if(res)
{
ORCA_WASM3_ABORT(app->runtime.m3Runtime, res, "Runtime error");
}
}
return (0);
}

View File

@ -26,7 +26,8 @@
X(OC_EXPORT_KEY_UP, "oc_on_key_up", "", "i") \
X(OC_EXPORT_FRAME_REFRESH, "oc_on_frame_refresh", "", "") \
X(OC_EXPORT_FRAME_RESIZE, "oc_on_resize", "", "ii") \
X(OC_EXPORT_RAW_EVENT, "oc_on_raw_event", "", "i")
X(OC_EXPORT_RAW_EVENT, "oc_on_raw_event", "", "i") \
X(OC_EXPORT_TERMINATE, "oc_on_terminate", "", "")
typedef enum
{

View File

@ -62,6 +62,10 @@
"name": "oc_get_host_platform",
"cname": "oc_get_host_platform",
"ret": {"name": "int", "tag": "i"},
"args": []
},
{
"name": "oc_request_quit_stub",
"cname": "oc_request_quit",
"ret": {"name": "void", "tag": "v"},
}
]