java/Ref: allow LocalRef to be nullable
Makes using the Java glue classes simpler to use, at the cost of very little overhead.
This commit is contained in:
parent
791245dec2
commit
1d49f1108f
@ -47,13 +47,13 @@ namespace Java {
|
||||
|
||||
public:
|
||||
/**
|
||||
* The local reference is obtained by the caller.
|
||||
* The local reference is obtained by the caller. May
|
||||
* be nullptr.
|
||||
*/
|
||||
LocalRef(JNIEnv *_env, T _value) noexcept
|
||||
:env(_env), value(_value)
|
||||
{
|
||||
assert(env != nullptr);
|
||||
assert(value != nullptr);
|
||||
}
|
||||
|
||||
~LocalRef() noexcept {
|
||||
@ -67,6 +67,10 @@ namespace Java {
|
||||
return env;
|
||||
}
|
||||
|
||||
operator bool() const noexcept {
|
||||
return value != nullptr;
|
||||
}
|
||||
|
||||
T Get() const noexcept {
|
||||
return value;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user