the_language/
lib.rs

1mod lang;
2use lang::{lang, _lua_data, _lua_str, _lua_call, _lua_lookup};
3
4// TODO 用std::panic::catch_unwind 及 Option
5
6pub struct Lang (_lua_data);
7pub struct LangValue (_lua_data);
8impl Lang {
9    pub fn new() -> Self {
10        Lang(lang())
11    }
12    pub fn complex_parse(&self, x: &String) -> LangValue {
13        LangValue(_lua_call(_lua_lookup(self.0.clone(), _lua_str("complex_parse")), vec![_lua_str(&x.clone())]))
14    }
15    pub fn machinetext_parse(&self, x: &String) -> LangValue {
16        LangValue(_lua_call(_lua_lookup(self.0.clone(), _lua_str("complex_parse")), vec![_lua_str(&x.clone())]))
17    }
18    pub fn complex_print(&self, x: &LangValue) -> String {
19        _lua_call(_lua_lookup(self.0.clone(), _lua_str("complex_print")), vec![x.0.clone()]).as_string().clone()
20    }
21    pub fn machinetest_print(&self, x: &LangValue) -> String {
22        _lua_call(_lua_lookup(self.0.clone(), _lua_str("machinetest_print")), vec![x.0.clone()]).as_string().clone()
23    }
24}
25
26#[cfg(test)]
27mod tests {
28    #[test]
29    fn it_works() {
30        assert_eq!(2 + 2, 4);
31    }
32}