cxx_build/syntax/primitive.rs
1use crate::syntax::atom::Atom::{self, *};
2use crate::syntax::Type;
3
4pub(crate) enum PrimitiveKind {
5 Boolean,
6 Number,
7 Pointer,
8}
9
10pub(crate) fn kind(ty: &Type) -> Option<PrimitiveKind> {
11 match ty {
12 Type::Ident(ident) => Atom::from(&ident.rust).and_then(|atom| match atom {
13 Bool => Some(PrimitiveKind::Boolean),
14 Char | U8 | U16 | U32 | U64 | Usize | I8 | I16 | I32 | I64 | Isize | F32 | F64 => {
15 Some(PrimitiveKind::Number)
16 }
17 CxxString | RustString => None,
18 }),
19 Type::Ptr(_) => Some(PrimitiveKind::Pointer),
20 _ => None,
21 }
22}