Safe FFI between Rust and C++
diff --git a/syntax/atom.rs b/syntax/atom.rs
new file mode 100644
index 0000000..57325d8
--- /dev/null
+++ b/syntax/atom.rs
@@ -0,0 +1,40 @@
+use proc_macro2::Ident;
+
+#[derive(Copy, Clone, PartialEq)]
+pub enum Atom {
+ Bool,
+ U8,
+ U16,
+ U32,
+ U64,
+ Usize,
+ I8,
+ I16,
+ I32,
+ I64,
+ Isize,
+ CxxString,
+ RustString,
+}
+
+impl Atom {
+ pub fn from(ident: &Ident) -> Option<Self> {
+ use self::Atom::*;
+ match ident.to_string().as_str() {
+ "bool" => Some(Bool),
+ "u8" => Some(U8),
+ "u16" => Some(U16),
+ "u32" => Some(U32),
+ "u64" => Some(U64),
+ "usize" => Some(Usize),
+ "i8" => Some(I8),
+ "i16" => Some(I16),
+ "i32" => Some(I32),
+ "i64" => Some(I64),
+ "isize" => Some(Isize),
+ "CxxString" => Some(CxxString),
+ "String" => Some(RustString),
+ _ => None,
+ }
+ }
+}