1use xmlserde_derives::XmlDeserialize;
2
3use crate::{
4 attribute::Attribute,
5 callback::Callback,
6 constant::Constant,
7 documentation::{DocDeprecated, DocStability, DocVersion, Documentation, SourcePosition},
8 field::Field,
9 function::{Function, FunctionInline},
10 method::{Method, MethodInline},
11 prelude::*,
12 property::Property,
13 record::Record,
14 signal::Signal,
15 union::Union,
16 version::Version,
17 virtual_method::VirtualMethod,
18 Stability,
19};
20
21#[derive(Clone, Debug, XmlDeserialize)]
22#[xmlserde(root = b"implements")]
23#[xmlserde(deny_unknown_fields)]
24pub struct Implements {
25 #[xmlserde(name = b"name", ty = "attr")]
26 name: String,
27}
28
29impl Implements {
30 pub fn name(&self) -> &str {
31 &self.name
32 }
33}
34
35#[derive(Clone, Debug, XmlDeserialize)]
36#[xmlserde(root = b"class")]
37#[xmlserde(deny_unknown_fields)]
38pub struct Class {
39 #[xmlserde(name = b"name", ty = "attr")]
40 name: String,
41 #[xmlserde(name = b"c:symbol-prefix", ty = "attr")]
42 symbol_prefix: Option<String>,
43 #[xmlserde(name = b"c:type", ty = "attr")]
44 c_type: Option<String>,
45 #[xmlserde(name = b"parent", ty = "attr")]
46 parent: Option<String>,
47 #[xmlserde(name = b"introspectable", ty = "attr")]
49 introspectable: Option<bool>,
50 #[xmlserde(name = b"deprecated", ty = "attr")]
51 deprecated: Option<bool>,
52 #[xmlserde(name = b"version", ty = "attr")]
53 version: Option<Version>,
54 #[xmlserde(name = b"deprecated-version", ty = "attr")]
55 deprecated_version: Option<Version>,
56 #[xmlserde(name = b"stability", ty = "attr")]
57 stability: Option<Stability>,
58 #[xmlserde(name = b"doc", ty = "child")]
60 doc: Option<Documentation>,
61 #[xmlserde(name = b"doc-deprecated", ty = "child")]
62 doc_deprecated: Option<DocDeprecated>,
63 #[xmlserde(name = b"doc-stability", ty = "child")]
64 doc_stability: Option<DocStability>,
65 #[xmlserde(name = b"doc-version", ty = "child")]
66 doc_version: Option<DocVersion>,
67 #[xmlserde(name = b"source-position", ty = "child")]
68 source_position: Option<SourcePosition>,
69 #[xmlserde(name = b"attribute", ty = "child")]
71 attributes: Vec<Attribute>,
72
73 #[xmlserde(name = b"glib:type-name", ty = "attr")]
74 g_type_name: String,
75 #[xmlserde(name = b"glib:get-type", ty = "attr")]
76 g_get_type: String,
77 #[xmlserde(name = b"glib:type-struct", ty = "attr")]
78 g_type_struct: Option<String>,
79 #[xmlserde(name = b"glib:fundamental", ty = "attr")]
80 g_fundamental: Option<bool>,
81 #[xmlserde(name = b"final", ty = "attr")]
82 r#final: Option<bool>,
83 #[xmlserde(name = b"abstract", ty = "attr")]
84 r#abstract: Option<bool>,
85 #[xmlserde(name = b"glib:ref-func", ty = "attr")]
86 g_ref_func: Option<String>,
87 #[xmlserde(name = b"glib:unref-func", ty = "attr")]
88 g_unref_func: Option<String>,
89 #[xmlserde(name = b"glib:set-value-func", ty = "attr")]
90 g_set_value_func: Option<String>,
91 #[xmlserde(name = b"glib:get-value-func", ty = "attr")]
92 g_get_value_func: Option<String>,
93 #[xmlserde(name = b"implements", ty = "child")]
94 implements: Vec<Implements>,
95 #[xmlserde(name = b"constructor", ty = "child")]
96 constructors: Vec<Function>,
97 #[xmlserde(name = b"function", ty = "child")]
98 functions: Vec<Function>,
99 #[xmlserde(name = b"function-inline", ty = "child")]
100 inline_functions: Vec<FunctionInline>,
101
102 #[xmlserde(name = b"method", ty = "child")]
103 methods: Vec<Method>,
104 #[xmlserde(name = b"inline-methods", ty = "child")]
105 inline_methods: Vec<MethodInline>,
106
107 #[xmlserde(name = b"property", ty = "child")]
108 properties: Vec<Property>,
109 #[xmlserde(name = b"glib:signal", ty = "child")]
110 signals: Vec<Signal>,
111 #[xmlserde(name = b"virtual-method", ty = "child")]
112 virtual_methods: Vec<VirtualMethod>,
113 #[xmlserde(name = b"field", ty = "child")]
114 fields: Vec<Field>,
115 #[xmlserde(name = b"record", ty = "child")]
116 records: Vec<Record>,
117 #[xmlserde(name = b"constant", ty = "child")]
118 constants: Vec<Constant>,
119 #[xmlserde(name = b"union", ty = "child")]
120 unions: Vec<Union>,
121 #[xmlserde(name = b"callback", ty = "child")]
122 callbacks: Vec<Callback>,
123}
124
125impl Class {
126 pub fn name(&self) -> &str {
127 &self.name
128 }
129
130 pub fn is_fundamental(&self) -> bool {
131 self.g_fundamental.unwrap_or(false)
132 }
133
134 pub fn is_final(&self) -> bool {
135 self.r#final.unwrap_or(false)
136 }
137
138 pub fn is_abstract(&self) -> bool {
139 self.r#abstract.unwrap_or(false)
140 }
141
142 pub fn symbol_prefix(&self) -> Option<&str> {
143 self.symbol_prefix.as_deref()
144 }
145
146 pub fn c_type(&self) -> Option<&str> {
147 self.c_type.as_deref()
148 }
149
150 pub fn parent(&self) -> Option<&str> {
151 self.parent.as_deref()
152 }
153
154 pub fn g_type_name(&self) -> &str {
155 &self.g_type_name
156 }
157
158 pub fn g_get_type(&self) -> &str {
159 &self.g_get_type
160 }
161
162 pub fn g_type_struct(&self) -> Option<&str> {
163 self.g_type_struct.as_deref()
164 }
165
166 pub fn g_ref_func(&self) -> Option<&str> {
167 self.g_ref_func.as_deref()
168 }
169
170 pub fn g_unref_func(&self) -> Option<&str> {
171 self.g_unref_func.as_deref()
172 }
173
174 pub fn g_set_value_func(&self) -> Option<&str> {
175 self.g_set_value_func.as_deref()
176 }
177
178 pub fn g_get_value_func(&self) -> Option<&str> {
179 self.g_get_value_func.as_deref()
180 }
181
182 pub fn implements(&self) -> &[Implements] {
183 &self.implements
184 }
185
186 pub fn constructors(&self) -> &[Function] {
187 &self.constructors
188 }
189
190 pub fn methods(&self) -> &[Method] {
191 &self.methods
192 }
193
194 pub fn inlined_methods(&self) -> &[MethodInline] {
195 &self.inline_methods
196 }
197
198 pub fn functions(&self) -> &[Function] {
199 &self.functions
200 }
201
202 pub fn inlined_functions(&self) -> &[FunctionInline] {
203 &self.inline_functions
204 }
205
206 pub fn virtual_methods(&self) -> &[VirtualMethod] {
207 &self.virtual_methods
208 }
209
210 pub fn fields(&self) -> &[Field] {
211 &self.fields
212 }
213
214 pub fn properties(&self) -> &[Property] {
215 &self.properties
216 }
217
218 pub fn signals(&self) -> &[Signal] {
219 &self.signals
220 }
221
222 pub fn unions(&self) -> &[Union] {
223 &self.unions
224 }
225
226 pub fn constants(&self) -> &[Constant] {
227 &self.constants
228 }
229
230 pub fn records(&self) -> &[Record] {
231 &self.records
232 }
233
234 pub fn callbacks(&self) -> &[Callback] {
235 &self.callbacks
236 }
237}
238
239impl_documentable!(Class);
240impl_attributable!(Class);
241impl_info!(Class);