diff options
author | Myron Ahn <myronahn@gmail.com> | 2020-02-05 19:41:51 +0700 |
---|---|---|
committer | David Tolnay <dtolnay@gmail.com> | 2020-04-25 12:47:04 -0700 |
commit | eba35cfce75094c0e4b459f63cc1e8ab915c10af (patch) | |
tree | 0d02ac0c8297e243ffa1e1a42af3f24c6af880f6 /syntax/atom.rs | |
parent | b17b9f3bf4b34a81e2a0f9226ef89bc0d3c4167a (diff) | |
download | cxx-eba35cfce75094c0e4b459f63cc1e8ab915c10af.tar.gz |
C++ std::vector<T> and Rust std::vec::Vec<T> support
Add basic std::vector and std::vec::Vec support across FFI boundary.
Diffstat (limited to 'syntax/atom.rs')
-rw-r--r-- | syntax/atom.rs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/syntax/atom.rs b/syntax/atom.rs index eeea831e..c68b3fe1 100644 --- a/syntax/atom.rs +++ b/syntax/atom.rs @@ -42,6 +42,43 @@ impl Atom { _ => None, } } + + 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 + || *self == U16 + || *self == U32 + || *self == U64 + || *self == Usize + || *self == I8 + || *self == I16 + || *self == I32 + || *self == I64 + || *self == Isize + || *self == F32 + || *self == F64 + } } impl PartialEq<Atom> for Ident { |