1 /******************************************************************
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 ******************************************************************/
21 #ifndef SIMULATOR_COMMON_JNI_H_
22 #define SIMULATOR_COMMON_JNI_H_
33 jclass classSimulatorResource;
34 jclass classSimulatorResourceModel;
35 jclass classSimulatorResourceAttribute;
36 jclass classSimulatorRemoteResource;
37 jclass classSimulatorCallback;
39 jmethodID classIntegerCtor;
40 jmethodID classDoubleCtor;
41 jmethodID classHashMapCtor;
42 jmethodID classHashMapPut;
43 jmethodID classVectorCtor;
44 jmethodID classVectorAddElement;
45 jmethodID classSimulatorResourceCtor;
46 jmethodID classSimulatorResourceSetURI;
47 jmethodID classSimulatorResourceSetResourceType;
48 jmethodID classSimulatorResourceSetInterfaceType;
49 jmethodID classSimulatorResourceSetName;
50 jmethodID classSimulatorResourceModelCtor;
51 jmethodID classSimulatorResourceAttributeCtor;
54 static jfieldID GetHandleField(JNIEnv *env, jobject jobj)
56 jclass cls = env->GetObjectClass(jobj);
57 return env->GetFieldID(cls, "nativeHandle", "J");
61 static T *GetHandle(JNIEnv *env, jobject jobj)
63 jlong handle = env->GetLongField(jobj, GetHandleField(env, jobj));
64 return reinterpret_cast<T *>(handle);
68 static void SetHandle(JNIEnv *env, jobject jobj, T *type)
70 jlong handle = reinterpret_cast<jlong>(type);
72 env->SetLongField(jobj, GetHandleField(env, jobj), handle);