mirror of
https://gitee.com/openharmony/third_party_rust_cxx
synced 2025-02-17 15:09:41 +00:00
Move C++-specific type printing back into C++ generator
This commit is contained in:
parent
cd08c440ce
commit
029f1d6a2e
16
gen/write.rs
16
gen/write.rs
@ -810,7 +810,21 @@ fn write_extern_arg(out: &mut OutFile, arg: &Var, types: &Types) {
|
||||
fn write_type(out: &mut OutFile, ty: &Type) {
|
||||
match ty {
|
||||
Type::Ident(ident) => match Atom::from(ident) {
|
||||
Some(a) => write!(out, "{}", a.to_cxx()),
|
||||
Some(Bool) => write!(out, "bool"),
|
||||
Some(U8) => write!(out, "uint8_t"),
|
||||
Some(U16) => write!(out, "uint16_t"),
|
||||
Some(U32) => write!(out, "uint32_t"),
|
||||
Some(U64) => write!(out, "uint64_t"),
|
||||
Some(Usize) => write!(out, "size_t"),
|
||||
Some(I8) => write!(out, "int8_t"),
|
||||
Some(I16) => write!(out, "int16_t"),
|
||||
Some(I32) => write!(out, "int32_t"),
|
||||
Some(I64) => write!(out, "int64_t"),
|
||||
Some(Isize) => write!(out, "::rust::isize"),
|
||||
Some(F32) => write!(out, "float"),
|
||||
Some(F64) => write!(out, "double"),
|
||||
Some(CxxString) => write!(out, "::std::string"),
|
||||
Some(RustString) => write!(out, "::rust::String"),
|
||||
None => write!(out, "{}", ident),
|
||||
},
|
||||
Type::RustBox(ty) => {
|
||||
|
@ -43,27 +43,6 @@ impl Atom {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_cxx(&self) -> &'static str {
|
||||
use self::Atom::*;
|
||||
match self {
|
||||
Bool => "bool",
|
||||
U8 => "uint8_t",
|
||||
U16 => "uint16_t",
|
||||
U32 => "uint32_t",
|
||||
U64 => "uint64_t",
|
||||
Usize => "size_t",
|
||||
I8 => "int8_t",
|
||||
I16 => "int16_t",
|
||||
I32 => "int32_t",
|
||||
I64 => "int64_t",
|
||||
Isize => "::rust::isize",
|
||||
F32 => "float",
|
||||
F64 => "double",
|
||||
CxxString => "::std::string",
|
||||
RustString => "::rust::String",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_valid_vector_target(&self) -> bool {
|
||||
use self::Atom::*;
|
||||
*self == U8
|
||||
|
Loading…
x
Reference in New Issue
Block a user