bind: fix reverse binding generation on Windows
The filepath package works on native paths, not package paths. Replace
it with the path package. Do it for Objective-C as well, for correctness.
No new tests; the existing reverse tests fails on Windows without
this CL.
Change-Id: I8963db992d4bed30e8828579fb83ecaf8c9d9ade
Reviewed-on: https://go-review.googlesource.com/35176
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
diff --git a/bind/genclasses.go b/bind/genclasses.go
index 6bb8970..7934506 100644
--- a/bind/genclasses.go
+++ b/bind/genclasses.go
@@ -6,7 +6,7 @@
import (
"fmt"
- "path/filepath"
+ "path"
"strings"
"unicode"
"unicode/utf8"
@@ -111,7 +111,7 @@
g.imported[cls.Name] = struct{}{}
clsPkg := strings.Replace(cls.Name, ".", "/", -1)
g.clsPkgs[clsPkg] = cls
- typePkg := filepath.Dir(clsPkg)
+ typePkg := path.Dir(clsPkg)
g.typePkgs[typePkg] = append(g.typePkgs[typePkg], cls)
if _, exists := pkgSet[clsPkg]; !exists {
pkgSet[clsPkg] = struct{}{}
@@ -132,7 +132,7 @@
func (g *ClassGen) GenPackage(idx int) {
jpkg := g.jpkgs[idx]
g.Printf("// File is generated by gobind. Do not edit.\n\n")
- g.Printf("package %s\n\n", filepath.Base(jpkg))
+ g.Printf("package %s\n\n", path.Base(jpkg))
g.Printf("import \"Java\"\n\n")
g.Printf("const _ = Java.Dummy\n\n")
for _, cls := range g.typePkgs[jpkg] {
diff --git a/bind/genobjcw.go b/bind/genobjcw.go
index 13c510a..6b4b0b0 100644
--- a/bind/genobjcw.go
+++ b/bind/genobjcw.go
@@ -5,7 +5,7 @@
package bind
import (
- "path/filepath"
+ "path"
"strings"
"golang.org/x/mobile/internal/importers/objc"
@@ -535,7 +535,7 @@
func (g *ObjcWrapper) GenPackage(idx int) {
pkg := g.pkgNames[idx]
g.Printf("//File is generated by gobind. Do not edit.\n\n")
- g.Printf("package %s\n\n", filepath.Base(pkg))
+ g.Printf("package %s\n\n", path.Base(pkg))
g.Printf("import \"ObjC\"\n\n")
g.Printf("const _ = ObjC.Dummy\n\n")
for _, n := range g.modMap[pkg] {