예제 #1
0
파일: z_jni.c 프로젝트: pjlegato/libpd
static jobjectArray makeJavaArray(JNIEnv *env, int argc, t_atom *argv) {
  jobjectArray jarray = (*env)->NewObjectArray(env, argc, objClass, NULL);
  int i;
  for (i = 0; i < argc; i++) {
    t_atom a = argv[i];
    jobject obj = NULL;
    if (libpd_is_float(a)) {
      obj = (*env)->NewObject(env, floatClass, floatInit, libpd_get_float(a));
    } else if (libpd_is_symbol(a)) {
      obj = (*env)->NewStringUTF(env, libpd_get_symbol(a));
    }
    (*env)->SetObjectArrayElement(env, jarray, i, obj);
  }
  return jarray;
}
예제 #2
0
static jobjectArray makeJavaArray(JNIEnv *env, int argc, t_atom *argv) {
  jobjectArray jarray = (*env)->NewObjectArray(env, argc, objClass, NULL);
  int i;
  for (i = 0; i < argc; i++) {
    t_atom *a = &argv[i];
    jobject obj = NULL;
    if (libpd_is_float(a)) {
      obj = (*env)->NewObject(env, floatClass, floatInit, libpd_get_float(a));
    } else if (libpd_is_symbol(a)) {
      obj = (*env)->NewStringUTF(env, libpd_get_symbol(a));
    }
    (*env)->SetObjectArrayElement(env, jarray, i, obj);
    if (obj != NULL) {
      (*env)->DeleteLocalRef(env, obj);  // The reference in the array remains.
    }
  }
  return jarray;
}