tclfn!() { /* proc-macro */ }
Expand description
Helps to register rust functions as Tcl commands
Syntax
tclfn!( interp, cmd, args, func )
Input parameters
-
interp, the Tcl interpreter instance.
-
cmd, the name of the command being registered in Tcl. Optional.
-
args, the arguments provided in Tcl on executing the command. Optional.
-
func, the function defined in Rust.
Output
Returns a String
of the command name.
Example
use tcl::*;
let interpreter = Interpreter::new()?;
let cmd = tclfn!( &interpreter, /*cmd: "mul", args: "",*/
fn mul( a: i32, b: i32 ) -> TclResult<i32> { Ok( a * b )}
);
let c = interpreter.eval( "mul 3 7" )?;
assert_eq!( c.as_i32(), 21 );