当前位置: 首页>>代码示例>>C++>>正文


C++ JNIEnv::CallBooleanMethodA方法代码示例

本文整理汇总了C++中JNIEnv::CallBooleanMethodA方法的典型用法代码示例。如果您正苦于以下问题:C++ JNIEnv::CallBooleanMethodA方法的具体用法?C++ JNIEnv::CallBooleanMethodA怎么用?C++ JNIEnv::CallBooleanMethodA使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JNIEnv的用法示例。


在下文中一共展示了JNIEnv::CallBooleanMethodA方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
   }
开发者ID:deltaluca,项目名称:Haxe-NME--fork-,代码行数:57,代码来源:JNI.cpp

示例2:

Handle<Value> TiAndroidRequeststoragepermissionModule::hasStoragePermission(const Arguments& args)
{
	LOGD(TAG, "hasStoragePermission()");
	HandleScope scope;

	JNIEnv *env = titanium::JNIScope::getEnv();
	if (!env) {
		return titanium::JSException::GetJNIEnvironmentError();
	}
	static jmethodID methodID = NULL;
	if (!methodID) {
		methodID = env->GetMethodID(TiAndroidRequeststoragepermissionModule::javaClass, "hasStoragePermission", "()Z");
		if (!methodID) {
			const char *error = "Couldn't find proxy method 'hasStoragePermission' with signature '()Z'";
			LOGE(TAG, error);
				return titanium::JSException::Error(error);
		}
	}

	titanium::Proxy* proxy = titanium::Proxy::unwrap(args.Holder());

	jvalue* jArguments = 0;

	jobject javaProxy = proxy->getJavaObject();
	jboolean jResult = (jboolean)env->CallBooleanMethodA(javaProxy, methodID, jArguments);



	if (!JavaObject::useGlobalRefs) {
		env->DeleteLocalRef(javaProxy);
	}



	if (env->ExceptionCheck()) {
		Handle<Value> jsException = titanium::JSException::fromJavaException();
		env->ExceptionClear();
		return jsException;
	}


	Handle<Boolean> v8Result = titanium::TypeConverter::javaBooleanToJsBoolean(env, jResult);



	return v8Result;

}
开发者ID:benbahrenburg,项目名称:Ti-Android-RequestStoragePermission,代码行数:48,代码来源:com.boxoutthinkers.reqstorageperm.TiAndroidRequeststoragepermissionModule.cpp

示例3: call


