mirror of
https://gitee.com/openharmony/third_party_rust_cxx
synced 2025-02-20 08:33:26 +00:00
Pare down to_typename to match usage
This commit is contained in:
parent
63da4d37b9
commit
cd08c440ce
29
gen/write.rs
29
gen/write.rs
@ -889,32 +889,21 @@ fn write_space_after_type(out: &mut OutFile, ty: &Type) {
|
||||
}
|
||||
}
|
||||
|
||||
// Only called for legal referent types of unique_ptr and element types of
|
||||
// std::vector and Vec.
|
||||
fn to_typename(namespace: &Namespace, ty: &Type) -> String {
|
||||
match ty {
|
||||
Type::Ident(ident) => {
|
||||
let mut inner = String::new();
|
||||
// Do not apply namespace to built-in type
|
||||
let is_user_type = Atom::from(ident).is_none();
|
||||
if is_user_type {
|
||||
for name in namespace {
|
||||
inner += name;
|
||||
inner += "::";
|
||||
}
|
||||
let mut path = String::new();
|
||||
for name in namespace {
|
||||
path += name;
|
||||
path += "::";
|
||||
}
|
||||
if let Some(ti) = Atom::from(ident) {
|
||||
inner += ti.to_cxx();
|
||||
} else {
|
||||
inner += &ident.to_string();
|
||||
};
|
||||
inner
|
||||
}
|
||||
Type::RustBox(ptr) => format!("rust_box<{}>", to_typename(namespace, &ptr.inner)),
|
||||
Type::RustVec(ptr) => format!("rust_vec<{}>", to_typename(namespace, &ptr.inner)),
|
||||
Type::UniquePtr(ptr) => {
|
||||
format!("::std::unique_ptr<{}>", to_typename(namespace, &ptr.inner))
|
||||
path += &ident.to_string();
|
||||
path
|
||||
}
|
||||
Type::CxxVector(ptr) => format!("::std::vector<{}>", to_typename(namespace, &ptr.inner)),
|
||||
_ => unimplemented!(),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user