public inbox for java@gcc.gnu.org
 help / color / mirror / Atom feed
* wrote misc header, JNI wrapper
@ 2008-10-26 11:30 BGB
  0 siblings, 0 replies; only message in thread
From: BGB @ 2008-10-26 11:30 UTC (permalink / raw)
  To: java

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); }
..

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-10-26 11:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-26 11:30 wrote misc header, JNI wrapper BGB

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).