diff --git a/main.go b/cmd/nswrap/main.go similarity index 95% rename from main.go rename to cmd/nswrap/main.go index 7321300..9bc6e77 100644 --- a/main.go +++ b/cmd/nswrap/main.go @@ -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) diff --git a/types/convert.go b/types/convert.go index 9fe3300..7f42661 100644 --- a/types/convert.go +++ b/types/convert.go @@ -350,7 +350,12 @@ func GoToC(name string, pnames []string, rtype *Type, ptypes []*Type) string { if IsGoInterface(rtgt) { rtgt = "*Id" } - ret.WriteString("return (" + rtgt + ")(") + 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() } diff --git a/wrap/main.go b/wrap/main.go index 7c63dff..f4bba42 100644 --- a/wrap/main.go +++ b/wrap/main.go @@ -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 }