How to capture the default value of TRTTIParamter

I have this class:

TMyClass = class public function DoSomethingNice(const Value: string = 'Yes please!'): Boolean; end; 

Now, using RTTI, is it possible to get the default value of the DoSomethingNice method value ? if so, how?

I'm more interested in the D2010 solution, but there will be XE too.

+6
source share
1 answer

impossible because RTTI has no default parameter information. default parameter values ​​are used only at compile time

therefore, if we have ... procedure test(x : integer = 3) and then the call method without the parameter value: test() , then it will be compiled as test(3)

to check this, you can open the CPU window in the debugger: and test() looks like

  mov eax, $00000003 call test 
+11
source

Source: https://habr.com/ru/post/909378/


All Articles