Debian Codegraph @

native/common/jp_voidtype.cpp

raw symbols SCIP
1 /*****************************************************************************
2 Licensed under the Apache License, Version 2.0 (the "License");
3 you may not use this file except in compliance with the License.
4 You may obtain a copy of the License at
5
6 http://www.apache.org/licenses/LICENSE-2.0
7
8 Unless required by applicable law or agreed to in writing, software
9 distributed under the License is distributed on an "AS IS" BASIS,
10 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 See the License for the specific language governing permissions and
12 limitations under the License.
13
14 See NOTICE file for details.
15 *****************************************************************************/
16 #include "jpype.h"
17 #include "jp_voidtype.h"
18
19 JPVoidType::JPVoidType()
20 : JPPrimitiveType("void")
21 {
22 }
23
24 JPVoidType::~JPVoidType()
25 = default;
26
27 JPClass* JPVoidType::getBoxedClass(JPJavaFrame& frame) const
28 {
29 return frame.getContext()->_java_lang_Void;
30 }
31
32 JPPyObject JPVoidType::invokeStatic(JPJavaFrame& frame, jclass claz, jmethodID mth, jvalue* val)
33 {
34 {
35 JPPyCallRelease call;
36 frame.CallStaticVoidMethodA(claz, mth, val);
37 }
38 return JPPyObject::getNone();
39 }
40
41 JPPyObject JPVoidType::invoke(JPJavaFrame& frame, jobject obj, jclass clazz, jmethodID mth, jvalue* val)
42 {
43 {
44 JPPyCallRelease call;
45 if (clazz == nullptr)
46 frame.CallVoidMethodA(obj, mth, val);
47 else
48 frame.CallNonvirtualVoidMethodA(obj, clazz, mth, val);
49 }
50 return JPPyObject::getNone();
51 }
52
53 // GCOVR_EXCL_START
54
55 JPValue JPVoidType::getValueFromObject(JPJavaFrame& frame, const JPValue& obj)
56 {
57 // This is needed if we call a caller sensitive method
58 // and we get a return which is expected to be a void object
59 JP_TRACE_IN("JPVoidType::getValueFromObject");
60 return JPValue(this, (jobject) nullptr);
61 JP_TRACE_OUT;
62 }
63
64 JPPyObject JPVoidType::getStaticField(JPJavaFrame& frame, jclass c, jfieldID fid)
65 {
66 JP_RAISE(PyExc_SystemError, "void cannot be the type of a static field.");
67 }
68
69 JPPyObject JPVoidType::getField(JPJavaFrame& frame, jobject c, jfieldID fid)
70 {
71 JP_RAISE(PyExc_SystemError, "void cannot be the type of a field.");
72 }
73
74 JPPyObject JPVoidType::convertToPythonObject(JPJavaFrame& frame, jvalue val, bool cast)
75 {
76 return JPPyObject::getNone();
77 }
78
79 JPMatch::Type JPVoidType::findJavaConversion(JPMatch &match)
80 {
81 return match.type = JPMatch::_none;
82 }
83
84 void JPVoidType::setStaticField(JPJavaFrame& frame, jclass c, jfieldID fid, PyObject*)
85 {
86 JP_RAISE(PyExc_SystemError, "void cannot be the type of a static field.");
87 }
88
89 void JPVoidType::setField(JPJavaFrame& frame, jobject c, jfieldID fid, PyObject*)
90 {
91 JP_RAISE(PyExc_SystemError, "void cannot be the type of a field.");
92 }
93
94 void JPVoidType::setArrayRange(JPJavaFrame& frame, jarray,
95 jsize start, jsize length, jsize step,
96 PyObject* sequence)
97 {
98 JP_RAISE(PyExc_SystemError, "void cannot be the type of an array.");
99 }
100
101 JPPyObject JPVoidType::getArrayItem(JPJavaFrame& frame, jarray, jsize)
102 {
103 JP_RAISE(PyExc_SystemError, "void cannot be the type of an array.");
104 }
105
106 void JPVoidType::setArrayItem(JPJavaFrame& frame, jarray, jsize, PyObject*)
107 {
108 JP_RAISE(PyExc_SystemError, "void cannot be the type of an array.");
109 }
110
111 jarray JPVoidType::newArrayOf(JPJavaFrame& frame, jsize)
112 {
113 JP_RAISE(PyExc_SystemError, "void cannot be the type of an array.");
114 }
115
116 void JPVoidType::getView(JPArrayView& view)
117 {
118 }
119
120 void JPVoidType::releaseView(JPArrayView& view)
121 {
122 }
123
124 const char* JPVoidType::getBufferFormat()
125 {
126 return nullptr;
127 }
128
129 Py_ssize_t JPVoidType::getItemSize()
130 {
131 return 0;
132 }
133
134 void JPVoidType::copyElements(JPJavaFrame &frame,
135 jarray a, jsize start, jsize len,
136 void* memory, int offset)
137 {
138 }
139
140 char JPVoidType::getTypeCode()
141 {
142 return 'V';
143 }
144
145 jlong JPVoidType::getAsLong(jvalue v)
146 {
147 return 0;
148 }
149
150 jdouble JPVoidType::getAsDouble(jvalue v)
151 {
152 return 0;
153 }
154
155 PyObject *JPVoidType::newMultiArray(JPJavaFrame &frame,
156 JPPyBuffer& view, int subs, int base, jobject dims)
157 {
158 return nullptr;
159 }
160
161 // GCOVR_EXCL_STOP