__declspec(delphiclass) 을 지정해주는 것만으로는 실행파일에 클래스에 대한 개별적인 RTTI 정보가 생성이 되기는 하지만, RTTI 구현 레이어에서 참조되는 RTTI 테이블 구조 자체를 생성해 주는 것은 아니더군요.
아래 처럼 ... 따로 RTTI 속성을 지정해 주면 됩니다.
<소스코드>
#pragma explicit_rtti methods(public, protected)
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))); }
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 [4088] CCC 00000001 0.00002860 [4088] MyClassName 00000002 0.00005788 [4088] CCC 00000003 0.00008546 [4088] = 00000004 0.00011985 [4088] ~CCC 00000005 0.00014062 [4088] Create 00000006 0.00016786 [4088] Free 00000007 0.00019680 [4088] InitInstance 00000008 0.00022438 [4088] CleanupInstance 00000009 0.00025162 [4088] ClassType 00000010 0.00027852 [4088] ClassName 00000011 0.00030575 [4088] ClassNameIs 00000012 0.00033299 [4088] ClassParent 00000013 0.00036023 [4088] ClassInfo 00000014 0.00038713 [4088] InstanceSize 00000015 0.00046135 [4088] InheritsFrom 00000016 0.00048962 [4088] MethodAddress 00000017 0.00051685 [4088] MethodAddress 00000018 0.00054477 [4088] MethodName 00000019 0.00057201 [4088] QualifiedClassName 00000020 0.00059925 [4088] FieldAddress 00000021 0.00062615 [4088] FieldAddress 00000022 0.00065339 [4088] GetInterface 00000023 0.00068063 [4088] GetInterfaceEntry 00000024 0.00070752 [4088] GetInterfaceTable 00000025 0.00073476 [4088] UnitName 00000026 0.00076200 [4088] UnitScope 00000027 0.00078890 [4088] Equals 00000028 0.00081614 [4088] GetHashCode 00000029 0.00084338 [4088] ToString 00000030 0.00087062 [4088] SafeCallException 00000031 0.00089751 [4088] AfterConstruction 00000032 0.00092475 [4088] BeforeDestruction 00000033 0.00095165 [4088] Dispatch 00000034 0.00097957 [4088] DefaultHandler 00000035 0.00100647 [4088] NewInstance 00000036 0.00103337 [4088] FreeInstance 00000037 0.00106061 [4088] Destroy
|