jni: replace True and False with more convenient Bool function

Signed-off-by: Elias Naur <mail@eliasnaur.com>
pull/7/head
Elias Naur 3 years ago
parent 07b2373e6b
commit 33cf7c0aa1

@ -468,10 +468,7 @@ func (a *App) notify(state BackendState) {
case a.updates <- struct{}{}:
default:
}
ready := jni.False
if state.State >= ipn.Stopped {
ready = jni.True
}
ready := jni.Bool(state.State >= ipn.Stopped)
if err := a.callVoidMethod(a.appCtx, "setTileReady", "(Z)V", jni.Value(ready)); err != nil {
fatalErr(err)
}
@ -480,10 +477,7 @@ func (a *App) notify(state BackendState) {
func (a *App) setPrefs(prefs *ipn.Prefs) {
a.mu.Lock()
a.prefs = prefs
wantRunning := jni.True
if !prefs.WantRunning {
wantRunning = jni.False
}
wantRunning := jni.Bool(prefs.WantRunning)
a.mu.Unlock()
if err := a.callVoidMethod(a.appCtx, "setTileStatus", "(Z)V", jni.Value(wantRunning)); err != nil {
fatalErr(err)

@ -64,11 +64,6 @@ type (
Value uint64 // All JNI types fit into 64-bits.
)
const (
True Boolean = C.JNI_TRUE
False Boolean = C.JNI_FALSE
)
func env(e *Env) *C.JNIEnv {
return (*C.JNIEnv)(unsafe.Pointer(e))
}
@ -96,6 +91,13 @@ func Do(vm *JVM, f func(env *Env) error) error {
return f((*Env)(unsafe.Pointer(env)))
}
func Bool(b bool) Boolean {
if b {
return C.JNI_TRUE
}
return C.JNI_FALSE
}
func varArgs(args []Value) *C.jvalue {
if len(args) == 0 {
return nil

Loading…
Cancel
Save