1- use indoc:: indoc;
21use crate :: { compiletime:: command_map:: CommandMap , runtime:: { stack:: Stack , value:: { Array , Value } } } ;
32
4- use super :: { math:: append_math, stack_manipulators:: append_stack_manipulators, CommandExecutable , CommandMeta , DescribedCommand , DescribedCommandMaker , RuntimeException } ;
3+ use super :: { math:: append_math, stack_manipulators:: append_stack_manipulators, CommandExecutable , DescribedCommand , RuntimeException } ;
54
65pub fn bind_default_commands ( map : & mut CommandMap ) {
76 append_stack_manipulators ( map) ;
@@ -13,63 +12,6 @@ fn _test(_stack: &mut Stack) -> Result<(), RuntimeException> {
1312 Ok ( ( ) )
1413}
1514
16- /*
17- macro_rules! define_commands {
18- (define $group:ident $(($metadata:tt $stack:ident $defenitions:block)),+) => {
19- define_commands!{defenition $(($metadata $stack $defenitions)),+}
20- pub fn $group(cmd_map: &mut $crate::compiletime::command_map::CommandMap) {
21- define_commands!{meta cmd_map $(($metadata $stack $defenitions)),+}
22- }
23- };
24-
25- // With additional fields
26- (meta $command_map:ident ([$name:ident $key:tt [$($alias:expr),*] {$($vkey:ident : $value:expr),+}] $stack:ident $defenition:block)) => {
27- $command_map.set($crate::bytecode::commands::DescribedCommand {
28- execution: Box::new($name {}),
29- meta: std::sync::Arc::new($crate::bytecode::commands::CommandMeta {
30- key: String::from($key),
31- aliases: [$($alias),*].iter().map(|s: &&str| s.to_string()).collect::<Vec<String>>(),
32- $($vkey : $value),+,
33- ..core::default::Default::default()
34- })
35- });
36- };
37-
38- // No additional fields
39- (meta $command_map:ident ([$name:ident $key:tt [$($alias:expr),*] {}] $stack:ident $defenition:block)) => {
40- $command_map.set($crate::bytecode::commands::DescribedCommand {
41- execution: Box::new($name {}),
42- meta: std::sync::Arc::new($crate::bytecode::command::CommandMeta {
43- key: $key,
44- aliases: [$($alias),*].iter().map(|s: &&str| s.to_string()).collect::<Vec<String>>(),
45- ..core::default::Default::default()
46- })
47- });
48- };
49-
50- (meta $command_map:ident ($metadata:tt $stack:ident $defenition:block), $(($metadatas:tt $stacks:ident $defenitions:block)),+) => {{
51- define_commands!{meta $command_map ($metadata $stack $defenition)}
52- define_commands!{meta $command_map $(($metadatas $stacks $defenitions)),+}
53- }};
54-
55- (defenition ([$name:ident $key:tt [$($alias:expr),*] $others:tt] $stack:ident $defenition:block)) => {
56- pub struct $name {}
57- impl $crate::bytecode::commands::CommandExecutable for $name {
58- fn execute(&self, $stack: &mut $crate::runtime::stack::Stack) -> Result<(), $crate::bytecode::commands::RuntimeException> $defenition
59-
60- fn to_string(&self) -> String {
61- String::from($key)
62- }
63- }
64- };
65-
66- (defenition ($metadata:tt $stack:ident $defenition:block), $(($metadatas:tt $stacks:ident $defenitions:block)),+) => {
67- define_commands!{defenition ($metadata $stack $defenition)}
68- define_commands!{defenition $(($metadatas $stacks $defenitions)),+}
69- };
70- }
71- */
72-
7315macro_rules! define_commands {
7416 ( $group: ident $( $name: ident $args: tt $body: tt) ,* ) => {
7517 pub fn $group( cmd_map: & mut $crate:: compiletime:: command_map:: CommandMap ) {
0 commit comments