Skip to content

Commit

Permalink
core/wm: Update C/Rust bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
caseif committed Jul 11, 2024
1 parent 4acc4a4 commit 71bf273
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 2 deletions.
6 changes: 6 additions & 0 deletions engine/auxiliary/core_rustabi/src/argus/core/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ pub fn initialize_engine() {
}
}

pub fn crash(format: &str) -> ! {
unsafe {
argus_crash(string_to_cstring(format));
}
}

pub fn start_engine(callback: DeltaCallback) -> ! {
unsafe {
argus_start_engine(Some(callback));
Expand Down
1 change: 1 addition & 0 deletions engine/auxiliary/core_rustabi/src/core_cabi/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ extern "C" {
pub fn argus_get_present_dynamic_modules() -> StringArray;
pub fn argus_initialize_engine();
pub fn argus_start_engine(callback: delta_callback_t) -> !;
pub fn argus_crash(format: *const ::std::os::raw::c_char) -> !;
pub fn argus_get_current_lifecycle_stage() -> LifecycleStage;
pub fn argus_register_update_callback(
update_callback: delta_callback_t,
Expand Down
2 changes: 1 addition & 1 deletion engine/auxiliary/wm_rustabi/src/wm_cabi/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub const GL_CONTEXT_FLAG_PROFILE_COMPAT: GLContextFlags = 4;
pub const GL_CONTEXT_FLAG_DEBUG_CONTEXT: GLContextFlags = 256;
pub const GL_CONTEXT_FLAG_PROFILE_MASK: GLContextFlags = 7;
pub type GLContextFlags = ::std::os::raw::c_uint;
pub const EVENT_TYPE_WINDOW: &[u8; 7] = b"window\0";
pub const k_event_type_window: &[u8; 7] = b"window\0";
pub const WINDOW_EVENT_TYPE_CREATE: WindowEventType = 0;
pub const WINDOW_EVENT_TYPE_UPDATE: WindowEventType = 1;
pub const WINDOW_EVENT_TYPE_REQUEST_CLOSE: WindowEventType = 2;
Expand Down
2 changes: 2 additions & 0 deletions engine/static/core/include/argus/core/cabi/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ void argus_initialize_engine(void);

ARGUS_NORETURN void argus_start_engine(delta_callback_t callback);

ARGUS_NORETURN void argus_crash(const char *msg);

LifecycleStage argus_get_current_lifecycle_stage(void);

Index argus_register_update_callback(delta_callback_t update_callback, Ordering ordering);
Expand Down
3 changes: 2 additions & 1 deletion engine/static/core/include/argus/core/engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,11 @@ namespace argus {
/**
* @brief Crashes the engine with the given error message.
*
* The message will be printed to stdout and may be displayed to the end
* The message will be printed to stderr and may be displayed to the end
* user in some form, but this is not guaranteed.
*
* @param format The message to display.
* @param args The format arguments for the message.
*/
[[noreturn]] void crash(const char *format, va_list args);

Expand Down
4 changes: 4 additions & 0 deletions engine/static/core/src/cabi/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ void argus_initialize_engine(void) {
argus::start_engine(_wrap_delta_callback(callback));
}

[[noreturn]] void argus_crash(const char *msg) {
argus::crash(msg);
}

LifecycleStage argus_get_current_lifecycle_stage(void) {
return static_cast<LifecycleStage>(argus::get_current_lifecycle_stage());
}
Expand Down

0 comments on commit 71bf273

Please sign in to comment.