2024-08-25 07:08:28 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
// takeChildren recursively takes the children of the class.
|
|
|
|
func takeChildren(c *CppClass) []CppClass {
|
|
|
|
if len(c.ChildClassdefs) == 0 {
|
|
|
|
return []CppClass{}
|
|
|
|
}
|
|
|
|
|
|
|
|
var ret []CppClass
|
|
|
|
for _, child := range c.ChildClassdefs {
|
|
|
|
ret = append(ret, takeChildren(&child)...)
|
|
|
|
|
|
|
|
child.ChildClassdefs = nil
|
|
|
|
ret = append(ret, child)
|
|
|
|
}
|
|
|
|
c.ChildClassdefs = nil
|
|
|
|
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
|
|
|
// astTransformChildClasses expands all classes with child class definitions
|
|
|
|
// into new top-level entries within the header.
|
|
|
|
func astTransformChildClasses(parsed *CppParsedHeader) {
|
|
|
|
var taken []CppClass
|
|
|
|
|
2024-08-26 10:49:33 +00:00
|
|
|
for i, c := range parsed.Classes {
|
2024-09-20 23:02:05 +00:00
|
|
|
|
|
|
|
nestedClasses := takeChildren(&parsed.Classes[i])
|
|
|
|
|
|
|
|
taken = append(taken, nestedClasses...)
|
2024-08-26 10:49:33 +00:00
|
|
|
|
|
|
|
// Also lift all child typedefs and enums
|
|
|
|
parsed.Typedefs = append(parsed.Typedefs, c.ChildTypedefs...)
|
|
|
|
parsed.Enums = append(parsed.Enums, c.ChildEnums...)
|
2024-09-20 23:02:05 +00:00
|
|
|
for _, nc := range nestedClasses {
|
|
|
|
parsed.Typedefs = append(parsed.Typedefs, nc.ChildTypedefs...)
|
|
|
|
parsed.Enums = append(parsed.Enums, nc.ChildEnums...)
|
|
|
|
}
|
2024-08-25 07:08:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
parsed.Classes = append(parsed.Classes, taken...)
|
2024-08-26 10:49:33 +00:00
|
|
|
|
2024-08-25 07:08:28 +00:00
|
|
|
}
|