-
Notifications
You must be signed in to change notification settings - Fork 6
/
JNIObjects.swift
33 lines (26 loc) · 1.12 KB
/
JNIObjects.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
import CJNI
public extension JNI {
public func AllocObject(targetClass: jclass) -> jobject {
let env = self._env
return env.memory.memory.AllocObject(env, targetClass)
}
public func NewObject(targetClass: jclass, _ methodID: jmethodID, _ args: jvalue...) -> jobject {
return self.NewObjectA(targetClass, _ methodID: methodID, _ args: args)
}
@available(*, unavailable, message="CVaListPointer unavailable, use NewObject or NewObjectA")
public func NewObjectV(targetClass: jclass, _ methodID: jmethodID, _ args: CVaListPointer) -> jobject {
// let env = self._env
// return env.memory.memory.NewObjectV(env, targetClass, methodID, args)
return jobject()
}
public func NewObjectA(targetClass: jclass, _ methodID: jmethodID, _ args: [jvalue]) -> jobject {
let env = self._env
var mutableArgs = args
return env.memory.memory.NewObjectA(env, targetClass, methodID, &mutableArgs)
}
public func GetObjectClass(obj: jobject) -> jclass? {
let env = self._env
let result = env.memory.memory.GetObjectClass(env, obj)
return (result != nil) ? result : .None
}
}