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