mirror of
https://github.com/mappu/miqt.git
synced 2025-01-03 14:18:37 +00:00
genbindings: refactor class handling
This commit is contained in:
parent
aaa9340808
commit
c06acd0a1b
@ -33,23 +33,19 @@ func parseHeader(inner []interface{}) (*CppParsedHeader, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("-> %q name=%q\n", kind, nodename)
|
fmt.Printf("-> %q name=%q\n", kind, nodename)
|
||||||
if classInner, ok := node["inner"].([]interface{}); ok {
|
|
||||||
|
|
||||||
// Check if this was 'struct' (default visible) or 'class' (default invisible)
|
if _, ok := node["inner"]; !ok {
|
||||||
visible := true
|
continue // Forward class declaration only, do not include
|
||||||
if tagUsed, ok := node["tagUsed"].(string); ok && tagUsed == "class" {
|
|
||||||
visible = false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Process the inner class definition
|
|
||||||
obj, err := processType(classInner, nodename, visible)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
ret.Classes = append(ret.Classes, obj)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Process the inner class definition
|
||||||
|
obj, err := processClassType(node, nodename)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
ret.Classes = append(ret.Classes, obj)
|
||||||
|
|
||||||
case "StaticAssertDecl":
|
case "StaticAssertDecl":
|
||||||
// ignore
|
// ignore
|
||||||
|
|
||||||
@ -61,10 +57,17 @@ func parseHeader(inner []interface{}) (*CppParsedHeader, error) {
|
|||||||
return &ret, nil // done
|
return &ret, nil // done
|
||||||
}
|
}
|
||||||
|
|
||||||
func processType(inner []interface{}, className string, visibility bool) (CppClass, error) {
|
func processClassType(node map[string]interface{}, className string) (CppClass, error) {
|
||||||
var ret CppClass
|
var ret CppClass
|
||||||
ret.ClassName = className
|
ret.ClassName = className
|
||||||
|
|
||||||
|
inner, _ := node["inner"].([]interface{}) // Cannot fail, the parent call already checked that `inner` was present
|
||||||
|
|
||||||
|
// Check if this was 'struct' (default visible) or 'class' (default invisible)
|
||||||
|
visibility := true
|
||||||
|
if tagUsed, ok := node["tagUsed"].(string); ok && tagUsed == "class" {
|
||||||
|
visibility = false
|
||||||
|
}
|
||||||
nextMethod:
|
nextMethod:
|
||||||
for _, node := range inner {
|
for _, node := range inner {
|
||||||
node, ok := node.(map[string]interface{})
|
node, ok := node.(map[string]interface{})
|
||||||
@ -97,6 +100,9 @@ nextMethod:
|
|||||||
case "FriendDecl":
|
case "FriendDecl":
|
||||||
// Safe to ignore
|
// Safe to ignore
|
||||||
|
|
||||||
|
case "VisibilityAttr":
|
||||||
|
// These seem to have no useful content
|
||||||
|
|
||||||
case "CXXConstructorDecl":
|
case "CXXConstructorDecl":
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,6 +69,7 @@ func (nm CppMethod) SafeMethodName() string {
|
|||||||
|
|
||||||
type CppClass struct {
|
type CppClass struct {
|
||||||
ClassName string
|
ClassName string
|
||||||
|
Abstract bool
|
||||||
Ctors []CppMethod // only use the parameters
|
Ctors []CppMethod // only use the parameters
|
||||||
Extends []string
|
Extends []string
|
||||||
Methods []CppMethod
|
Methods []CppMethod
|
||||||
|
Loading…
Reference in New Issue
Block a user