Direct-BT
2.3.1
Direct-BT - Direct Bluetooth Programming.
|
Go to the documentation of this file.
29 #ifndef JAU_JNIMEM__HPP_
30 #define JAU_JNIMEM__HPP_
46 JNIEnv *env =
nullptr;
47 bool needsDetach =
false;
80 static inline void check(jobject
object,
const char* file,
int line) {
81 if(
nullptr ==
object ) {
105 jobject operator*() noexcept {
return object; }
110 jclass
getClass() const noexcept {
return (jclass)object; }
115 {
return !( *
this == rhs ); }
125 template <
typename T,
typename U>
144 jboolean isCopy =
false;
166 if(
nullptr != narray ) {
167 env->ReleasePrimitiveArrayCritical(jarray, narray, mode);
168 this->jarray =
nullptr;
169 this->narray =
nullptr;
178 if(
nullptr == jarray_val ) {
181 T* _narray =
static_cast<T*
>( env->GetPrimitiveArrayCritical(jarray_val, &isCopy) );
182 if(
nullptr != _narray ) {
183 this->mode = mode_val;
184 this->jarray = jarray_val;
185 this->narray = _narray;
void clear() noexcept
Clears the java reference, i.e.
void release()
Manual release of the acquired primitive array, usually one likes to simply do this via the destructo...
jobject getObject() const noexcept
JNICriticalArray(JNIEnv *env_val)
bool getIsCopy() const
Returns true if the primitive array had been acquired and the JVM utilizes a copy of the underlying j...
JNICriticalArray(JNICriticalArray &&o)=delete
thread_local JNIEnvContainer jni_env
@ UPDATE_AND_RELEASE
Like default 0: If 'isCopy': Update the java array data with the copy and free the copy.
~JNICriticalArray()
Release the acquired primitive array, RAII style.
bool operator==(const JNIGlobalRef &rhs) const noexcept
static void check(jobject object, const char *file, int line)
bool operator!=(const JNIGlobalRef &rhs) const noexcept
T * get(U jarray_val, Mode mode_val=UPDATE_AND_RELEASE)
Acquired the primitive array.
@ NO_UPDATE_AND_RELEASE
Like default JNI_ABORT: If 'isCopy': Do not update the java array data with the copy,...
JNICriticalArray & operator=(JNICriticalArray &&o)=delete
JNICriticalArray(const JNICriticalArray &o)=delete
@ UPDATE_NO_RELEASE
Like JNI_COMMIT: If 'isCopy': Update the java array data with the copy, but do not free the copy.
JNICriticalArray & operator=(const JNICriticalArray &o)=delete
jclass getClass() const noexcept