[Pas2js] Before compile Notifier to the pas2jsdesign plugin
Michael Van Canneyt
michael at freepascal.org
Sat Mar 24 07:41:19 CET 2018
On Fri, 23 Mar 2018, warleyalex via Pas2js wrote:
> In Delphi, using Open Tools API, it is possible form notifiers that fire
> notifications for BeforeSave or AfterSave. One can AddNotifier and watch for
> notifications directly from the IDE plugin:
>
> TIdeNotifier = class(TNotifierObject, IOTANotifier, IOTAIDENotifier)
> protected
> procedure AfterCompile(Succeeded: Boolean);
> procedure BeforeCompile(const Project: IOTAProject; var Cancel:
> Boolean);
> procedure FileNotification(NotifyCode: TOTAFileNotification;
> const FileName: string; var Cancel: Boolean);
> end;
>
> The plan would be to implement an IDE notifier to the Lazarus pas2jsdesign
> plugin. For instance, before compile, I want to fire the method DFMTOPAS. As
> I was stuck on this “Plan A”, I will try the plan B, which is a simple menu
> button to call DFMTOPAS manually, this DFMTOPAS method is
> (component-to-code) will translate ALL "instantiated" and "unassigned" forms
> as well in the current project to pascal code, then I will add this
> directive.
>
> procedure TForm1.LoadDFMValues;
> begin
> inherited;
> { $I Form1.lfm.inc }
>
> //{ $I %form% }
>
> end;
>
> Any thoughts on this.
1. As far as I know, Mattias intends to integrate the pas2js compiler as a
'real' compiler, so the 'before compile' command will no longer be needed
2. I think that you are re-inventing the wheel: lazarus already used this
mechanism in the past, maybe it can be simply resurrected or hooked into.
As far as I know, the support for it is still there.
3. I would create the {$I Form1.lfm.inc} (or {$I Form1.lrs} as it used to be
called) by default empty, then you don't need to modify the original source.
Maybe Mattias can share some ideas, he is better informed about the IDE
mechanisms.
Michael.
More information about the Pas2js
mailing list