IceShard 1
A personal game engine project, with development focused on 2D/2.5D games.
Loading...
Searching...
No Matches
android.hxx
Go to the documentation of this file.
1
3
4#pragma once
5#include <ice/os/unix.hxx>
6
7#if ISP_ANDROID
8#include <jni.h>
9
10template<typename JNIType>
11struct AndroidJNIHandleDescriptorBase
12{
15 using PlatformHandleType = JNIType;
16 using HandleManagerType = JNIEnv*;
17
20 static constexpr PlatformHandleType InvalidHandle = JNIType{};
21
22 static bool is_valid(PlatformHandleType handle, HandleManagerType jni) noexcept
23 {
24 return handle != InvalidHandle && jni != nullptr;
25 }
26
27 static bool close(PlatformHandleType handle, HandleManagerType jni) noexcept
28 {
29 jni->DeleteLocalRef(handle);
30 return true;
31 }
32};
33
34template<>
35struct ice::os::HandleDescriptor<ice::os::HandleType::JClass> : AndroidJNIHandleDescriptorBase<jclass> { };
36template<>
37struct ice::os::HandleDescriptor<ice::os::HandleType::JObject> : AndroidJNIHandleDescriptorBase<jobject> { };
38template<>
39struct ice::os::HandleDescriptor<ice::os::HandleType::JString> : AndroidJNIHandleDescriptorBase<jstring> { };
40
41// Can't use 'unix' since it's a define
42namespace ice::jni
43{
44
45 using JClass = ice::os::Handle<ice::os::HandleType::JClass>;
46 using JObject = ice::os::Handle<ice::os::HandleType::JObject>;
47 using JString = ice::os::Handle<ice::os::HandleType::JString>;
48
49} // namespace ice::unix
50
51#endif // ISP_ANDROID
SPDX-License-Identifier: MIT.
Definition array.hxx:12
Definition handle.hxx:26