3#if PL_ENABLED(PL_PLATFORM_ANDROID)
5# include <Foundation/Logging/Log.h>
6# include <Foundation/Strings/StringBuilder.h>
14enum class plJniErrorState
54class PL_FOUNDATION_DLL plJniAttachment
66 static plJniObject GetActivity();
69 static JNIEnv* GetEnv();
75 static plJniErrorState GetLastError();
81 static void ClearLastError();
86 static bool HasPendingException();
91 static plJniObject GetPendingException();
94 static void ClearPendingException();
97 static void SetLastError(plJniErrorState state);
100 static bool FailOnPendingErrorOrException();
103 static thread_local JNIEnv* s_env;
104 static thread_local bool s_ownsEnv;
105 static thread_local int s_attachCount;
106 static thread_local plJniErrorState s_lastError;
108 plJniAttachment(
const plJniAttachment&);
109 plJniAttachment& operator=(
const plJniAttachment&);
113enum class plJniOwnerShip
126class PL_FOUNDATION_DLL plJniObject
136 inline plJniObject(jobject
object, plJniOwnerShip ownerShip);
139 inline plJniObject(
const plJniObject& other);
142 inline plJniObject(plJniObject&& other);
145 inline plJniObject& operator=(
const plJniObject& other);
148 inline plJniObject& operator=(plJniObject&& other);
151 inline virtual ~plJniObject();
167 inline bool operator==(
const plJniObject& other)
const;
183 inline bool operator!=(
const plJniObject& other)
const;
186 bool IsNull()
const {
return m_object ==
nullptr; }
189 jobject GetHandle()
const;
194 plJniClass GetClass()
const;
202 bool IsInstanceOf(
const plJniClass& clazz)
const;
279 template <
typename Ret = void,
typename... Args>
280 Ret Call(
const char* name,
const Args&... args)
const;
291 template <
typename Ret>
292 Ret GetField(
const char* name)
const;
304 template <
typename T>
305 void SetField(
const char* name,
const T& arg)
const;
308 template <
typename Ret,
typename... Args>
309 Ret UnsafeCall(
const char* name,
const char* signature,
const Args&... args)
const;
312 template <
typename Ret>
313 Ret UnsafeGetField(
const char* name,
const char* signature)
const;
316 template <
typename T>
317 void UnsafeSetField(
const char* name,
const char* signature,
const T& arg)
const;
321 inline jobject GetJObject()
const;
323 static void DumpTypes(
const plJniClass* inputTypes,
int N,
const plJniClass* returnType);
325 static int CompareMethodSpecificity(
const plJniObject& method1,
const plJniObject& method2);
326 static bool IsMethodViable(
bool bStatic,
const plJniObject& candidateMethod,
const plJniClass& returnType, plJniClass* inputTypes,
int N);
327 static plJniObject FindMethod(
bool bStatic,
const char* name,
const plJniClass& type,
const plJniClass& returnType, plJniClass* inputTypes,
int N);
329 static int CompareConstructorSpecificity(
const plJniObject& method1,
const plJniObject& method2);
330 static bool IsConstructorViable(
const plJniObject& candidateMethod, plJniClass* inputTypes,
int N);
331 static plJniObject FindConstructor(
const plJniClass& type, plJniClass* inputTypes,
int N);
345class PL_FOUNDATION_DLL plJniString :
public plJniObject
352 plJniString(
const char* str);
358 plJniString(jstring
string, plJniOwnerShip ownerShip);
361 plJniString(
const plJniString& other);
364 plJniString(plJniString&& other);
367 plJniString& operator=(
const plJniString& other);
370 plJniString& operator=(plJniString&& other);
373 virtual ~plJniString();
376 const char* GetData()
const;
383class PL_FOUNDATION_DLL plJniClass :
public plJniObject
403 plJniClass(
const char* className);
409 plJniClass(jclass clazz, plJniOwnerShip ownerShip);
412 plJniClass(
const plJniClass& other);
415 plJniClass(plJniClass&& other);
418 plJniClass& operator=(
const plJniClass& other);
421 plJniClass& operator=(plJniClass&& other);
424 jclass GetHandle()
const;
441 template <
typename... Args>
442 plJniObject CreateInstance(
const Args&... args)
const;
448 bool IsAssignableFrom(
const plJniClass& other)
const;
472 template <
typename Ret = void,
typename... Args>
473 Ret CallStatic(
const char* name,
const Args&... args)
const;
478 template <
typename Ret>
479 Ret GetStaticField(
const char* name)
const;
485 template <
typename T>
486 void SetStaticField(
const char* name,
const T& arg)
const;
489 template <
typename Ret,
typename... Args>
490 Ret UnsafeCallStatic(
const char* name,
const char* signature,
const Args&... args)
const;
493 template <
typename Ret>
494 Ret UnsafeGetStaticField(
const char* name,
const char* signature)
const;
497 template <
typename T>
498 void UnsafeSetStaticField(
const char* name,
const char* signature,
const T& arg)
const;
501# include <Foundation/Basics/Platform/Android/AndroidJni.inl>
PL_ALWAYS_INLINE const plStringBuilder & ToString(bool value, plStringBuilder &out_sResult)
Converts a bool to a string.
Definition ConversionUtils.h:176