Gobind uses strings for passing errors across the language barrier. However, since Gobind doesn't have a concept of a nil string, it can't separate an empty native string from a nil string. In turn, that means that empty errors, exceptions or NSError * with an empty description are treated as no error. With ObjC, empty errors are replaced with a default string to workaround the issue, while with Java empty errors are silently ignored. Fix this by replacing strings with actual error objects, wrapping the Go error, Java Throwable or ObjC NSError *, and letting the existing bind machinery take care of passing the references across. It's a large change for a small corner case, but I believe objects are a better fit for exception that strings. Error objects also naturally leads to future additions, for example accessing the exception class name or chained exception. Change-Id: Ie03b47cafcb231ad1e12a80195693fa7459c6265 Reviewed-on: https://go-review.googlesource.com/24100 Reviewed-by: David Crawshaw <crawshaw@golang.org>
73 lines
1.7 KiB
Plaintext
73 lines
1.7 KiB
Plaintext
// Package gomobile_bind is an autogenerated binder stub for package basictypes.
|
|
// gobind -lang=go basictypes
|
|
//
|
|
// File is generated by gobind. Do not edit.
|
|
package gomobile_bind
|
|
|
|
/*
|
|
#include <stdlib.h>
|
|
#include <stdint.h>
|
|
#include "seq.h"
|
|
#include "basictypes.h"
|
|
|
|
*/
|
|
import "C"
|
|
|
|
import (
|
|
"basictypes"
|
|
_seq "golang.org/x/mobile/bind/seq"
|
|
)
|
|
|
|
// suppress the error if seq ends up unused
|
|
var _ = _seq.FromRefNum
|
|
|
|
//export proxybasictypes__Bool
|
|
func proxybasictypes__Bool(param_p0 C.char) C.char {
|
|
_param_p0 := param_p0 != 0
|
|
res_0 := basictypes.Bool(_param_p0)
|
|
var _res_0 C.char = 0
|
|
if res_0 {
|
|
_res_0 = 1
|
|
}
|
|
return _res_0
|
|
}
|
|
|
|
//export proxybasictypes__ByteArrays
|
|
func proxybasictypes__ByteArrays(param_x C.nbyteslice) C.nbyteslice {
|
|
_param_x := toSlice(param_x, false)
|
|
res_0 := basictypes.ByteArrays(_param_x)
|
|
_res_0 := fromSlice(res_0, true)
|
|
return _res_0
|
|
}
|
|
|
|
//export proxybasictypes__Error
|
|
func proxybasictypes__Error() C.int32_t {
|
|
res_0 := basictypes.Error()
|
|
var _res_0 C.int32_t = _seq.NullRefNum
|
|
if res_0 != nil {
|
|
_res_0 = C.int32_t(_seq.ToRefNum(res_0))
|
|
}
|
|
return _res_0
|
|
}
|
|
|
|
//export proxybasictypes__ErrorPair
|
|
func proxybasictypes__ErrorPair() (C.nint, C.int32_t) {
|
|
res_0, res_1 := basictypes.ErrorPair()
|
|
_res_0 := C.nint(res_0)
|
|
var _res_1 C.int32_t = _seq.NullRefNum
|
|
if res_1 != nil {
|
|
_res_1 = C.int32_t(_seq.ToRefNum(res_1))
|
|
}
|
|
return _res_0, _res_1
|
|
}
|
|
|
|
//export proxybasictypes__Ints
|
|
func proxybasictypes__Ints(param_x C.int8_t, param_y C.int16_t, param_z C.int32_t, param_t C.int64_t, param_u C.nint) {
|
|
_param_x := int8(param_x)
|
|
_param_y := int16(param_y)
|
|
_param_z := int32(param_z)
|
|
_param_t := int64(param_t)
|
|
_param_u := int(param_u)
|
|
basictypes.Ints(_param_x, _param_y, _param_z, _param_t, _param_u)
|
|
}
|