From: Matt Corallo Date: Mon, 27 Feb 2023 18:51:59 +0000 (+0000) Subject: Support passing `Option<&OpaqueStruct>` to C X-Git-Tag: v0.0.114.0^2~15 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=6ee7c2a51f172ea1c5cb68249b10e32a3a22ac82;p=ldk-c-bindings Support passing `Option<&OpaqueStruct>` to C 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. --- diff --git a/c-bindings-gen/src/types.rs b/c-bindings-gen/src/types.rs index b13db9e..85ce3e9 100644 --- a/c-bindings-gen/src/types.rs +++ b/c-bindings-gen/src/types.rs @@ -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();