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
|
@ -167,9 +167,16 @@ func Start() (err error) {
|
|||
if err != nil {
|
||||
// If clang fails it still prints out the AST, so we have to run it
|
||||
// again to get the real error.
|
||||
// errBody, _ := exec.Command("clang", cargs...).CombinedOutput()
|
||||
|
||||
panic("clang failed: " + err.Error() + ":\n\n")
|
||||
//errBody, _ := exec.Command("clang", cargs...).CombinedOutput()
|
||||
var txt string
|
||||
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)
|
|
@ -350,7 +350,12 @@ func GoToC(name string, pnames []string, rtype *Type, ptypes []*Type) string {
|
|||
if IsGoInterface(rtgt) {
|
||||
rtgt = "*Id"
|
||||
}
|
||||
if rtgt == "BOOL" {
|
||||
ret.WriteString("return (")
|
||||
rtgt = "bool"
|
||||
} else {
|
||||
ret.WriteString("return (" + rtgt + ")(")
|
||||
}
|
||||
if rtype.IsPointer() {
|
||||
ret.WriteString("unsafe.Pointer(")
|
||||
}
|
||||
|
@ -382,6 +387,9 @@ func GoToC(name string, pnames []string, rtype *Type, ptypes []*Type) string {
|
|||
ret.WriteString(")")
|
||||
}
|
||||
}
|
||||
if rt == "BOOL" {
|
||||
ret.WriteString(" != 0")
|
||||
}
|
||||
return ret.String()
|
||||
}
|
||||
|
||||
|
|
|
@ -610,6 +610,9 @@ func (w *Wrapper) _processMethod(m *Method,fun bool) {
|
|||
if types.IsGoInterface(grtype) {
|
||||
grtype = "*Id"
|
||||
}
|
||||
if grtype == "BOOL" { // convert objective-c bools to Go bools
|
||||
grtype = "bool"
|
||||
}
|
||||
if gname == grtype { // avoid name conflicts between methods and types
|
||||
gname = "Get" + gname
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user