Return Golang bools from Objective-C functions that return BOOL.
Move nswrap command to cmd/nswrap.
This commit is contained in:
parent
717c7e76fe
commit
959b87342e
|
@ -168,8 +168,15 @@ func Start() (err error) {
|
||||||
// If clang fails it still prints out the AST, so we have to run it
|
// If clang fails it still prints out the AST, so we have to run it
|
||||||
// again to get the real error.
|
// again to get the real error.
|
||||||
//errBody, _ := exec.Command("clang", cargs...).CombinedOutput()
|
//errBody, _ := exec.Command("clang", cargs...).CombinedOutput()
|
||||||
|
var txt string
|
||||||
panic("clang failed: " + err.Error() + ":\n\n")
|
switch x := err.(type) {
|
||||||
|
case *exec.ExitError:
|
||||||
|
txt = string(x.Stderr)
|
||||||
|
default:
|
||||||
|
txt = err.Error()
|
||||||
|
}
|
||||||
|
fmt.Printf("clang failed:\n%s\n", txt)
|
||||||
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
|
|
||||||
lines := readAST(astPP)
|
lines := readAST(astPP)
|
|
@ -350,7 +350,12 @@ func GoToC(name string, pnames []string, rtype *Type, ptypes []*Type) string {
|
||||||
if IsGoInterface(rtgt) {
|
if IsGoInterface(rtgt) {
|
||||||
rtgt = "*Id"
|
rtgt = "*Id"
|
||||||
}
|
}
|
||||||
|
if rtgt == "BOOL" {
|
||||||
|
ret.WriteString("return (")
|
||||||
|
rtgt = "bool"
|
||||||
|
} else {
|
||||||
ret.WriteString("return (" + rtgt + ")(")
|
ret.WriteString("return (" + rtgt + ")(")
|
||||||
|
}
|
||||||
if rtype.IsPointer() {
|
if rtype.IsPointer() {
|
||||||
ret.WriteString("unsafe.Pointer(")
|
ret.WriteString("unsafe.Pointer(")
|
||||||
}
|
}
|
||||||
|
@ -382,6 +387,9 @@ func GoToC(name string, pnames []string, rtype *Type, ptypes []*Type) string {
|
||||||
ret.WriteString(")")
|
ret.WriteString(")")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if rt == "BOOL" {
|
||||||
|
ret.WriteString(" != 0")
|
||||||
|
}
|
||||||
return ret.String()
|
return ret.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -610,6 +610,9 @@ func (w *Wrapper) _processMethod(m *Method,fun bool) {
|
||||||
if types.IsGoInterface(grtype) {
|
if types.IsGoInterface(grtype) {
|
||||||
grtype = "*Id"
|
grtype = "*Id"
|
||||||
}
|
}
|
||||||
|
if grtype == "BOOL" { // convert objective-c bools to Go bools
|
||||||
|
grtype = "bool"
|
||||||
|
}
|
||||||
if gname == grtype { // avoid name conflicts between methods and types
|
if gname == grtype { // avoid name conflicts between methods and types
|
||||||
gname = "Get" + gname
|
gname = "Get" + gname
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user