JniApi.cpp 2.1 KB

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