|
@@ -3,7 +3,7 @@
|
|
* Company: Lynar Studios
|
|
* Company: Lynar Studios
|
|
* E-Mail: webmaster@lynarstudios.com
|
|
* E-Mail: webmaster@lynarstudios.com
|
|
* Created: 2023-04-07
|
|
* Created: 2023-04-07
|
|
-* Changed: 2023-04-07
|
|
|
|
|
|
+* Changed: 2023-04-08
|
|
*
|
|
*
|
|
* */
|
|
* */
|
|
|
|
|
|
@@ -20,6 +20,8 @@ using ls::std::core::EmptyStringArgumentEvaluator;
|
|
using ls::std::core::JniApi;
|
|
using ls::std::core::JniApi;
|
|
using ls::std::core::JniClass;
|
|
using ls::std::core::JniClass;
|
|
using ls::std::core::JniClassParameter;
|
|
using ls::std::core::JniClassParameter;
|
|
|
|
+using ls::std::core::JniMethod;
|
|
|
|
+using ls::std::core::JniReturnValue;
|
|
using ls::std::core::NullPointerArgumentEvaluator;
|
|
using ls::std::core::NullPointerArgumentEvaluator;
|
|
using ls::std::core::NullPointerEvaluator;
|
|
using ls::std::core::NullPointerEvaluator;
|
|
using std::make_pair;
|
|
using std::make_pair;
|
|
@@ -40,6 +42,18 @@ JniClass::JniClass(const shared_ptr<JniClassParameter> &_parameter, const string
|
|
|
|
|
|
JniClass::~JniClass() = default;
|
|
JniClass::~JniClass() = default;
|
|
|
|
|
|
|
|
+JniReturnValue JniClass::callMethod(const string &_methodIdentifier)
|
|
|
|
+{
|
|
|
|
+ JniReturnValue returnValue{};
|
|
|
|
+
|
|
|
|
+ if (this->_hasMethod(_methodIdentifier))
|
|
|
|
+ {
|
|
|
|
+ this->_callByteMethod(_methodIdentifier, returnValue);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return returnValue;
|
|
|
|
+}
|
|
|
|
+
|
|
bool JniClass::hasMethod(const string &_methodIdentifier)
|
|
bool JniClass::hasMethod(const string &_methodIdentifier)
|
|
{
|
|
{
|
|
return this->_hasMethod(_methodIdentifier);
|
|
return this->_hasMethod(_methodIdentifier);
|
|
@@ -59,12 +73,27 @@ bool JniClass::loadMethod(const string &_methodIdentifier, const string &_method
|
|
|
|
|
|
if (succeeded)
|
|
if (succeeded)
|
|
{
|
|
{
|
|
- succeeded = this->methods.insert(make_pair<string, jmethodID>(string{_methodIdentifier}, jmethodID{methodId})).second;
|
|
|
|
|
|
+ JniMethod method{_methodIdentifier, _methodSignature};
|
|
|
|
+ method.setMethodId(methodId);
|
|
|
|
+ succeeded = this->methods.insert(make_pair<string, JniMethod>(string{_methodIdentifier}, JniMethod{method})).second;
|
|
}
|
|
}
|
|
|
|
|
|
return succeeded;
|
|
return succeeded;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void JniClass::_callByteMethod(const string &_methodIdentifier, JniReturnValue &_returnValue)
|
|
|
|
+{
|
|
|
|
+ JniMethod method = this->methods.at(_methodIdentifier);
|
|
|
|
+ string searchString = ")B";
|
|
|
|
+ string methodSignature = method.getMethodSignature();
|
|
|
|
+ bool hasBooleanReturnType = methodSignature.rfind(searchString) == (methodSignature.size() - searchString.size());
|
|
|
|
+
|
|
|
|
+ if (hasBooleanReturnType)
|
|
|
|
+ {
|
|
|
|
+ _returnValue.setByteValue(this->parameter->getJniApi()->callByteMethod(this->parameter->getJavaObject(), method.getMethodId()));
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
void JniClass::_createJniApi()
|
|
void JniClass::_createJniApi()
|
|
{
|
|
{
|
|
this->parameter->setJniApi(make_shared<JniApi>(this->parameter->getJavaEnvironment()));
|
|
this->parameter->setJniApi(make_shared<JniApi>(this->parameter->getJavaEnvironment()));
|