Generate go and objc wrapper functions. Translate classes into wrapped

unsafe.Pointer() instances. Embed super-class to simulate inheritance
and hold pointers only at the base class.
This commit is contained in:
gmp
2019-04-10 14:00:48 -04:00
parent bcb4a0680d
commit 2fbd9134a0
6 changed files with 309 additions and 34 deletions
+3 -1
View File
@@ -188,12 +188,14 @@ func Parse(fullline string) Node {
return parseNotTailCalledAttr(line)
case "ObjCCategoryDecl":
return parseObjCCategoryDecl(line)
case "ObjCImplementation":
return parseObjCImplementation(line)
case "ObjCInterface":
return parseObjCInterface(line)
case "ObjCInterfaceType":
return parseObjCInterfaceType(line)
case "super ObjCInterface":
return parseObjCInterface(line)
return parseSuperObjCInterface(line)
case "ObjCInterfaceDecl":
return parseObjCInterfaceDecl(line)
case "getter ObjCMethod":
+44
View File
@@ -0,0 +1,44 @@
package ast
// ObjCImplementation is an Objective-C implementation
type ObjCImplementation struct {
Addr Address
Name string
ChildNodes []Node
}
func parseObjCImplementation(line string) *ObjCImplementation {
groups := groupsFromRegex(
"'(?P<name>.*)'",
line,
)
return &ObjCImplementation{
Addr: ParseAddress(groups["address"]),
Name: groups["name"],
ChildNodes: []Node{},
}
}
// AddChild adds a new child node. Child nodes can then be accessed with the
// Children attribute.
func (n *ObjCImplementation) AddChild(node Node) {
n.ChildNodes = append(n.ChildNodes, node)
}
// Address returns the numeric address of the node. See the documentation for
// the Address type for more information.
func (n *ObjCImplementation) Address() Address {
return n.Addr
}
// Children returns the child nodes. If this node does not have any children or
// this node does not support children it will always return an empty slice.
func (n *ObjCImplementation) Children() []Node {
return n.ChildNodes
}
// Position returns the position in the original source code.
func (n *ObjCImplementation) Position() Position {
return Position{}
}
+8
View File
@@ -4,9 +4,16 @@ package ast
type ObjCInterface struct {
Addr Address
Name string
Super bool
ChildNodes []Node
}
func parseSuperObjCInterface(line string) *ObjCInterface {
ret := parseObjCInterface(line)
ret.Super = true
return ret
}
func parseObjCInterface(line string) *ObjCInterface {
groups := groupsFromRegex(
"'(?P<name>.*)'",
@@ -16,6 +23,7 @@ func parseObjCInterface(line string) *ObjCInterface {
return &ObjCInterface{
Addr: ParseAddress(groups["address"]),
Name: groups["name"],
Super: false,
ChildNodes: []Node{},
}
}