Beispiel #1
0
static void awtLock(JNIEnv *env, XlibBlitter *blt) {
  jmethodID mid;
  jclass cls;
  
  if ( jawt == 1 ) {
    cls = (jclass)(*env)->FindClass(env, "com/sun/media/DrawingSurfaceJAWT");
    if ( cls == NULL ) {
	printf("in awtLock cls is null\n");
	return;
    }
    mid = (*env)->GetStaticMethodID(env, cls, "lockAWT", "(I)Z");
    if ( mid == NULL ) {
	printf("in awtLock mid is null\n");
	return;
    }

    (*env)->CallStaticBooleanMethod(env, cls, mid, blt->drawingSurface);
    if((*env)->ExceptionOccurred(env)) {
	(*env)->ExceptionDescribe(env);
	(*env)->ExceptionClear(env);
    }

    return;
  } else {
    CallIntMethod(env, blt->surface, "lock", "()I", NULL);
  }
}
int platformVibrate(uint64_t milliseconds)
{
	auto env = gApp->activity->env;
	auto vm = gApp->activity->vm;
	auto obj = gApp->activity->clazz;

    vm->AttachCurrentThread( &env, NULL );

	auto clazz = env->GetObjectClass(obj);
	jmethodID vibrateID = env->GetMethodID(clazz, "vibrate", "(J)I");
    auto result = env->CallIntMethod(obj, vibrateID, milliseconds);
    vm->DetachCurrentThread();
    return result;
}
uint32_t platformLanIP()
{
	auto env = gApp->activity->env;
	auto vm = gApp->activity->vm;
	auto obj = gApp->activity->clazz;

	vm->AttachCurrentThread( &env, NULL );

	auto clazz = env->GetObjectClass(obj);
	jmethodID methodID = env->GetMethodID(clazz, "getLanIp", "()I");
	auto result = env->CallIntMethod(obj, methodID);
	vm->DetachCurrentThread();
	return result;
}
Beispiel #4
0
int JInputStream::read(JArray<jbyte>& buffer, jint byteOffset, jint byteCount) {
	return CallIntMethod("read", "([BII)I", buffer.GetJObject(), byteOffset, byteCount);
}
Beispiel #5
0
int JInputStream::read(JArray<jbyte>& buffer) {
	return CallIntMethod("read", "([B)I", buffer.GetJObject());
}
Beispiel #6
0
int JInputStream::read() {
	return CallIntMethod("read", "()I");
}
Beispiel #7
0
USER_OBJECT_ 
RS_JAVA(MethodConverter)(jobject obj, jclass type, JNIEnv *env, RSFromJavaConverter *converter)
{
 int i = 0, k, n;
 int numSlots;
 USER_OBJECT_ ans, names;
 const char *tmp;

 jboolean isCopy;
 jstring jval;
 jclass klass;
 jobject jsig, jobj;
 ReflectanceMethodIDs *mids;
 boolean isMethod;
 jint modifier;

 if(ModifierStringID == NULL)
  initReflectanceMethods(env);

  /* Determine whether we have a constructor or method
     and set the method identifiers and number of slots
     appropriately.
   */
 isMethod = VMENV IsSameObject(env, type, VMENV FindClass(env, "java/lang/reflect/Method")) == JNI_TRUE;

 if(isMethod) {
   mids = &MethodIDs;
   numSlots = 6;
 } else {
   mids = &ConstructorIDs;
   numSlots = 5; /* Drop out the */
 }
 
 
 PROTECT(ans = NEW_LIST(numSlots));
 PROTECT(names = NEW_CHARACTER(numSlots));
 
 SET_VECTOR_ELT(ans, i, NEW_CHARACTER(1));
 jval = VMENV CallObjectMethod(env, obj, mids->getName);
 tmp = VMENV GetStringUTFChars(env, jval, &isCopy);  
 SET_STRING_ELT(VECTOR_ELT(ans, i), 0, COPY_TO_USER_STRING(tmp));
 if(isCopy)
   VMENV ReleaseStringUTFChars(env, jval, tmp);
 SET_STRING_ELT(names, i, COPY_TO_USER_STRING("name"));
 i++;

 SET_VECTOR_ELT(ans, i, NEW_CHARACTER(1));
 klass = VMENV CallObjectMethod(env, obj, mids->getClass);
 tmp = getClassName(env, klass, &isCopy);
 SET_STRING_ELT(VECTOR_ELT(ans, i), 0, COPY_TO_USER_STRING(tmp));
 SET_STRING_ELT(names, i, COPY_TO_USER_STRING("Declaring class")); 
 i++;


 jsig = VMENV CallObjectMethod(env, obj, mids->getParameters);
 n = VMENV GetArrayLength(env, jsig);
 SET_VECTOR_ELT(ans, i, NEW_CHARACTER(n));
 for(k = 0; k < n ; k++) {
   jobj = VMENV GetObjectArrayElement(env, jsig, k);
   tmp = getClassName(env, jobj, &isCopy);
   SET_STRING_ELT(VECTOR_ELT(ans, i), k, COPY_TO_USER_STRING(tmp));
 }
 SET_STRING_ELT(names, i, COPY_TO_USER_STRING("Parameters"));    
 i++;

 
 SET_VECTOR_ELT(ans, i, NEW_INTEGER(1));
 modifier = VMENV CallIntMethod(env, obj, mids->getModifiers);
 INTEGER_DATA(VECTOR_ELT(ans, i))[0] = modifier;
 SET_STRING_ELT(names, i, COPY_TO_USER_STRING("Modifiers"));
 {
      /* Now get the string that represents the modifier value.
         Do this by calling the static method toString(int)
         in the java.lang.reflect.Modifier class.
         We assume we have initialized the ModifierStringID
         method id earlier when getting all the method ids
         for the reflectance classes.
       */
   USER_OBJECT_ tmpr;
   const char *modName;
   jstring jmodName;
    PROTECT(tmpr = NEW_CHARACTER(1));
    jmodName = VMENV CallStaticObjectMethod(env, (jclass)VMENV FindClass(env, "java/lang/reflect/Modifier"), ModifierStringID, modifier);

   if(jmodName != NULL_JAVA_OBJECT) {
      modName = VMENV GetStringUTFChars(env, jmodName, &isCopy);   
      SET_STRING_ELT(tmpr, 0, COPY_TO_USER_STRING(modName));
    }
    SET_NAMES(VECTOR_ELT(ans, i), tmpr);
    UNPROTECT(1);
 }
 i++;


 jsig = VMENV CallObjectMethod(env, obj, mids->getExceptions);
 n = VMENV GetArrayLength(env, jsig);
 SET_VECTOR_ELT(ans, i, NEW_CHARACTER(n));
 for(k = 0; k < n ; k++) {
   jobj = VMENV GetObjectArrayElement(env, jsig, k);
   tmp = getClassName(env, jobj, &isCopy);
   SET_STRING_ELT(VECTOR_ELT(ans, i), k, COPY_TO_USER_STRING(tmp));
 }
 SET_STRING_ELT(names, i, COPY_TO_USER_STRING("Exceptions"));    
 i++;

 

 if(isMethod) {
   SET_VECTOR_ELT(ans, i, NEW_CHARACTER(1));
   klass = VMENV CallObjectMethod(env, obj, mids->getReturnType);
   tmp = getClassName(env, klass, &isCopy);
   SET_VECTOR_ELT(VECTOR_ELT(ans, i), 0, COPY_TO_USER_STRING(tmp));
   SET_STRING_ELT(names, i, COPY_TO_USER_STRING("Return type"));    
   i++;
 }
 
 SET_NAMES(ans, names); 
 
 /* Now set the class to be "JavaMethod" */

 UNPROTECT(2);

 return(ans);
}
Beispiel #8
0
jint JNumber::intValue() {
	return CallIntMethod("intValue", "()I");
}