Skip to main content

luaur_repl_cli/functions/
assertion_handler.rs

1use core::ffi::{c_char, c_int, CStr};
2
3/// C++ static function: assertionHandler
4/// Prints assertion failure message to stdout and returns 1.
5pub unsafe fn assertion_handler(
6    expr: *const c_char,
7    file: *const c_char,
8    line: c_int,
9    _function: *const c_char,
10) -> i32 {
11    let expr_str = if expr.is_null() {
12        ""
13    } else {
14        CStr::from_ptr(expr).to_str().unwrap_or("")
15    };
16    let file_str = if file.is_null() {
17        ""
18    } else {
19        CStr::from_ptr(file).to_str().unwrap_or("")
20    };
21    println!("{}({}): ASSERTION FAILED: {}", file_str, line, expr_str);
22    1
23}