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_
38 jclass classLinkedList;
40 jclass classSimulatorResource;
41 jclass classSimulatorResourceModel;
42 jclass classResourceAttribute;
43 jclass classSimulatorRemoteResource;
44 jclass classSimulatorCallback;
45 jclass classObserverInfo;
46 jclass classDeviceInfo;
47 jclass classPlatformInfo;
48 jclass classSimulatorException;
49 jclass classInvalidArgsException;
50 jclass classNoSupportException;
51 jclass classOperationInProgressException;
53 jmethodID classIntegerCtor;
54 jmethodID classDoubleCtor;
55 jmethodID classHashMapCtor;
56 jmethodID classHashMapPut;
57 jmethodID classVectorCtor;
58 jmethodID classVectorAddElement;
59 jmethodID classMapEntrySet;
60 jmethodID classMapGetKey;
61 jmethodID classMapGetValue;
62 jmethodID classIteratorId;
63 jmethodID classHasNextId;
64 jmethodID classNextId;
65 jmethodID classLinkedListCtor;
66 jmethodID classLinkedListAddObject;
68 jmethodID classSimulatorResourceCtor;
69 jmethodID classSimulatorResourceModelCtor;
70 jmethodID classResourceAttributeCtor;
71 jmethodID classResourceAttributeSetRange;
72 jmethodID classSimulatorResourceModelId;
73 jmethodID classObserverInfoCtor;
74 jmethodID classSimulatorExceptionCtor;
75 jmethodID classInvalidArgsExceptionCtor;
76 jmethodID classNoSupportExceptionCtor;
77 jmethodID classOperationInProgressExceptionCtor;
81 static jfieldID GetHandleField(JNIEnv *env, jobject jobj)
83 jclass cls = env->GetObjectClass(jobj);
84 return env->GetFieldID(cls, "nativeHandle", "J");
88 static T *GetHandle(JNIEnv *env, jobject jobj)
90 jlong handle = env->GetLongField(jobj, GetHandleField(env, jobj));
91 return reinterpret_cast<T *>(handle);
95 static void SetHandle(JNIEnv *env, jobject jobj, T *type)
97 jlong handle = reinterpret_cast<jlong>(type);
99 env->SetLongField(jobj, GetHandleField(env, jobj), handle);