]> git.bitcoin.ninja Git - ldk-c-bindings/commitdiff
Add type for 8 u16s (which is used for the scoring data)
authorMatt Corallo <git@bluematt.me>
Tue, 28 Feb 2023 23:25:38 +0000 (23:25 +0000)
committerMatt Corallo <git@bluematt.me>
Mon, 6 Mar 2023 04:16:09 +0000 (04:16 +0000)
c-bindings-gen/src/types.rs
lightning-c-bindings/src/c_types/mod.rs

index 3cf9643293ac1a25a199f1e2cf363d894ab44734..64f2a688adf2441b51b196da4ffe5fb7b60933a8 100644 (file)
@@ -805,6 +805,7 @@ fn initial_clonable_types() -> HashSet<String> {
        res.insert("crate::c_types::SixteenBytes".to_owned());
        res.insert("crate::c_types::TwentyBytes".to_owned());
        res.insert("crate::c_types::ThirtyTwoBytes".to_owned());
+       res.insert("crate::c_types::EightU16s".to_owned());
        res.insert("crate::c_types::SecretKey".to_owned());
        res.insert("crate::c_types::PublicKey".to_owned());
        res.insert("crate::c_types::Transaction".to_owned());
@@ -971,6 +972,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        "[u8; 12]" if !is_ref => Some("crate::c_types::TwelveBytes"),
                        "[u8; 4]" if !is_ref => Some("crate::c_types::FourBytes"),
                        "[u8; 3]" if !is_ref => Some("crate::c_types::ThreeBytes"), // Used for RGB values
+                       "[u16; 8]" if !is_ref => Some("crate::c_types::EightU16s"),
 
                        "str" if is_ref => Some("crate::c_types::Str"),
                        "alloc::string::String"|"String" => Some("crate::c_types::Str"),
@@ -1060,6 +1062,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        "[u8; 12]" if !is_ref => Some(""),
                        "[u8; 4]" if !is_ref => Some(""),
                        "[u8; 3]" if !is_ref => Some(""),
+                       "[u16; 8]" if !is_ref => Some(""),
 
                        "[u8]" if is_ref => Some(""),
                        "[usize]" if is_ref => Some(""),
@@ -1155,6 +1158,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        "[u8; 12]" if !is_ref => Some(".data"),
                        "[u8; 4]" if !is_ref => Some(".data"),
                        "[u8; 3]" if !is_ref => Some(".data"),
+                       "[u16; 8]" if !is_ref => Some(".data"),
 
                        "[u8]" if is_ref => Some(".to_slice()"),
                        "[usize]" if is_ref => Some(".to_slice()"),
@@ -1253,6 +1257,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        "[u8; 12]" if !is_ref => Some("crate::c_types::TwelveBytes { data: "),
                        "[u8; 4]" if !is_ref => Some("crate::c_types::FourBytes { data: "),
                        "[u8; 3]" if is_ref => Some(""),
+                       "[u16; 8]" if !is_ref => Some("crate::c_types::EightU16s { data: "),
 
                        "[u8]" if is_ref => Some("local_"),
                        "[usize]" if is_ref => Some("local_"),
@@ -1338,6 +1343,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        "[u8; 12]" if !is_ref => Some(" }"),
                        "[u8; 4]" if !is_ref => Some(" }"),
                        "[u8; 3]" if is_ref => Some(""),
+                       "[u16; 8]" if !is_ref => Some(" }"),
 
                        "[u8]" if is_ref => Some(""),
                        "[usize]" if is_ref => Some(""),
index f23f002d05c7ccfe8607ffd5b30eae0c79d0017b..cf708d03df49082d47d4ad6e6428679d413b25ff 100644 (file)
@@ -629,6 +629,11 @@ pub struct SixteenBytes { /** The sixteen bytes */ pub data: [u8; 16], }
 /// A 20-byte byte array.
 pub struct TwentyBytes { /** The twenty bytes */ pub data: [u8; 20], }
 
+#[derive(Clone)]
+#[repr(C)]
+/// 8 u16s
+pub struct EightU16s { /** The eight 16-bit integers */ pub data: [u16; 8], }
+
 pub(crate) struct VecWriter(pub Vec<u8>);
 impl lightning::util::ser::Writer for VecWriter {
        fn write_all(&mut self, buf: &[u8]) -> Result<(), io::Error> {