wrote misc header, JNI wrapper

"BGB" <[email protected]>
Newsgroups gmane.comp.gcc.java.devel
Message-ID <[email protected]>
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); }
..
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.