I use the functionality in the database desktop actively.
The generated code even runs in Delphi.
If you look at it and find ways to improve it, I'm all ears :-)
I got a quick look at it (Lazarus 2.0.6, FPC 3.0.4).
I saw there is a distinct generator for each case:
fpcsrc/3.0.4/packages/fcl-db/src/codegen/fpcgdbcoll.pp
fpcsrc/3.0.4/packages/fcl-db/src/codegen/fpcgcreatedbf.pp
fpcsrc/3.0.4/packages/fcl-db/src/codegen/fpcgtiopf.pp
In my case, there is a single generator which is based on
StringReplace with key/values stored in a StringList.
My first versions back to 2004 where coded as a plug-in for
ModelMaker (UML modeling tool) .
A few years later, I transformed it in a StarUML plug-in, and
finally as a standalone freepascal program.
At the beginning the composition of lists of fields or lists of
tables was hard coded for example to make a list of labels for
each field of table on a form's dfm:
( https://github.com/jsuzineau/pascal_o_r_mapping/blob/TjsDataContexte/pascal_o_r_mapping/03_Data/Automatic/Code_Generation/JoinPoint/02_Pascal/ujpPascal_LabelsDFM.pas
)
the key value in the template is : Cle:= ' object lNomChamp:
TLabel';
and a part of the generated value could be:
...
object lNPROJECT: TLabel
Caption = 'nProject'
Left = 16
Top = 26
Height = 13
end
object lBEGINNING: TLabel
Caption = 'Beginning'
Left = 16
Top = 48
Height = 13
end
object lEND: TLabel
Caption = 'End'
Left = 16
Top = 70
Height = 13
end
...
In the case of the dfm, I cannot use a comment for the key value
so I put a Tlabel named lNomChamp in the template dfm, and add a
' object lNomChamp: TLabel' at the end of the generated value
to avoid breaking the dfm.
I ended up with a huge number of different kinds of hard coded lists for each situation in Pascal , C# and PHP.
A few years ago , while testing Google Angular 4, to avoid to have to modify the generator for each new kind of list, I added the possibility to define a list with 4 files:
listname.01_key.* for definition of the key for list listname
listname.02_begin.* for definition of the header of list listname
listname.03_element.* for definition of the body of each element of list listname
listname.04_separateur.* for definition of the separator between each element of list listname
listname.05_end.* for definition of the footer of list listname
For example in Angular:
file Angular_TypeScript_RouterLinks.01_key.html contains "<!--Angular_TypeScript_RouterLinks-->"
file Angular_TypeScript_RouterLinks.02_begin.html is empty
file Angular_TypeScript_RouterLinks.03_element.html contains " <a routerLink="/Classe.Nom_de_la_classes" routerLinkActive="active">Classe.Nom_de_la_classes</a>"
file Angular_TypeScript_RouterLinks.04_separateur.html contains a newline
file Angular_TypeScript_RouterLinks.05_end.html is empty.
(you can find these files at https://github.com/jsuzineau/pascal_o_r_mapping/tree/TjsDataContexte/jsWorks/Generateur_de_code/01_Listes/Tables )
Theses files are used in unit https://github.com/jsuzineau/pascal_o_r_mapping/blob/TjsDataContexte/pascal_o_r_mapping/03_Data/Automatic/Code_Generation/JoinPoint/ujpFile.pas
.
I used the term "JoinPoint" with Aspect Oriented Programming in mind, though it's not strictly aspect oriented programming.
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal