Skip to main content

cxx2flow_lib/
lib.rs

1mod ast;
2#[cfg(not(target_family = "wasm"))]
3pub mod cli;
4pub mod display;
5#[cfg(not(target_family = "wasm"))]
6pub mod dump;
7pub mod error;
8mod graph;
9mod parser;
10#[cfg(target_family = "wasm")]
11mod wasm;
12#[cfg(target_family = "wasm")]
13mod wasm_sysroot;
14
15#[cfg(target_family = "wasm")]
16pub use wasm::*;
17
18use display::{GraphDisplay, GraphDisplayBackend};
19use error::Result;
20pub fn generate(
21    content: &[u8],
22    file_name: &str,
23    function_name: Option<String>,
24    backend: GraphDisplayBackend,
25) -> Result<String> {
26    let ast = parser::parse(content, file_name, function_name)?;
27    // dbg!(&ast);
28    let graph = graph::from_ast(ast, &String::from_utf8(content.to_vec())?, file_name)?;
29    // dbg!(&graph);
30    backend.generate_from_graph(&graph)
31}