|
class __declspec( delphiclass ) CCC : public TObject
{
public:
virtual CCC(){};
__classmethod String __fastcall MyClassName();
};
System::String __fastcall CCC::MyClassName()
{
return UTF8ToString(*PShortString(*PPointer(System::PByte(this) + vmtClassName)));
}
위와 같이 CCC는 TObject 를 상속받은 클래스고, 델파이 스타일의 RTTI 정보도 링크시 생성됩니다.
그래서 클래스 CCC 에서 정의된 함수들을 다음과 같이 RTTI를 이용해서 출력해 보았는데 조금 이상하네요.
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TRttiContext context;
TRttiType *type = context.GetType(__classid(CCC));
DynamicArray<TRttiMethod*>theMethods = type->GetMethods();
for( int i = 0; i < theMethods.Length; i++ ) {
TRttiMethod *method = theMethods[i];
OutputDebugStringW(method->Name.c_str());
}
}
다음은 Debug 덤프로 출력된 것을 캡쳐한 겁니다.
00000000 0.00000000 [1228] Create
00000001 0.00003064 [1228] Free
00000002 0.00005958 [1228] InitInstance
00000003 0.00008750 [1228] CleanupInstance
00000004 0.00011508 [1228] ClassType
00000005 0.00014266 [1228] ClassName
00000006 0.00017024 [1228] ClassNameIs
00000007 0.00019884 [1228] ClassParent
00000008 0.00022574 [1228] ClassInfo
00000009 0.00025502 [1228] InstanceSize
00000010 0.00028192 [1228] InheritsFrom
00000011 0.00030916 [1228] MethodAddress
00000012 0.00033640 [1228] MethodAddress
00000013 0.00036364 [1228] MethodName
00000014 0.00039087 [1228] QualifiedClassName
00000015 0.00041914 [1228] FieldAddress
00000016 0.00044705 [1228] FieldAddress
00000017 0.00047463 [1228] GetInterface
00000018 0.00050357 [1228] GetInterfaceEntry
00000019 0.00053115 [1228] GetInterfaceTable
00000020 0.00055907 [1228] UnitName
00000021 0.00058699 [1228] UnitScope
00000022 0.00061457 [1228] Equals
00000023 0.00064249 [1228] GetHashCode
00000024 0.00067007 [1228] ToString
00000025 0.00069799 [1228] SafeCallException
00000026 0.00072557 [1228] AfterConstruction
00000027 0.00075417 [1228] BeforeDestruction
00000028 0.00078209 [1228] Dispatch
00000029 0.00080967 [1228] DefaultHandler
00000030 0.00083725 [1228] NewInstance
00000031 0.00086517 [1228] FreeInstance
00000032 0.00089309 [1228] Destroy
이상하게 패런트 클래스인 TObject 메소드들만 출력되고 상속 받은 CCC 클래스의 메소드들은
하나도 출력이 되질 않네요. 패런트의 경우는 constructor 도 출력이 되는데?????
컴파일은 RAD XE2 에서 했습니다 (런타임 패키지로 빌드)
|