Commit f4483037 authored by Volker Krause's avatar Volker Krause
Browse files

Implement writing to JNI arrays for arrays holding non-primitive content

parent 47660886
Pipeline #184796 passed with stage
in 2 minutes and 14 seconds
......@@ -102,6 +102,7 @@ private Q_SLOTS:
{
auto a1 = Jni::Array<jshort>(10);
auto a2 = Jni::Array<java::lang::String>(5);
a2[2] = QStringLiteral("test");
auto a3 = Jni::Array<java::lang::String>(3, QStringLiteral("test"));
}
};
......
......@@ -234,6 +234,32 @@ public:
return Internal::return_wrapper<T>::toReturnValue(QAndroidJniObject::fromLocalRef(env->GetObjectArrayElement(this->handle(), index)));
}
class ref
{
public:
inline operator auto()
{
QAndroidJniEnvironment env;
return Internal::return_wrapper<T>::toReturnValue(QAndroidJniObject::fromLocalRef(env->GetObjectArrayElement(c.handle(), index)));
}
inline ref& operator=(typename Internal::argument<T>::type v)
{
QAndroidJniEnvironment env;
env->SetObjectArrayElement(c.handle(), index, Internal::argument<T>::toCallArgument(v));
return *this;
}
private:
ArrayImpl<T, false> &c;
jsize index;
friend class ArrayImpl<T, false>;
inline ref(jsize _i, ArrayImpl<T, false> &_c) : c(_c), index(_i) {}
};
ref operator[](jsize index)
{
return ref(index, *this);
}
class const_iterator
{
const ArrayImpl<T, false> &c;
......
Supports Markdown
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