bobcat_console/
lib.rs

1#![no_std]
2
3extern crate alloc;
4
5#[link(wasm_import_module = "console")]
6unsafe extern "C" {
7    pub fn log_txt(ptr: *const u8, len: usize);
8}
9
10#[macro_export]
11macro_rules! console {
12    ($val:expr) => {
13    {
14        let tmp = $val;
15        let msg = alloc::format!("[{}:{}] {} = {:#?}\n", file!(), line!(), stringify!($val), &tmp);
16        unsafe { $crate::log_txt(msg.as_ptr(), msg.len()) };
17        tmp
18    }};
19    ($($vals:expr),+ $(,)?) => {
20    {
21        let tup = ($($vals),+);
22        let msg = alloc::format!("[{}:{}] {} = {:#?}\n", file!(), line!(), stringify!(($($vals),+)), &tup);
23        unsafe { $crate::log_txt(msg.as_ptr(), msg.len()) };
24        tup
25    }};
26}