1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// /// A macro to create an Object from a literal or expression.
// /// It can handle dictionaries, lists, booleans, strings, and numeric values.
// /// # Example
// /// ```rust
// /// use akari::Object;
// /// use akari::object;
// /// let num_obj = object!(3);
// /// assert_eq!(num_obj, Object::Numerical(3.0));
// /// ```
// /// ```rust
// /// use akari::Object;
// /// use std::collections::HashMap;
// /// use akari::object;
// /// let list_obj = object!(["aaa", "bbb"]);
// /// assert_eq!(list_obj, Object::List(vec![Object::Str("aaa".to_string()), Object::Str("bbb".to_string())]));
// /// ```
// /// ```rust
// /// use akari::Object;
// /// use std::collections::HashMap;
// /// use akari::object;
// /// let obj_obj = object!({c: "p", b: ["aaa", "bbb"], u: 32});
// /// assert_eq!(obj_obj, Object::Dictionary(HashMap::from([
// /// ("c".to_string(), Object::Str("p".to_string())),
// /// ("b".to_string(), Object::List(vec![Object::Str("aaa".to_string()), Object::Str("bbb".to_string())])),
// /// ("u".to_string(), Object::Numerical(32.0)),
// /// ])));
// /// ```
// /// ```rust
// /// use akari::Object;
// /// use std::collections::HashMap;
// /// use akari::object;
// /// let obj_obj = object!({
// /// string: String::from("hello"),
// /// number: 42
// /// });
// /// ```
// #[macro_export]
// macro_rules! object {
// // Dictionary: keys become Strings now.
// ({ $( $key:ident : $value:tt ),* $(,)? }) => {{
// let mut map = ::std::collections::HashMap::new();
// $(
// map.insert(stringify!($key).to_string(), object!($value));
// )*
// Object::Dictionary(map)
// }};
// // List
// ([ $( $elem:tt ),* $(,)? ]) => {{
// let mut vec = Vec::new();
// $(
// vec.push(object!($elem));
// )*
// Object::List(vec)
// }};
// // Booleans
// (true) => {
// Object::new(true)
// };
// (false) => {
// Object::new(false)
// };
// // String literals
// ($e:literal) => {
// Object::new($e)
// };
// // Fallback for expressions (like numbers)
// ($e:expr) => {
// Object::new($e)
// };
// }