mobile/bind: replace panics with errors
cgoType panics on types not yet supported by bind. Replace the panics with more appropriate error messages. Change-Id: I0b8609b50de07ca93db13c50654f62ffbd9f25c2 Reviewed-on: https://go-review.googlesource.com/20472 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This commit is contained in:
parent
2e1e39e5a6
commit
0d3fdd1e30
11
bind/gen.go
11
bind/gen.go
|
@ -159,7 +159,7 @@ func (g *generator) cgoType(t types.Type) string {
|
|||
case types.String:
|
||||
return "nstring"
|
||||
default:
|
||||
panic(fmt.Sprintf("unsupported basic type: %s", t))
|
||||
g.errorf("unsupported basic type: %s", t)
|
||||
}
|
||||
case *types.Slice:
|
||||
switch e := t.Elem().(type) {
|
||||
|
@ -168,21 +168,22 @@ func (g *generator) cgoType(t types.Type) string {
|
|||
case types.Uint8: // Byte.
|
||||
return "nbyteslice"
|
||||
default:
|
||||
panic(fmt.Sprintf("unsupported slice type: %s", t))
|
||||
g.errorf("unsupported slice type: %s", t)
|
||||
}
|
||||
default:
|
||||
panic(fmt.Sprintf("unsupported slice type: %s", t))
|
||||
g.errorf("unsupported slice type: %s", t)
|
||||
}
|
||||
case *types.Pointer:
|
||||
if _, ok := t.Elem().(*types.Named); ok {
|
||||
return g.cgoType(t.Elem())
|
||||
}
|
||||
panic(fmt.Sprintf("unsupported pointer to type: %s", t))
|
||||
g.errorf("unsupported pointer to type: %s", t)
|
||||
case *types.Named:
|
||||
return "int32_t"
|
||||
default:
|
||||
panic(fmt.Sprintf("unsupported type: %s", t))
|
||||
g.errorf("unsupported type: %s", t)
|
||||
}
|
||||
return "TODO"
|
||||
}
|
||||
|
||||
func (g *generator) genInterfaceMethodSignature(m *types.Func, iName string, header bool) {
|
||||
|
|
Loading…
Reference in New Issue