| 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 _JPARRAYCLASS_H_ |
| 17 | #define _JPARRAYCLASS_H_ |
| 18 | |
| 19 | /** |
| 20 | * Class to wrap Java Class and provide low-level behavior |
| 21 | */ |
| 22 | class JPArrayClass : public JPClass |
| 23 | { |
| 24 | public: |
| 25 | JPArrayClass(JPJavaFrame& frame, |
| 26 | jclass cls, |
| 27 | const string& name, |
| 28 | JPClass* superClass, |
| 29 | JPClass* componentType, |
| 30 | jint modifiers); |
| 31 | ~ JPArrayClass() override; |
| 32 | |
| 33 | JPPyObject convertToPythonObject(JPJavaFrame& frame, jvalue val, bool cast) override; |
| 34 | JPMatch::Type findJavaConversion(JPMatch &match) override; |
| 35 | void getConversionInfo(JPConversionInfo &info) override; |
| 36 | |
| 37 | JPValue newArray(JPJavaFrame& frame, int length); |
| 38 | |
| 39 | /** |
| 40 | * Create a new java array containing a set of items take from |
| 41 | * a range. |
| 42 | * |
| 43 | * This is used to support variable arguments. |
| 44 | * |
| 45 | * @param refs contains a vector of python objects. |
| 46 | * @param start is the start of the range inclusive. |
| 47 | * @param end is the end of the range exclusive. |
| 48 | * @return a jvalue containing a java vector. |
| 49 | */ |
| 50 | jvalue convertToJavaVector(JPJavaFrame& frame, JPPyObjectVector& refs, jsize start, jsize end); |
| 51 | |
| 52 | virtual JPClass* getComponentType() |
| 53 | { |
| 54 | return m_ComponentType; |
| 55 | } |
| 56 | |
| 57 | bool isArray() const override |
| 58 | { |
| 59 | return true; |
| 60 | } |
| 61 | |
| 62 | private: |
| 63 | JPClass* m_ComponentType; |
| 64 | } ; |
| 65 | |
| 66 | #endif // _JPARRAYCLASS_H_ |