Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: how to use GetMethodProp with an overloaded method ?



Permlink Replies: 3 - Last Post: Oct 18, 2015 6:41 AM Last Post By: loki loki
loki loki

Posts: 787
Registered: 7/1/02
how to use GetMethodProp with an overloaded method ?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 17, 2015 5:25 PM
hello,

before i used RTTIMethod.Invoke to call a function by his name inside an object, but it's very very slow, so i need a replacement for it

i was thinking to use instead GetMethodProp, but it's seam that i can't access overloaded method :( and worse it's seam i can access only published method :(

is their any workaround? any way to use GetMethodProp with public and overloaded method ? or any replacement for RTTIMethod.Invoke that can do the job more faster ?

thanks by advance !
stéphane
Peter Below

Posts: 1,227
Registered: 12/16/99
Re: how to use GetMethodProp with an overloaded method ?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 18, 2015 2:31 AM   in response to: loki loki in response to: loki loki
loki loki wrote:

hello,

before i used RTTIMethod.Invoke to call a function by his name inside
an object, but it's very very slow, so i need a replacement for it

i was thinking to use instead GetMethodProp, but it's seam that i
can't access overloaded method :( and worse it's seam i can access
only published method :(

GetMethodProp uses the old-style RTTI, and that is only generated for
published members of a class. It also predates the introduction of
overloaded methods in Delphi by about a decade and was designed for the
requirements of the Delphi form streaming mechanism. The code for
finding a method by name is intended to resolve event handler
assignments, and event handlers cannot be overloaded methods, as far as
I know.

is their any workaround? any way to use GetMethodProp with public and
overloaded method ? or any replacement for RTTIMethod.Invoke that can
do the job more faster ?

Have you tried to determine which part of the whole process is the slow
one? Is it the search for the RTTIMethod you need, or the call to
Invoke itself? You cannot do much about the second, but if it is the
search you could cache the result so you only have to do the
time-consuming search once.


--
Peter Below
TeamB

loki loki

Posts: 787
Registered: 7/1/02
Re: how to use GetMethodProp with an overloaded method ?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 18, 2015 2:47 AM   in response to: Peter Below in response to: Peter Below
Have you tried to determine which part of the whole process is the slow
one? Is it the search for the RTTIMethod you need, or the call to
Invoke itself?

unfortunatly it's the invoke its self :(
you can take a look here : http://www.armin-pfaeffle.de/blog/2010/06/rtti-in-delphi-2010-nice-but-a-little-bit-too-slow/
it's not about invoke but the problem is the same..

their is absolutely no way to know the address of a not published method ? i can't believe it :(
loki loki

Posts: 787
Registered: 7/1/02
Re: how to use GetMethodProp with an overloaded method ?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 18, 2015 6:41 AM   in response to: loki loki in response to: loki loki
their is absolutely no way to know the address of a not published method ? i can't believe it :(

ok i found, it's RTTIMethod.codeAddress :)

it's much more fast to do

aMethod.Code := aRttiMethod.CodeAddress;
aMethod.Data := aObj;
_aResultStr := _TProcxxx(aMethod);

than calling invoke !

90 ms with invoke, 55ms with the method below

the drawback is that you need to define all possible _TProcxxx and use the good _TProcxxx according to the parameters and result of the RTTIMethod
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02