| 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 _JPBOXEDCLASS_H_ |
| 17 | #define _JPBOXEDCLASS_H_ |
| 18 | |
| 19 | // Boxed types have special conversion rules so that they can convert |
| 20 | // from python primitives. This code specializes the class wrappers |
| 21 | // to make that happen. |
| 22 | |
| 23 | /** |
| 24 | * Class to wrap for Boxed types. |
| 25 | * |
| 26 | * These are linked to primitives. |
| 27 | * They specialize the conversion rules to set up our table for conversion. |
| 28 | */ |
| 29 | class JPBoxedType : public JPClass |
| 30 | { |
| 31 | public: |
| 32 | JPBoxedType(JPJavaFrame& frame, |
| 33 | jclass clss, |
| 34 | const string& name, |
| 35 | JPClass* super, |
| 36 | JPClassList& interfaces, |
| 37 | jint modifiers, |
| 38 | JPPrimitiveType* primitiveType); |
| 39 | ~JPBoxedType() override; |
| 40 | |
| 41 | JPMatch::Type findJavaConversion(JPMatch &match) override; |
| 42 | void getConversionInfo(JPConversionInfo &info) override; |
| 43 | |
| 44 | JPPrimitiveType* getPrimitive() |
| 45 | { |
| 46 | return m_PrimitiveType; |
| 47 | } |
| 48 | |
| 49 | jobject box(JPJavaFrame &frame, jvalue v); |
| 50 | JPPyObject convertToPythonObject(JPJavaFrame& frame, jvalue val, bool cast) override; |
| 51 | |
| 52 | protected: |
| 53 | JPPrimitiveType* m_PrimitiveType; |
| 54 | public: |
| 55 | jmethodID m_CtorID; |
| 56 | jmethodID m_DoubleValueID; |
| 57 | jmethodID m_FloatValueID; |
| 58 | jmethodID m_IntValueID; |
| 59 | jmethodID m_LongValueID; |
| 60 | jmethodID m_BooleanValueID; |
| 61 | jmethodID m_CharValueID; |
| 62 | } ; |
| 63 | |
| 64 | #endif // _JPBOXEDCLASS_H_ |