[Android] jni: Reorganize getters and setters
Edward Wang
git at videolan.org
Fri Aug 24 14:41:06 CEST 2012
vlc-ports/android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Wed Aug 22 17:15:03 2012 -0400| [3641da43278c7630841ae422aee3163f20d160e2] | committer: Jean-Baptiste Kempf
jni: Reorganize getters and setters
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=3641da43278c7630841ae422aee3163f20d160e2
---
vlc-android/jni/libvlcjni.c | 108 ++++++++++++++++++++++---------------------
1 file changed, 55 insertions(+), 53 deletions(-)
diff --git a/vlc-android/jni/libvlcjni.c b/vlc-android/jni/libvlcjni.c
index 5a1d5ef..9c14c76 100644
--- a/vlc-android/jni/libvlcjni.c
+++ b/vlc-android/jni/libvlcjni.c
@@ -67,6 +67,61 @@ static void setInt(JNIEnv *env, jobject item, const char* field, jint value) {
(*env)->SetIntField(env, item, fieldId, value);
}
+static jlong getLong(JNIEnv *env, jobject thiz, const char* field) {
+ jclass clazz = (*env)->GetObjectClass(env, thiz);
+ jfieldID fieldMP = (*env)->GetFieldID(env, clazz,
+ field, "J");
+ return (*env)->GetLongField(env, thiz, fieldMP);
+}
+static void setLong(JNIEnv *env, jobject item, const char* field, jlong value) {
+ jclass cls;
+ jfieldID fieldId;
+
+ /* Get a reference to item's class */
+ cls = (*env)->GetObjectClass(env, item);
+
+ /* Look for the instance field s in cls */
+ fieldId = (*env)->GetFieldID(env, cls, field, "J");
+ if (fieldId == NULL)
+ return;
+
+ (*env)->SetLongField(env, item, fieldId, value);
+}
+
+static void setFloat(JNIEnv *env, jobject item, const char* field, jfloat value) {
+ jclass cls;
+ jfieldID fieldId;
+
+ /* Get a reference to item's class */
+ cls = (*env)->GetObjectClass(env, item);
+
+ /* Look for the instance field s in cls */
+ fieldId = (*env)->GetFieldID(env, cls, field, "F");
+ if (fieldId == NULL)
+ return;
+
+ (*env)->SetFloatField(env, item, fieldId, value);
+}
+static void setString(JNIEnv *env, jobject item, const char* field, const char* text) {
+ jclass cls;
+ jfieldID fieldId;
+ jstring jstr;
+
+ /* Get a reference to item's class */
+ cls = (*env)->GetObjectClass(env, item);
+
+ /* Look for the instance field s in cls */
+ fieldId = (*env)->GetFieldID(env, cls, field, "Ljava/lang/String;");
+ if (fieldId == NULL)
+ return;
+
+ /* Create a new string and overwrite the instance field */
+ jstr = (*env)->NewStringUTF(env, text);
+ if (jstr == NULL)
+ return;
+ (*env)->SetObjectField(env, item, fieldId, jstr);
+}
+
struct length_change_monitor {
pthread_mutex_t doneMutex;
pthread_cond_t doneCondVar;
@@ -408,59 +463,6 @@ void Java_org_videolan_vlc_LibVLC_setEventManager(JNIEnv *env, jobject thiz, job
eventManagerInstance = (*env)->NewGlobalRef(env, eventManager);
}
-void setLong(JNIEnv *env, jobject item, const char* field, long value)
-{
- jclass cls;
- jfieldID fieldId;
-
- /* Get a reference to item's class */
- cls = (*env)->GetObjectClass(env, item);
-
- /* Look for the instance field s in cls */
- fieldId = (*env)->GetFieldID(env, cls, field, "J");
- if (fieldId == NULL)
- return;
-
- (*env)->SetLongField(env, item, fieldId, value);
-}
-
-void setFloat(JNIEnv *env, jobject item, const char* field, float value)
-{
- jclass cls;
- jfieldID fieldId;
-
- /* Get a reference to item's class */
- cls = (*env)->GetObjectClass(env, item);
-
- /* Look for the instance field s in cls */
- fieldId = (*env)->GetFieldID(env, cls, field, "F");
- if (fieldId == NULL)
- return;
-
- (*env)->SetFloatField(env, item, fieldId, value);
-}
-
-void setString(JNIEnv *env, jobject item, const char* field, const char* text)
-{
- jclass cls;
- jfieldID fieldId;
- jstring jstr;
-
- /* Get a reference to item's class */
- cls = (*env)->GetObjectClass(env, item);
-
- /* Look for the instance field s in cls */
- fieldId = (*env)->GetFieldID(env, cls, field, "Ljava/lang/String;");
- if (fieldId == NULL)
- return;
-
- /* Create a new string and overwrite the instance field */
- jstr = (*env)->NewStringUTF(env, text);
- if (jstr == NULL)
- return;
- (*env)->SetObjectField(env, item, fieldId, jstr);
-}
-
jobjectArray Java_org_videolan_vlc_LibVLC_readMediaMeta(JNIEnv *env,
jobject thiz, jint instance, jstring mrl)
{
More information about the Android
mailing list