bind: error for packages with no exported names.
For error message improvement mentioned in golang/go#12842 Change-Id: I066ae9dc9415b34bf93128098199bbb935b7dedc Reviewed-on: https://go-review.googlesource.com/15410 Reviewed-by: David Crawshaw <crawshaw@golang.org>
This commit is contained in:
Родитель
45ed283c80
Коммит
bb506cefe4
|
@ -401,11 +401,14 @@ func (g *goGen) gen() error {
|
|||
|
||||
scope := g.pkg.Scope()
|
||||
names := scope.Names()
|
||||
|
||||
hasExported := false
|
||||
for _, name := range names {
|
||||
obj := scope.Lookup(name)
|
||||
if !obj.Exported() {
|
||||
continue
|
||||
}
|
||||
hasExported = true
|
||||
|
||||
switch obj := obj.(type) {
|
||||
// TODO(crawshaw): case *types.Var:
|
||||
|
@ -433,6 +436,9 @@ func (g *goGen) gen() error {
|
|||
continue
|
||||
}
|
||||
}
|
||||
if !hasExported {
|
||||
g.errorf("no exported names in the package %q", g.pkg.Path())
|
||||
}
|
||||
|
||||
if len(funcs) > 0 {
|
||||
g.Printf("func init() {\n")
|
||||
|
|
|
@ -668,11 +668,13 @@ func (g *javaGen) gen() error {
|
|||
|
||||
scope := g.pkg.Scope()
|
||||
names := scope.Names()
|
||||
hasExported := false
|
||||
for _, name := range names {
|
||||
obj := scope.Lookup(name)
|
||||
if !obj.Exported() {
|
||||
continue
|
||||
}
|
||||
hasExported = true
|
||||
|
||||
switch o := obj.(type) {
|
||||
// TODO(crawshaw): case *types.Var:
|
||||
|
@ -700,6 +702,9 @@ func (g *javaGen) gen() error {
|
|||
g.errorf("unsupported exported type: %T", obj)
|
||||
}
|
||||
}
|
||||
if !hasExported {
|
||||
g.errorf("no exported names in the package %q", g.pkg.Path())
|
||||
}
|
||||
|
||||
for i, name := range funcs {
|
||||
g.Printf("private static final int CALL_%s = %d;\n", name, i+1)
|
||||
|
|
|
@ -39,11 +39,13 @@ func (g *objcGen) init() {
|
|||
g.names = nil
|
||||
|
||||
scope := g.pkg.Scope()
|
||||
hasExported := false
|
||||
for _, name := range scope.Names() {
|
||||
obj := scope.Lookup(name)
|
||||
if !obj.Exported() {
|
||||
continue
|
||||
}
|
||||
hasExported = true
|
||||
switch obj := obj.(type) {
|
||||
case *types.Func:
|
||||
if isCallable(obj) {
|
||||
|
@ -63,6 +65,9 @@ func (g *objcGen) init() {
|
|||
g.errorf("unsupported exported type for %s: %T", obj.Name(), obj)
|
||||
}
|
||||
}
|
||||
if !hasExported {
|
||||
g.errorf("no exported names in the package %q", g.pkg.Path())
|
||||
}
|
||||
}
|
||||
|
||||
const objcPreamble = `// Objective-C API for talking to %[1]s Go package.
|
||||
|
|
Загрузка…
Ссылка в новой задаче