| 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 "pyjp.h" |
| 18 | #include "jp_objecttype.h" |
| 19 | |
| 20 | JPObjectType::JPObjectType(JPJavaFrame& frame, |
| 21 | jclass clss, |
| 22 | const string& name, |
| 23 | JPClass* super, |
| 24 | JPClassList& interfaces, |
| 25 | jint modifiers) |
| 26 | : JPClass(frame, clss, name, super, interfaces, modifiers) |
| 27 | { |
| 28 | } |
| 29 | |
| 30 | JPObjectType::~JPObjectType() |
| 31 | = default; |
| 32 | |
| 33 | JPMatch::Type JPObjectType::findJavaConversion(JPMatch& match) |
| 34 | { |
| 35 | // Rules for java.lang.Object |
| 36 | JP_TRACE_IN("JPObjectType::canConvertToJava"); |
| 37 | if (nullConversion->matches(this, match) |
| 38 | || javaObjectAnyConversion->matches(this, match) |
| 39 | || stringConversion->matches(this, match) |
| 40 | || boxBooleanConversion->matches(this, match) |
| 41 | || boxLongConversion->matches(this, match) |
| 42 | || boxDoubleConversion->matches(this, match) |
| 43 | || classConversion->matches(this, match) |
| 44 | || proxyConversion->matches(this, match) |
| 45 | || hintsConversion->matches(this, match) |
| 46 | ) |
| 47 | return match.type; |
| 48 | return match.type = JPMatch::_none; |
| 49 | JP_TRACE_OUT; |
| 50 | } |
| 51 | |
| 52 | void JPObjectType::getConversionInfo(JPConversionInfo &info) |
| 53 | { |
| 54 | JP_TRACE_IN("JPObjectType::getConversionInfo"); |
| 55 | JPJavaFrame frame = JPJavaFrame::outer(); |
| 56 | nullConversion->getInfo(this, info); |
| 57 | objectConversion->getInfo(this, info); |
| 58 | stringConversion->getInfo(this, info); |
| 59 | boxBooleanConversion->getInfo(this, info); |
| 60 | boxLongConversion->getInfo(this, info); |
| 61 | boxDoubleConversion->getInfo(this, info); |
| 62 | classConversion->getInfo(this, info); |
| 63 | proxyConversion->getInfo(this, info); |
| 64 | hintsConversion->getInfo(this, info); |
| 65 | PyList_Append(info.ret, PyJPClass_create(frame, this).get()); |
| 66 | JP_TRACE_OUT; |
| 67 | } |