Debian Codegraph @

native/common/include/jp_method.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 _JPMETHOD_H_
17 #define _JPMETHOD_H_
18 #include "jp_modifier.h"
19 class JPMethod;
20
21 class JPMethod : public JPResource
22 {
23 friend class JPMethodDispatch;
24 public:
25 JPMethod() = default;
26 JPMethod(JPJavaFrame& frame,
27 JPClass* claz,
28 const string& name,
29 jobject mth,
30 jmethodID mid,
31 JPMethodList& moreSpecific,
32 jint modifiers);
33
34 ~JPMethod() override;
35
36 void setParameters(
37 JPClass *returnType,
38 JPClassList&& parameterTypes);
39
40 /** Check to see if this overload matches the argument list.
41 *
42 * @param frame is the scope to hold Java local variables.
43 * @param match holds the details of the match that is found.
44 * @param isInstance is true if the first argument is an instance object.
45 * @param args is a list of arguments including the instance.
46 *
47 * @return the quality of the match.
48 *
49 */
50 JPMatch::Type matches(JPJavaFrame &frame, JPMethodMatch& match, bool isInstance, JPPyObjectVector& args);
51 JPPyObject invoke(JPJavaFrame &frame, JPMethodMatch& match, JPPyObjectVector& arg, bool instance);
52 JPPyObject invokeCallerSensitive(JPMethodMatch& match, JPPyObjectVector& arg, bool instance);
53 JPValue invokeConstructor(JPJavaFrame &frame, JPMethodMatch& match, JPPyObjectVector& arg);
54
55 bool isAbstract() const
56 {
57 return JPModifier::isAbstract(m_Modifiers);
58 }
59
60 bool isConstructor() const
61 {
62 return JPModifier::isConstructor(m_Modifiers);
63 }
64
65 bool isInstance() const
66 {
67 return !JPModifier::isStatic(m_Modifiers) && !JPModifier::isConstructor(m_Modifiers);
68 }
69
70 bool isFinal() const
71 {
72 return JPModifier::isFinal(m_Modifiers);
73 }
74
75 bool isStatic() const
76 {
77 return JPModifier::isStatic(m_Modifiers);
78 }
79
80 bool isVarArgs() const
81 {
82 return JPModifier::isVarArgs(m_Modifiers);
83 }
84
85 bool isCallerSensitive() const
86 {
87 return JPModifier::isCallerSensitive(m_Modifiers);
88 }
89
90 string toString() const;
91
92 string matchReport(JPPyObjectVector& args);
93 bool checkMoreSpecificThan(JPMethod* other) const;
94
95 jobject getJava()
96 {
97 return m_Method.get();
98 }
99
100 JPMethod& operator=(const JPMethod&) = delete;
101
102 private:
103 void packArgs(JPJavaFrame &frame, JPMethodMatch &match, vector<jvalue> &v, JPPyObjectVector &arg);
104 void ensureTypeCache();
105
106 JPMethod(const JPMethod& o);
107
108 private:
109 JPClass* m_Class{};
110 string m_Name;
111 JPObjectRef m_Method;
112 jmethodID m_MethodID{};
113 JPClass* m_ReturnType{};
114 JPClassList m_ParameterTypes;
115 JPMethodList m_MoreSpecificOverloads;
116 jint m_Modifiers{};
117 } ;
118
119 #endif // _JPMETHOD_H_