@@ -62,18 +62,22 @@ fn maybe_convert_trait_impl<W: std::io::Write>(w: &mut W, trait_path: &syn::Path
62
62
if let Some ( t) = types. maybe_resolve_path ( & trait_path, Some ( generics) ) {
63
63
let for_obj;
64
64
let full_obj_path;
65
+ let native_path;
65
66
let mut has_inner = false ;
66
67
if let syn:: Type :: Path ( ref p) = for_ty {
67
68
let resolved_path = types. resolve_path ( & p. path , Some ( generics) ) ;
68
69
for_obj = format ! ( "{}" , p. path. segments. last( ) . unwrap( ) . ident) ;
69
70
full_obj_path = format ! ( "crate::{}" , resolved_path) ;
70
71
has_inner = types. c_type_has_inner_from_path ( & resolved_path) ;
72
+ let ( path, name) = full_obj_path. rsplit_once ( "::" ) . unwrap ( ) ;
73
+ native_path = path. to_string ( ) + "::native" + name;
71
74
} else {
72
75
// We assume that anything that isn't a Path is somehow a generic that ends up in our
73
76
// derived-types module.
74
77
let mut for_obj_vec = Vec :: new ( ) ;
75
78
types. write_c_type ( & mut for_obj_vec, for_ty, Some ( generics) , false ) ;
76
79
full_obj_path = String :: from_utf8 ( for_obj_vec) . unwrap ( ) ;
80
+ native_path = full_obj_path. clone ( ) ;
77
81
if !full_obj_path. starts_with ( TypeResolver :: generated_container_path ( ) ) { return ; }
78
82
for_obj = full_obj_path[ TypeResolver :: generated_container_path ( ) . len ( ) + 2 ..] . into ( ) ;
79
83
}
@@ -98,7 +102,7 @@ fn maybe_convert_trait_impl<W: std::io::Write>(w: &mut W, trait_path: &syn::Path
98
102
writeln ! ( w, "#[allow(unused)]" ) . unwrap ( ) ;
99
103
writeln ! ( w, "pub(crate) extern \" C\" fn {}_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {{" , for_obj) . unwrap ( ) ;
100
104
if has_inner {
101
- writeln ! ( w, "\t crate::c_types::serialize_obj(unsafe {{ &*(obj as *const native {}) }})" , for_obj ) . unwrap ( ) ;
105
+ writeln ! ( w, "\t crate::c_types::serialize_obj(unsafe {{ &*(obj as *const {}) }})" , native_path ) . unwrap ( ) ;
102
106
} else {
103
107
writeln ! ( w, "\t {}_write(unsafe {{ &*(obj as *const {}) }})" , for_obj, for_obj) . unwrap ( ) ;
104
108
}
0 commit comments