@@ -189,18 +189,68 @@ for member in message.structure.members:
189
189
190
190
191
191
class @ (message .structure .namespaced_type .name )(metaclass = Metaclass_@ (message .structure .namespaced_type .name )):
192
- @ [if not message .constants ]@
193
- """ Message class '@(message.structure.namespaced_type.name)'."""
194
- @ [else ]@
195
192
"""
196
193
Message class '@(message.structure.namespaced_type.name)'.
194
+ @[if len(message.structure.get_comment_lines()) > 0]@
195
+
196
+ @[ for comment in message.structure.get_comment_lines()]@
197
+ @((" " + comment).rstrip(' ') + "\n ")@
198
+ @[ end for]@
199
+ @[end if]@
200
+
201
+ @[if message.constants]@
197
202
198
203
Constants:
199
204
@[ for constant_name in [c.name for c in message.constants]]@
200
205
@(constant_name)
201
206
@[ end for]@
202
- """
203
207
@[end if]@
208
+ @[if message.structure.members]@
209
+
210
+ Fields:
211
+ @[for member in message.structure.members]@
212
+ @[ if len(message.structure.members) == 1 and member.name == EMPTY_STRUCTURE_REQUIRED_MEMBER_NAME]@
213
+ @[ continue]@
214
+ @[ end if]@
215
+ @{
216
+ type_ = member.type
217
+ if isinstance(type_, AbstractNestedType):
218
+ type_ = type_.value_type
219
+ }@
220
+ @(member.name) (@
221
+ @# the prefix for nested types
222
+ @[ if isinstance(member.type, AbstractSequence)]@
223
+ sequence<@
224
+ @[ end if]@
225
+ @# the typename of the non-nested type or the nested basetype
226
+ @[ if isinstance(type_, BasicType)]@
227
+ @(type_.typename)@
228
+ @[ elif isinstance(type_, AbstractGenericString)]@
229
+ @
230
+ @[ if isinstance(type_, AbstractWString)]@
231
+ w@
232
+ @[ end if]@
233
+ string@
234
+ @[ if type_.has_maximum_size()]@
235
+ <@(type_.maximum_size)>@
236
+ @[ end if]@
237
+ @[ elif isinstance(type_, NamespacedType)]@
238
+ @('/'.join([type_.namespaces[0], type_.name]))@
239
+ @[ end if]@
240
+ @# the suffix for nested types
241
+ @[ if isinstance(member.type, AbstractSequence)]@
242
+ @[ if isinstance(member.type, BoundedSequence)]@
243
+ , @(member.type.maximum_size)@
244
+ @[ end if]@
245
+ >@
246
+ @[ elif isinstance(member.type, Array)]@
247
+ [@(member.type.size)]@
248
+ @[ end if]@
249
+ )@(" ".join([':'] + member.get_comment_lines()).strip(' '))@
250
+
251
+ @[end for]@
252
+ @[end if]@
253
+ """
204
254
205
255
__slots__ = [
206
256
@ [for member in message .structure .members ]@
0 commit comments