Mercurial > hg > jvamp
view src/handle.h @ 0:f718b0961713
First draft -- can load a plugin and print its name & description
author | Chris Cannam |
---|---|
date | Fri, 13 Jan 2012 14:08:01 +0000 |
parents | |
children | c9515589be7d |
line wrap: on
line source
#ifndef _HANDLE_H_INCLUDED_ #define _HANDLE_H_INCLUDED_ inline jfieldID getHandleField(JNIEnv *env, jobject obj) { jclass c = env->GetObjectClass(obj); return env->GetFieldID(c, "nativeHandle", "J"); } template <typename T> T *getHandle(JNIEnv *env, jobject obj) { jlong handle = env->GetLongField(obj, getHandleField(env, obj)); return reinterpret_cast<T *>(handle); } template <typename T> void setHandle(JNIEnv *env, jobject obj, T *t) { jlong handle = reinterpret_cast<jlong>(t); env->SetLongField(obj, getHandleField(env, obj), handle); } #endif