Debian Codegraph @

native/common/include/jp_classhints.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 JP_CLASSHINTS_H
17 #define JP_CLASSHINTS_H
18
19 class JPConversion
20 {
21 public:
22 virtual ~JPConversion();
23
24 virtual JPMatch::Type matches(JPClass *cls, JPMatch &match) = 0;
25
26 virtual void getInfo(JPClass *cls, JPConversionInfo &info) = 0;
27
28 virtual jvalue convert(JPMatch &match) = 0;
29 } ;
30
31 class JPIndexConversion : public JPConversion
32 {
33 public:
34
35 void getInfo(JPClass *cls, JPConversionInfo &info) override;
36
37 } ;
38
39 class JPNumberConversion : public JPIndexConversion
40 {
41 public:
42
43 void getInfo(JPClass *cls, JPConversionInfo &info) override;
44
45 } ;
46
47 class JPConversionJavaValue : public JPConversion
48 {
49 public:
50 JPMatch::Type matches(JPClass *cls, JPMatch &match) override;
51 void getInfo(JPClass *cls, JPConversionInfo &info) override;
52 jvalue convert(JPMatch &match) override;
53 } ;
54
55 class JPClassHints
56 {
57 public:
58 JPClassHints();
59 ~JPClassHints();
60
61 /** Get the conversion of this type.
62 *
63 * Searches the list for a conversion. The first conversion better than
64 * explicit is returned immediately.
65 *
66 * @returns the quality of the match
67 */
68 JPMatch::Type getConversion(JPMatch& match, JPClass *cls);
69
70 /**
71 * Add a conversion based on a specified attribute.
72 *
73 * If the attribute is found in in the object, it is assumed to be a match.
74 * This is for "duck type" conversions. The Python routine must return
75 * something that holds a __javavalue__ which will be used as the converted
76 * object.
77 *
78 * @param attribute is the attribute to search for.
79 * @param method is a Python routine to call to complete the conversion
80 * process.
81 */
82 void addAttributeConversion(const string& attribute, PyObject* method);
83
84 /**
85 * Add a type conversion based on the Python type.
86 *
87 * The Python routine must return something that holds a __javavalue__
88 * which will be used as the converted object.
89 *
90 * @param type is a Python type object
91 * @param method is a Python routine to call to complete the conversion
92 * process.
93 * @param exact require the type to be an exact match.
94 */
95 void addTypeConversion(PyObject* type, PyObject* method, bool exact);
96
97 void excludeConversion(PyObject* type);
98
99 void getInfo(JPClass *cls, JPConversionInfo &info);
100
101 bool m_ConvertJava;
102 private:
103 std::list<JPConversion*> conversions;
104 } ;
105
106 extern JPConversion *hintsConversion;
107 extern JPConversion *charArrayConversion;
108 extern JPConversion *byteArrayConversion;
109 extern JPConversion *bufferConversion;
110 extern JPConversion *sequenceConversion;
111 extern JPConversion *nullConversion;
112 extern JPConversion *classConversion;
113 extern JPConversion *objectConversion;
114 extern JPConversion *javaObjectAnyConversion;
115 extern JPConversion *javaNumberAnyConversion;
116 extern JPConversion *javaValueConversion;
117 extern JPConversion *stringConversion;
118 extern JPConversion *boxConversion;
119 extern JPConversion *boxBooleanConversion;
120 extern JPConversion *boxLongConversion;
121 extern JPConversion *boxDoubleConversion;
122 extern JPConversion *unboxConversion;
123 extern JPConversion *proxyConversion;
124
125 #endif /* JP_CLASSHINTS_H */