From a42111704963f4f0d1266674e1e97489aa8dcca0 Mon Sep 17 00:00:00 2001 From: Steeve Morin Date: Sat, 26 Jan 2019 17:25:49 +0000 Subject: [PATCH] bind: always include ref.h in generated ObjC headers Current generated headers work because they require `ref.h` to be loaded beforehand by the bridging header. However, in some cases where the bridging header is generated by another tool (such as Bazel), the order can't be guaranteed. Fix that by explicitly importing `ref.h` in the headers that need it. Change-Id: I444453a0ebdf53e14ba1b5290f7cc7084eaf2c07 GitHub-Last-Rev: e1e1e915bf0428d871cb1a268c8456cf7051d383 GitHub-Pull-Request: golang/mobile#28 Reviewed-on: https://go-review.googlesource.com/c/159758 Reviewed-by: Elias Naur --- bind/genobjc.go | 1 + bind/testdata/basictypes.objc.h.golden | 1 + bind/testdata/customprefix.objc.h.golden | 1 + bind/testdata/customprefixEX.objc.h.golden | 1 + bind/testdata/doc.objc.h.golden | 1 + bind/testdata/ignore.objc.h.golden | 1 + bind/testdata/interfaces.objc.h.golden | 1 + bind/testdata/issue10788.objc.h.golden | 1 + bind/testdata/issue12328.objc.h.golden | 1 + bind/testdata/issue12403.objc.h.golden | 1 + bind/testdata/issue29559.objc.h.golden | 1 + bind/testdata/keywords.objc.h.golden | 1 + bind/testdata/structs.objc.h.golden | 1 + bind/testdata/try.objc.h.golden | 1 + bind/testdata/underscores.objc.h.golden | 1 + bind/testdata/universe.objc.h.golden | 1 + bind/testdata/vars.objc.h.golden | 1 + 17 files changed, 17 insertions(+) diff --git a/bind/genobjc.go b/bind/genobjc.go index 63be71c..573dffc 100644 --- a/bind/genobjc.go +++ b/bind/genobjc.go @@ -149,6 +149,7 @@ func (g *ObjcGen) GenH() error { for _, m := range g.modules { g.Printf("@import %s;\n", m) } + g.Printf("#include \"ref.h\"\n") if g.Pkg != nil { g.Printf("#include \"Universe.objc.h\"\n\n") } diff --git a/bind/testdata/basictypes.objc.h.golden b/bind/testdata/basictypes.objc.h.golden index 63d28d1..eaffdb2 100644 --- a/bind/testdata/basictypes.objc.h.golden +++ b/bind/testdata/basictypes.objc.h.golden @@ -7,6 +7,7 @@ #define __Basictypes_H__ @import Foundation; +#include "ref.h" #include "Universe.objc.h" diff --git a/bind/testdata/customprefix.objc.h.golden b/bind/testdata/customprefix.objc.h.golden index 8e098b4..ec805b2 100644 --- a/bind/testdata/customprefix.objc.h.golden +++ b/bind/testdata/customprefix.objc.h.golden @@ -7,6 +7,7 @@ #define __Customprefix_H__ @import Foundation; +#include "ref.h" #include "Universe.objc.h" diff --git a/bind/testdata/customprefixEX.objc.h.golden b/bind/testdata/customprefixEX.objc.h.golden index 167d4cc..058f9ef 100644 --- a/bind/testdata/customprefixEX.objc.h.golden +++ b/bind/testdata/customprefixEX.objc.h.golden @@ -7,6 +7,7 @@ #define __EXCustomprefix_H__ @import Foundation; +#include "ref.h" #include "Universe.objc.h" diff --git a/bind/testdata/doc.objc.h.golden b/bind/testdata/doc.objc.h.golden index b87c6d1..11d01a7 100644 --- a/bind/testdata/doc.objc.h.golden +++ b/bind/testdata/doc.objc.h.golden @@ -7,6 +7,7 @@ #define __Doc_H__ @import Foundation; +#include "ref.h" #include "Universe.objc.h" diff --git a/bind/testdata/ignore.objc.h.golden b/bind/testdata/ignore.objc.h.golden index 3004348..98df76c 100644 --- a/bind/testdata/ignore.objc.h.golden +++ b/bind/testdata/ignore.objc.h.golden @@ -7,6 +7,7 @@ #define __Ignore_H__ @import Foundation; +#include "ref.h" #include "Universe.objc.h" diff --git a/bind/testdata/interfaces.objc.h.golden b/bind/testdata/interfaces.objc.h.golden index c54288e..f78b482 100644 --- a/bind/testdata/interfaces.objc.h.golden +++ b/bind/testdata/interfaces.objc.h.golden @@ -7,6 +7,7 @@ #define __Interfaces_H__ @import Foundation; +#include "ref.h" #include "Universe.objc.h" diff --git a/bind/testdata/issue10788.objc.h.golden b/bind/testdata/issue10788.objc.h.golden index 952a9eb..751e5d9 100644 --- a/bind/testdata/issue10788.objc.h.golden +++ b/bind/testdata/issue10788.objc.h.golden @@ -7,6 +7,7 @@ #define __Issue10788_H__ @import Foundation; +#include "ref.h" #include "Universe.objc.h" diff --git a/bind/testdata/issue12328.objc.h.golden b/bind/testdata/issue12328.objc.h.golden index d5699bc..cf77c41 100644 --- a/bind/testdata/issue12328.objc.h.golden +++ b/bind/testdata/issue12328.objc.h.golden @@ -7,6 +7,7 @@ #define __Issue12328_H__ @import Foundation; +#include "ref.h" #include "Universe.objc.h" diff --git a/bind/testdata/issue12403.objc.h.golden b/bind/testdata/issue12403.objc.h.golden index 03ba5ea..b617237 100644 --- a/bind/testdata/issue12403.objc.h.golden +++ b/bind/testdata/issue12403.objc.h.golden @@ -7,6 +7,7 @@ #define __Issue12403_H__ @import Foundation; +#include "ref.h" #include "Universe.objc.h" diff --git a/bind/testdata/issue29559.objc.h.golden b/bind/testdata/issue29559.objc.h.golden index 412eed1..0ce3cf8 100644 --- a/bind/testdata/issue29559.objc.h.golden +++ b/bind/testdata/issue29559.objc.h.golden @@ -7,6 +7,7 @@ #define __Issue29559_H__ @import Foundation; +#include "ref.h" #include "Universe.objc.h" diff --git a/bind/testdata/keywords.objc.h.golden b/bind/testdata/keywords.objc.h.golden index 1ca7325..8ebd53d 100644 --- a/bind/testdata/keywords.objc.h.golden +++ b/bind/testdata/keywords.objc.h.golden @@ -7,6 +7,7 @@ #define __Keywords_H__ @import Foundation; +#include "ref.h" #include "Universe.objc.h" diff --git a/bind/testdata/structs.objc.h.golden b/bind/testdata/structs.objc.h.golden index 6abbcd4..f53802c 100644 --- a/bind/testdata/structs.objc.h.golden +++ b/bind/testdata/structs.objc.h.golden @@ -7,6 +7,7 @@ #define __Structs_H__ @import Foundation; +#include "ref.h" #include "Universe.objc.h" diff --git a/bind/testdata/try.objc.h.golden b/bind/testdata/try.objc.h.golden index f5c9a48..7045c6b 100644 --- a/bind/testdata/try.objc.h.golden +++ b/bind/testdata/try.objc.h.golden @@ -7,6 +7,7 @@ #define __Try_H__ @import Foundation; +#include "ref.h" #include "Universe.objc.h" diff --git a/bind/testdata/underscores.objc.h.golden b/bind/testdata/underscores.objc.h.golden index 12606fe..302b30f 100644 --- a/bind/testdata/underscores.objc.h.golden +++ b/bind/testdata/underscores.objc.h.golden @@ -7,6 +7,7 @@ #define __Underscore_pkg_H__ @import Foundation; +#include "ref.h" #include "Universe.objc.h" diff --git a/bind/testdata/universe.objc.h.golden b/bind/testdata/universe.objc.h.golden index e47f716..ce2b08c 100644 --- a/bind/testdata/universe.objc.h.golden +++ b/bind/testdata/universe.objc.h.golden @@ -7,6 +7,7 @@ #define __Universe_H__ @import Foundation; +#include "ref.h" @protocol Universeerror; @class Universeerror; diff --git a/bind/testdata/vars.objc.h.golden b/bind/testdata/vars.objc.h.golden index 666e16d..d5964a8 100644 --- a/bind/testdata/vars.objc.h.golden +++ b/bind/testdata/vars.objc.h.golden @@ -7,6 +7,7 @@ #define __Vars_H__ @import Foundation; +#include "ref.h" #include "Universe.objc.h"