8303227: JniObjWithEnv should be NullablePointer compliant
Reviewed-by: asemenyuk
This commit is contained in:
parent
61e8867591
commit
50dc041ee6
@ -26,6 +26,7 @@
|
|||||||
#ifndef JNIUTILS_H
|
#ifndef JNIUTILS_H
|
||||||
#define JNIUTILS_H
|
#define JNIUTILS_H
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "jni.h"
|
#include "jni.h"
|
||||||
#include "tstrings.h"
|
#include "tstrings.h"
|
||||||
@ -41,6 +42,9 @@ struct JniObjWithEnv {
|
|||||||
JniObjWithEnv(JNIEnv *env, jobject obj) : env(env), obj(obj) {
|
JniObjWithEnv(JNIEnv *env, jobject obj) : env(env), obj(obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JniObjWithEnv(const std::nullptr_t ptr) : env(ptr), obj(ptr) {
|
||||||
|
}
|
||||||
|
|
||||||
bool operator == (const JniObjWithEnv& other) const {
|
bool operator == (const JniObjWithEnv& other) const {
|
||||||
return env == other.env && obj == other.obj;
|
return env == other.env && obj == other.obj;
|
||||||
}
|
}
|
||||||
@ -49,6 +53,14 @@ struct JniObjWithEnv {
|
|||||||
return ! operator == (other);
|
return ! operator == (other);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool operator == (const std::nullptr_t ptr) const {
|
||||||
|
return env == ptr || obj == ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator != (const std::nullptr_t ptr) const {
|
||||||
|
return env != ptr && obj != ptr;
|
||||||
|
}
|
||||||
|
|
||||||
explicit operator bool() const {
|
explicit operator bool() const {
|
||||||
return env && obj;
|
return env && obj;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user