mirror of
https://github.com/mappu/miqt.git
synced 2024-12-22 00:48:38 +00:00
genbindings: refactor move state tracker to new file
This commit is contained in:
parent
6ae2235cb4
commit
4fbf4c702a
@ -5,33 +5,6 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
type lookupResultClass struct {
|
||||
PackageName string
|
||||
Class CppClass
|
||||
}
|
||||
|
||||
type lookupResultTypedef struct {
|
||||
PackageName string
|
||||
Typedef CppTypedef
|
||||
}
|
||||
|
||||
type lookupResultEnum struct {
|
||||
PackageName string
|
||||
Enum CppEnum
|
||||
}
|
||||
|
||||
var (
|
||||
KnownClassnames map[string]lookupResultClass // Entries of the form QFoo::Bar if it is an inner class
|
||||
KnownTypedefs map[string]lookupResultTypedef
|
||||
KnownEnums map[string]lookupResultEnum
|
||||
)
|
||||
|
||||
func flushKnownTypes() {
|
||||
KnownClassnames = make(map[string]lookupResultClass)
|
||||
KnownTypedefs = make(map[string]lookupResultTypedef)
|
||||
KnownEnums = make(map[string]lookupResultEnum)
|
||||
}
|
||||
|
||||
type CppParameter struct {
|
||||
ParameterName string
|
||||
ParameterType string
|
||||
|
@ -164,15 +164,7 @@ func generate(packageName string, srcDirs []string, allowHeaderFn func(string) b
|
||||
atr.Process(parsed)
|
||||
|
||||
// Update global state tracker (AFTER astTransformChildClasses)
|
||||
for _, c := range parsed.Classes {
|
||||
KnownClassnames[c.ClassName] = lookupResultClass{packageName, c /* copy */}
|
||||
}
|
||||
for _, td := range parsed.Typedefs {
|
||||
KnownTypedefs[td.Alias] = lookupResultTypedef{packageName, td /* copy */}
|
||||
}
|
||||
for _, en := range parsed.Enums {
|
||||
KnownEnums[en.EnumName] = lookupResultEnum{packageName, en /* copy */}
|
||||
}
|
||||
addKnownTypes(packageName, parsed)
|
||||
|
||||
processHeaders = append(processHeaders, parsed)
|
||||
}
|
||||
|
40
cmd/genbindings/statetracker.go
Normal file
40
cmd/genbindings/statetracker.go
Normal file
@ -0,0 +1,40 @@
|
||||
package main
|
||||
|
||||
type lookupResultClass struct {
|
||||
PackageName string
|
||||
Class *CppClass
|
||||
}
|
||||
|
||||
type lookupResultTypedef struct {
|
||||
PackageName string
|
||||
Typedef CppTypedef
|
||||
}
|
||||
|
||||
type lookupResultEnum struct {
|
||||
PackageName string
|
||||
Enum CppEnum
|
||||
}
|
||||
|
||||
var (
|
||||
KnownClassnames map[string]lookupResultClass // Entries of the form QFoo::Bar if it is an inner class
|
||||
KnownTypedefs map[string]lookupResultTypedef
|
||||
KnownEnums map[string]lookupResultEnum
|
||||
)
|
||||
|
||||
func flushKnownTypes() {
|
||||
KnownClassnames = make(map[string]lookupResultClass)
|
||||
KnownTypedefs = make(map[string]lookupResultTypedef)
|
||||
KnownEnums = make(map[string]lookupResultEnum)
|
||||
}
|
||||
|
||||
func addKnownTypes(packageName string, parsed *CppParsedHeader) {
|
||||
for i, c := range parsed.Classes {
|
||||
KnownClassnames[c.ClassName] = lookupResultClass{packageName, &parsed.Classes[i] /* reference */}
|
||||
}
|
||||
for _, td := range parsed.Typedefs {
|
||||
KnownTypedefs[td.Alias] = lookupResultTypedef{packageName, td /* copy */}
|
||||
}
|
||||
for _, en := range parsed.Enums {
|
||||
KnownEnums[en.EnumName] = lookupResultEnum{packageName, en /* copy */}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user