~emersion/gyosu

2001e591dc4888804afeb5f9690f1c9c48c74b3e — Simon Ser 2 months ago 1e97b1f
Iterate over all DeclarationSpecifiers when handling enum/struct/union
1 files changed, 28 insertions(+), 26 deletions(-)

M main.go
M main.go => main.go +28 -26
@@ 463,32 463,34 @@ func main() {
		desc := extractDocComment(firstToken)

		if decl.InitDeclaratorList == nil {
			if decl.DeclarationSpecifiers.Case != cc.DeclarationSpecifiersTypeSpec {
				continue // TODO
			}
			typeSpec := decl.DeclarationSpecifiers.TypeSpecifier

			proto := append(declSpecsProto, token{Value: ";"})
			switch typeSpec.Case {
			case cc.TypeSpecifierStructOrUnion:
				structOrUnionSpec := typeSpec.StructOrUnionSpecifier
				kind := structOrUnionSpec.StructOrUnion.Token.Value.String()
				decls = append(decls, declData{
					Kind:        declKind(kind),
					Name:        structOrUnionSpec.Token.Value.String(),
					Prototype:   proto,
					Description: desc,
					Filename:    origFilename,
				})
			case cc.TypeSpecifierEnum:
				enumSpec := typeSpec.EnumSpecifier
				decls = append(decls, declData{
					Kind:        declEnum,
					Name:        enumSpec.Token2.Value.String(),
					Prototype:   proto,
					Description: desc,
					Filename:    origFilename,
				})
			for declSpec := decl.DeclarationSpecifiers; declSpec != nil; declSpec = declSpec.DeclarationSpecifiers {
				if declSpec.Case != cc.DeclarationSpecifiersTypeSpec {
					continue // TODO
				}
				typeSpec := declSpec.TypeSpecifier

				proto := append(declSpecsProto, token{Value: ";"})
				switch typeSpec.Case {
				case cc.TypeSpecifierStructOrUnion:
					structOrUnionSpec := typeSpec.StructOrUnionSpecifier
					kind := structOrUnionSpec.StructOrUnion.Token.Value.String()
					decls = append(decls, declData{
						Kind:        declKind(kind),
						Name:        structOrUnionSpec.Token.Value.String(),
						Prototype:   proto,
						Description: desc,
						Filename:    origFilename,
					})
				case cc.TypeSpecifierEnum:
					enumSpec := typeSpec.EnumSpecifier
					decls = append(decls, declData{
						Kind:        declEnum,
						Name:        enumSpec.Token2.Value.String(),
						Prototype:   proto,
						Description: desc,
						Filename:    origFilename,
					})
				}
			}
		} else {
			for idl := decl.InitDeclaratorList; idl != nil; idl = idl.InitDeclaratorList {