Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2013-02

Creating methods using rtti-info

6 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Joost van der Sluis

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 , 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. ;)

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.

Any ideas how to proceed?

Joost.

Reply by email

Mattias Gaertner
to Joost van der Sluis
Show quoted text 5 lines
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 , 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.

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?

Any ideas how to proceed?

Mattias

Reply by email

Joost van der Sluis
Show quoted text 17 lines
Joost van der Sluis 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 , 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)

Show quoted text 8 lines
> 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.

Reply by email

Joost van der Sluis
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?

I can think of two other options: (Maybe there are more, let me know if you can think of any...)

1: Adapt the codetools in such a way that when dealing with an objcclass the typeinfo is always used to get the parameter-information.

2: I could create a complete new property-editor, which does not inherits from the default event propertyeditor. That way I can also get rid of the other hacks and don't have to work with the TJITMethod. But in that case these 'events' will not show up in the Events-tab of the Object Inspector, but in the Properties-tab. But I'm sure that there's a possibility to add a class-method to TPropertyEditor to check in which tb the property/event should show up.

Maybe 2 is the best solution (although more work for me ;) )

I think I still need some help from you to get the right 'UnitInfo' and 'SrcEdit' in the new property-editor, since I can not use BeginCodeTool.

btw: if you want to try it yourself, It's about the iOSDesigner package in the lazarus-ccr. You have to apply the patch from bug 23814 though to make it work.

Joost.

Reply by email

Mattias Gaertner
to Joost van der Sluis: Because in my case, there are no events in the project-sources. It's an iOS…
Show quoted text 21 lines
> Joost van der Sluis 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 , 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)

I added a TDesignerMediator.UseRTTIForMethods.
I don't have an example to test it myself.
Please test.

Mattias

Reply by email

Joost van der Sluis
I added a TDesignerMediator.UseRTTIForMethods. I don't have an example to test it myself.

Works flawless. Thanks.

Joost.

Reply by email