dvm: Add some more helper macros
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Thu, 13 Dec 2012 12:13:12 +0000 (12:13 +0000)
committerNicolas Dufresne <nicolas.dufresne@collabora.com>
Thu, 21 Jan 2016 18:49:14 +0000 (13:49 -0500)
gst-libs/gst/dvm/gst-dvm.h

index e3f15fd..5905d81 100644 (file)
     return FALSE;                                                       \
   }
 
+#define GST_DVM_GET_STATIC_FIELD(k, field, signature)                   \
+  k.field = (*env)->GetStaticFieldID (env, k.klass, #field, signature); \
+  if (!k.field) {                                                       \
+    (*env)->ExceptionClear (env);                                       \
+    GST_ERROR ("Failed to get static field %s for %s", #field, #k);     \
+    return FALSE;                                                       \
+  }
+
 #define GST_DVM_GET_FIELD(k, field, signature)                          \
   k.field = (*env)->GetFieldID (env, k.klass, #field, signature);       \
   if (!k.field) {                                                       \
     error_statement;                                                    \
   }
 
+#define GST_DVM_FIELD(error_statement, obj, type, k, field)             \
+  (*env)->Get##type##Field (env, obj, k.field);                         \
+  if ((*env)->ExceptionCheck (env)) {                                   \
+    GST_ERROR ("Failed to get Java field");                             \
+    (*env)->ExceptionDescribe (env);                                    \
+    (*env)->ExceptionClear (env);                                       \
+    error_statement;                                                    \
+  }
 
+#define GST_DVM_STATIC_FIELD(error_statement, type, k, field)           \
+  (*env)->Get##type##Field (env, k.klass, k.field);                     \
+  if ((*env)->ExceptionCheck (env)) {                                   \
+    GST_ERROR ("Failed to get Java static field");                      \
+    (*env)->ExceptionDescribe (env);                                    \
+    (*env)->ExceptionClear (env);                                       \
+    error_statement;                                                    \
+  }
 
 JNIEnv *gst_dvm_get_env (void);
 gboolean gst_dvm_init (void);