Skip to content

Commit c00f948

Browse files
committed
feat: add documentation to ClassMethod
1 parent 5dff885 commit c00f948

File tree

2 files changed

+73
-2
lines changed

2 files changed

+73
-2
lines changed

engine/foundation/core/private/rtti/func/class_method.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ ClassMethod::ClassMethod(const String& name, FuncBase* func)
5454
}
5555

5656
ClassMethod::~ClassMethod() {
57+
mFunc = nullptr;
5758
}
5859

5960
bool ClassMethod::operator==(const ClassMethod& other) const {

engine/foundation/core/public/core/rtti/func/class_method.h

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,31 +50,101 @@ namespace core {
5050
//[-------------------------------------------------------]
5151

5252

53-
5453
//[-------------------------------------------------------]
5554
//[ Classes ]
5655
//[-------------------------------------------------------]
56+
/**
57+
* @class
58+
* ClassMethod
59+
*
60+
* @brief
61+
* Represents a method for a class.
62+
*
63+
* This class represents a method for a class. It is used by the RTTI system to
64+
* store metadata about a class method.
65+
*/
5766
class ClassMethod : public RttiMember {
5867
public:
5968

69+
/**
70+
* @brief Default constructor for the ClassMethod class.
71+
*
72+
* Initializes an instance of the ClassMethod class with a default name and a nullptr
73+
* as the function to be invoked.
74+
*/
6075
ClassMethod();
6176

77+
/**
78+
* @brief Constructor for the ClassMethod class.
79+
*
80+
* Initializes an instance of the ClassMethod class with a specified name and a
81+
* function to be invoked.
82+
*
83+
* @param name The name of the method.
84+
* @param func The function to be invoked.
85+
*/
6286
ClassMethod(const String& name, FuncBase* func);
6387

88+
/**
89+
* @brief Destructor for the ClassMethod class.
90+
*
91+
* Cleans up any resources associated with the ClassMethod instance.
92+
*/
6493
~ClassMethod() override;
6594

6695

96+
/**
97+
* @brief
98+
* Checks if the current ClassMethod instance is equal to another one.
99+
*
100+
* This method checks if the current ClassMethod instance is equal to
101+
* another ClassMethod instance. Two ClassMethod instances are considered
102+
* equal if they have the same name and the same function associated.
103+
*
104+
* @param[in] other The other ClassMethod instance to compare with.
105+
*
106+
* @return True if the current ClassMethod instance is equal to the other
107+
* one, false otherwise.
108+
*/
67109
bool operator==(const ClassMethod& other) const;
68110

69111

112+
/**
113+
* @brief
114+
* Invokes the method with the specified arguments.
115+
*
116+
* This method calls the underlying function associated with this ClassMethod
117+
* instance, passing the provided arguments to it, and returns the result.
118+
*
119+
* @param[in] args A vector of DynamicObjects representing the arguments to
120+
* invoke the function with.
121+
*
122+
* @return A DynamicObject containing the result of the method invocation.
123+
*/
70124
DynamicObject invoke(Vector<DynamicObject>* args) override;
71125

126+
/**
127+
* @brief
128+
* Directly calls the method with the given arguments.
129+
*
130+
* This method directly calls the method with the given arguments. It is
131+
* a low-level call and does not perform any of the additional checks
132+
* that the `invoke` method performs.
133+
*
134+
* @param obj The object to call the method on.
135+
* @param args... The arguments to pass to the method.
136+
*
137+
* @return The return value of the method.
138+
*/
72139
template<typename TReturn, typename TObject, typename... TArgs>
73-
inline TReturn call_direct(TObject* obj, TArgs... args) const;
140+
TReturn call_direct(TObject* obj, TArgs... args) const;
74141

75142
private:
76143

144+
/** Name of the method. */
77145
String mName;
146+
147+
/** Pointer to the function to be invoked. */
78148
FuncBase* mFunc;
79149
};
80150

0 commit comments

Comments
 (0)