<div dir="ltr">Hello,<div><div><br></div><div>I need to call a method dynamically by its name over string and pass some parameters to it. OK, I don't know if it is possibly in the current version of the compiler, but I'm trying to do something like this:</div><div><br></div><div>TMethodInvoker.Invoke(VMyObj, ['Param 1', 'Param 2', 1, True]);</div><div><br></div><div>I already get some paramerter informations using this code[1], that prints all parameters and its types using RTTI.</div><div><br></div><div>So I have a question: how can I get the method typedata looking for it in the VMT? Please see this:</div><div><br></div><div><div> WriteLn(HexStr(@TMyObject.Test));</div><div> WriteLn(HexStr(TMyObject.MethodAddress('Test')));</div></div><div><br></div><div>Prints the same address. But:</div><div><br></div><div><div> TI := TypeInfo(@TMyObject.Test);</div><div> WriteLn(HexStr(TI));</div><div> TI := TypeInfo(TMyObject.MethodAddress('Test'));</div><div> WriteLn(HexStr(TI));</div></div><div><br></div><div>Prints different results.</div><div><br></div><div>How System.TypeInfo retrieve the typeinfo from my @TMyObject.Test address? It is done by the method address so?</div><div><br></div><div>I took a look at the TRTTIWriter class and also in the VMT, but I don't know how the compiler handles this informations internally, so sorry it this question sounds nonsense. =P</div><div><div><br></div><div>[1] - <a href="http://pastebin.com/bPascrwe" target="_blank">http://pastebin.com/bPascrwe</a></div><div><br></div>-- <br><div>Silvio Clécio<br>My public projects - <a href="http://github.com/silvioprog" target="_blank">github.com/silvioprog</a></div>
</div></div></div>