aboutsummaryrefslogtreecommitdiff
path: root/syntax/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'syntax/mod.rs')
-rw-r--r--syntax/mod.rs135
1 files changed, 86 insertions, 49 deletions
diff --git a/syntax/mod.rs b/syntax/mod.rs
index 4f19d964..eacba554 100644
--- a/syntax/mod.rs
+++ b/syntax/mod.rs
@@ -1,33 +1,33 @@
// Functionality that is shared between the cxxbridge macro and the cmd.
-pub mod atom;
-pub mod attrs;
-pub mod cfg;
-pub mod check;
-pub mod derive;
+pub(crate) mod atom;
+pub(crate) mod attrs;
+pub(crate) mod cfg;
+pub(crate) mod check;
+pub(crate) mod derive;
mod discriminant;
mod doc;
-pub mod error;
-pub mod file;
-pub mod ident;
+pub(crate) mod error;
+pub(crate) mod file;
+pub(crate) mod ident;
mod impls;
mod improper;
-pub mod instantiate;
-pub mod mangle;
-pub mod map;
+pub(crate) mod instantiate;
+pub(crate) mod mangle;
+pub(crate) mod map;
mod names;
-pub mod namespace;
+pub(crate) mod namespace;
mod parse;
mod pod;
-pub mod qualified;
-pub mod report;
-pub mod resolve;
-pub mod set;
-pub mod symbol;
+pub(crate) mod qualified;
+pub(crate) mod report;
+pub(crate) mod resolve;
+pub(crate) mod set;
+pub(crate) mod symbol;
mod tokens;
mod toposort;
-pub mod trivial;
-pub mod types;
+pub(crate) mod trivial;
+pub(crate) mod types;
mod visit;
use self::attrs::OtherAttrs;
@@ -40,15 +40,16 @@ use syn::punctuated::Punctuated;
use syn::token::{Brace, Bracket, Paren};
use syn::{Attribute, Expr, Generics, Lifetime, LitInt, Token, Type as RustType};
-pub use self::atom::Atom;
-pub use self::derive::{Derive, Trait};
-pub use self::discriminant::Discriminant;
-pub use self::doc::Doc;
-pub use self::names::ForeignName;
-pub use self::parse::parse_items;
-pub use self::types::Types;
+pub(crate) use self::atom::Atom;
+pub(crate) use self::derive::{Derive, Trait};
+pub(crate) use self::discriminant::Discriminant;
+pub(crate) use self::doc::Doc;
+pub(crate) use self::names::ForeignName;
+pub(crate) use self::parse::parse_items;
+pub(crate) use self::types::Types;
-pub enum Api {
+pub(crate) enum Api {
+ #[allow(dead_code)] // only used by cxx-build, not cxxbridge-macro
Include(Include),
Struct(Struct),
Enum(Enum),
@@ -60,11 +61,13 @@ pub enum Api {
Impl(Impl),
}
-pub struct Include {
+pub(crate) struct Include {
pub cfg: CfgExpr,
pub path: String,
pub kind: IncludeKind,
+ #[allow(dead_code)] // only used by cxx-build, not cxxbridge-macro
pub begin_span: Span,
+ #[allow(dead_code)] // only used by cxx-build, not cxxbridge-macro
pub end_span: Span,
}
@@ -77,27 +80,35 @@ pub enum IncludeKind {
Bracketed,
}
-pub struct ExternType {
+pub(crate) struct ExternType {
+ #[allow(dead_code)] // only used by cxx-build, not cxxbridge-macro
pub cfg: CfgExpr,
pub lang: Lang,
pub doc: Doc,
pub derives: Vec<Derive>,
+ #[allow(dead_code)] // only used by cxxbridge-macro, not cxx-build
pub attrs: OtherAttrs,
+ #[allow(dead_code)] // only used by cxxbridge-macro, not cxx-build
pub visibility: Token![pub],
pub type_token: Token![type],
pub name: Pair,
pub generics: Lifetimes,
+ #[allow(dead_code)]
pub colon_token: Option<Token![:]>,
pub bounds: Vec<Derive>,
+ #[allow(dead_code)] // only used by cxxbridge-macro, not cxx-build
pub semi_token: Token![;],
pub trusted: bool,
}
-pub struct Struct {
+pub(crate) struct Struct {
+ #[allow(dead_code)] // only used by cxx-build, not cxxbridge-macro
pub cfg: CfgExpr,
pub doc: Doc,
pub derives: Vec<Derive>,
+ #[allow(dead_code)] // only used by cxxbridge-macro, not cxx-build
pub attrs: OtherAttrs,
+ #[allow(dead_code)] // only used by cxxbridge-macro, not cxx-build
pub visibility: Token![pub],
pub struct_token: Token![struct],
pub name: Pair,
@@ -106,11 +117,14 @@ pub struct Struct {
pub fields: Vec<Var>,
}
-pub struct Enum {
+pub(crate) struct Enum {
+ #[allow(dead_code)] // only used by cxx-build, not cxxbridge-macro
pub cfg: CfgExpr,
pub doc: Doc,
pub derives: Vec<Derive>,
+ #[allow(dead_code)] // only used by cxxbridge-macro, not cxx-build
pub attrs: OtherAttrs,
+ #[allow(dead_code)] // only used by cxxbridge-macro, not cxx-build
pub visibility: Token![pub],
pub enum_token: Token![enum],
pub name: Pair,
@@ -118,12 +132,13 @@ pub struct Enum {
pub brace_token: Brace,
pub variants: Vec<Variant>,
pub variants_from_header: bool,
+ #[allow(dead_code)]
pub variants_from_header_attr: Option<Attribute>,
pub repr: EnumRepr,
pub explicit_repr: bool,
}
-pub enum EnumRepr {
+pub(crate) enum EnumRepr {
Native {
atom: Atom,
repr_type: Type,
@@ -134,11 +149,14 @@ pub enum EnumRepr {
},
}
-pub struct ExternFn {
+pub(crate) struct ExternFn {
+ #[allow(dead_code)] // only used by cxx-build, not cxxbridge-macro
pub cfg: CfgExpr,
pub lang: Lang,
pub doc: Doc,
+ #[allow(dead_code)] // only used by cxxbridge-macro, not cxx-build
pub attrs: OtherAttrs,
+ #[allow(dead_code)] // only used by cxxbridge-macro, not cxx-build
pub visibility: Token![pub],
pub name: Pair,
pub sig: Signature,
@@ -146,39 +164,49 @@ pub struct ExternFn {
pub trusted: bool,
}
-pub struct TypeAlias {
+pub(crate) struct TypeAlias {
+ #[allow(dead_code)] // only used by cxx-build, not cxxbridge-macro
pub cfg: CfgExpr,
+ #[allow(dead_code)] // only used by cxxbridge-macro, not cxx-build
pub doc: Doc,
pub derives: Vec<Derive>,
+ #[allow(dead_code)] // only used by cxxbridge-macro, not cxx-build
pub attrs: OtherAttrs,
+ #[allow(dead_code)] // only used by cxxbridge-macro, not cxx-build
pub visibility: Token![pub],
pub type_token: Token![type],
pub name: Pair,
pub generics: Lifetimes,
+ #[allow(dead_code)] // only used by cxxbridge-macro, not cxx-build
pub eq_token: Token![=],
+ #[allow(dead_code)] // only used by cxxbridge-macro, not cxx-build
pub ty: RustType,
+ #[allow(dead_code)] // only used by cxxbridge-macro, not cxx-build
pub semi_token: Token![;],
}
-pub struct Impl {
+pub(crate) struct Impl {
+ #[allow(dead_code)] // only used by cxx-build, not cxxbridge-macro
pub cfg: CfgExpr,
pub impl_token: Token![impl],
pub impl_generics: Lifetimes,
+ #[allow(dead_code)]
pub negative: bool,
pub ty: Type,
+ #[allow(dead_code)] // only used by cxxbridge-macro, not cxx-build
pub ty_generics: Lifetimes,
pub brace_token: Brace,
pub negative_token: Option<Token![!]>,
}
#[derive(Clone, Default)]
-pub struct Lifetimes {
+pub(crate) struct Lifetimes {
pub lt_token: Option<Token![<]>,
pub lifetimes: Punctuated<Lifetime, Token![,]>,
pub gt_token: Option<Token![>]>,
}
-pub struct Signature {
+pub(crate) struct Signature {
pub asyncness: Option<Token![async]>,
pub unsafety: Option<Token![unsafe]>,
pub fn_token: Token![fn],
@@ -191,39 +219,48 @@ pub struct Signature {
pub throws_tokens: Option<(kw::Result, Token![<], Token![>])>,
}
-pub struct Var {
+pub(crate) struct Var {
+ #[allow(dead_code)] // only used by cxx-build, not cxxbridge-macro
pub cfg: CfgExpr,
pub doc: Doc,
+ #[allow(dead_code)] // only used by cxxbridge-macro, not cxx-build
pub attrs: OtherAttrs,
+ #[allow(dead_code)] // only used by cxxbridge-macro, not cxx-build
pub visibility: Token![pub],
pub name: Pair,
+ #[allow(dead_code)] // only used by cxxbridge-macro, not cxx-build
pub colon_token: Token![:],
pub ty: Type,
}
-pub struct Receiver {
+pub(crate) struct Receiver {
pub pinned: bool,
pub ampersand: Token![&],
pub lifetime: Option<Lifetime>,
pub mutable: bool,
pub var: Token![self],
pub ty: NamedType,
+ #[allow(dead_code)] // only used by cxxbridge-macro, not cxx-build
pub colon_token: Token![:],
pub shorthand: bool,
+ #[allow(dead_code)] // only used by cxxbridge-macro, not cxx-build
pub pin_tokens: Option<(kw::Pin, Token![<], Token![>])>,
pub mutability: Option<Token![mut]>,
}
-pub struct Variant {
+pub(crate) struct Variant {
+ #[allow(dead_code)] // only used by cxx-build, not cxxbridge-macro
pub cfg: CfgExpr,
pub doc: Doc,
+ #[allow(dead_code)] // only used by cxxbridge-macro, not cxx-build
pub attrs: OtherAttrs,
pub name: Pair,
pub discriminant: Discriminant,
+ #[allow(dead_code)]
pub expr: Option<Expr>,
}
-pub enum Type {
+pub(crate) enum Type {
Ident(NamedType),
RustBox(Box<Ty1>),
RustVec(Box<Ty1>),
@@ -240,14 +277,14 @@ pub enum Type {
Array(Box<Array>),
}
-pub struct Ty1 {
+pub(crate) struct Ty1 {
pub name: Ident,
pub langle: Token![<],
pub inner: Type,
pub rangle: Token![>],
}
-pub struct Ref {
+pub(crate) struct Ref {
pub pinned: bool,
pub ampersand: Token![&],
pub lifetime: Option<Lifetime>,
@@ -257,7 +294,7 @@ pub struct Ref {
pub mutability: Option<Token![mut]>,
}
-pub struct Ptr {
+pub(crate) struct Ptr {
pub star: Token![*],
pub mutable: bool,
pub inner: Type,
@@ -265,7 +302,7 @@ pub struct Ptr {
pub constness: Option<Token![const]>,
}
-pub struct SliceRef {
+pub(crate) struct SliceRef {
pub ampersand: Token![&],
pub lifetime: Option<Lifetime>,
pub mutable: bool,
@@ -274,7 +311,7 @@ pub struct SliceRef {
pub mutability: Option<Token![mut]>,
}
-pub struct Array {
+pub(crate) struct Array {
pub bracket: Bracket,
pub inner: Type,
pub semi_token: Token![;],
@@ -283,7 +320,7 @@ pub struct Array {
}
#[derive(Copy, Clone, PartialEq)]
-pub enum Lang {
+pub(crate) enum Lang {
Cxx,
Rust,
}
@@ -291,7 +328,7 @@ pub enum Lang {
// An association of a defined Rust name with a fully resolved, namespace
// qualified C++ name.
#[derive(Clone)]
-pub struct Pair {
+pub(crate) struct Pair {
pub namespace: Namespace,
pub cxx: ForeignName,
pub rust: Ident,
@@ -300,7 +337,7 @@ pub struct Pair {
// Wrapper for a type which needs to be resolved before it can be printed in
// C++.
#[derive(PartialEq, Eq, Hash)]
-pub struct NamedType {
+pub(crate) struct NamedType {
pub rust: Ident,
pub generics: Lifetimes,
}