📄 method.h
字号:
#ifndef __METHOD_H__
#define __METHOD_H__
/**
* Method qualifying flags
*/
enum RTTIMethodFlags {
RTTI_MTH_INSTANCE = RTTI_FLD_INSTANCE,
RTTI_MTH_STATIC = RTTI_FLD_STATIC,
RTTI_MTH_CONST = RTTI_FLD_CONST,
RTTI_MTH_PUBLIC = RTTI_FLD_PUBLIC,
RTTI_MTH_PROTECTED = RTTI_FLD_PROTECTED,
RTTI_MTH_PRIVATE = RTTI_FLD_PRIVATE,
RTTI_MTH_VIRTUAL = RTTI_FLD_VIRTUAL,
RTTI_MTH_CONSTRUCTOR = 0x0200,
RTTI_MTH_ABSTRACT = 0x0400
};
/**
* Method descriptor
*/
class RTTIMethodDescriptor {
public:
/**
* Get method's name
*/
char const* getName() {
return name;
}
/**
* Gte type of the method
* @return method type
*/
RTTIMethodType* getType() {
return type;
}
/**
* Get flags associated with the method
* @return combination of <code>RTTIMethodFlags>/code> flags
*/
int getFlags() {
return flags;
}
/**
* Print to the buffer forward declaration of the method, ifor example:
* <PRE>
* void SomeClass::foo(char* name);
* </PRE>
* @param buf buffer to which method declaration will be printed
*/
void getMethodDeclaration(char* buf) {
type->getMethodDeclaration(buf, name);
}
/**
* Invoke method
* @param result pointer to the location where method result will be stored.
* @param obj target object (ignired for static methods)
* @param parameters array of pointer to the parameter values
*/
void invoke(void* result, void* obj, void* parameters[]) {
type->invoke(result, obj, parameters);
}
/**
* Get class to which the method belongs
* @return descriptor of the class containing this method
*/
RTTIClassDescriptor* getDeclaringClass() {
return type->getClass();
}
/**
* Method descriptor constructor
* @param name name of the method
* @param flags method qualifiers
* @param type method type
*/
RTTIMethodDescriptor(char const* name, int flags, RTTIMethodType* type) {
this->name = name;
this->flags = flags;
this->type = type;
type->isStatic = (flags & RTTI_MTH_STATIC) != 0;
next = NULL;
chain = &next;
}
/**
* Comma operator used to concatenate metod descriptors in the list
* @param method descriptor tail conctateneted with this head method descriptor, <code>chain</code>
* component of which contains address of <code>next</code> field of last element of the list
* @return head of the list
*/
RTTIMethodDescriptor& operator, (RTTIMethodDescriptor& method) {
*chain = &method;
chain = &method.next;
return *this;
}
/**
* Destructor of method descriptor
*/
~RTTIMethodDescriptor() {
type->destroy();
}
/**
* Get index of the metod in the array returned by <Code>RTTIClassDescriptor::getMethods()</code> method
* @param index of method descriptor in the array sorted by method name
*/
int getIndex() {
return index;
}
protected:
friend class RTTIType;
friend class RTTIClassDescriptor;
friend class RTTIBfdRepository;
int flags;
int index;
RTTIMethodType* type;
char const* name;
RTTIMethodDescriptor* next;
RTTIMethodDescriptor** chain;
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -