mirror of
https://github.com/mappu/miqt.git
synced 2024-12-23 01:18:37 +00:00
genbindings/typedefs: collect child class typedefs
This commit is contained in:
parent
f6336617a0
commit
02370ce0ea
@ -93,20 +93,11 @@ func parseHeader(topLevel []interface{}) (*CppParsedHeader, error) {
|
|||||||
// Should be treated like a typedef
|
// Should be treated like a typedef
|
||||||
|
|
||||||
case "TypedefDecl":
|
case "TypedefDecl":
|
||||||
// Must have a name
|
td, err := processTypedef(node, "")
|
||||||
nodename, ok := node["name"].(string)
|
if err != nil {
|
||||||
if !ok {
|
return nil, fmt.Errorf("processTypedef: %w", err)
|
||||||
return nil, errors.New("node has no name")
|
|
||||||
}
|
|
||||||
|
|
||||||
if typ, ok := node["type"].(map[string]interface{}); ok {
|
|
||||||
if qualType, ok := typ["qualType"].(string); ok {
|
|
||||||
ret.Typedefs = append(ret.Typedefs, CppTypedef{
|
|
||||||
Alias: nodename,
|
|
||||||
UnderlyingType: qualType,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
ret.Typedefs = append(ret.Typedefs, td)
|
||||||
|
|
||||||
case "CXXMethodDecl":
|
case "CXXMethodDecl":
|
||||||
// A C++ class method implementation directly in the header
|
// A C++ class method implementation directly in the header
|
||||||
@ -120,6 +111,25 @@ func parseHeader(topLevel []interface{}) (*CppParsedHeader, error) {
|
|||||||
return &ret, nil // done
|
return &ret, nil // done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func processTypedef(node map[string]interface{}, addNamePrefix string) (CppTypedef, error) {
|
||||||
|
// Must have a name
|
||||||
|
nodename, ok := node["name"].(string)
|
||||||
|
if !ok {
|
||||||
|
return CppTypedef{}, errors.New("node has no name")
|
||||||
|
}
|
||||||
|
|
||||||
|
if typ, ok := node["type"].(map[string]interface{}); ok {
|
||||||
|
if qualType, ok := typ["qualType"].(string); ok {
|
||||||
|
return CppTypedef{
|
||||||
|
Alias: addNamePrefix + nodename,
|
||||||
|
UnderlyingType: parseSingleTypeString(qualType),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return CppTypedef{}, errors.New("processTypedef: ???")
|
||||||
|
}
|
||||||
|
|
||||||
func processClassType(node map[string]interface{}, addNamePrefix string) (CppClass, error) {
|
func processClassType(node map[string]interface{}, addNamePrefix string) (CppClass, error) {
|
||||||
var ret CppClass
|
var ret CppClass
|
||||||
ret.CanDelete = true
|
ret.CanDelete = true
|
||||||
@ -257,6 +267,14 @@ nextMethod:
|
|||||||
|
|
||||||
ret.ChildClassdefs = append(ret.ChildClassdefs, child)
|
ret.ChildClassdefs = append(ret.ChildClassdefs, child)
|
||||||
|
|
||||||
|
case "TypedefDecl":
|
||||||
|
// Child class typedef
|
||||||
|
td, err := processTypedef(node, nodename+"::")
|
||||||
|
if err != nil {
|
||||||
|
panic(fmt.Errorf("processTypedef: %w", err)) // A real problem
|
||||||
|
}
|
||||||
|
ret.ChildTypedefs = append(ret.ChildTypedefs, td)
|
||||||
|
|
||||||
case "CXXConstructorDecl":
|
case "CXXConstructorDecl":
|
||||||
|
|
||||||
if isImplicit, ok := node["isImplicit"].(bool); ok && isImplicit {
|
if isImplicit, ok := node["isImplicit"].(bool); ok && isImplicit {
|
||||||
|
@ -185,6 +185,7 @@ type CppClass struct {
|
|||||||
Props []CppProperty
|
Props []CppProperty
|
||||||
CanDelete bool
|
CanDelete bool
|
||||||
|
|
||||||
|
ChildTypedefs []CppTypedef
|
||||||
ChildClassdefs []CppClass
|
ChildClassdefs []CppClass
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user