Skip to content

Commit 05c3f9d

Browse files
authored
Merge pull request #126 from TheBlueMatt/main
0.0.123.1
2 parents 4fdcd27 + 636543d commit 05c3f9d

23 files changed

+11785
-9104
lines changed

c-bindings-gen/src/main.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1408,7 +1408,9 @@ fn writeln_impl<W: std::io::Write>(w: &mut W, w_uses: &mut HashSet<String, NonRa
14081408

14091409
write!(w, "\talloc::format!(\"{{:?}}\", unsafe {{ o as *const crate::{} }}).into()", resolved_path).unwrap();
14101410
writeln!(w, "}}").unwrap();
1411-
} else if path_matches_nongeneric(&trait_path.1, &["Display"]) {
1411+
} else if full_trait_path_opt.as_ref().map(|s| s.as_str()) == Some("core::fmt::Display") ||
1412+
path_matches_nongeneric(&trait_path.1, &["Display"])
1413+
{
14121414
writeln!(w, "#[no_mangle]").unwrap();
14131415
writeln!(w, "/// Get the string representation of a {} object", ident).unwrap();
14141416
writeln!(w, "pub extern \"C\" fn {}_to_str(o: &crate::{}) -> Str {{", ident, resolved_path).unwrap();

c-bindings-gen/src/types.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ impl<'mod_lifetime, 'crate_lft: 'mod_lifetime> ImportResolver<'mod_lifetime, 'cr
656656
}
657657
}
658658

659-
if p.leading_colon.is_some() {
659+
let result = if p.leading_colon.is_some() {
660660
let mut res: String = p.segments.iter().enumerate().map(|(idx, seg)| {
661661
format!("{}{}", if idx == 0 { "" } else { "::" }, seg.ident)
662662
}).collect();
@@ -667,11 +667,10 @@ impl<'mod_lifetime, 'crate_lft: 'mod_lifetime> ImportResolver<'mod_lifetime, 'cr
667667
Some(res)
668668
} else if let Some(id) = p.get_ident() {
669669
self.maybe_resolve_ident(id)
670+
} else if p.segments.len() == 1 {
671+
let seg = p.segments.iter().next().unwrap();
672+
self.maybe_resolve_ident(&seg.ident)
670673
} else {
671-
if p.segments.len() == 1 {
672-
let seg = p.segments.iter().next().unwrap();
673-
return self.maybe_resolve_ident(&seg.ident);
674-
}
675674
let mut seg_iter = p.segments.iter();
676675
let first_seg = seg_iter.next().unwrap();
677676
let remaining: String = seg_iter.map(|seg| {
@@ -693,6 +692,13 @@ impl<'mod_lifetime, 'crate_lft: 'mod_lifetime> ImportResolver<'mod_lifetime, 'cr
693692
} else if self.library.modules.get(&format!("{}::{}", self.module_path, first_seg.ident)).is_some() {
694693
Some(format!("{}::{}{}", self.module_path, first_seg.ident, remaining))
695694
} else { None }
695+
};
696+
// We're only set up to handle `Vec` imported via the prelude, but its often imported
697+
// via the alloc stdlib crate, so map it here.
698+
if result.as_ref().map(|s| s.as_str()) == Some("alloc::vec::Vec") {
699+
Some("Vec".to_string())
700+
} else {
701+
result
696702
}
697703
}
698704

lightning-c-bindings/include/ldk_rust_types.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,6 @@ struct nativeChannelManagerOpaque;
167167
typedef struct nativeChannelManagerOpaque LDKnativeChannelManager;
168168
struct nativeChainParametersOpaque;
169169
typedef struct nativeChainParametersOpaque LDKnativeChainParameters;
170-
struct nativeCounterpartyForwardingInfoOpaque;
171-
typedef struct nativeCounterpartyForwardingInfoOpaque LDKnativeCounterpartyForwardingInfo;
172-
struct nativeChannelCounterpartyOpaque;
173-
typedef struct nativeChannelCounterpartyOpaque LDKnativeChannelCounterparty;
174-
struct nativeChannelDetailsOpaque;
175-
typedef struct nativeChannelDetailsOpaque LDKnativeChannelDetails;
176170
struct nativePhantomRouteHintsOpaque;
177171
typedef struct nativePhantomRouteHintsOpaque LDKnativePhantomRouteHints;
178172
struct nativeChannelManagerReadArgsOpaque;
@@ -339,6 +333,16 @@ struct nativeTrampolineOnionPacketOpaque;
339333
typedef struct nativeTrampolineOnionPacketOpaque LDKnativeTrampolineOnionPacket;
340334
struct nativeRecordOpaque;
341335
typedef struct nativeRecordOpaque LDKnativeRecord;
336+
struct nativeInboundHTLCDetailsOpaque;
337+
typedef struct nativeInboundHTLCDetailsOpaque LDKnativeInboundHTLCDetails;
338+
struct nativeOutboundHTLCDetailsOpaque;
339+
typedef struct nativeOutboundHTLCDetailsOpaque LDKnativeOutboundHTLCDetails;
340+
struct nativeCounterpartyForwardingInfoOpaque;
341+
typedef struct nativeCounterpartyForwardingInfoOpaque LDKnativeCounterpartyForwardingInfo;
342+
struct nativeChannelCounterpartyOpaque;
343+
typedef struct nativeChannelCounterpartyOpaque LDKnativeChannelCounterparty;
344+
struct nativeChannelDetailsOpaque;
345+
typedef struct nativeChannelDetailsOpaque LDKnativeChannelDetails;
342346
struct nativeFutureOpaque;
343347
typedef struct nativeFutureOpaque LDKnativeFuture;
344348
struct nativeSleeperOpaque;

0 commit comments

Comments
 (0)