1#[cfg(feature = "_web")]
2mod generators;
3#[cfg(feature = "_web")]
4pub use generators::rhai::generate_web;
5
6mod ast;
7mod helper;
8mod parser;
9pub use parser::{parse, parse_file, parse_file_with_namespace};
10pub use helper::{update_types_from_file, print_or_write, parse_raw_data};
11#[cfg(not(feature = "_bin"))]
12pub use helper::update_types;
13
14#[cfg(feature = "_python")]
15mod python {
16 use std::path::Path;
17
18 use pyo3::exceptions::PyException;
19 use pyo3::prelude::*;
20 use pyo3::Python;
21
22 use ssd_data::Namespace;
23 use ssd_data::SsdModule;
24
25 #[pyfunction]
26 pub fn parse(content: &str, namespace: &str) -> PyResult<SsdModule> {
27 crate::parse(content, Namespace::new(namespace))
28 .map_err(|e| PyException::new_err(e.to_string()))
29 }
30
31 #[pyfunction]
32 pub fn parse_file(base: &str, path: &str) -> PyResult<SsdModule> {
33 crate::parse_file(&Path::new(base), &Path::new(path))
34 .map_err(|e| PyException::new_err(e.to_string()))
35 }
36
37 #[pyfunction]
38 pub fn parse_file_with_namespace(path: &str, namespace: &str) -> PyResult<SsdModule> {
39 crate::parse_file_with_namespace(Path::new(path), Namespace::new(namespace))
40 .map_err(|e| PyException::new_err(e.to_string()))
41 }
42
43 #[pymodule]
44 fn py_ssd(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
45 m.add_function(wrap_pyfunction!(parse, m)?)?;
46 m.add_function(wrap_pyfunction!(parse_file, m)?)?;
47 m.add_function(wrap_pyfunction!(parse_file_with_namespace, m)?)?;
48 Ok(())
49 }
50}