<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div class="moz-cite-prefix">Le 21/06/2020 à 09:55, Michael Van
Canneyt a écrit :<br>
</div>
<blockquote type="cite"
cite="mid:alpine.DEB.2.21.2006210953570.9564@home">
I use the functionality in the database desktop actively.
<br>
The generated code even runs in Delphi.
<br>
<br>
If you look at it and find ways to improve it, I'm all ears :-)
<br>
</blockquote>
<p>I got a quick look at it (Lazarus 2.0.6, FPC 3.0.4).<br>
I saw there is a distinct generator for each case:</p>
<p>fpcsrc/3.0.4/packages/fcl-db/src/codegen/fpcgdbcoll.pp<br>
fpcsrc/3.0.4/packages/fcl-db/src/codegen/fpcgcreatedbf.pp<br>
fpcsrc/3.0.4/packages/fcl-db/src/codegen/fpcgtiopf.pp<br>
</p>
<p>In my case, there is a single generator which is based on
StringReplace with key/values stored in a StringList.<br>
My first versions back to 2004 where coded as a plug-in for
ModelMaker (UML modeling tool) . <br>
A few years later, I transformed it in a StarUML plug-in, and
finally as a standalone freepascal program.<br>
<br>
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: <br>
( <a moz-do-not-send="true"
href="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">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</a>
)</p>
<p>the key value in the template is : Cle:= ' object lNomChamp:
TLabel';<br>
and a part of the generated value could be:<br>
</p>
<p>...</p>
<p> object lNPROJECT: TLabel<br>
Caption = 'nProject' <br>
Left = 16 <br>
Top = 26 <br>
Height = 13 <br>
end <br>
object lBEGINNING: TLabel<br>
Caption = 'Beginning' <br>
Left = 16 <br>
Top = 48 <br>
Height = 13 <br>
end <br>
object lEND: TLabel<br>
Caption = 'End' <br>
Left = 16 <br>
Top = 70 <br>
Height = 13 <br>
end <br>
...</p>
<p>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.<br>
</p>
<p>I ended up with a huge number of different kinds of hard coded
lists for each situation in Pascal , C# and PHP.</p>
<p>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:</p>
<blockquote>
<p>listname.01_key.* for definition of the key for list listname</p>
<p>listname.02_begin.* for definition of the header of list
listname</p>
<p>listname.03_element.* for definition of the body of each
element of list listname</p>
<p>listname.04_separateur.* for definition of the separator
between each element of list listname</p>
<p>listname.05_end.* for definition of the footer of list
listname</p>
</blockquote>
<p>For example in Angular:<br>
</p>
<blockquote>
<p>file Angular_TypeScript_RouterLinks.01_key.html contains
"<!--Angular_TypeScript_RouterLinks-->"</p>
<p>file Angular_TypeScript_RouterLinks.02_begin.html is empty</p>
<p>file Angular_TypeScript_RouterLinks.03_element.html contains "
<a routerLink="/Classe.Nom_de_la_classes"
routerLinkActive="active">Classe.Nom_de_la_classes</a>"</p>
<p>file Angular_TypeScript_RouterLinks.04_separateur.html contains
a newline</p>
<p>file Angular_TypeScript_RouterLinks.05_end.html is empty. <br>
</p>
</blockquote>
<p>(you can find these files at <a moz-do-not-send="true"
href="https://github.com/jsuzineau/pascal_o_r_mapping/tree/TjsDataContexte/jsWorks/Generateur_de_code/01_Listes/Tables">https://github.com/jsuzineau/pascal_o_r_mapping/tree/TjsDataContexte/jsWorks/Generateur_de_code/01_Listes/Tables</a>
)</p>
<p>Theses files are used in unit <a moz-do-not-send="true"
href="https://github.com/jsuzineau/pascal_o_r_mapping/blob/TjsDataContexte/pascal_o_r_mapping/03_Data/Automatic/Code_Generation/JoinPoint/ujpFile.pas">https://github.com/jsuzineau/pascal_o_r_mapping/blob/TjsDataContexte/pascal_o_r_mapping/03_Data/Automatic/Code_Generation/JoinPoint/ujpFile.pas</a>
.<br>
</p>
<p>I used the term "JoinPoint" with Aspect Oriented Programming in
mind, though it's not strictly aspect oriented programming.</p>
</body>
</html>