Expand description
§Native Function Interop
This module provides traits and macros for calling Rust functions from Lisp code.
§Overview
The native function interop system allows you to:
- Register Rust functions that can be called from Lisp
- Automatically convert Lisp values to Rust types and back
- Handle errors gracefully
§Key Traits
§Usage
use grift_eval::{NativeRegistry, register_native};
// Define a native function using the register_native! macro
register_native!(add_one, (x: isize) -> isize, { x + 1 });
// Register it with an evaluator
// eval.register_native("add-one", add_one).unwrap();§Design Notes
This module is no_std compatible and uses no heap allocation.
All conversions work directly with arena-allocated values.
Structs§
- Native
Entry - A registered native function with its name.
- Native
Registry - Registry for native functions.
Constants§
- MAX_
NATIVE_ FUNCTIONS - Maximum number of native functions that can be registered.
Traits§
- From
Lisp - Trait for converting Lisp values to Rust types.
- ToLisp
- Trait for converting Rust types to Lisp values.
Functions§
- args_
empty - Check if the argument list is empty (nil).
- count_
args - Count the number of arguments in a list.
- extract_
arg - Extract a single argument from a Lisp argument list.
- simple_
hash - Simple hash function for native function names.
Type Aliases§
- Native
Fn - A native function that can be called from Lisp.