From: Matt Corallo Date: Fri, 19 Feb 2021 17:51:07 +0000 (-0500) Subject: [bindings] Correctly use access string in to-Rust container conv X-Git-Tag: v0.0.13~24^2~4 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=6c0025439e2d93c186e4859e474ce4f67aaec0d2;p=rust-lightning [bindings] Correctly use access string in to-Rust container conv `from_c_conversion_container_new_var` should use var_access when it wishes to access the variable being converted, not `var_name`, but in a few cases it did not. Note that this has no impact on the generated bindings as of this commit. --- diff --git a/c-bindings-gen/src/types.rs b/c-bindings-gen/src/types.rs index f7d1e7fa6..0c570bff7 100644 --- a/c-bindings-gen/src/types.rs +++ b/c-bindings-gen/src/types.rs @@ -1004,8 +1004,8 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { match full_path { "Result" if !is_ref => { Some(("match ", - vec![(".result_ok { true => Ok(".to_string(), format!("(*unsafe {{ Box::from_raw(<*mut _>::take_ptr(&mut {}.contents.result)) }})", var_name)), - ("), false => Err(".to_string(), format!("(*unsafe {{ Box::from_raw(<*mut _>::take_ptr(&mut {}.contents.err)) }})", var_name))], + vec![(".result_ok { true => Ok(".to_string(), format!("(*unsafe {{ Box::from_raw(<*mut _>::take_ptr(&mut {}.contents.result)) }})", var_access)), + ("), false => Err(".to_string(), format!("(*unsafe {{ Box::from_raw(<*mut _>::take_ptr(&mut {}.contents.err)) }})", var_access))], ")}")) }, "Vec"|"Slice" if !is_ref => { @@ -1018,9 +1018,9 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { if let Some(syn::Type::Path(p)) = single_contained { if self.c_type_has_inner_from_path(&self.resolve_path(&p.path, generics)) { if is_ref { - return Some(("if ", vec![(".inner.is_null() { None } else { Some((*".to_string(), format!("{}", var_name))], ").clone()) }")) + return Some(("if ", vec![(".inner.is_null() { None } else { Some((*".to_string(), format!("{}", var_access))], ").clone()) }")) } else { - return Some(("if ", vec![(".inner.is_null() { None } else { Some(".to_string(), format!("{}", var_name))], ") }")); + return Some(("if ", vec![(".inner.is_null() { None } else { Some(".to_string(), format!("{}", var_access))], ") }")); } } }