MCPcopy Create free account
hub / github.com/NativeScript/android / JniLocalRef

Class JniLocalRef

test-app/runtime/src/main/cpp/JniLocalRef.h:9–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7
8namespace tns {
9class JniLocalRef {
10 public:
11 JniLocalRef()
12 : m_obj(nullptr), m_isGlobal(false) {
13 }
14
15 JniLocalRef(jobject obj, bool isGlobal = false)
16 : m_obj(obj), m_isGlobal(isGlobal) {
17 }
18
19 JniLocalRef(jclass obj)
20 : m_obj(obj), m_isGlobal(false) {
21 }
22
23 JniLocalRef(JniLocalRef&& rhs)
24 : m_obj(rhs.m_obj), m_isGlobal(rhs.m_isGlobal) {
25 rhs.m_obj = nullptr;
26 }
27
28 bool IsNull() const {
29 return m_obj == nullptr;
30 }
31
32 bool IsGlobal() const {
33 return m_isGlobal;
34 }
35
36 jobject Move() {
37 auto value = m_obj;
38 m_obj = nullptr;
39 return value;
40 }
41
42 JniLocalRef& operator=(JniLocalRef&& rhs) {
43 m_obj = rhs.m_obj;
44 m_isGlobal = rhs.m_isGlobal;
45 rhs.m_obj = nullptr;
46 return *this;
47 }
48
49 operator jobject() const {
50 return m_obj;
51 }
52
53 operator jstring() const {
54 return reinterpret_cast<jstring>(m_obj);
55 }
56
57 operator jclass() const {
58 return reinterpret_cast<jclass>(m_obj);
59 }
60
61 operator jboolean() const {
62 JEnv env;
63 return JType::BooleanValue(env, m_obj);
64 }
65
66 operator jthrowable() const {

Callers 4

NativeScriptExceptionMethod · 0.85
CreateJavaArrayMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected