AUI Framework  master
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
TypedMethods.h
    1/*
    2 * AUI Framework - Declarative UI toolkit for modern C++20
    3 * Copyright (C) 2020-2025 Alex2772 and Contributors
    4 *
    5 * SPDX-License-Identifier: MPL-2.0
    6 *
    7 * This Source Code Form is subject to the terms of the Mozilla Public
    8 * License, v. 2.0. If a copy of the MPL was not distributed with this
    9 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
   10 */
   11
   12#pragma once
   13
   14#include "GlobalRef.h"
   15
   16namespace aui::jni {
   17
   18    template <typename T> struct TypedMethods;
   19
   20    template <> struct TypedMethods<jobject*>
   21    {
   22        static constexpr auto CallMethod           = &JNIEnv::CallObjectMethod;
   23        static constexpr auto CallNonvirtualMethod = &JNIEnv::CallNonvirtualObjectMethod;
   24        static constexpr auto GetField             = &JNIEnv::GetObjectField;
   25        static constexpr auto SetField             = &JNIEnv::SetObjectField;
   26        static constexpr auto CallStaticMethod     = &JNIEnv::CallStaticObjectMethod;
   27        static constexpr auto GetStaticField       = &JNIEnv::GetStaticObjectField;
   28        static constexpr auto SetStaticField       = &JNIEnv::SetStaticObjectField;
   29    };
   30
   31    template <> struct TypedMethods<jboolean>
   32    {
   33        static constexpr auto CallMethod           = &JNIEnv::CallBooleanMethod;
   34        static constexpr auto CallNonvirtualMethod = &JNIEnv::CallNonvirtualBooleanMethod;
   35        static constexpr auto GetField             = &JNIEnv::GetBooleanField;
   36        static constexpr auto SetField             = &JNIEnv::SetBooleanField;
   37        static constexpr auto CallStaticMethod     = &JNIEnv::CallStaticBooleanMethod;
   38        static constexpr auto GetStaticField       = &JNIEnv::GetStaticBooleanField;
   39        static constexpr auto SetStaticField       = &JNIEnv::SetStaticBooleanField;
   40        static constexpr auto NewArray             = &JNIEnv::NewBooleanArray;
   41        static constexpr auto GetArrayElements     = &JNIEnv::GetBooleanArrayElements;
   42        static constexpr auto ReleaseArrayElements = &JNIEnv::ReleaseBooleanArrayElements;
   43        static constexpr auto GetArrayRegion       = &JNIEnv::GetBooleanArrayRegion;
   44        static constexpr auto SetArrayRegion       = &JNIEnv::SetBooleanArrayRegion;
   45    };
   46
   47    template <> struct TypedMethods<bool>: TypedMethods<jboolean> {};
   48
   49    template <> struct TypedMethods<jbyte>
   50    {
   51        static constexpr auto CallMethod           = &JNIEnv::CallByteMethod;
   52        static constexpr auto CallNonvirtualMethod = &JNIEnv::CallNonvirtualByteMethod;
   53        static constexpr auto GetField             = &JNIEnv::GetByteField;
   54        static constexpr auto SetField             = &JNIEnv::SetByteField;
   55        static constexpr auto CallStaticMethod     = &JNIEnv::CallStaticByteMethod;
   56        static constexpr auto GetStaticField       = &JNIEnv::GetStaticByteField;
   57        static constexpr auto SetStaticField       = &JNIEnv::SetStaticByteField;
   58        static constexpr auto NewArray             = &JNIEnv::NewByteArray;
   59        static constexpr auto GetArrayElements     = &JNIEnv::GetByteArrayElements;
   60        static constexpr auto ReleaseArrayElements = &JNIEnv::ReleaseByteArrayElements;
   61        static constexpr auto GetArrayRegion       = &JNIEnv::GetByteArrayRegion;
   62        static constexpr auto SetArrayRegion       = &JNIEnv::SetByteArrayRegion;
   63    };
   64
   65    template <> struct TypedMethods<jchar>
   66    {
   67        static constexpr auto CallMethod           = &JNIEnv::CallCharMethod;
   68        static constexpr auto CallNonvirtualMethod = &JNIEnv::CallNonvirtualCharMethod;
   69        static constexpr auto GetField             = &JNIEnv::GetCharField;
   70        static constexpr auto SetField             = &JNIEnv::SetCharField;
   71        static constexpr auto CallStaticMethod     = &JNIEnv::CallStaticCharMethod;
   72        static constexpr auto GetStaticField       = &JNIEnv::GetStaticCharField;
   73        static constexpr auto SetStaticField       = &JNIEnv::SetStaticCharField;
   74        static constexpr auto NewArray             = &JNIEnv::NewCharArray;
   75        static constexpr auto GetArrayElements     = &JNIEnv::GetCharArrayElements;
   76        static constexpr auto ReleaseArrayElements = &JNIEnv::ReleaseCharArrayElements;
   77        static constexpr auto GetArrayRegion       = &JNIEnv::GetCharArrayRegion;
   78        static constexpr auto SetArrayRegion       = &JNIEnv::SetCharArrayRegion;
   79    };
   80
   81    template <> struct TypedMethods<jshort>
   82    {
   83        static constexpr auto CallMethod           = &JNIEnv::CallShortMethod;
   84        static constexpr auto CallNonvirtualMethod = &JNIEnv::CallNonvirtualShortMethod;
   85        static constexpr auto GetField             = &JNIEnv::GetShortField;
   86        static constexpr auto SetField             = &JNIEnv::SetShortField;
   87        static constexpr auto CallStaticMethod     = &JNIEnv::CallStaticShortMethod;
   88        static constexpr auto GetStaticField       = &JNIEnv::GetStaticShortField;
   89        static constexpr auto SetStaticField       = &JNIEnv::SetStaticShortField;
   90        static constexpr auto NewArray             = &JNIEnv::NewShortArray;
   91        static constexpr auto GetArrayElements     = &JNIEnv::GetShortArrayElements;
   92        static constexpr auto ReleaseArrayElements = &JNIEnv::ReleaseShortArrayElements;
   93        static constexpr auto GetArrayRegion       = &JNIEnv::GetShortArrayRegion;
   94        static constexpr auto SetArrayRegion       = &JNIEnv::SetShortArrayRegion;
   95    };
   96
   97    template <> struct TypedMethods<jint>
   98    {
   99        static constexpr auto CallMethod           = &JNIEnv::CallIntMethod;
  100        static constexpr auto CallNonvirtualMethod = &JNIEnv::CallNonvirtualIntMethod;
  101        static constexpr auto GetField             = &JNIEnv::GetIntField;
  102        static constexpr auto SetField             = &JNIEnv::SetIntField;
  103        static constexpr auto CallStaticMethod     = &JNIEnv::CallStaticIntMethod;
  104        static constexpr auto GetStaticField       = &JNIEnv::GetStaticIntField;
  105        static constexpr auto SetStaticField       = &JNIEnv::SetStaticIntField;
  106        static constexpr auto NewArray             = &JNIEnv::NewIntArray;
  107        static constexpr auto GetArrayElements     = &JNIEnv::GetIntArrayElements;
  108        static constexpr auto ReleaseArrayElements = &JNIEnv::ReleaseIntArrayElements;
  109        static constexpr auto GetArrayRegion       = &JNIEnv::GetIntArrayRegion;
  110        static constexpr auto SetArrayRegion       = &JNIEnv::SetIntArrayRegion;
  111    };
  112
  113    template <> struct TypedMethods<jlong>
  114    {
  115        static constexpr auto CallMethod           = &JNIEnv::CallLongMethod;
  116        static constexpr auto CallNonvirtualMethod = &JNIEnv::CallNonvirtualLongMethod;
  117        static constexpr auto GetField             = &JNIEnv::GetLongField;
  118        static constexpr auto SetField             = &JNIEnv::SetLongField;
  119        static constexpr auto CallStaticMethod     = &JNIEnv::CallStaticLongMethod;
  120        static constexpr auto GetStaticField       = &JNIEnv::GetStaticLongField;
  121        static constexpr auto SetStaticField       = &JNIEnv::SetStaticLongField;
  122        static constexpr auto NewArray             = &JNIEnv::NewLongArray;
  123        static constexpr auto GetArrayElements     = &JNIEnv::GetLongArrayElements;
  124        static constexpr auto ReleaseArrayElements = &JNIEnv::ReleaseLongArrayElements;
  125        static constexpr auto GetArrayRegion       = &JNIEnv::GetLongArrayRegion;
  126        static constexpr auto SetArrayRegion       = &JNIEnv::SetLongArrayRegion;
  127    };
  128
  129    template <> struct TypedMethods<jfloat>
  130    {
  131        static constexpr auto CallMethod           = &JNIEnv::CallFloatMethod;
  132        static constexpr auto CallNonvirtualMethod = &JNIEnv::CallNonvirtualFloatMethod;
  133        static constexpr auto GetField             = &JNIEnv::GetFloatField;
  134        static constexpr auto SetField             = &JNIEnv::SetFloatField;
  135        static constexpr auto CallStaticMethod     = &JNIEnv::CallStaticFloatMethod;
  136        static constexpr auto GetStaticField       = &JNIEnv::GetStaticFloatField;
  137        static constexpr auto SetStaticField       = &JNIEnv::SetStaticFloatField;
  138        static constexpr auto NewArray             = &JNIEnv::NewFloatArray;
  139        static constexpr auto GetArrayElements     = &JNIEnv::GetFloatArrayElements;
  140        static constexpr auto ReleaseArrayElements = &JNIEnv::ReleaseFloatArrayElements;
  141        static constexpr auto GetArrayRegion       = &JNIEnv::GetFloatArrayRegion;
  142        static constexpr auto SetArrayRegion       = &JNIEnv::SetFloatArrayRegion;
  143    };
  144
  145    template <> struct TypedMethods<jdouble>
  146    {
  147        static constexpr auto CallMethod           = &JNIEnv::CallDoubleMethod;
  148        static constexpr auto CallNonvirtualMethod = &JNIEnv::CallNonvirtualDoubleMethod;
  149        static constexpr auto GetField             = &JNIEnv::GetDoubleField;
  150        static constexpr auto SetField             = &JNIEnv::SetDoubleField;
  151        static constexpr auto CallStaticMethod     = &JNIEnv::CallStaticDoubleMethod;
  152        static constexpr auto GetStaticField       = &JNIEnv::GetStaticDoubleField;
  153        static constexpr auto SetStaticField       = &JNIEnv::SetStaticDoubleField;
  154        static constexpr auto NewArray             = &JNIEnv::NewDoubleArray;
  155        static constexpr auto GetArrayElements     = &JNIEnv::GetDoubleArrayElements;
  156        static constexpr auto ReleaseArrayElements = &JNIEnv::ReleaseDoubleArrayElements;
  157        static constexpr auto GetArrayRegion       = &JNIEnv::GetDoubleArrayRegion;
  158        static constexpr auto SetArrayRegion       = &JNIEnv::SetDoubleArrayRegion;
  159    };
  160
  161    template <> struct TypedMethods<jobject>
  162    {
  163        static constexpr auto CallMethod           = &JNIEnv::CallObjectMethod;
  164        static constexpr auto CallNonvirtualMethod = &JNIEnv::CallNonvirtualObjectMethod;
  165        static constexpr auto GetField             = &JNIEnv::GetObjectField;
  166        static constexpr auto SetField             = &JNIEnv::SetObjectField;
  167        static constexpr auto CallStaticMethod     = &JNIEnv::CallStaticObjectMethod;
  168        static constexpr auto GetStaticField       = &JNIEnv::GetStaticObjectField;
  169        static constexpr auto SetStaticField       = &JNIEnv::SetStaticObjectField;
  170        static constexpr auto NewArray             = &JNIEnv::NewObjectArray;
  171    };
  172
  173    template <> struct TypedMethods<jstring>: TypedMethods<jobject> {};
  174
  175    template <> struct TypedMethods<void>
  176    {
  177        static constexpr auto CallMethod           = &JNIEnv::CallVoidMethod;
  178        static constexpr auto CallNonvirtualMethod = &JNIEnv::CallNonvirtualVoidMethod;
  179        static constexpr auto CallStaticMethod     = &JNIEnv::CallStaticVoidMethod;
  180    };
  181}
Definition TypedMethods.h:18