mirror of
https://github.com/mappu/miqt.git
synced 2024-12-23 01:18:37 +00:00
genbindings: find all Qt types for PVOID typedefs, not just direct classes
This commit is contained in:
parent
2dc9d1bab7
commit
8f266f5202
@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -80,8 +81,41 @@ extern "C" {
|
|||||||
|
|
||||||
`)
|
`)
|
||||||
|
|
||||||
|
// Find all referenced Qt types in this file, and generate PVoid typedefs
|
||||||
|
// for them
|
||||||
|
foundTypes := map[string]struct{}{}
|
||||||
|
for _, c := range src.Classes {
|
||||||
|
foundTypes[c.ClassName] = struct{}{}
|
||||||
|
for _, ctor := range c.Ctors {
|
||||||
|
for _, p := range ctor.Parameters {
|
||||||
|
if p.QtClassType() {
|
||||||
|
foundTypes[p.ParameterType] = struct{}{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, m := range c.Methods {
|
||||||
|
for _, p := range m.Parameters {
|
||||||
|
if p.QtClassType() {
|
||||||
|
foundTypes[p.ParameterType] = struct{}{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if m.ReturnType.QtClassType() {
|
||||||
|
foundTypes[m.ReturnType.ParameterType] = struct{}{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foundTypesList := make([]string, 0, len(foundTypes))
|
||||||
|
for ft := range foundTypes {
|
||||||
|
foundTypesList = append(foundTypesList, ft)
|
||||||
|
}
|
||||||
|
sort.Strings(foundTypesList)
|
||||||
|
for _, ft := range foundTypesList {
|
||||||
|
ret.WriteString(`typedef void* P` + ft + ";\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
ret.WriteString("\n")
|
||||||
|
|
||||||
for _, c := range src.Classes {
|
for _, c := range src.Classes {
|
||||||
ret.WriteString(`typedef void* P` + c.ClassName + ";\n\n")
|
|
||||||
|
|
||||||
for i, ctor := range c.Ctors {
|
for i, ctor := range c.Ctors {
|
||||||
ret.WriteString(fmt.Sprintf("P%s %s_new%s(%s);\n", c.ClassName, maybeSuffix(i), emitParametersCpp(ctor.Parameters, "")))
|
ret.WriteString(fmt.Sprintf("P%s %s_new%s(%s);\n", c.ClassName, maybeSuffix(i), emitParametersCpp(ctor.Parameters, "")))
|
||||||
|
Loading…
Reference in New Issue
Block a user