Add experimental "arc" directive to nswrap.yaml to experiment
with enabling Objective-C automatic reference counting. Bindings currently will not compile with this turned on.
This commit is contained in:
parent
5a5a4f9406
commit
e29ae58a9c
5
main.go
5
main.go
|
@ -33,6 +33,8 @@ type conf struct {
|
|||
Sysimports []string
|
||||
Pragma []string
|
||||
Vaargs int
|
||||
//Arc flag for debugging only, builds will break
|
||||
Arc bool
|
||||
}
|
||||
|
||||
var Config conf
|
||||
|
@ -190,6 +192,9 @@ func Start() (err error) {
|
|||
if Config.Positions {
|
||||
ast.TrackPositions = true
|
||||
}
|
||||
if Config.Arc {
|
||||
wrap.Arc = true
|
||||
}
|
||||
//NOTE: converting in parallel is slower on my system
|
||||
//nodes := convertLinesToNodesParallel(lines)
|
||||
nodes := convertLinesToNodes(lines)
|
||||
|
|
16
wrap/main.go
16
wrap/main.go
|
@ -15,6 +15,8 @@ import (
|
|||
|
||||
var (
|
||||
Debug = false
|
||||
// Arc flag is for debugging only, your builds will break if you turn it on
|
||||
Arc = false
|
||||
)
|
||||
|
||||
type Wrapper struct {
|
||||
|
@ -55,9 +57,13 @@ func NewWrapper(debug bool) *Wrapper {
|
|||
ProcessedClassMethods: map[string]bool{},
|
||||
Vaargs: 16,
|
||||
}
|
||||
arc := " -fno-objc-arc"
|
||||
if Arc {
|
||||
arc = " -fobjc-arc"
|
||||
}
|
||||
ret.cgoFlags.WriteString(fmt.Sprintf(`/*
|
||||
#cgo CFLAGS: -x objective-c
|
||||
`))
|
||||
#cgo CFLAGS: -x objective-c%s
|
||||
`,arc))
|
||||
ret.goTypes.WriteString(`
|
||||
type Id struct {
|
||||
ptr unsafe.Pointer
|
||||
|
@ -432,6 +438,12 @@ func (w *Wrapper) AddProtocol(n *ast.ObjCProtocolDecl) {
|
|||
for _,c := range n.Children() {
|
||||
switch x := c.(type) {
|
||||
case *ast.ObjCMethodDecl:
|
||||
if Arc {
|
||||
switch x.Name {
|
||||
case "retain","release","autorelease":
|
||||
continue
|
||||
}
|
||||
}
|
||||
if x.ClassMethod {
|
||||
w.AddMethod(p.ClassMethods,x)
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue
Block a user