-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutil.c.v
39 lines (31 loc) · 829 Bytes
/
util.c.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright(C) 2021 Lars Pontoppidan. All rights reserved.
// Use of this source code is governed by an MIT license file distributed with this software package
module jni
pub fn default_vm() &JavaVM {
return C.gGetJavaVM()
}
pub fn default_env() &Env {
return C.gGetEnv()
}
pub fn set_java_vm(vm &JavaVM) {
C.gSetJavaVM(vm)
}
pub fn env_detach() (&Env, bool) {
env := &C.JNIEnv(unsafe { nil })
need_detach := C.gEnvNeedDetach(&env)
if isnil(env) {
panic(@MOD + '.' + @FN + ': JNI environment pointer jni.Env(${ptr_str(env)})" is invalid')
}
return env, need_detach
}
pub fn detach_thread(need_detach bool) {
if need_detach {
C.gDetachThread()
}
}
pub fn setup_android(fq_activity_name string) {
$if android {
activity_name := fq_activity_name.replace('.', '/')
C.gSetupAndroid(activity_name.str)
}
}