This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
wrote misc header, JNI wrapper
- From: "BGB" <cr88192 at hotmail dot com>
- To: <java at gcc dot gnu dot org>
- Date: Sun, 26 Oct 2008 21:30:09 +1000
- Subject: wrote misc header, JNI wrapper
well, I wrote a header, mostly for my own uses, which I will call
'jniwrap.h'.
the purpose is to provide a slightly less ugly interface to the JNI
functions, and also to add consistency between C and C++.
the structure is a big mass of static inline functions which wrap the
various JNI calls.
for example:
(*env)->GetVersion(env); //C
or:
env->GetVersion(); //C++
becomes:
jGetVersion(env); //C & C++
not sure if this is anything anyone would be interested in, I can send the
header if needed (just dunno if these lists like attachments).
start of header (partly reformated for OE-reasons...):
---
#ifndef JNIWRAP_H
#define JNIWRAP_H
#include <jni.h>
#ifdef __cplusplus
#define JNIENV env
#else
#define JNIENV (*env)
#endif
static inline jint jGetVersion(JNIEnv *env)
{ return JNIENV->GetVersion(env); }
static inline jclass jDefineClass(JNIEnv *env, const char *name,
jobject loader, const jbyte *buf, jsize len)
{ return JNIENV->DefineClass(env, name, loader, buf, len); }
static inline jclass jFindClass(JNIEnv *env, const char *name)
{ return JNIENV->FindClass(env, name); }
static inline jmethodID jFromReflectedMethod(JNIEnv *env, jobject mth)
{ return JNIENV->FromReflectedMethod(env, mth); }
static inline jfieldID jFromReflectedField(JNIEnv *env, jobject fld)
{ return JNIENV->FromReflectedField(env, fld); }
static inline jobject jToReflectedMethod(JNIEnv *env,
jclass cls, jmethodID mth, jboolean staticP)
{ return JNIENV->ToReflectedMethod(env, cls, mth, staticP); }
static inline jclass jGetSuperclass(JNIEnv *env, jclass sub)
{ return JNIENV->GetSuperclass(env, sub); }
static inline jboolean jIsAssignableFrom(JNIEnv *env,
jclass sub, jclass sup)
{ return JNIENV->IsAssignableFrom(env, sub, sup); }
..