Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for unstable WebIDL #1997

Merged
merged 6 commits into from
Feb 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Easy support for interacting between JS and Rust.
edition = "2018"

[package.metadata.docs.rs]
features = ['serde-serialize']
features = ["serde-serialize"]
rustc-args = ["--cfg=web_sys_unstable_apis"]

[lib]
test = false
Expand Down
10 changes: 10 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ jobs:
- script: cargo build --manifest-path crates/web-sys/Cargo.toml --target wasm32-unknown-unknown --features Element
- script: cargo build --manifest-path crates/web-sys/Cargo.toml --target wasm32-unknown-unknown --features Window
- script: cargo test --manifest-path crates/web-sys/Cargo.toml --target wasm32-unknown-unknown --all-features
- script: cargo test --manifest-path crates/web-sys/Cargo.toml --target wasm32-unknown-unknown --all-features
displayName: "web-sys unstable APIs"
env:
RUSTFLAGS: --cfg=web_sys_unstable_apis

- job: test_js_sys
displayName: "Run js-sys crate tests"
Expand Down Expand Up @@ -150,6 +154,10 @@ jobs:
- script: cargo test -p webidl-tests --target wasm32-unknown-unknown
env:
WBINDGEN_I_PROMISE_JS_SYNTAX_WORKS_IN_NODE: 1
- script: cargo test -p webidl-tests --target wasm32-unknown-unknown
displayName: "webidl-tests unstable APIs"
env:
RUSTFLAGS: --cfg=web_sys_unstable_apis

- job: test_ui
displayName: "Run UI tests"
Expand Down Expand Up @@ -319,6 +327,8 @@ jobs:
displayName: "Document js-sys"
- script: cargo doc --no-deps --manifest-path crates/web-sys/Cargo.toml --all-features
displayName: "Document web-sys"
env:
RUSTFLAGS: --cfg=web_sys_unstable_apis
- script: cargo doc --no-deps --manifest-path crates/futures/Cargo.toml
displayName: "Document wasm-bindgen-futures"
# Make a tarball even though a zip is uploaded, it looks like the tarball
Expand Down
11 changes: 11 additions & 0 deletions crates/backend/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ pub struct Export {
/// Whether or not this function should be flagged as the wasm start
/// function.
pub start: bool,
/// Whether the API is unstable. This is only used internally.
pub unstable_api: bool,
}

/// The 3 types variations of `self`.
Expand All @@ -71,6 +73,7 @@ pub struct Import {
pub module: ImportModule,
pub js_namespace: Option<Ident>,
pub kind: ImportKind,
pub unstable_api: bool,
}

#[cfg_attr(feature = "extra-traits", derive(Debug))]
Expand Down Expand Up @@ -126,6 +129,7 @@ pub struct ImportFunction {
pub kind: ImportFunctionKind,
pub shim: Ident,
pub doc_comment: Option<String>,
pub unstable_api: bool,
}

#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
Expand Down Expand Up @@ -182,6 +186,7 @@ pub struct ImportType {
pub js_name: String,
pub attrs: Vec<syn::Attribute>,
pub typescript_name: Option<String>,
pub unstable_api: bool,
pub doc_comment: Option<String>,
pub instanceof_shim: String,
pub is_type_of: Option<syn::Expr>,
Expand All @@ -202,6 +207,8 @@ pub struct ImportEnum {
pub variant_values: Vec<String>,
/// Attributes to apply to the Rust enum
pub rust_attrs: Vec<syn::Attribute>,
/// Whether the enum is part of an unstable WebIDL
pub unstable_api: bool,
}

#[cfg_attr(feature = "extra-traits", derive(Debug))]
Expand Down Expand Up @@ -237,6 +244,7 @@ pub struct StructField {
pub getter: Ident,
pub setter: Ident,
pub comments: Vec<String>,
pub unstable_api: bool,
}

#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
Expand All @@ -246,6 +254,7 @@ pub struct Enum {
pub variants: Vec<Variant>,
pub comments: Vec<String>,
pub hole: u32,
pub unstable_api: bool,
}

#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
Expand Down Expand Up @@ -278,6 +287,7 @@ pub struct Const {
pub class: Option<Ident>,
pub ty: syn::Type,
pub value: ConstValue,
pub unstable_api: bool,
}

#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq))]
Expand All @@ -299,6 +309,7 @@ pub struct Dictionary {
pub ctor: bool,
pub doc_comment: Option<String>,
pub ctor_doc_comment: Option<String>,
pub unstable_api: bool,
}

#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
Expand Down
Loading