[Lazarus] Creating methods using rtti-info
Joost van der Sluis
joost at cnoc.nl
Sat Feb 2 15:05:51 CET 2013
> Joost van der Sluis <joost at cnoc.nl> wrote:
>
> > Hi all,
> >
> > I'm writing my own method propertyeditor. And I want it to create the source
> for a new method. Only problem is that it should use the RTTI-information to
> obtain the method's parameters.
> >
> > Now if I look at TMainIDE.OnPropHookCreateMethod, it does exactly what I want
> except that CodeToolBoss.CreatePublishedMethod is called with the
> UseTypeInfoForParameters parameter set to false. In my case it has to be true.
> ;)
>
> Why?
> The RTTI might use mediator objects or things from the wrong
> platform. The codetools use the project sources and that's what
> the compiler is seeing too.
Because in my case, there are no events in the project-sources. It's an iOS objective-pascal project. The events for objective-c objects are not defined in the sources/headers, afaik. So it is not possible to adapt the codetools to find them from the sources.
It's just: event 1 is always onTouchDown, which has one parameter 'id'. (Actually only the amount of parameters is important for Objective-C, but Objective-Pascal also needs the type)
> > Now I could try to write my own method which does the same thing, but then
> I'll need several things which are defined in the ide-package, which I can not
> use. Especially the FormEditor1.CreateNewJITMethod is necessary, or else it is
> not possible to return a create JITMethod for the new event.
>
> Wow. That's the worst hack of the IDE. I was glad to get rid of it and
> now someone asks for its return.
> Are you sure you need them?
Well... I needed them earlier, for reading the events. To work around the absence of CreateNewJITMethods I had to use the TReader-class, and keep a list of all defined TJITMethods, so I know which TJITMethod actually corresponds with each real event.
But I don't need direct access to TJITMethod, if I have a way to create an event based on the rtti-info in some other way.
Joost.
More information about the Lazarus
mailing list