| 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 _JPBUFFER_H_ |
| 17 | #define _JPBUFFER_H_ |
| 18 | |
| 19 | #include "jp_javaframe.h" |
| 20 | |
| 21 | class JPBufferType; |
| 22 | |
| 23 | /** |
| 24 | * Class to wrap Java Class and provide low-level behavior |
| 25 | */ |
| 26 | class JPBuffer |
| 27 | { |
| 28 | public: |
| 29 | explicit JPBuffer(const JPValue& array); |
| 30 | virtual~ JPBuffer(); |
| 31 | |
| 32 | JPBufferType* getClass() |
| 33 | { |
| 34 | return m_Class; |
| 35 | } |
| 36 | |
| 37 | jobject getJava() |
| 38 | { |
| 39 | return m_Object.get(); |
| 40 | } |
| 41 | |
| 42 | bool isReadOnly() const; |
| 43 | |
| 44 | Py_buffer& getView(); |
| 45 | |
| 46 | bool isValid() const; |
| 47 | |
| 48 | private: |
| 49 | JPBufferType* m_Class; |
| 50 | JPObjectRef m_Object; |
| 51 | void *m_Address; |
| 52 | Py_ssize_t m_Capacity; |
| 53 | Py_buffer m_Buffer{}; |
| 54 | char m_Format[3]{}; |
| 55 | } ; |
| 56 | |
| 57 | #endif // _JPBUFFER_H_ |