mirror of
https://github.com/netbirdio/gomobile-tvos-fork.git
synced 2026-05-22 18:43:29 -07:00
bind: add missing unsafe import in generated code
The ClassGen.genGo function always uses unsafe, contrary to what the check in GenGo says. With this CL, generated code always imports unsafe if there are any classes to be generated. Change-Id: Ic807111a26e494b4941790830b1950bb8b1f73d5 Reviewed-on: https://go-review.googlesource.com/29873 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This commit is contained in:
+1
-3
@@ -162,18 +162,16 @@ func (g *ClassGen) GenPackage(idx int) {
|
||||
|
||||
func (g *ClassGen) GenGo() {
|
||||
g.Printf(classesGoHeader)
|
||||
impUnsafe := false
|
||||
for _, cls := range g.classes {
|
||||
for _, f := range cls.Funcs {
|
||||
if f.Public && g.isFuncSupported(f) {
|
||||
impUnsafe = true
|
||||
pkgName := strings.Replace(cls.Name, ".", "/", -1)
|
||||
g.Printf("import %q\n", "Java/"+pkgName)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if impUnsafe {
|
||||
if len(g.classes) > 0 {
|
||||
g.Printf("import \"unsafe\"\n\n")
|
||||
}
|
||||
g.Printf("type proxy interface { Bind_proxy_refnum__() int32 }\n\n")
|
||||
|
||||
Vendored
+2
@@ -44,6 +44,8 @@ import (
|
||||
_seq "golang.org/x/mobile/bind/seq"
|
||||
)
|
||||
|
||||
import "unsafe"
|
||||
|
||||
type proxy interface { Bind_proxy_refnum__() int32 }
|
||||
|
||||
// Suppress unused package error
|
||||
|
||||
Vendored
+2
@@ -39,6 +39,8 @@ import (
|
||||
_seq "golang.org/x/mobile/bind/seq"
|
||||
)
|
||||
|
||||
import "unsafe"
|
||||
|
||||
type proxy interface { Bind_proxy_refnum__() int32 }
|
||||
|
||||
// Suppress unused package error
|
||||
|
||||
Reference in New Issue
Block a user