根据IDL文件生成RUST文件
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

пре 2 месеци
1234567891011121314151617
  1. use std::fs::File;
  2. use std::io::Write;
  3. use anyhow::Result;
  4. use crate::parser::IdlTypedef;
  5. use super::map_idl_type_to_rust;
  6. /// 生成类型定义代码
  7. pub fn generate_typedef_code(file: &mut File, typedef: &IdlTypedef, indent: &str) -> Result<()> {
  8. // 将IDL类型映射到Rust类型
  9. let rust_type = map_idl_type_to_rust(&typedef.type_spec);
  10. // 生成类型定义
  11. writeln!(file, "{}pub type {} = {};", indent, typedef.name, rust_type)?;
  12. writeln!(file, "")?;
  13. Ok(())
  14. }