gir_parser/
function_macro.rs1use xmlserde_derives::XmlDeserialize;
2
3use crate::{
4 attribute::Attribute,
5 documentation::{DocDeprecated, DocStability, DocVersion, Documentation, SourcePosition},
6 parameter::Parameters,
7 prelude::*,
8 version::Version,
9 Stability,
10};
11
12#[derive(Clone, Debug, XmlDeserialize)]
13#[xmlserde(root = b"function-macro")]
14#[xmlserde(deny_unknown_fields)]
15pub struct FunctionMacro {
16 #[xmlserde(name = b"name", ty = "attr")]
18 name: String,
19 #[xmlserde(name = b"c:identifier", ty = "attr")]
20 c_identifier: Option<String>,
21 #[xmlserde(name = b"shadows", ty = "attr")]
22 shadows: Option<String>,
23 #[xmlserde(name = b"shadowed-by", ty = "attr")]
24 shadowed_by: Option<String>,
25 #[xmlserde(name = b"throws", ty = "attr")]
26 throws: Option<bool>,
27 #[xmlserde(name = b"moved-to", ty = "attr")]
28 moved_to: Option<String>,
29 #[xmlserde(name = b"glib:async-func", ty = "attr")]
30 async_func: Option<String>,
31 #[xmlserde(name = b"glib:finish-func", ty = "attr")]
32 finish_func: Option<String>,
33 #[xmlserde(name = b"glib:sync-func", ty = "attr")]
34 sync_func: Option<String>,
35 #[xmlserde(name = b"introspectable", ty = "attr")]
37 introspectable: Option<bool>,
38 #[xmlserde(name = b"deprecated", ty = "attr")]
39 deprecated: Option<bool>,
40 #[xmlserde(name = b"version", ty = "attr")]
41 version: Option<Version>,
42 #[xmlserde(name = b"deprecated-version", ty = "attr")]
43 deprecated_version: Option<Version>,
44 #[xmlserde(name = b"stability", ty = "attr")]
45 stability: Option<Stability>,
46 #[xmlserde(name = b"doc", ty = "child")]
48 doc: Option<Documentation>,
49 #[xmlserde(name = b"doc-deprecated", ty = "child")]
50 doc_deprecated: Option<DocDeprecated>,
51 #[xmlserde(name = b"doc-stability", ty = "child")]
52 doc_stability: Option<DocStability>,
53 #[xmlserde(name = b"doc-version", ty = "child")]
54 doc_version: Option<DocVersion>,
55 #[xmlserde(name = b"source-position", ty = "child")]
56 source_position: Option<SourcePosition>,
57 #[xmlserde(name = b"attribute", ty = "child")]
59 attributes: Vec<Attribute>,
60
61 #[xmlserde(name = b"parameters", ty = "child", default = "Parameters::default")]
62 parameters: Parameters,
63}
64
65impl FunctionMacro {
66 pub fn parameters(&self) -> &Parameters {
67 &self.parameters
68 }
69
70 pub fn throws(&self) -> Option<bool> {
71 self.throws
72 }
73}
74
75impl_info!(FunctionMacro);
76impl_attributable!(FunctionMacro);
77impl_documentable!(FunctionMacro);
78impl_callable!(FunctionMacro);