- writeln!(w, "\tcrate::c_types::serialize_obj(unsafe {{ &(*(*obj).inner) }})").unwrap();
- writeln!(w, "}}").unwrap();
- writeln!(w, "#[no_mangle]").unwrap();
- writeln!(w, "pub(crate) extern \"C\" fn {}_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {{", for_obj).unwrap();
- writeln!(w, "\tcrate::c_types::serialize_obj(unsafe {{ &*(obj as *const native{}) }})", for_obj).unwrap();
+
+ let ref_type = syn::Type::Reference(syn::TypeReference {
+ and_token: syn::Token!(&)(Span::call_site()), lifetime: None, mutability: None,
+ elem: Box::new(for_ty.clone()) });
+ assert!(!types.write_from_c_conversion_new_var(w, &syn::Ident::new("obj", Span::call_site()), &ref_type, None));
+
+ write!(w, "\tcrate::c_types::serialize_obj(").unwrap();
+ types.write_from_c_conversion_prefix(w, &ref_type, None);
+ write!(w, "unsafe {{ &*obj }}").unwrap();
+ types.write_from_c_conversion_suffix(w, &ref_type, None);
+ writeln!(w, ")").unwrap();
+