Commit 1d49f110 authored by Max Kellermann's avatar Max Kellermann

java/Ref: allow LocalRef to be nullable

Makes using the Java glue classes simpler to use, at the cost of very little overhead.
parent 791245de
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment