JniApi.cpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Co-Author: Claude Sonnet 4.6 (LLM)
  4. * Company: Lynar Studios
  5. * E-Mail: webmaster@lynarstudios.com
  6. * Created: 2023-04-07
  7. * Changed: 2026-06-23
  8. *
  9. * */
  10. #include <ls-std/core/evaluator/RawNullPointerArgumentEvaluator.hpp>
  11. #include <ls-std/core/jni/JniApi.hpp>
  12. using ls::standard::core::RawNullPointerArgumentEvaluator;
  13. using ls::standard::core::experimental::JniApi;
  14. using ls::standard::core::type::RawPointer;
  15. using std::string;
  16. JniApi::JniApi(JNIEnv *_environment) : environment(_environment)
  17. {
  18. RawNullPointerArgumentEvaluator<JNIEnv>{RawPointer<JNIEnv>{_environment}, "Java environment is not being provided!"}.evaluate();
  19. }
  20. JniApi::~JniApi() noexcept = default;
  21. jboolean JniApi::callBooleanMethod(jobject _javaObject, jmethodID _methodId)
  22. {
  23. return this->environment->CallBooleanMethod(_javaObject, _methodId);
  24. }
  25. jbyte JniApi::callByteMethod(jobject _javaObject, jmethodID _methodId)
  26. {
  27. return this->environment->CallByteMethod(_javaObject, _methodId);
  28. }
  29. jchar JniApi::callCharMethod(jobject _javaObject, jmethodID _methodId)
  30. {
  31. return this->environment->CallCharMethod(_javaObject, _methodId);
  32. }
  33. jdouble JniApi::callDoubleMethod(jobject _javaObject, jmethodID _methodId)
  34. {
  35. return this->environment->CallDoubleMethod(_javaObject, _methodId);
  36. }
  37. jfloat JniApi::callFloatMethod(jobject _javaObject, jmethodID _methodId)
  38. {
  39. return this->environment->CallFloatMethod(_javaObject, _methodId);
  40. }
  41. jint JniApi::callIntMethod(jobject _javaObject, jmethodID _methodId)
  42. {
  43. return this->environment->CallIntMethod(_javaObject, _methodId);
  44. }
  45. jlong JniApi::callLongMethod(jobject _javaObject, jmethodID _methodId)
  46. {
  47. return this->environment->CallLongMethod(_javaObject, _methodId);
  48. }
  49. jshort JniApi::callShortMethod(jobject _javaObject, jmethodID _methodId)
  50. {
  51. return this->environment->CallShortMethod(_javaObject, _methodId);
  52. }
  53. jclass JniApi::findClass(const string &_classPath)
  54. {
  55. return this->environment->FindClass(_classPath.c_str());
  56. }
  57. jmethodID JniApi::getMethodId(jclass _javaClass, const char *_methodIdentifier, const char *_methodSignature)
  58. {
  59. return this->environment->GetMethodID(_javaClass, _methodIdentifier, _methodSignature);
  60. }