javauis/javalegacyutils/inc/JniEnvWrapper.h
changeset 76 4ad59aaee882
parent 69 773449708c84
child 79 2f468c1958d0
equal deleted inserted replaced
69:773449708c84 76:4ad59aaee882
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef JNIENVWRAPPER_H
       
    20 #define JNIENVWRAPPER_H
       
    21 
       
    22 #include <jni.h>
       
    23 #define JNIENV_TO_VM(aJni) JavaVM* vm;\
       
    24                            aJni->GetJavaVM(&vm); /* Get pointer to VM*/\
       
    25                            JNIEnv* castedJNIEnv = reinterpret_cast< JNIEnv* >(vm); /* Get pointer to VM*/
       
    26 #define JNI_PARAM castedJNIEnv
       
    27 #define JNIENV_ATTACH(aJni) (reinterpret_cast< JavaVM* >(aJni))->AttachCurrentThreadAsDaemon((void**)&aJni, 0)
       
    28 
       
    29 class JniEnvWrapper
       
    30 {
       
    31 public:
       
    32     static void     InitJavaVmRef(JNIEnv* aJni);
       
    33     IMPORT_C static JNIEnv*  GetValidJniRef();
       
    34 };
       
    35 #endif // JNIENVWRAPPER_H