本文整理汇总了C++中JNIEnv::CallByteMethodA方法的典型用法代码示例。如果您正苦于以下问题:C++ JNIEnv::CallByteMethodA方法的具体用法?C++ JNIEnv::CallByteMethodA怎么用?C++ JNIEnv::CallByteMethodA使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JNIEnv
的用法示例。
在下文中一共展示了JNIEnv::CallByteMethodA方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CallMember
value CallMember(jobject inObject, value inArgs)
{
JNIEnv *env = GetEnv();
jvalue jargs[MAX];
if (!HaxeToJNIArgs(env,inArgs,jargs))
{
CleanStringArgs();
ELOG("CallMember - bad argument list");
return alloc_null();
}
value result = 0;
switch(mReturn)
{
case jniVoid:
result = alloc_null();
env->CallVoidMethodA(inObject, mMethod, jargs);
break;
case jniObject:
result = JObjectToHaxe(env->CallObjectMethodA(inObject,mMethod, jargs));
break;
case jniObjectString:
result = JStringToHaxe(env,env->CallObjectMethodA(inObject, mMethod, jargs));
break;
case jniObjectArray:
result = JArrayToHaxe(env->CallObjectMethodA(inObject, mMethod, jargs));
break;
case jniBoolean:
result = alloc_bool(env->CallBooleanMethodA(inObject, mMethod, jargs));
break;
case jniByte:
result = alloc_int(env->CallByteMethodA(inObject, mMethod, jargs));
break;
case jniChar:
result = alloc_int(env->CallCharMethodA(inObject, mMethod, jargs));
break;
case jniShort:
result = alloc_int(env->CallShortMethodA(inObject, mMethod, jargs));
break;
case jniInt:
result = alloc_int(env->CallIntMethodA(mClass, mMethod, jargs));
break;
case jniLong:
result = alloc_int(env->CallLongMethodA(inObject, mMethod, jargs));
break;
case jniFloat:
result = alloc_float(env->CallFloatMethodA(inObject, mMethod, jargs));
break;
case jniDouble:
result = alloc_float(env->CallDoubleMethodA(inObject, mMethod, jargs));
break;
}
CleanStringArgs();
return result;
}
示例2: _call_method
//.........这里部分代码省略.........
}
break;
}
}
r_error.error=Variant::CallError::CALL_OK;
bool success=true;
switch(method->return_type) {
case ARG_TYPE_VOID: {
if (method->_static) {
env->CallStaticVoidMethodA(_class,method->method,argv);
} else {
env->CallVoidMethodA(p_instance->instance,method->method,argv);
}
ret=Variant();
}
break;
case ARG_TYPE_BOOLEAN: {
if (method->_static) {
ret=env->CallStaticBooleanMethodA(_class,method->method,argv);
} else {
ret=env->CallBooleanMethodA(p_instance->instance,method->method,argv);
}
}
break;
case ARG_TYPE_BYTE: {
if (method->_static) {
ret=env->CallStaticByteMethodA(_class,method->method,argv);
} else {
ret=env->CallByteMethodA(p_instance->instance,method->method,argv);
}
}
break;
case ARG_TYPE_CHAR: {
if (method->_static) {
ret=env->CallStaticCharMethodA(_class,method->method,argv);
} else {
ret=env->CallCharMethodA(p_instance->instance,method->method,argv);
}
}
break;
case ARG_TYPE_SHORT: {
if (method->_static) {
ret=env->CallStaticShortMethodA(_class,method->method,argv);
} else {
ret=env->CallShortMethodA(p_instance->instance,method->method,argv);
}
}
break;
case ARG_TYPE_INT: {
if (method->_static) {
ret=env->CallStaticIntMethodA(_class,method->method,argv);
} else {
ret=env->CallIntMethodA(p_instance->instance,method->method,argv);
}
}
break;
示例3: methodSig
NS_IMETHODIMP
nsJavaXPTCStub::CallMethod(PRUint16 aMethodIndex,
const XPTMethodDescriptor *aMethodInfo,
nsXPTCMiniVariant *aParams)
{
#ifdef DEBUG_JAVAXPCOM
const char* ifaceName;
mIInfo->GetNameShared(&ifaceName);
LOG(("---> (Java) %s::%s()\n", ifaceName, aMethodInfo->name));
#endif
nsresult rv = NS_OK;
JNIEnv* env = GetJNIEnv();
jobject javaObject = env->CallObjectMethod(mJavaWeakRef, getReferentMID);
nsCAutoString methodSig("(");
// Create jvalue array to hold Java params
PRUint8 paramCount = aMethodInfo->num_args;
jvalue* java_params = nsnull;
const nsXPTParamInfo* retvalInfo = nsnull;
if (paramCount) {
java_params = new jvalue[paramCount];
if (!java_params)
return NS_ERROR_OUT_OF_MEMORY;
for (PRUint8 i = 0; i < paramCount && NS_SUCCEEDED(rv); i++)
{
const nsXPTParamInfo ¶mInfo = aMethodInfo->params[i];
if (!paramInfo.IsRetval()) {
rv = SetupJavaParams(paramInfo, aMethodInfo, aMethodIndex, aParams,
aParams[i], java_params[i], methodSig);
} else {
retvalInfo = ¶mInfo;
}
}
NS_ASSERTION(NS_SUCCEEDED(rv), "SetupJavaParams failed");
}
// Finish method signature
if (NS_SUCCEEDED(rv)) {
methodSig.Append(')');
if (retvalInfo) {
nsCAutoString retvalSig;
rv = GetRetvalSig(retvalInfo, aMethodInfo, aMethodIndex, aParams,
retvalSig);
methodSig.Append(retvalSig);
} else {
methodSig.Append('V');
}
NS_ASSERTION(NS_SUCCEEDED(rv), "GetRetvalSig failed");
}
// Get Java method to call
jmethodID mid = nsnull;
if (NS_SUCCEEDED(rv)) {
nsCAutoString methodName;
if (XPT_MD_IS_GETTER(aMethodInfo->flags) ||
XPT_MD_IS_SETTER(aMethodInfo->flags)) {
if (XPT_MD_IS_GETTER(aMethodInfo->flags))
methodName.AppendLiteral("get");
else
methodName.AppendLiteral("set");
methodName.AppendASCII(aMethodInfo->name);
methodName.SetCharAt(toupper(methodName[3]), 3);
} else {
methodName.AppendASCII(aMethodInfo->name);
methodName.SetCharAt(tolower(methodName[0]), 0);
}
// If it's a Java keyword, then prepend an underscore
if (gJavaKeywords->GetEntry(methodName.get())) {
methodName.Insert('_', 0);
}
jclass clazz = env->GetObjectClass(javaObject);
if (clazz)
mid = env->GetMethodID(clazz, methodName.get(), methodSig.get());
NS_ASSERTION(mid, "Failed to get requested method for Java object");
if (!mid)
rv = NS_ERROR_FAILURE;
}
// Call method
jvalue retval;
if (NS_SUCCEEDED(rv)) {
if (!retvalInfo) {
env->CallVoidMethodA(javaObject, mid, java_params);
} else {
switch (retvalInfo->GetType().TagPart())
{
case nsXPTType::T_I8:
retval.b = env->CallByteMethodA(javaObject, mid, java_params);
break;
case nsXPTType::T_I16:
case nsXPTType::T_U8:
retval.s = env->CallShortMethodA(javaObject, mid, java_params);
break;
case nsXPTType::T_I32:
//.........这里部分代码省略.........