From d8bbc7858622b6d9c278469aab701ca0b609cddf Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:35:49 +0200 Subject: Merging upstream version 126.0. Signed-off-by: Daniel Baumann --- third_party/rust/weedle2/.cargo-checksum.json | 2 +- third_party/rust/weedle2/Cargo.toml | 5 ++- third_party/rust/weedle2/README.md | 2 +- third_party/rust/weedle2/src/common.rs | 45 +++++++++++++++++++++++++++ third_party/rust/weedle2/src/dictionary.rs | 3 +- third_party/rust/weedle2/src/interface.rs | 4 ++- third_party/rust/weedle2/src/lib.rs | 16 ++++++++-- third_party/rust/weedle2/src/namespace.rs | 4 ++- third_party/rust/weedle2/src/whitespace.rs | 1 + 9 files changed, 72 insertions(+), 10 deletions(-) (limited to 'third_party/rust/weedle2') diff --git a/third_party/rust/weedle2/.cargo-checksum.json b/third_party/rust/weedle2/.cargo-checksum.json index 9eb63aa3c1..13a9d357d5 100644 --- a/third_party/rust/weedle2/.cargo-checksum.json +++ b/third_party/rust/weedle2/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"1c9da38b083da061c42208494a1161d95938a524054f95b39097248da32ebfd0","LICENSE.md":"467e2e44913e850ca4fb6760fa3b78ffefda2a21688a6b1e26a8b706963669eb","README.md":"32092d702b93e9cc8d95fbcad1e30e315882a55496ad90a855ea575dc47aa7d4","release.toml":"fce2a51533478f7e7d663b11ac69676323856780adf8af158ce213c9dbc86c75","src/argument.rs":"aa7a119364de0a1f91b00db6cffb0a7b2ee73e0fb79a764211165ccebed56dc8","src/attribute.rs":"b3577059be9c1262d3360b4b4cf4cc6cb052251e5b9d64906fb40fc5e925da69","src/common.rs":"9d781dacc2582ac375f2c3b6b22bcb01add4a63db525d18ebb3af6fe633a311e","src/dictionary.rs":"be209d70b0db33acf753ca63998a63dd37a9d4b193583a1490782781360c2d01","src/interface.rs":"bd2f32bfbcab2167f056fabbf92da9852300141ffc80d9542c6e1bbea9d521ac","src/lib.rs":"42466a14426416dc0d3500842c86fe00471c2d73be6df823c3e05ba0e4572d20","src/literal.rs":"16d44ae36f893c3b2d8d807921b31b992b7e3ce7d1729913b4f392f52db44f9e","src/macros.rs":"2f24c285806c863fd9dc65534479d36961d9666ca5e11c9137f2ce2659a712b6","src/mixin.rs":"d65ff3a49615dabdf3f7845723f01ae730a83c8ef5bdd9a945d35149a9ef2858","src/namespace.rs":"fe6b406c2ab8bd904d0dff8a12321c77f4082ab364559e578e53ab415c8541fa","src/term.rs":"049514b2b44f1bcb5c23d225d3bb0a6135892a5660049c694681c5b99d47d8e7","src/types.rs":"0fe236336e71079c88ae4848624af29c87dd16266ba36c30a0d47e7dc4d33587","src/whitespace.rs":"552ebc98857859e8714e06bb25681ceab6052d009e00f55cceda0d4fb3c4f059"},"package":"2e79c5206e1f43a2306fd64bdb95025ee4228960f2e6c5a8b173f3caaf807741"} \ No newline at end of file +{"files":{"Cargo.toml":"cd75893e67b7ed5e1ee200efddc874a7d235a7275b3d9bbadd728d47a5d5b8c6","LICENSE.md":"467e2e44913e850ca4fb6760fa3b78ffefda2a21688a6b1e26a8b706963669eb","README.md":"b18a5a8af93ebf01f28b3ec637e64fb0bd21d556e356984974d0031f6eeda47a","release.toml":"fce2a51533478f7e7d663b11ac69676323856780adf8af158ce213c9dbc86c75","src/argument.rs":"aa7a119364de0a1f91b00db6cffb0a7b2ee73e0fb79a764211165ccebed56dc8","src/attribute.rs":"b3577059be9c1262d3360b4b4cf4cc6cb052251e5b9d64906fb40fc5e925da69","src/common.rs":"c0ae3236856bbe9917326ac9769e2fe15283cd4d1a0216aafcea3bc03ad724cc","src/dictionary.rs":"d0c9a40e694eb563d7d8307d36a3f9a3be1766846bdfa809d614a6e1e9e149d1","src/interface.rs":"352f7773e9e3870fa61efdb2b737d777a34def1eb8301ec66f7c416b31d5e88b","src/lib.rs":"95c6b27082959165f3899b4a5a520b10fbcab80dcf94ecf030aba74df0748203","src/literal.rs":"16d44ae36f893c3b2d8d807921b31b992b7e3ce7d1729913b4f392f52db44f9e","src/macros.rs":"2f24c285806c863fd9dc65534479d36961d9666ca5e11c9137f2ce2659a712b6","src/mixin.rs":"d65ff3a49615dabdf3f7845723f01ae730a83c8ef5bdd9a945d35149a9ef2858","src/namespace.rs":"417a9a6cb26efc8f84bd84e59c6ae7378502f920a76738b355e8c905e62efed8","src/term.rs":"049514b2b44f1bcb5c23d225d3bb0a6135892a5660049c694681c5b99d47d8e7","src/types.rs":"0fe236336e71079c88ae4848624af29c87dd16266ba36c30a0d47e7dc4d33587","src/whitespace.rs":"9b58cfc0a4b8667a26ff3d4dcd424a3d00bf23abab4dd0d286318cb18bd77a13"},"package":"998d2c24ec099a87daf9467808859f9d82b61f1d9c9701251aea037f514eae0e"} \ No newline at end of file diff --git a/third_party/rust/weedle2/Cargo.toml b/third_party/rust/weedle2/Cargo.toml index 072d3f9a2a..66703cf607 100644 --- a/third_party/rust/weedle2/Cargo.toml +++ b/third_party/rust/weedle2/Cargo.toml @@ -12,7 +12,7 @@ [package] edition = "2021" name = "weedle2" -version = "4.0.0" +version = "5.0.0" authors = [ "Sharad Chand ", "Jan-Erik Rediger ", @@ -21,10 +21,9 @@ exclude = ["tests"] description = "A WebIDL Parser" homepage = "https://github.com/mozilla/uniffi-rs/tree/main/weedle2" documentation = "https://docs.rs/weedle2" -readme = "./README.md" +readme = "README.md" license = "MIT" repository = "https://github.com/mozilla/uniffi-rs" -resolver = "2" [lib] name = "weedle" diff --git a/third_party/rust/weedle2/README.md b/third_party/rust/weedle2/README.md index 889dc0da19..88e4cec017 100644 --- a/third_party/rust/weedle2/README.md +++ b/third_party/rust/weedle2/README.md @@ -28,7 +28,7 @@ Parses valid WebIDL definitions & produces a data structure starting from ```toml [dependencies] -weedle2 = "4.0.0" +weedle2 = "5.0.0" ``` ### `src/main.rs` diff --git a/third_party/rust/weedle2/src/common.rs b/third_party/rust/weedle2/src/common.rs index fadf89ba8b..d36f6e5438 100644 --- a/third_party/rust/weedle2/src/common.rs +++ b/third_party/rust/weedle2/src/common.rs @@ -33,6 +33,18 @@ impl<'a, T: Parse<'a>, U: Parse<'a>, V: Parse<'a>> Parse<'a> for (T, U, V) { parser!(nom::sequence::tuple((T::parse, U::parse, V::parse))); } +pub(crate) fn docstring(input: &str) -> IResult<&str, String> { + nom::multi::many1(nom::sequence::preceded( + nom::character::complete::multispace0, + nom::sequence::delimited( + nom::bytes::complete::tag("///"), + nom::bytes::complete::take_until("\n"), + nom::bytes::complete::tag("\n"), + ), + ))(input) + .map(|io| (io.0, io.1.join("\n"))) +} + ast_types! { /// Parses `( body )` #[derive(Copy, Default)] @@ -103,6 +115,11 @@ ast_types! { assign: term!(=), value: DefaultValue<'a>, } + + /// Represents consecutive comment lines starting with `///`, joined by `\n`. + struct Docstring( + String = docstring, + ) } #[cfg(test)] @@ -211,4 +228,32 @@ mod test { Identifier; 0 == "hello"; }); + + test!(should_parse_docstring { "///hello world\n" => + ""; + Docstring; + 0 == "hello world"; + }); + + test!(should_parse_multiline_docstring { "///hello\n///world\n" => + ""; + Docstring; + 0 == "hello\nworld"; + }); + + test!(should_parse_multiline_indented_docstring { "///hello\n ///world\n" => + ""; + Docstring; + 0 == "hello\nworld"; + }); + + test!(should_not_parse_docstring_with_comments { "///hello\n//comment1\n///world\n" => + "//comment1\n///world\n"; + Docstring; + 0 == "hello"; + }); + + test!(err should_not_parse_not_docstring { "" => + Docstring + }); } diff --git a/third_party/rust/weedle2/src/dictionary.rs b/third_party/rust/weedle2/src/dictionary.rs index 3c9b23cac5..b775d526dc 100644 --- a/third_party/rust/weedle2/src/dictionary.rs +++ b/third_party/rust/weedle2/src/dictionary.rs @@ -1,5 +1,5 @@ use crate::attribute::ExtendedAttributeList; -use crate::common::{Default, Identifier}; +use crate::common::{Default, Docstring, Identifier}; use crate::types::Type; /// Parses dictionary members @@ -8,6 +8,7 @@ pub type DictionaryMembers<'a> = Vec>; ast_types! { /// Parses dictionary member `[attributes]? required? type identifier ( = default )?;` struct DictionaryMember<'a> { + docstring: Option, attributes: Option>, required: Option, type_: Type<'a>, diff --git a/third_party/rust/weedle2/src/interface.rs b/third_party/rust/weedle2/src/interface.rs index 5e30909c38..ab3c10d3c3 100644 --- a/third_party/rust/weedle2/src/interface.rs +++ b/third_party/rust/weedle2/src/interface.rs @@ -1,6 +1,6 @@ use crate::argument::ArgumentList; use crate::attribute::ExtendedAttributeList; -use crate::common::{Generics, Identifier, Parenthesized}; +use crate::common::{Docstring, Generics, Identifier, Parenthesized}; use crate::literal::ConstValue; use crate::types::{AttributedType, ConstType, ReturnType}; @@ -41,6 +41,7 @@ ast_types! { /// /// (( )) means ( ) chars Constructor(struct ConstructorInterfaceMember<'a> { + docstring: Option, attributes: Option>, constructor: term!(constructor), args: Parenthesized>, @@ -50,6 +51,7 @@ ast_types! { /// /// (( )) means ( ) chars Operation(struct OperationInterfaceMember<'a> { + docstring: Option, attributes: Option>, modifier: Option, special: Option, diff --git a/third_party/rust/weedle2/src/lib.rs b/third_party/rust/weedle2/src/lib.rs index 610a34fa14..71ab7c33b5 100644 --- a/third_party/rust/weedle2/src/lib.rs +++ b/third_party/rust/weedle2/src/lib.rs @@ -23,7 +23,7 @@ use self::argument::ArgumentList; use self::attribute::ExtendedAttributeList; -use self::common::{Braced, Identifier, Parenthesized, PunctuatedNonEmpty}; +use self::common::{Braced, Docstring, Identifier, Parenthesized, PunctuatedNonEmpty}; use self::dictionary::DictionaryMembers; use self::interface::{Inheritance, InterfaceMembers}; use self::literal::StringLit; @@ -109,6 +109,7 @@ ast_types! { }), /// Parses `[attributes]? callback interface identifier ( : inheritance )? { members };` CallbackInterface(struct CallbackInterfaceDefinition<'a> { + docstring: Option, attributes: Option>, callback: term!(callback), interface: term!(interface), @@ -119,6 +120,7 @@ ast_types! { }), /// Parses `[attributes]? interface identifier ( : inheritance )? { members };` Interface(struct InterfaceDefinition<'a> { + docstring: Option, attributes: Option>, interface: term!(interface), identifier: Identifier<'a>, @@ -137,6 +139,7 @@ ast_types! { }), /// Parses `[attributes]? namespace identifier { members };` Namespace(struct NamespaceDefinition<'a> { + docstring: Option, attributes: Option>, namespace: term!(namespace), identifier: Identifier<'a>, @@ -145,6 +148,7 @@ ast_types! { }), /// Parses `[attributes]? dictionary identifier ( : inheritance )? { members };` Dictionary(struct DictionaryDefinition<'a> { + docstring: Option, attributes: Option>, dictionary: term!(dictionary), identifier: Identifier<'a>, @@ -191,6 +195,7 @@ ast_types! { }), /// Parses `[attributes]? enum identifier { values };` Enum(struct EnumDefinition<'a> { + docstring: Option, attributes: Option>, enum_: term!(enum), identifier: Identifier<'a>, @@ -224,8 +229,15 @@ ast_types! { } } +ast_types! { + struct EnumVariant<'a> { + docstring: Option, + value: StringLit<'a>, + } +} + /// Parses a non-empty enum value list -pub type EnumValueList<'a> = PunctuatedNonEmpty, term!(,)>; +pub type EnumValueList<'a> = PunctuatedNonEmpty, term!(,)>; #[cfg(test)] mod test { diff --git a/third_party/rust/weedle2/src/namespace.rs b/third_party/rust/weedle2/src/namespace.rs index ed28573218..60673cdcec 100644 --- a/third_party/rust/weedle2/src/namespace.rs +++ b/third_party/rust/weedle2/src/namespace.rs @@ -1,6 +1,6 @@ use crate::argument::ArgumentList; use crate::attribute::ExtendedAttributeList; -use crate::common::{Identifier, Parenthesized}; +use crate::common::{Docstring, Identifier, Parenthesized}; use crate::types::{AttributedType, ReturnType}; /// Parses namespace members declaration @@ -13,6 +13,7 @@ ast_types! { /// /// (( )) means ( ) chars Operation(struct OperationNamespaceMember<'a> { + docstring: Option, attributes: Option>, return_type: ReturnType<'a>, identifier: Option>, @@ -21,6 +22,7 @@ ast_types! { }), /// Parses `[attribute]? readonly attributetype type identifier;` Attribute(struct AttributeNamespaceMember<'a> { + docstring: Option, attributes: Option>, readonly: term!(readonly), attribute: term!(attribute), diff --git a/third_party/rust/weedle2/src/whitespace.rs b/third_party/rust/weedle2/src/whitespace.rs index 336e4784e1..4be3ca43e8 100644 --- a/third_party/rust/weedle2/src/whitespace.rs +++ b/third_party/rust/weedle2/src/whitespace.rs @@ -7,6 +7,7 @@ pub(crate) fn sp(input: &str) -> IResult<&str, &str> { (), nom::sequence::tuple(( nom::bytes::complete::tag("//"), + nom::combinator::not(nom::bytes::complete::tag("/")), nom::bytes::complete::take_until("\n"), nom::bytes::complete::tag("\n"), )), -- cgit v1.2.3