Recent

Author Topic: [Solved] RTTI - Method Parameters / Return Type  (Read 17059 times)

mse

  • Sr. Member
  • ****
  • Posts: 286
Re: [Solved] RTTI - Method Parameters / Return Type
« Reply #15 on: April 07, 2016, 10:31:21 pm »
MSEide uses RTTI for method handling, GetMethodParamInfo() reads the parameter names and type names:
https://gitlab.com/mseide-msegui/mseide-msegui/raw/master/apps/ide/msedesignparser.pas

Int

  • Newbie
  • Posts: 5
Re: [Solved] RTTI - Method Parameters / Return Type
« Reply #16 on: April 08, 2016, 12:22:03 am »
@mse Thanks for the link. That's a big project! Could you please help me with using
Code: Pascal  [Select][+][-]
  1. procedure GetMethodParamInfo(const atype: ptypeinfo; var info: methodparaminfoty);
How to get PTypeInfo for a method in FPC?

mse

  • Sr. Member
  • ****
  • Posts: 286
Re: [Solved] RTTI - Method Parameters / Return Type
« Reply #17 on: April 08, 2016, 08:58:14 am »
How to get PTypeInfo for a method in FPC?
I don't know if methods have parameter RTTI, as enking writes, probably not.

MSEide queries the RTTI of method properties in order to get the method parameters.
Please have a look at nested procedure doinit() at apps/ide/msedesigner.pas:4430
https://gitlab.com/mseide-msegui/mseide-msegui/tree/master

lib/common/kernel/mseclasses.pas:1956 getpropinfoar() reads the propinfos from object instance by calling GetPropInfos() from "typeinfo" unit.
The field TPropInfo.PropType returns the PTypeInfo.

Int

  • Newbie
  • Posts: 5
Re: [Solved] RTTI - Method Parameters / Return Type
« Reply #18 on: April 08, 2016, 06:04:38 pm »
I've read about the GetPropInfo (I suppose it's almost like GetPropInfos), but I haven't find a way how to get PTypeInfo for a method. I've asked about it on Stackoverflow, there's no answer so far (http://stackoverflow.com/questions/36426460/delphi-which-methods-are-supposed-to-be-in-rtti)

darupe

  • New Member
  • *
  • Posts: 15
Re: [Solved] RTTI - Method Parameters / Return Type
« Reply #19 on: July 18, 2016, 04:19:07 pm »
I'm sorry that I haven't noticed the new replies to this thread.

Regarding my library, I never got around to finishing it. However, I now need it for another project where a custom interface would take too long to code.

Due to this, I expect to continue my work on it and release it under LGPL at the end of august. I will post a link to the project once it's either done or at least stable enough for testing. I don't expect to include support for ARM in the first release though I will most likely implement that later.

To clarify to others, this project is about providing the same classes as the RTTI unit in Delphi. I have implemented most of them already though some features require the latest development version of FPC (a lot of features still work with the latest stable version). The invoke functions currently works with x86 (all calling conventions) and x86_64 (Microsoft x64 and AMD64/System V).

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: [Solved] RTTI - Method Parameters / Return Type
« Reply #20 on: December 01, 2016, 05:02:08 pm »
Can anyone tell me how to access the RTTI information for published methods (FPC 2.6.4)? I can easily find the published methods through TVmt.vMethodTable but that's only the method names and addresses. What I would really like to access is the information about parameters and return types. I can't seem to find anything about it in the TypInfo unit, except for GetMethodProp which seems to return NIL no matter what.
In short and afaik: you can't.

Reason is  because FPC does not create/supply rtti information for (published) methods (or perhaps better rephrase in: i was unable to find it)

So, even though the link in Int's SO question (to hallvards blogspot) delivers some interesting code, it unfortunately won't work for Free Pascal (even after adjusting the delphi oriented code to match FPC). The directive $METHODINFO which (if not mistaken) is present in Delphi 7 to generate this information is also not available for FPC.

Any chance this will ever be implemented/supported ?
« Last Edit: December 01, 2016, 05:13:35 pm by molly »

 

TinyPortal © 2005-2018