@@ -156,7 +156,7 @@ func AssignSectionTypes(doc *Doc, top *Section) error {
156
156
157
157
assignSectionType (doc , section , getSectionType (ps , section ))
158
158
switch section .SecType {
159
- case matter .SectionDataTypeBitmap , matter .SectionDataTypeEnum , matter .SectionDataTypeStruct :
159
+ case matter .SectionDataTypeBitmap , matter .SectionDataTypeEnum , matter .SectionDataTypeStruct , matter . SectionDataTypeDef :
160
160
if section .Base .Level > 2 {
161
161
slog .Debug ("Unusual depth for section type" , slog .String ("name" , section .Name ), slog .String ("type" , section .SecType .String ()), slog .String ("path" , doc .Path .String ()))
162
162
}
@@ -177,6 +177,8 @@ func assignSectionType(doc *Doc, s *Section, sectionType matter.Section) {
177
177
ignore = doc .errata .Spec .IgnoreSection (s .Name , errata .SpecPurposeDataTypesEnum )
178
178
case matter .SectionDataTypeStruct :
179
179
ignore = doc .errata .Spec .IgnoreSection (s .Name , errata .SpecPurposeDataTypesStruct )
180
+ case matter .SectionDataTypeDef :
181
+ ignore = doc .errata .Spec .IgnoreSection (s .Name , errata .SpecPurposeDataTypesDef )
180
182
case matter .SectionCluster :
181
183
ignore = doc .errata .Spec .IgnoreSection (s .Name , errata .SpecPurposeCluster )
182
184
case matter .SectionDeviceType :
@@ -360,6 +362,8 @@ func deriveSectionType(section *Section, parent *Section) matter.Section {
360
362
return matter .SectionDataTypeBitmap
361
363
} else if dataType .BaseType == types .BaseDataTypeCustom {
362
364
return matter .SectionDataTypeStruct
365
+ } else if dataType .BaseType .IsSimple () {
366
+ return matter .SectionDataTypeDef
363
367
}
364
368
}
365
369
slog .Debug ("unknown section type" , "path" , section .Doc .Path , "name" , name )
@@ -453,7 +457,7 @@ func (s *Section) toGlobalObjects(d *Doc, entityMap map[asciidoc.Attributable][]
453
457
return entities , nil
454
458
}
455
459
456
- var dataTypeDefinitionPattern = regexp .MustCompile (`is\s+derived\s+from\s+(?:<<enum-def\s*,\s*)?(enum8|enum16|enum32|map8|map16|map32)(?:\s*>>)?` )
460
+ var dataTypeDefinitionPattern = regexp .MustCompile (`is\s+derived\s+from\s+(?:<<enum-def\s*,\s*)?(enum8|enum16|enum32|map8|map16|map32|uint8|uint16|uint24|uint32|uint40|uint48|uint56|uint64|int8|int16|int24|int32|int40|int48|int56|int64|string )(?:\s*>>)?` )
457
461
458
462
func (s * Section ) GetDataType () * types.DataType {
459
463
var dts string
@@ -527,6 +531,15 @@ func findLooseEntities(doc *Doc, section *Section, entityMap map[asciidoc.Attrib
527
531
} else {
528
532
entities = append (entities , s )
529
533
}
534
+ case matter .SectionDataTypeDef :
535
+ var t * matter.TypeDef
536
+ t , err = section .toTypeDef (doc , entityMap )
537
+ if err != nil {
538
+ slog .Warn ("Error converting loose section to typedef" , log .Element ("path" , doc .Path , section .Base ), slog .Any ("error" , err ))
539
+ err = nil
540
+ } else {
541
+ entities = append (entities , t )
542
+ }
530
543
case matter .SectionGlobalElements :
531
544
var ges []types.Entity
532
545
ges , err = section .toGlobalElements (doc , entityMap )
0 commit comments