Skip to content

Commit

Permalink
Fix array manipulation
Browse files Browse the repository at this point in the history
  • Loading branch information
yujincheng08 committed Jul 22, 2024
1 parent 85ab3c8 commit bd64ecb
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lsplant/src/main/jni/include/utils/jni_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,18 @@ class JObjectArrayElement {
return *this;
}

template<JObject T>
JObjectArrayElement &operator=(ScopedLocalRef<T> &&s) {
reset(s.release());
return *this;
}

template<JObject T>
JObjectArrayElement &operator=(ScopedLocalRef<T> &s) {
reset(s.clone());
return *this;
}

JObjectArrayElement &operator=(jobject s) {
reset(env_->NewLocalRef(s));
return *this;
Expand Down Expand Up @@ -1215,9 +1227,7 @@ class ScopedLocalRef<jobjectArray> {
jobjectArray get() const { return local_ref_; }

JObjectArrayElement operator[](size_t index) {
return JObjectArrayElement(
env_, local_ref_, index,
JNI_SafeInvoke(env_, &JNIEnv::GetObjectArrayElement, local_ref_, index));
return JObjectArrayElement(env_, local_ref_, index, size_);
}

const ScopedLocalRef<jobject> operator[](size_t index) const {
Expand Down

0 comments on commit bd64ecb

Please sign in to comment.