X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=c-bindings-gen%2Fsrc%2Ftypes.rs;h=f9c894a23cc70ba070a0fc0e67c75d608b042453;hb=cf73ef67e997143b5182153aac534d1e471b021a;hp=da2d1807db088e6336b7a9186a0d9df85d0e338c;hpb=41e053cac1a23c669ac48a347c80f3ca8aedf571;p=ldk-c-bindings diff --git a/c-bindings-gen/src/types.rs b/c-bindings-gen/src/types.rs index da2d180..f9c894a 100644 --- a/c-bindings-gen/src/types.rs +++ b/c-bindings-gen/src/types.rs @@ -65,6 +65,17 @@ pub fn path_matches_nongeneric(p: &syn::Path, exp: &[&str]) -> bool { true } +pub fn string_path_to_syn_path(path: &str) -> syn::Path { + let mut segments = syn::punctuated::Punctuated::new(); + for seg in path.split("::") { + segments.push(syn::PathSegment { + ident: syn::Ident::new(seg, Span::call_site()), + arguments: syn::PathArguments::None, + }); + } + syn::Path { leading_colon: Some(syn::Token![::](Span::call_site())), segments } +} + #[derive(Debug, PartialEq)] pub enum ExportStatus { Export, @@ -391,7 +402,7 @@ pub enum DeclType<'a> { } pub struct ImportResolver<'mod_lifetime, 'crate_lft: 'mod_lifetime> { - crate_name: &'mod_lifetime str, + pub crate_name: &'mod_lifetime str, dependencies: &'mod_lifetime HashSet, module_path: &'mod_lifetime str, imports: HashMap, @@ -741,7 +752,7 @@ pub struct CrateTypes<'a> { /// Aliases from paths to some other Type pub type_aliases: HashMap, /// Value is an alias to Key (maybe with some generics) - pub reverse_alias_map: HashMap>, + pub reverse_alias_map: HashMap>, /// Template continer types defined, map from mangled type name -> whether a destructor fn /// exists. /// @@ -785,7 +796,7 @@ impl<'a> CrateTypes<'a> { pub struct TypeResolver<'mod_lifetime, 'crate_lft: 'mod_lifetime> { pub module_path: &'mod_lifetime str, pub crate_types: &'mod_lifetime CrateTypes<'crate_lft>, - types: ImportResolver<'mod_lifetime, 'crate_lft>, + pub types: ImportResolver<'mod_lifetime, 'crate_lft>, } /// Returned by write_empty_rust_val_check_suffix to indicate what type of dereferencing needs to @@ -2874,7 +2885,6 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { assert!(self.write_c_type_intern(w, t, generics, false, false, ptr_for_ref, true, false)); } pub fn understood_c_path(&self, p: &syn::Path) -> bool { - if p.leading_colon.is_some() { return false; } self.write_c_path_intern(&mut std::io::sink(), p, None, false, false, false, false, true) } pub fn understood_c_type(&self, t: &syn::Type, generics: Option<&GenericTypes>) -> bool {