Improve type handling for enums. Handle "__kindof" qualifiers.

Add examples/app. Allow VisibilityAttr "Hidden".
This commit is contained in:
gmp
2019-05-06 13:21:36 -04:00
parent 959b87342e
commit 511f2f1968
12 changed files with 105 additions and 24 deletions
+3 -2
View File
@@ -103,8 +103,6 @@ func clean(n *Node,c string) (*Node,bool) {
recur = ret.renameTypedefs(k,v)
}
}
// recur = recur || ret.renameTypedefs("instancename",c)
// recur = recur || ret.renameTypedefs("instancetype",c + "*")
if recur {
clean(n, c)
return ret,true
@@ -199,6 +197,9 @@ func _goType(ct string) string {
if ct == "Id" {
ct = "*Id"
}
if len(ct) > 4 && ct[len(ct)-4:len(ct)] == "Void" {
ct = ct[:len(ct)-5] + "unsafe.Pointer"
}
return ct
}
+1
View File
@@ -329,6 +329,7 @@ func BareTypedefName(s string, n *Node) (string, *Node) {
func TypedefName(s string, n *Node) (string, *Node) {
return Seq(
Opt(NodeNamed("KindQualifier",Lit("__kindof"))),
BareTypedefName,
Opt(AngBracketed(GenericList)),
Opt(NullableAnnotation),
+14 -5
View File
@@ -120,7 +120,10 @@ func (n *Node) IsStruct() bool {
if n == nil || len(n.Children) < 1 {
return false
}
return n.Children[0].Kind == "Struct"
i := 0
for ; i<len(n.Children) &&
n.Children[i].Kind == "KindQualifier"; i++ {}
return n.Children[i].Kind == "Struct"
}
func (n *Node) IsFunction() bool {
@@ -146,17 +149,23 @@ func (n *Node) IsId() bool {
if n == nil || len(n.Children) < 1 {
return false
}
i := 0
for ; i < len(n.Children) &&
n.Children[i].Kind == "KindQualifier"; i++ {}
return !n.IsFunction() &&
n.Children[0].Kind == "TypedefName" &&
n.Children[0].Content == "id"
n.Children[i].Kind == "TypedefName" &&
n.Children[i].Content == "id"
}
func (n *Node) IsInstancetype() bool {
if n == nil || len(n.Children) < 1 {
return false
}
return n.Children[0].Kind == "TypedefName" &&
n.Children[0].Content == "instancetype"
i := 0
for ; i < len(n.Children) &&
n.Children[i].Kind == "KindQualifier"; i++ {}
return n.Children[i].Kind == "TypedefName" &&
n.Children[i].Content == "instancetype"
}
//BaseType strips off all layers of pointer indirection
+1
View File
@@ -88,6 +88,7 @@ func (n *Node) renameTypedefs(a,b string) (ret bool) {
func (n *Node) CtypeSimplified() string {
ignore := map[string]bool{
"NullableAnnotation": true,
"KindQualifier": true,
"TypeQualifier": true,
"GenericList": true,
}