Mercurial > hg > jvamp
view src/handle.h @ 21:0a91d898acc3
Finish implementation of RealTime; add dispose() calls
author | Chris Cannam |
---|---|
date | Thu, 09 Feb 2012 16:18:33 +0000 |
parents | f718b0961713 |
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