mirror of
https://github.com/topjohnwu/cxx.git
synced 2024-11-24 04:20:02 +00:00
Rename variants_from_header optin to "experimental-enum-variants-from-header"
In preparation for "experimental-async-fn" as a completely orthogonal experimental feature.
This commit is contained in:
parent
cf5bbe629e
commit
d58307a1f0
@ -318,7 +318,7 @@ fn write_struct_decl(out: &mut OutFile, ident: &Pair) {
|
||||
|
||||
fn write_enum_decl(out: &mut OutFile, enm: &Enum) {
|
||||
let repr = match &enm.repr {
|
||||
#[cfg(feature = "experimental")]
|
||||
#[cfg(feature = "experimental-enum-variants-from-header")]
|
||||
EnumRepr::Foreign { .. } => return,
|
||||
EnumRepr::Native { atom, .. } => *atom,
|
||||
};
|
||||
@ -382,7 +382,7 @@ fn write_opaque_type<'a>(out: &mut OutFile<'a>, ety: &'a ExternType, methods: &[
|
||||
|
||||
fn write_enum<'a>(out: &mut OutFile<'a>, enm: &'a Enum) {
|
||||
let repr = match &enm.repr {
|
||||
#[cfg(feature = "experimental")]
|
||||
#[cfg(feature = "experimental-enum-variants-from-header")]
|
||||
EnumRepr::Foreign { .. } => return,
|
||||
EnumRepr::Native { atom, .. } => *atom,
|
||||
};
|
||||
@ -408,7 +408,7 @@ fn write_enum<'a>(out: &mut OutFile<'a>, enm: &'a Enum) {
|
||||
|
||||
fn check_enum<'a>(out: &mut OutFile<'a>, enm: &'a Enum) {
|
||||
let repr = match &enm.repr {
|
||||
#[cfg(feature = "experimental")]
|
||||
#[cfg(feature = "experimental-enum-variants-from-header")]
|
||||
EnumRepr::Foreign { .. } => return,
|
||||
EnumRepr::Native { atom, .. } => *atom,
|
||||
};
|
||||
|
@ -16,7 +16,7 @@ categories = ["development-tools::ffi"]
|
||||
proc-macro = true
|
||||
|
||||
[features]
|
||||
experimental = ["clang-ast", "flate2", "memmap", "serde", "serde_json"]
|
||||
experimental-enum-variants-from-header = ["clang-ast", "flate2", "memmap", "serde", "serde_json"]
|
||||
|
||||
[dependencies]
|
||||
proc-macro2 = "1.0"
|
||||
|
@ -36,7 +36,7 @@ pub fn bridge(mut ffi: Module) -> Result<TokenStream> {
|
||||
let trusted = ffi.unsafety.is_some();
|
||||
let namespace = &ffi.namespace;
|
||||
let ref mut apis = syntax::parse_items(errors, content, trusted, namespace);
|
||||
#[cfg(feature = "experimental")]
|
||||
#[cfg(feature = "experimental-enum-variants-from-header")]
|
||||
crate::load::load(errors, apis);
|
||||
let ref types = Types::collect(errors, apis);
|
||||
errors.propagate()?;
|
||||
|
@ -37,9 +37,9 @@ mod syntax;
|
||||
mod tokens;
|
||||
mod type_id;
|
||||
|
||||
#[cfg(feature = "experimental")]
|
||||
#[cfg(feature = "experimental-enum-variants-from-header")]
|
||||
mod clang;
|
||||
#[cfg(feature = "experimental")]
|
||||
#[cfg(feature = "experimental-enum-variants-from-header")]
|
||||
mod load;
|
||||
|
||||
use crate::syntax::file::Module;
|
||||
|
@ -142,7 +142,9 @@ pub fn parse(cx: &mut Errors, attrs: Vec<Attribute>, mut parser: Parser) -> Othe
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if attr.path.is_ident("variants_from_header") && cfg!(feature = "experimental") {
|
||||
} else if attr.path.is_ident("variants_from_header")
|
||||
&& cfg!(feature = "experimental-enum-variants-from-header")
|
||||
{
|
||||
if let Err(err) = Nothing::parse.parse2(attr.tokens.clone()) {
|
||||
cx.push(err);
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ impl Discriminant {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "experimental")]
|
||||
#[cfg(feature = "experimental-enum-variants-from-header")]
|
||||
pub const fn checked_succ(self) -> Option<Self> {
|
||||
match self.sign {
|
||||
Sign::Negative => {
|
||||
|
@ -128,7 +128,7 @@ pub enum EnumRepr {
|
||||
atom: Atom,
|
||||
repr_type: Type,
|
||||
},
|
||||
#[cfg(feature = "experimental")]
|
||||
#[cfg(feature = "experimental-enum-variants-from-header")]
|
||||
Foreign {
|
||||
rust_type: syn::Path,
|
||||
},
|
||||
|
@ -286,7 +286,7 @@ impl ToTokens for EnumRepr {
|
||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||
match self {
|
||||
EnumRepr::Native { atom, repr_type: _ } => atom.to_tokens(tokens),
|
||||
#[cfg(feature = "experimental")]
|
||||
#[cfg(feature = "experimental-enum-variants-from-header")]
|
||||
EnumRepr::Foreign { rust_type } => rust_type.to_tokens(tokens),
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ impl<'a> Types<'a> {
|
||||
EnumRepr::Native { atom: _, repr_type } => {
|
||||
all.insert(repr_type);
|
||||
}
|
||||
#[cfg(feature = "experimental")]
|
||||
#[cfg(feature = "experimental-enum-variants-from-header")]
|
||||
EnumRepr::Foreign { rust_type: _ } => {}
|
||||
}
|
||||
let ident = &enm.name.rust;
|
||||
|
Loading…
Reference in New Issue
Block a user