Debian Codegraph @

native/common/include/jp_array.h

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 #ifndef _JPARRAY_H_
17 #define _JPARRAY_H_
18
19 #include "jp_javaframe.h"
20
21 class JPArray;
22
23 class JPArrayView
24 {
25 public:
26 explicit JPArrayView(JPArray* array);
27 JPArrayView(JPArray* array, jobject collection);
28 ~JPArrayView();
29 void reference();
30 bool unreference();
31 public:
32 JPArray *m_Array;
33 void *m_Memory{};
34 Py_buffer m_Buffer{};
35 int m_RefCount;
36 Py_ssize_t m_Shape[5]{};
37 Py_ssize_t m_Strides[5]{};
38 jboolean m_IsCopy{};
39 jboolean m_Owned{};
40 } ;
41
42 /**
43 * Class to wrap Java Class and provide low-level behavior
44 */
45 class JPArray
46 {
47 friend class JPArrayView;
48 public:
49 explicit JPArray(const JPValue& array);
50 JPArray(JPArray* cls, jsize start, jsize stop, jsize step);
51 virtual~ JPArray();
52
53 JPArrayClass* getClass()
54 {
55 return m_Class;
56 }
57
58 jsize getLength() const;
59 void setRange(jsize start, jsize length, jsize step, PyObject* val);
60 JPPyObject getItem(jsize ndx);
61 void setItem(jsize ndx, PyObject*);
62
63 /**
64 * Create a shallow copy of an array.
65 *
66 * This is used to extract a slice before calling or casting operations.
67 *
68 * @param frame
69 * @param obj
70 * @return
71 */
72 jarray clone(JPJavaFrame& frame, PyObject* obj);
73
74 bool isSlice() const
75 {
76 return m_Slice;
77 }
78
79 jarray getJava()
80 {
81 return m_Object.get();
82 }
83
84 private:
85 JPArrayClass* m_Class;
86 JPArrayRef m_Object;
87 jsize m_Start;
88 jsize m_Step;
89 jsize m_Length;
90 bool m_Slice;
91 } ;
92
93 #endif // _JPARRAY_H_