/// a concrete Deref to the Rust trait.
fn writeln_trait<'a, 'b, W: std::io::Write>(w: &mut W, t: &'a syn::ItemTrait, types: &mut TypeResolver<'b, 'a>, extra_headers: &mut File, cpp_headers: &mut File) {
let trait_name = format!("{}", t.ident);
/// a concrete Deref to the Rust trait.
fn writeln_trait<'a, 'b, W: std::io::Write>(w: &mut W, t: &'a syn::ItemTrait, types: &mut TypeResolver<'b, 'a>, extra_headers: &mut File, cpp_headers: &mut File) {
let trait_name = format!("{}", t.ident);
ExportStatus::NoExport|ExportStatus::TestOnly => return,
}
writeln_docs(w, &t.attrs, "");
ExportStatus::NoExport|ExportStatus::TestOnly => return,
}
writeln_docs(w, &t.attrs, "");
},
ExportStatus::Export => {},
ExportStatus::TestOnly => continue,
},
ExportStatus::Export => {},
ExportStatus::TestOnly => continue,
// Finally, implement the original Rust trait for the newly created mapped trait.
writeln!(w, "\nuse {}::{} as rust{};", types.module_path, t.ident, trait_name).unwrap();
// Finally, implement the original Rust trait for the newly created mapped trait.
writeln!(w, "\nuse {}::{} as rust{};", types.module_path, t.ident, trait_name).unwrap();
- write!(w, "impl rust{}", t.ident).unwrap();
- maybe_write_generics(w, &t.generics, types, false);
- writeln!(w, " for {} {{", trait_name).unwrap();
- impl_trait_for_c!(t, "", types);
- writeln!(w, "}}\n").unwrap();
- writeln!(w, "// We're essentially a pointer already, or at least a set of pointers, so allow us to be used").unwrap();
- writeln!(w, "// directly as a Deref trait in higher-level structs:").unwrap();
- writeln!(w, "impl std::ops::Deref for {} {{\n\ttype Target = Self;", trait_name).unwrap();
- writeln!(w, "\tfn deref(&self) -> &Self {{\n\t\tself\n\t}}\n}}").unwrap();
+ if implementable {
+ write!(w, "impl rust{}", t.ident).unwrap();
+ maybe_write_generics(w, &t.generics, types, false);
+ writeln!(w, " for {} {{", trait_name).unwrap();
+ impl_trait_for_c!(t, "", types);
+ writeln!(w, "}}\n").unwrap();
+ writeln!(w, "// We're essentially a pointer already, or at least a set of pointers, so allow us to be used").unwrap();
+ writeln!(w, "// directly as a Deref trait in higher-level structs:").unwrap();
+ writeln!(w, "impl std::ops::Deref for {} {{\n\ttype Target = Self;", trait_name).unwrap();
+ writeln!(w, "\tfn deref(&self) -> &Self {{\n\t\tself\n\t}}\n}}").unwrap();
+ }
writeln!(w, "/// Calls the free function if one is set").unwrap();
writeln!(w, "#[no_mangle]\npub extern \"C\" fn {}_free(this_ptr: {}) {{ }}", trait_name, trait_name).unwrap();
writeln!(w, "/// Calls the free function if one is set").unwrap();
writeln!(w, "#[no_mangle]\npub extern \"C\" fn {}_free(this_ptr: {}) {{ }}", trait_name, trait_name).unwrap();
match export_status(&i.attrs) {
ExportStatus::Export => {},
ExportStatus::NoExport|ExportStatus::TestOnly => return,
match export_status(&i.attrs) {
ExportStatus::Export => {},
ExportStatus::NoExport|ExportStatus::TestOnly => return,
match export_status(&trait_method.attrs) {
ExportStatus::Export => {},
ExportStatus::NoExport|ExportStatus::TestOnly => continue,
match export_status(&trait_method.attrs) {
ExportStatus::Export => {},
ExportStatus::NoExport|ExportStatus::TestOnly => continue,
match export_status(&m.attrs) {
ExportStatus::Export => {},
ExportStatus::NoExport|ExportStatus::TestOnly => continue,
match export_status(&m.attrs) {
ExportStatus::Export => {},
ExportStatus::NoExport|ExportStatus::TestOnly => continue,
}
if m.defaultness.is_some() { unimplemented!(); }
writeln_docs(w, &m.attrs, "");
}
if m.defaultness.is_some() { unimplemented!(); }
writeln_docs(w, &m.attrs, "");
match export_status(&e.attrs) {
ExportStatus::Export => {},
ExportStatus::NoExport|ExportStatus::TestOnly => return,
match export_status(&e.attrs) {
ExportStatus::Export => {},
ExportStatus::NoExport|ExportStatus::TestOnly => return,
match export_status(&f.attrs) {
ExportStatus::Export => {},
ExportStatus::NoExport|ExportStatus::TestOnly => return,
match export_status(&f.attrs) {
ExportStatus::Export => {},
ExportStatus::NoExport|ExportStatus::TestOnly => return,
match export_status(&t.attrs) {
ExportStatus::Export => {},
ExportStatus::NoExport|ExportStatus::TestOnly => continue,
match export_status(&t.attrs) {
ExportStatus::Export => {},
ExportStatus::NoExport|ExportStatus::TestOnly => continue,
match export_status(&s.attrs) {
ExportStatus::Export => {},
ExportStatus::NoExport|ExportStatus::TestOnly => continue,
match export_status(&s.attrs) {
ExportStatus::Export => {},
ExportStatus::NoExport|ExportStatus::TestOnly => continue,
}
let struct_path = format!("{}::{}", module, s.ident);
crate_types.opaques.insert(struct_path, &s.ident);
}
let struct_path = format!("{}::{}", module, s.ident);
crate_types.opaques.insert(struct_path, &s.ident);
ExportStatus::NoExport|ExportStatus::TestOnly => continue,
}
let trait_path = format!("{}::{}", module, t.ident);
ExportStatus::NoExport|ExportStatus::TestOnly => continue,
}
let trait_path = format!("{}::{}", module, t.ident);
match export_status(&t.attrs) {
ExportStatus::Export => {},
ExportStatus::NoExport|ExportStatus::TestOnly => continue,
match export_status(&t.attrs) {
ExportStatus::Export => {},
ExportStatus::NoExport|ExportStatus::TestOnly => continue,
}
let type_path = format!("{}::{}", module, t.ident);
let mut process_alias = true;
}
let type_path = format!("{}::{}", module, t.ident);
let mut process_alias = true;
match export_status(&e.attrs) {
ExportStatus::Export => {},
ExportStatus::NoExport|ExportStatus::TestOnly => continue,
match export_status(&e.attrs) {
ExportStatus::Export => {},
ExportStatus::NoExport|ExportStatus::TestOnly => continue,
}
let enum_path = format!("{}::{}", module, e.ident);
crate_types.opaques.insert(enum_path, &e.ident);
}
let enum_path = format!("{}::{}", module, e.ident);
crate_types.opaques.insert(enum_path, &e.ident);
match export_status(&e.attrs) {
ExportStatus::Export => {},
ExportStatus::NoExport|ExportStatus::TestOnly => continue,
match export_status(&e.attrs) {
ExportStatus::Export => {},
ExportStatus::NoExport|ExportStatus::TestOnly => continue,
}
let enum_path = format!("{}::{}", module, e.ident);
crate_types.mirrored_enums.insert(enum_path, &e);
}
let enum_path = format!("{}::{}", module, e.ident);
crate_types.mirrored_enums.insert(enum_path, &e);