]> git.bitcoin.ninja Git - ldk-c-bindings/commitdiff
Support passing `Option<&OpaqueStruct>` to C
authorMatt Corallo <git@bluematt.me>
Mon, 27 Feb 2023 18:51:59 +0000 (18:51 +0000)
committerMatt Corallo <git@bluematt.me>
Mon, 27 Feb 2023 18:51:59 +0000 (18:51 +0000)
Luckily the solution is trivial - just treat the conversion for the
inner pointer as `ptr_for_ref`, because we ultimately want a
pointer on the inside, not on the outside.

c-bindings-gen/src/types.rs

index b13db9e648b91f0534733961a5e56d599ecd2a42..85ce3e9fc1472202f2b0cb55346169baaa141207 100644 (file)
@@ -2377,7 +2377,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                        write!(w, "let mut local_{}{} = ", ident,
                                                if (!to_c && needs_ref_map) || (to_c && $container_type == "Option" && contains_slice) {"_base"} else { "" }).unwrap();
                                        if prefix_location == ContainerPrefixLocation::OutsideConv {
-                                               var_prefix(w, $args_iter().next().unwrap(), generics, is_ref, ptr_for_ref, true);
+                                               var_prefix(w, $args_iter().next().unwrap(), generics, is_ref, true, true);
                                        }
                                        write!(w, "{}{}", prefix, var).unwrap();