diff options
author | Max Kellermann <max@musicpd.org> | 2019-04-11 11:32:07 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2019-04-11 11:32:07 +0200 |
commit | 1d49f1108f8c2f3998744310505d9d34afd8115d (patch) | |
tree | 163a781b00e7b474c68d20687089949df978361e /src/java/Ref.hxx | |
parent | 791245dec2081c00e9175df0a205eaec64c904fe (diff) |
java/Ref: allow LocalRef to be nullable
Makes using the Java glue classes simpler to use, at the cost of very
little overhead.
Diffstat (limited to 'src/java/Ref.hxx')
-rw-r--r-- | src/java/Ref.hxx | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/java/Ref.hxx b/src/java/Ref.hxx index 686907477..37dc50bd8 100644 --- a/src/java/Ref.hxx +++ b/src/java/Ref.hxx @@ -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; } |