本文整理汇总了C++中JEnv::CallVoidMethodA方法的典型用法代码示例。如果您正苦于以下问题:C++ JEnv::CallVoidMethodA方法的具体用法?C++ JEnv::CallVoidMethodA怎么用?C++ JEnv::CallVoidMethodA使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JEnv
的用法示例。
在下文中一共展示了JEnv::CallVoidMethodA方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CallJavaMethod
//.........这里部分代码省略.........
}
auto isolate = Isolate::GetCurrent();
jweak callerJavaObject;
jvalue* javaArgs = argConverter.ToArgs();
if (!isStatic)
{
callerJavaObject = objectManager->GetJavaObjectByJsObject(caller);
if(callerJavaObject == nullptr)
{
stringstream ss;
ss << "No java object found on which to call \"" << methodName << "\" method. It is possible your Javascript object is not linked with the corresponding Java class. Try passing context(this) to the constructor function.";
throw NativeScriptException(ss.str());
}
}
switch (retType)
{
case MethodReturnType::Void:
{
if (isStatic)
{
env.CallStaticVoidMethodA(clazz, mid, javaArgs);
}
else if (isSuper)
{
env.CallNonvirtualVoidMethodA(callerJavaObject, clazz, mid, javaArgs);
}
else
{
env.CallVoidMethodA(callerJavaObject, mid, javaArgs);
}
break;
}
case MethodReturnType::Boolean:
{
jboolean result;
if (isStatic)
{
result = env.CallStaticBooleanMethodA(clazz, mid, javaArgs);
}
else if (isSuper)
{
result = env.CallNonvirtualBooleanMethodA(callerJavaObject, clazz, mid, javaArgs);
}
else
{
result = env.CallBooleanMethodA(callerJavaObject, mid, javaArgs);
}
args.GetReturnValue().Set(result != 0 ? True(isolate) : False(isolate));
break;
}
case MethodReturnType::Byte:
{
jbyte result;
if (isStatic)
{
result = env.CallStaticByteMethodA(clazz, mid, javaArgs);
}
else if (isSuper)
{
result = env.CallNonvirtualByteMethodA(callerJavaObject, clazz, mid, javaArgs);
}
示例2: CallJavaMethod
//.........这里部分代码省略.........
jweak callerJavaObject;
jvalue* javaArgs = argConverter.ToArgs();
if (!isStatic)
{
callerJavaObject = objectManager->GetJavaObjectByJsObject(caller);
if(callerJavaObject == nullptr)
{
stringstream ss;
ss << "No java object found on which to call \"" << methodName << "\" method. It is possible your Javascript object is not linked with the corresponding Java class. Try passing context(this) to the constructor function.";
string exceptionMessage = ss.str();
isolate->ThrowException(v8::Exception::ReferenceError(ConvertToV8String(exceptionMessage)));
return;
}
}
auto returnType = GetReturnType(sig);
switch (returnType[0])
{
case 'V': //void
{
if (isStatic)
{
env.CallStaticVoidMethodA(clazz, mid, javaArgs);
}
else if (isSuper)
{
env.CallNonvirtualVoidMethodA(callerJavaObject, clazz, mid, javaArgs);
}
else
{
env.CallVoidMethodA(callerJavaObject, mid, javaArgs);
}
break;
}
case 'Z': //bool
{
jboolean result;
if (isStatic)
{
result = env.CallStaticBooleanMethodA(clazz, mid, javaArgs);
}
else if (isSuper)
{
result = env.CallNonvirtualBooleanMethodA(callerJavaObject, clazz, mid, javaArgs);
}
else
{
result = env.CallBooleanMethodA(callerJavaObject, mid, javaArgs);
}
args.GetReturnValue().Set(result != 0 ? True(isolate) : False(isolate));
break;
}
case 'B': //byte
{
jbyte result;
if (isStatic)
{
result = env.CallStaticByteMethodA(clazz, mid, javaArgs);
}
else if (isSuper)
{
result = env.CallNonvirtualByteMethodA(callerJavaObject, clazz, mid, javaArgs);
}