1
0
Fork 0
forked from fun/fun

Rust doc fixes. No code changes. (0.38.5)

This commit is contained in:
Johannes Findeisen 2026-01-29 15:17:46 +01:00
commit c03ac29e40

View file

@ -55,6 +55,7 @@
In src/rust/src/lib.rs: In src/rust/src/lib.rs:
```
#![no_std] #![no_std]
#[repr(C)] #[repr(C)]
@ -77,6 +78,7 @@
#[panic_handler] #[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! { loop {} } fn panic(_info: &core::panic::PanicInfo) -> ! { loop {} }
```
What this does: What this does:
- Pops two 64-bit integers from the VM stack. - Pops two 64-bit integers from the VM stack.
@ -91,6 +93,7 @@
String demo wiring (already present): src/vm/rust/hello.c String demo wiring (already present): src/vm/rust/hello.c
```
case OP_RUST_HELLO: { case OP_RUST_HELLO: {
#ifdef FUN_WITH_RUST #ifdef FUN_WITH_RUST
const char *s = fun_rust_get_string(); const char *s = fun_rust_get_string();
@ -102,9 +105,11 @@
#endif #endif
break; break;
} }
```
For a stack-based math opcode (like fun_op_radd), you would declare and call the Rust function similarly: For a stack-based math opcode (like fun_op_radd), you would declare and call the Rust function similarly:
```
#ifdef FUN_WITH_RUST #ifdef FUN_WITH_RUST
extern int fun_op_radd(void* vm); // or use the proper VM type if available extern int fun_op_radd(void* vm); // or use the proper VM type if available
#endif #endif
@ -118,8 +123,10 @@
#endif #endif
break; break;
} }
```
Notes: Notes:
- Follow the existing opcode conventions for your module (core, math, strings, etc.). - Follow the existing opcode conventions for your module (core, math, strings, etc.).
- If your build puts the Rust symbol into a static library, make sure the VM target links it when FUN_WITH_RUST is ON (the top-level CMake already does this for the examples provided). - If your build puts the Rust symbol into a static library, make sure the VM target links it when FUN_WITH_RUST is ON (the top-level CMake already does this for the examples provided).
@ -150,6 +157,7 @@
## Data types and FFI surface ## Data types and FFI surface
The minimal helpers shown cover 64-bit integers and simple strings. Extending the Rust<->C bridge usually involves: The minimal helpers shown cover 64-bit integers and simple strings. Extending the Rust<->C bridge usually involves:
- Declaring additional extern "C" functions in Rust that the C VM implements (to read/write values on the stack, construct arrays/maps/strings, etc.). - Declaring additional extern "C" functions in Rust that the C VM implements (to read/write values on the stack, construct arrays/maps/strings, etc.).
- Ensuring all pointers and lifetimes are well-defined: strings pushed to the VM should be copied or allocated using VM facilities so they remain valid after the call. - Ensuring all pointers and lifetimes are well-defined: strings pushed to the VM should be copied or allocated using VM facilities so they remain valid after the call.
- Keeping Rust no_std unless you add an allocator and link setup to support std. - Keeping Rust no_std unless you add an allocator and link setup to support std.