-
Notifications
You must be signed in to change notification settings - Fork 6
/
JNIStrings.swift
63 lines (51 loc) · 2.16 KB
/
JNIStrings.swift
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import CJNI
public extension JNI {
public func NewString(unicodeChars: UnsafePointer<jchar>, _ len: jsize) -> jstring {
let env = self._env
return env.memory.memory.NewString(env, unicodeChars, len)
}
public func GetStringLength(string: jstring) -> jsize {
let env = self._env
return env.memory.memory.GetStringLength(env, string)
}
public func GetStringChars(string: jstring, _ isCopy: UnsafeMutablePointer<jboolean>) -> UnsafePointer<jchar> {
let env = self._env
return env.memory.memory.GetStringChars(env, string, isCopy)
}
public func ReleaseStringChars(string: jstring, _ chars: UnsafePointer<jchar>) {
let env = self._env
env.memory.memory.ReleaseStringChars(env, string, chars)
}
public func NewStringUTF(bytes: String) -> jstring {
let env = self._env
return env.memory.memory.NewStringUTF(env, bytes)
}
public func GetStringUTFLength(string: jstring) -> jsize {
let env = self._env
return env.memory.memory.GetStringUTFLength(env, string)
}
public func GetStringUTFChars(string: jstring, _ isCopy: UnsafeMutablePointer<jboolean>) -> String {
let env = self._env
return String(env.memory.memory.GetStringUTFChars(env, string, isCopy))
}
public func ReleaseStringUTFChars(string: jstring, _ utf: String) {
let env = self._env
env.memory.memory.ReleaseStringUTFChars(env, string, utf)
}
public func GetStringRegion(str: jstring, _ start: jsize, _ len: jsize, _ buf: UnsafeMutablePointer<jchar>) {
let env = self._env
env.memory.memory.GetStringRegion(env, str, start, len, buf)
}
public func GetStringUTFRegion(str: jstring, _ start: jsize, _ len: jsize, _ buf: UnsafeMutablePointer<CChar>) {
let env = self._env
env.memory.memory.GetStringUTFRegion(env, str, start, len, buf)
}
public func GetStringCritical(string: jstring, _ isCopy: UnsafeMutablePointer<jboolean>) -> UnsafePointer<jchar> {
let env = self._env
return env.memory.memory.GetStringCritical(env, string, isCopy)
}
public func ReleaseStringCritical(string: jstring, _ carray: UnsafePointer<jchar>) {
let env = self._env
env.memory.memory.ReleaseStringCritical(env, string, carray)
}
}