//.........这里部分代码省略.........

				} break;
				case Variant::REAL_ARRAY: {

					DVector<float> array = *p_args[i];
					jfloatArray arr = env->NewFloatArray(array.size());
					DVector<float>::Read r = array.read();
					env->SetFloatArrayRegion(arr,0,array.size(),r.ptr());
					v[i].l=arr;

				} break;
				default: {

					ERR_FAIL_V(Variant());
				} break;

			}
		}

		print_line("calling method!!");

		Variant ret;

		switch(E->get().ret_type) {

			case Variant::NIL: {


				print_line("call void");
				env->CallVoidMethodA(instance,E->get().method,v);
			} break;
			case Variant::BOOL: {

				ret = env->CallBooleanMethodA(instance,E->get().method,v);
				print_line("call bool");
			} break;
			case Variant::INT: {

				ret = env->CallIntMethodA(instance,E->get().method,v);
				print_line("call int");
			} break;
			case Variant::REAL: {

				ret = env->CallFloatMethodA(instance,E->get().method,v);
			} break;
			case Variant::STRING: {

				jobject o = env->CallObjectMethodA(instance,E->get().method,v);
				String singname = env->GetStringUTFChars((jstring)o, NULL );
			} break;
			case Variant::STRING_ARRAY: {

				jobjectArray arr = (jobjectArray)env->CallObjectMethodA(instance,E->get().method,v);

				int stringCount = env->GetArrayLength(arr);
				DVector<String> sarr;

				for (int i=0; i<stringCount; i++) {
					jstring string = (jstring) env->GetObjectArrayElement(arr, i);
					const char *rawString = env->GetStringUTFChars(string, 0);
					sarr.push_back(String(rawString));
				}

				ret=sarr;

			} break;
开发者ID:0871087123,项目名称:godot,代码行数:67,代码来源:godot_android.cpp

示例4: call

	virtual Variant call(const StringName& p_method,const Variant** p_args,int p_argcount,Variant::CallError &r_error) {

		//print_line("attempt to call "+String(p_method));
		ERR_FAIL_COND_V(!instance,Variant());

		r_error.error=Variant::CallError::CALL_OK;

		Map<StringName,MethodData >::Element *E=method_map.find(p_method);
		if (!E) {

			print_line("no exists");
			r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD;
			return Variant();
		}



		int ac = E->get().argtypes.size();
		if (ac<p_argcount) {

			print_line("fewargs");
			r_error.error=Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
			r_error.argument=ac;
			return Variant();
		}

		if (ac>p_argcount) {

			print_line("manyargs");
			r_error.error=Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
			r_error.argument=ac;
			return Variant();
		}


		for(int i=0;i<p_argcount;i++) {

			if (!Variant::can_convert(p_args[i]->get_type(),E->get().argtypes[i])) {

				r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
				r_error.argument=i;
				r_error.expected=E->get().argtypes[i];
			}
		}


		jvalue *v=NULL;

		if (p_argcount) {

			v=(jvalue*)alloca( sizeof(jvalue)*p_argcount );
		}

		JNIEnv *env = ThreadAndroid::get_env();

		int res = env->PushLocalFrame(16);

		ERR_FAIL_COND_V(res!=0,Variant());

		//print_line("argcount "+String::num(p_argcount));
		List<jobject> to_erase;
		for(int i=0;i<p_argcount;i++) {

			jvalret vr = _variant_to_jvalue(env, E->get().argtypes[i], p_args[i]);
			v[i] = vr.val;
			if (vr.obj)
				to_erase.push_back(vr.obj);
		}

		//print_line("calling method!!");

		Variant ret;

		switch(E->get().ret_type) {

			case Variant::NIL: {


				//print_line("call void");
				env->CallVoidMethodA(instance,E->get().method,v);
			} break;
			case Variant::BOOL: {

				ret = env->CallBooleanMethodA(instance,E->get().method,v);
				//print_line("call bool");
			} break;
			case Variant::INT: {

				ret = env->CallIntMethodA(instance,E->get().method,v);
				//print_line("call int");
			} break;
			case Variant::REAL: {

				ret = env->CallFloatMethodA(instance,E->get().method,v);
			} break;
			case Variant::STRING: {

				jobject o = env->CallObjectMethodA(instance,E->get().method,v);
				String str = env->GetStringUTFChars((jstring)o, NULL );
				ret=str;
//.........这里部分代码省略.........
开发者ID:AutonomicStudios,项目名称:godot,代码行数:101,代码来源:java_glue.cpp

示例5: _call_method


//.........这里部分代码省略.........

            argv[i].l=a;
            to_free.push_back(a);
        }
        break;
        case ARG_ARRAY_BIT|ARG_TYPE_CLASS: {

            argv[i].l=NULL;
        }
        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: {
开发者ID:James-Z,项目名称:godot,代码行数:66,代码来源:java_class_wrapper.cpp

示例6: methodSig


//.........这里部分代码省略.........
      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:
        case nsXPTType::T_U16:
          retval.i = env->CallIntMethodA(javaObject, mid, java_params);
          break;

        case nsXPTType::T_I64:
        case nsXPTType::T_U32:
          retval.j = env->CallLongMethodA(javaObject, mid, java_params);
          break;

        case nsXPTType::T_FLOAT:
          retval.f = env->CallFloatMethodA(javaObject, mid, java_params);
          break;

        case nsXPTType::T_U64:
        case nsXPTType::T_DOUBLE:
          retval.d = env->CallDoubleMethodA(javaObject, mid, java_params);
          break;

        case nsXPTType::T_BOOL:
          retval.z = env->CallBooleanMethodA(javaObject, mid, java_params);
          break;

        case nsXPTType::T_CHAR:
        case nsXPTType::T_WCHAR:
          retval.c = env->CallCharMethodA(javaObject, mid, java_params);
          break;

        case nsXPTType::T_CHAR_STR:
        case nsXPTType::T_WCHAR_STR:
        case nsXPTType::T_IID:
        case nsXPTType::T_ASTRING:
        case nsXPTType::T_DOMSTRING:
        case nsXPTType::T_UTF8STRING:
        case nsXPTType::T_CSTRING:
        case nsXPTType::T_INTERFACE:
        case nsXPTType::T_INTERFACE_IS:
          retval.l = env->CallObjectMethodA(javaObject, mid, java_params);
          break;

        case nsXPTType::T_VOID:
          retval.j = env->CallLongMethodA(javaObject, mid, java_params);
          break;

        default:
          NS_WARNING("Unhandled retval type");
          break;
      }
    }

    // Check for exception from called Java function
    jthrowable exp = env->ExceptionOccurred();
    if (exp) {
开发者ID:bringhurst,项目名称:vbox,代码行数:67,代码来源:nsJavaXPTCStub.cpp


注:本文中的JNIEnv::CallBooleanMethodA方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。