JniApi.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-04-07
  6. * Changed: 2023-04-11
  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)
  15. {
  16. NullPointerArgumentEvaluator{_environment, "Java environment is not being provided!"}.evaluate();
  17. this->environment = _environment;
  18. }
  19. JniApi::~JniApi() noexcept = default;
  20. jboolean JniApi::callBooleanMethod(jobject _javaObject, jmethodID _methodId)
  21. {
  22. return this->environment->CallBooleanMethod(_javaObject, _methodId);
  23. }
  24. jbyte JniApi::callByteMethod(jobject _javaObject, jmethodID _methodId)
  25. {
  26. return this->environment->CallByteMethod(_javaObject, _methodId);
  27. }
  28. jchar JniApi::callCharMethod(jobject _javaObject, jmethodID _methodId)
  29. {
  30. return this->environment->CallCharMethod(_javaObject, _methodId);
  31. }
  32. jint JniApi::callIntMethod(jobject _javaObject, jmethodID _methodId)
  33. {
  34. return this->environment->CallIntMethod(_javaObject, _methodId);
  35. }
  36. jclass JniApi::findClass(const string &_classPath)
  37. {
  38. return this->environment->FindClass(_classPath.c_str());
  39. }
  40. jmethodID JniApi::getMethodId(jclass _javaClass, const char *_methodIdentifier, const char *_methodSignature)
  41. {
  42. return this->environment->GetMethodID(_javaClass, _methodIdentifier, _methodSignature);
  43. }