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
|
||||
#define JNIUTILS_H
|
||||
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
#include "jni.h"
|
||||
#include "tstrings.h"
|
||||
@ -41,6 +42,9 @@ struct JniObjWithEnv {
|
||||
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 {
|
||||
return env == other.env && obj == other.obj;
|
||||
}
|
||||
@ -49,6 +53,14 @@ struct JniObjWithEnv {
|
||||
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 {
|
||||
return env && obj;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user