Debian Codegraph @

Source/Control/Interface/JNI/CJNIHandlingClassData.cpp

raw
1 /*
2 * Copyright (C) 2013-2015, 2019 by the Konclude Developer Team.
3 *
4 * This file is part of the reasoning system Konclude.
5 * For details and support, see <http://konclude.com/>.
6 *
7 * Konclude is free software: you can redistribute it and/or modify
8 * it under the terms of version 3 of the GNU Lesser General Public
9 * License (LGPLv3) as published by the Free Software Foundation.
10 *
11 * Konclude is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU (Lesser) General Public License for more details.
15 *
16 * You should have received a copy of the GNU (Lesser) General Public
17 * License along with Konclude. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21 #include "CJNIHandlingClassData.h"
22
23
24 namespace Konclude {
25
26 namespace Control {
27
28 namespace Interface {
29
30 namespace JNI {
31
32 #ifdef KONCLUDE_COMPILE_JNI_INTERFACE
33
34 CJNIHandlingClassData::CJNIHandlingClassData(JNIEnv* jenv, const char* arrayClassName) {
35 mArrayClassName = arrayClassName;
36 mClassName = arrayClassName+1;
37
38 mJenv = jenv;
39 mClassID = nullptr;
40 mArrayClassID = nullptr;
41 mNativeDataFieldID = nullptr;
42 mConstructorMethodID = nullptr;
43 mVisitingMethodID = nullptr;
44 mEndVisitObjectSetMethodID = nullptr;
45 mStartVisitObjectSetMethodID = nullptr;
46 }
47
48 CJNIHandlingClassData::~CJNIHandlingClassData() {
49 if (mClassID) {
50 mJenv->DeleteGlobalRef(mClassID);
51 }
52 if (mArrayClassID) {
53 mJenv->DeleteGlobalRef(mArrayClassID);
54 }
55 }
56
57
58 jclass CJNIHandlingClassData::getClassID() {
59 if (!mClassID) {
60 mClassID = mJenv->FindClass(mClassName);
61 mClassID = (jclass)mJenv->NewGlobalRef(mClassID);
62 }
63 return mClassID;
64 }
65
66 jclass CJNIHandlingClassData::getArrayClassID() {
67 if (!mArrayClassID) {
68 mArrayClassID = mJenv->FindClass(mArrayClassName);
69 mArrayClassID = (jclass)mJenv->NewGlobalRef(mArrayClassID);
70 }
71 return mArrayClassID;
72 }
73
74 jfieldID CJNIHandlingClassData::getNativeDataFieldID() {
75 if (!mNativeDataFieldID) {
76 mNativeDataFieldID = mJenv->GetFieldID(getClassID(),"mNativeDataPointer","J");
77 }
78 return mNativeDataFieldID;
79 }
80
81 jmethodID CJNIHandlingClassData::getConstrutorMethodID() {
82 if (!mConstructorMethodID) {
83 mConstructorMethodID = mJenv->GetMethodID(getClassID(),"<init>","()V");
84 }
85 return mConstructorMethodID;
86 }
87
88 jmethodID CJNIHandlingClassData::getVisitObjectMethodID() {
89 if (!mVisitingMethodID) {
90 mVisitingMethodID = mJenv->GetMethodID(getClassID(),"visitObject","(Ljava/lang/Object;)V");
91 }
92 return mVisitingMethodID;
93 }
94
95 jmethodID CJNIHandlingClassData::getEndVisitObjectSetMethodID() {
96 if (!mEndVisitObjectSetMethodID) {
97 mEndVisitObjectSetMethodID = mJenv->GetMethodID(getClassID(),"endObjectSet","()V");
98 }
99 return mEndVisitObjectSetMethodID;
100 }
101
102 jmethodID CJNIHandlingClassData::getStartVisitObjectSetMethodID() {
103 if (!mStartVisitObjectSetMethodID) {
104 mStartVisitObjectSetMethodID = mJenv->GetMethodID(getClassID(),"startObjectSet","()V");
105 }
106 return mStartVisitObjectSetMethodID;
107 }
108 #endif
109
110
111 }; // end namespace JNI
112
113 }; // end namespace Interface
114
115 }; // end namespace Control
116
117 }; // end namespace Konclude