mimium-plugin-macros 4.0.0

Procedural macros for mimium plugin development
Documentation

Procedural macros for mimium plugin development.

This crate provides attribute macros that simplify the definition of plugin functions by automatically generating the boilerplate required to bridge between idiomatic Rust and mimium's runtime FFI.

Overview

Runtime Functions (mimium_plugin_fn)

Plugin authors write methods using normal Rust types (e.g. f64 arguments and return values). The [mimium_plugin_fn] macro transforms each annotated method into a pair:

  1. A private helper retaining the original signature and body.
  2. A public wrapper with the (&mut Self, &mut Machine) -> ReturnCode signature expected by SystemPluginFnType.

Internally the wrapper creates a RuntimeHandle and performs all argument extraction / return-value writing through it, ensuring that the actual plugin logic is decoupled from the VM implementation.

Macro Functions (mimium_plugin_macro)

For compile-time code generation, the [mimium_plugin_macro] attribute transforms methods with the signature (&mut self, &[(Value, TypeNodeId)]) -> Value into FFI-compatible wrappers that handle serialization/deserialization automatically.

Example

use mimium_plugin_macros::{mimium_plugin_fn, mimium_plugin_macro};

struct MyPlugin { value: f64 }

impl MyPlugin {
    #[mimium_plugin_fn]
    pub fn add_value(&mut self, x: f64) -> f64 {
        self.value + x
    }

    #[mimium_plugin_macro]
    pub fn my_macro(&mut self, args: &[(Value, TypeNodeId)]) -> Value {
        // Generate code based on arguments
        Value::Code(...)
    }
}