Commit Graph

16 Commits

Author SHA1 Message Date
David Tolnay
ed6ba4a63c
Add ForeignName wrapper around non-Rust names 2021-01-01 17:57:14 -08:00
David Tolnay
9f84fe8bbd
Check rust idents for cxxbridge prefix 2021-01-01 15:59:59 -08:00
David Tolnay
84ed6adda5
Track independent Rust/C++ names on struct fields and fn args 2021-01-01 15:46:10 -08:00
David Tolnay
e6f6214c00
Store enum variant name as Pair 2020-12-21 16:26:41 -08:00
David Tolnay
17a934c404
Rename non-Ident fields previously named ident
It will be clearer to avoid using 'ident' to refer to anything but Ident.
2020-11-02 00:53:59 -08:00
David Tolnay
8faec77e12
Move CppName's namespace into Pair 2020-11-02 00:31:34 -08:00
David Tolnay
d7a3a18e57
Prefer namespace over ns 2020-11-01 20:45:38 -08:00
Adrian Taylor
c871343ac2 Allow namespace override.
This change allows a

 #[namespace (namespace = A::B)]

attribute for each item in a cxx::bridge.

We now have a fair number of different types of name floating
around:
* C++ identifiers
* C++ fully-qualified names
* Rust identifiers
* Rust fully-qualified names (future, when we support sub-modules)
* Items with both a Rust and C++ name (a 'Pair')
* Types with only a known Rust name, which can be resolved to a
  C++ name.

This change attempts to put some sensible names for all these
things in syntax/mod.rs, and so that would be a good place to start
review.

At the moment, the Namespace (included in each CppName)
is ruthlessly cloned all over the place. As a given namespace is
likely to be applicable to many types and functions, it may
save significant memory in future to use Rc<> here. But let's not
optimise too early.
2020-10-26 15:23:34 -07:00
David Tolnay
a4641c738a
Store independent rust name and c++ name for extern functions 2020-10-09 19:12:17 -07:00
David Tolnay
7e69f89714
Explicitly requesting an instantiation 2020-10-04 00:20:17 -07:00
David Tolnay
3118fa6606
Type alias ident checking 2020-05-07 19:46:02 -07:00
David Tolnay
9938381aa7
Introduce type aliases in syntax tree 2020-05-07 19:46:02 -07:00
David Tolnay
6b6423edfb
Really check everything in check_all 2020-04-30 22:55:23 -07:00
David Tolnay
a83301ce5b
Update ident checker's error reporting to match type checker's 2020-04-30 22:55:23 -07:00
Joel Galenson
c03402aee5 Support C-style enums
This adds support for passing C-style enums between Rust and C++.

We use the Rust representation for enums suggested by dtolnay in #132.
Note that as this does not use real enums, Rust code cannot treat them
as normal enums, e.g., by converting them to integers.  But common
uses such as pattern matching remain unchanged.
2020-04-30 14:12:37 -07:00
David Tolnay
7db7369797
Safe FFI between Rust and C++ 2020-01-08 08:57:24 -08:00