Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion c-bindings-gen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1408,7 +1408,9 @@ fn writeln_impl<W: std::io::Write>(w: &mut W, w_uses: &mut HashSet<String, NonRa

write!(w, "\talloc::format!(\"{{:?}}\", unsafe {{ o as *const crate::{} }}).into()", resolved_path).unwrap();
writeln!(w, "}}").unwrap();
} else if path_matches_nongeneric(&trait_path.1, &["Display"]) {
} else if full_trait_path_opt.as_ref().map(|s| s.as_str()) == Some("core::fmt::Display") ||
path_matches_nongeneric(&trait_path.1, &["Display"])
{
writeln!(w, "#[no_mangle]").unwrap();
writeln!(w, "/// Get the string representation of a {} object", ident).unwrap();
writeln!(w, "pub extern \"C\" fn {}_to_str(o: &crate::{}) -> Str {{", ident, resolved_path).unwrap();
Expand Down
16 changes: 11 additions & 5 deletions c-bindings-gen/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ impl<'mod_lifetime, 'crate_lft: 'mod_lifetime> ImportResolver<'mod_lifetime, 'cr
}
}

if p.leading_colon.is_some() {
let result = if p.leading_colon.is_some() {
let mut res: String = p.segments.iter().enumerate().map(|(idx, seg)| {
format!("{}{}", if idx == 0 { "" } else { "::" }, seg.ident)
}).collect();
Expand All @@ -667,11 +667,10 @@ impl<'mod_lifetime, 'crate_lft: 'mod_lifetime> ImportResolver<'mod_lifetime, 'cr
Some(res)
} else if let Some(id) = p.get_ident() {
self.maybe_resolve_ident(id)
} else if p.segments.len() == 1 {
let seg = p.segments.iter().next().unwrap();
self.maybe_resolve_ident(&seg.ident)
} else {
if p.segments.len() == 1 {
let seg = p.segments.iter().next().unwrap();
return self.maybe_resolve_ident(&seg.ident);
}
let mut seg_iter = p.segments.iter();
let first_seg = seg_iter.next().unwrap();
let remaining: String = seg_iter.map(|seg| {
Expand All @@ -693,6 +692,13 @@ impl<'mod_lifetime, 'crate_lft: 'mod_lifetime> ImportResolver<'mod_lifetime, 'cr
} else if self.library.modules.get(&format!("{}::{}", self.module_path, first_seg.ident)).is_some() {
Some(format!("{}::{}{}", self.module_path, first_seg.ident, remaining))
} else { None }
};
// We're only set up to handle `Vec` imported via the prelude, but its often imported
// via the alloc stdlib crate, so map it here.
if result.as_ref().map(|s| s.as_str()) == Some("alloc::vec::Vec") {
Some("Vec".to_string())
} else {
result
}
}

Expand Down
16 changes: 10 additions & 6 deletions lightning-c-bindings/include/ldk_rust_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,6 @@ struct nativeChannelManagerOpaque;
typedef struct nativeChannelManagerOpaque LDKnativeChannelManager;
struct nativeChainParametersOpaque;
typedef struct nativeChainParametersOpaque LDKnativeChainParameters;
struct nativeCounterpartyForwardingInfoOpaque;
typedef struct nativeCounterpartyForwardingInfoOpaque LDKnativeCounterpartyForwardingInfo;
struct nativeChannelCounterpartyOpaque;
typedef struct nativeChannelCounterpartyOpaque LDKnativeChannelCounterparty;
struct nativeChannelDetailsOpaque;
typedef struct nativeChannelDetailsOpaque LDKnativeChannelDetails;
struct nativePhantomRouteHintsOpaque;
typedef struct nativePhantomRouteHintsOpaque LDKnativePhantomRouteHints;
struct nativeChannelManagerReadArgsOpaque;
Expand Down Expand Up @@ -339,6 +333,16 @@ struct nativeTrampolineOnionPacketOpaque;
typedef struct nativeTrampolineOnionPacketOpaque LDKnativeTrampolineOnionPacket;
struct nativeRecordOpaque;
typedef struct nativeRecordOpaque LDKnativeRecord;
struct nativeInboundHTLCDetailsOpaque;
typedef struct nativeInboundHTLCDetailsOpaque LDKnativeInboundHTLCDetails;
struct nativeOutboundHTLCDetailsOpaque;
typedef struct nativeOutboundHTLCDetailsOpaque LDKnativeOutboundHTLCDetails;
struct nativeCounterpartyForwardingInfoOpaque;
typedef struct nativeCounterpartyForwardingInfoOpaque LDKnativeCounterpartyForwardingInfo;
struct nativeChannelCounterpartyOpaque;
typedef struct nativeChannelCounterpartyOpaque LDKnativeChannelCounterparty;
struct nativeChannelDetailsOpaque;
typedef struct nativeChannelDetailsOpaque LDKnativeChannelDetails;
struct nativeFutureOpaque;
typedef struct nativeFutureOpaque LDKnativeFuture;
struct nativeSleeperOpaque;
Expand Down
Loading