1use crate::argument::ArgumentList;
2use crate::attribute::ExtendedAttributeList;
3use crate::common::{Docstring, Identifier, Parenthesized};
4use crate::types::{AttributedType, ReturnType};
5
6pub type NamespaceMembers<'a> = Vec<NamespaceMember<'a>>;
8
9ast_types! {
10 enum NamespaceMember<'a> {
12 Operation(struct OperationNamespaceMember<'a> {
16 docstring: Option<Docstring>,
17 attributes: Option<ExtendedAttributeList<'a>>,
18 return_type: ReturnType<'a>,
19 identifier: Option<Identifier<'a>>,
20 args: Parenthesized<ArgumentList<'a>>,
21 semi_colon: term!(;),
22 }),
23 Attribute(struct AttributeNamespaceMember<'a> {
25 docstring: Option<Docstring>,
26 attributes: Option<ExtendedAttributeList<'a>>,
27 readonly: term!(readonly),
28 attribute: term!(attribute),
29 type_: AttributedType<'a>,
30 identifier: Identifier<'a>,
31 semi_colon: term!(;),
32 }),
33 }
34}
35
36#[cfg(test)]
37mod test {
38 use super::*;
39 use crate::Parse;
40
41 test!(should_parse_attribute_namespace_member { "readonly attribute short name;" =>
42 "";
43 AttributeNamespaceMember;
44 attributes.is_none();
45 identifier.0 == "name";
46 });
47
48 test!(should_parse_operation_namespace_member { "short (long a, long b);" =>
49 "";
50 OperationNamespaceMember;
51 attributes.is_none();
52 identifier.is_none();
53 });
54}