| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 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 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 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 |