-
Notifications
You must be signed in to change notification settings - Fork 6
/
JNIFields.swift.gyb
56 lines (46 loc) · 1.62 KB
/
JNIFields.swift.gyb
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
// Hash maps and fields
import CJNI
%{
jTypes = [
('Object', 'jobject'),
('Boolean', 'jboolean'),
('Byte', 'jbyte'),
('Char', 'jchar'),
('Short', 'jshort'),
('Int', 'jint'),
('Long', 'jlong'),
('Float', 'jfloat'),
('Double', 'jdouble')
]
}%
public extension JNI {
public func GetFieldID(targetClass: jclass, _ name: String, _ sig: String) -> jfieldID {
let env = self._env
return env.memory.memory.GetFieldID(env, targetClass, name, sig)
}
public func GetStaticFieldID(targetClass: jclass, _ name: String, _ sig: String) -> jfieldID {
let env = self._env
return env.memory.memory.GetStaticFieldID(env, targetClass, name, sig)
}
% for (TypeName, Type) in jTypes:
public func Get${TypeName}Field(obj: jobject, _ fieldID: jfieldID) -> ${Type} {
let env = self._env
return env.memory.memory.Get${TypeName}Field(env, obj, fieldID)
}
public func Set${TypeName}Field(obj: jobject, _ fieldID: jfieldID, _ value: ${Type}) {
let env = self._env
env.memory.memory.Set${TypeName}Field(env, obj, fieldID, value)
}
public func GetStatic${TypeName}Field(targetClass: jclass, _ fieldID: jfieldID) -> ${Type} {
let env = self._env
return env.memory.memory.GetStatic${TypeName}Field(env, targetClass, fieldID)
}
public func SetStatic${TypeName}Field(targetClass: jclass, _ fieldID: jfieldID, _ value: ${Type}) {
let env = self._env
env.memory.memory.SetStatic${TypeName}Field(env, targetClass, fieldID, value)
}
% end
}
// ${'Local Variables'}:
// eval: (read-only-mode 1)
// End: