https://wiki.freepascal.org/api.php?action=feedcontributions&user=Michael&feedformat=atomFree Pascal wiki - User contributions [en]2024-03-29T08:20:36ZUser contributionsMediaWiki 1.35.6https://wiki.freepascal.org/index.php?title=FPC_Unicode_RTL&diff=158351FPC Unicode RTL2024-03-05T09:31:11Z<p>Michael: /* Compiling the Unicode RTL */</p>
<hr />
<div><br />
== The issue ==<br />
<br />
The Unicode RTL is part of an effort to create a more recent Delphi compatible RTL in Free Pascal.<br />
<br />
Currently, 2 points make creating code that will compile in Delphi and in Free Pascal difficult.<br />
* In the Delphi RTL/VCL, the string keyword means WideString (or UnicodeString): an array consisting of 2-byte characters.<br />
::In Free Pascal, String is still a single-byte character as it was before Delphi 2009..<br />
<br />
* In Delphi, units have a namespace: ''System.SysUtils'', ''VCL.Forms'' etc. <br />
::In Free Pascal, the unit names still conform to the Delphi 7 era.<br />
<br />
Free Pascal has backwards compatibility high in the list of priorities, so a complete switch from one to the other is not possible.<br />
<br />
== The solution ==<br />
<br />
2 RTLs and packages will be created from the same codebase:<br />
* The backwards compatible RTL (no namespaces, single-byte string)<br />
* The ''Unicode RTL'', which will be Delphi 2009 and upwards compatible as much as feasible.<br />
<br />
The default RTL will still be the Free Pascal, backwards compatible, RTL.<br />
<br />
=== Using unicode strings ===<br />
<br />
The Free Pascal codebase for the RTL, packages and utilities is cleaned up:<br />
<br />
* The compiler now defines 2 basic types: ''AnsiChar'' (1 byte) and ''UnicodeChar'' (2 bytes)<br />
* The system unit defines ''Char'' as an alias for one of the 2 types, using a define: '''UNICODERTL'''<br />
* The code of RTL and packages has been revised so the "string" identifier has been removed where needed.<br />
* In places where the code assumes an ''AnsiString'', the '''AnsiString''' string type is used.<br />
* In places where the code is agnostic of the actual string type the '''String''' keyword was left in place.<br />
* Similarly, ''Char'' has been replaced by ''AnsiChar'', ''PChar'' has been replaced by ''PAnsiChar''<br />
<br />
If you have code that must compile in both RTLs, you can use the following conditional compilation mechanism<br />
<pre><br />
{IF SIZEOF(CHAR)=2}<br />
// Unicode string code<br />
{$ELSE}<br />
// Ansistring string code<br />
{$ENDIF}<br />
</pre><br />
<br />
As of end of July 2023, this work is completed.<br />
<br />
Note that the compiler itself needs a single-byte rtl, compiling the compiler with the 2-byte RTL is not supported at this time.<br />
<br />
=== Using namespaced units ===<br />
<br />
The Free Pascal codebase is enhanced with namespaced units:<br />
<br />
* Using the system of include files, all available units will be made so that they exist in 2 versions: one namespaced, one not namespaced.<br />
<br />
Basically, the namespaced unit will look like<br />
<br />
<pre><br />
unit Api.Mysql57dyn;<br />
{$DEFINE FPC_DOTTEDUNITS}<br />
{$i mysql57dyn.pp}<br />
</pre><br />
as you can see, the not-namespaced unit '''mysql57dyn.pp''' is included, and it starts with:<br />
<pre><br />
{$IFNDEF FPC_DOTTEDUNITS}<br />
unit mysql57dyn;<br />
{$ENDIF FPC_DOTTEDUNITS}<br />
</pre><br />
<br />
The occasion has been used to make the unit names more consistent. <br />
While for many units, the name has been prefixed with the namespace, <br />
for equally many units, the name has been made more consistent.<br />
<br />
Depending on a define ''fpmake'' and the ''Makefiles'' will compile either the one-byte RTL or the Unicode RTL, never both together.<br />
<br />
=== What about the compiler itself? ===<br />
<br />
The compiler itself does not use unicode strings, and it does not use namespaced units. <br />
Therefore, if you wish to compile the compiler, you must still use the traditional Free Pascal RTL.<br />
<br />
This is also the reason why the unicode and/or namespaced RTL and packages must be compiled separately.<br />
<br />
== Compiling the Unicode RTL ==<br />
If you wish to use the 1-byte RTL, you don't need to do anything special: <br />
the makefiles will still by default create the backwards compatible RTL.<br />
<br />
The compilation of the unicode RTL rests on the use of [[FPC_Subtarget_Support|Subtarget support]].<br />
This means you can only create it using a version 3.3.1 or higher of FPC.<br />
<br />
The first step is to create a configuration file next to the standard free pascal config file, called '''fpc-unicodertl.cfg''':<br />
<pre><br />
-dUNICODERTL<br />
-Municodestrings<br />
</pre><br />
<br />
When used, this configuration file does 2 things:<br />
# It defines UNICODERTL. This can be used to make the difference (where needed) between the 2 rtls.<br />
# It sets the "string" type to UnicodeString.<br />
<br />
To compile the unicode RTL is is now sufficient to execute the following commands (replace ppcx64 with the compiler of your choice):<br />
<pre><br />
make -C rtl clean all SUB_TARGET=unicodertl PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C packages clean all SUB_TARGET=unicodertl OPT=-dUSEWIDESTRING PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C utils clean all SUB_TARGET=unicodertl PP=/path/to/fpc/3.3.1/ppcx64<br />
</pre><br />
(the '''-dUSEWIDESTRING''' is needed for the compilation of the regular expressions unit)<br />
<br />
To install, subsequently execute<br />
<pre><br />
make -C rtl install SUB_TARGET=unicodertl PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C packages install SUB_TARGET=unicodertl PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C utils install SUB_TARGET=unicodertl PP=/path/to/fpc/3.3.1/ppcx64<br />
</pre><br />
<br />
At this point, this will create a non-namespaced unicode rtl.<br />
<br />
To compile your own code with the unicode RTL, you must then of course specify the unicodertl subtarget:<br />
<pre><br />
fpc -tunicodertl yourproject.pas<br />
</pre><br />
<br />
== Compiling a namespaced RTL ==<br />
To compile a namespaced URL, it is sufficient to specify the ""FPC_DOTTEDUNITS=1"" define to the makefiles:<br />
<pre><br />
make -C rtl clean all FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C packages clean all FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C utils clean all FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
</pre><br />
To install, subsequently execute<br />
<pre><br />
make -C rtl install FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C packages install FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C utils install FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
</pre><br />
<br />
== Compiling the namespaced unicode RTL ==<br />
To compile a namespaced URL, it is sufficient to combine the techniques of the above 2 sections: specify the '''SUB_TARGET=unicodertl''' and the '''FPC_DOTTEDUNITS=1''' defines when calling make:<br />
<pre><br />
make -C rtl clean all SUB_TARGET=unicodertl FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C packages clean all SUB_TARGET=unicodertl FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C utils clean all SUB_TARGET=unicodertl FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
</pre><br />
To install, subsequently execute<br />
<pre><br />
make -C rtl install SUB_TARGET=unicodertl FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C packages install SUB_TARGET=unicodertl FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C utils install SUB_TARGET=unicodertl FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
</pre><br />
<br />
<br />
<br />
<br />
[[Category:RTL]]</div>Michaelhttps://wiki.freepascal.org/index.php?title=FPC_Unicode_RTL&diff=158350FPC Unicode RTL2024-03-05T09:27:13Z<p>Michael: /* What about the compiler itself? */</p>
<hr />
<div><br />
== The issue ==<br />
<br />
The Unicode RTL is part of an effort to create a more recent Delphi compatible RTL in Free Pascal.<br />
<br />
Currently, 2 points make creating code that will compile in Delphi and in Free Pascal difficult.<br />
* In the Delphi RTL/VCL, the string keyword means WideString (or UnicodeString): an array consisting of 2-byte characters.<br />
::In Free Pascal, String is still a single-byte character as it was before Delphi 2009..<br />
<br />
* In Delphi, units have a namespace: ''System.SysUtils'', ''VCL.Forms'' etc. <br />
::In Free Pascal, the unit names still conform to the Delphi 7 era.<br />
<br />
Free Pascal has backwards compatibility high in the list of priorities, so a complete switch from one to the other is not possible.<br />
<br />
== The solution ==<br />
<br />
2 RTLs and packages will be created from the same codebase:<br />
* The backwards compatible RTL (no namespaces, single-byte string)<br />
* The ''Unicode RTL'', which will be Delphi 2009 and upwards compatible as much as feasible.<br />
<br />
The default RTL will still be the Free Pascal, backwards compatible, RTL.<br />
<br />
=== Using unicode strings ===<br />
<br />
The Free Pascal codebase for the RTL, packages and utilities is cleaned up:<br />
<br />
* The compiler now defines 2 basic types: ''AnsiChar'' (1 byte) and ''UnicodeChar'' (2 bytes)<br />
* The system unit defines ''Char'' as an alias for one of the 2 types, using a define: '''UNICODERTL'''<br />
* The code of RTL and packages has been revised so the "string" identifier has been removed where needed.<br />
* In places where the code assumes an ''AnsiString'', the '''AnsiString''' string type is used.<br />
* In places where the code is agnostic of the actual string type the '''String''' keyword was left in place.<br />
* Similarly, ''Char'' has been replaced by ''AnsiChar'', ''PChar'' has been replaced by ''PAnsiChar''<br />
<br />
If you have code that must compile in both RTLs, you can use the following conditional compilation mechanism<br />
<pre><br />
{IF SIZEOF(CHAR)=2}<br />
// Unicode string code<br />
{$ELSE}<br />
// Ansistring string code<br />
{$ENDIF}<br />
</pre><br />
<br />
As of end of July 2023, this work is completed.<br />
<br />
Note that the compiler itself needs a single-byte rtl, compiling the compiler with the 2-byte RTL is not supported at this time.<br />
<br />
=== Using namespaced units ===<br />
<br />
The Free Pascal codebase is enhanced with namespaced units:<br />
<br />
* Using the system of include files, all available units will be made so that they exist in 2 versions: one namespaced, one not namespaced.<br />
<br />
Basically, the namespaced unit will look like<br />
<br />
<pre><br />
unit Api.Mysql57dyn;<br />
{$DEFINE FPC_DOTTEDUNITS}<br />
{$i mysql57dyn.pp}<br />
</pre><br />
as you can see, the not-namespaced unit '''mysql57dyn.pp''' is included, and it starts with:<br />
<pre><br />
{$IFNDEF FPC_DOTTEDUNITS}<br />
unit mysql57dyn;<br />
{$ENDIF FPC_DOTTEDUNITS}<br />
</pre><br />
<br />
The occasion has been used to make the unit names more consistent. <br />
While for many units, the name has been prefixed with the namespace, <br />
for equally many units, the name has been made more consistent.<br />
<br />
Depending on a define ''fpmake'' and the ''Makefiles'' will compile either the one-byte RTL or the Unicode RTL, never both together.<br />
<br />
=== What about the compiler itself? ===<br />
<br />
The compiler itself does not use unicode strings, and it does not use namespaced units. <br />
Therefore, if you wish to compile the compiler, you must still use the traditional Free Pascal RTL.<br />
<br />
This is also the reason why the unicode and/or namespaced RTL and packages must be compiled separately.<br />
<br />
== Compiling the Unicode RTL ==<br />
If you wish to use the 1-byte RTL, you don't need to do anything special: <br />
the makefiles will still by default create the backwards compatible RTL.<br />
<br />
The compilation of the unicode RTL rests on the use of [[FPC_Subtarget_Support|Subtarget support]].<br />
This means you can only create it using a version 3.3.1 or higher of FPC.<br />
<br />
The first step is to create a configuration file next to the standard free pascal config file, called '''fpc-unicodertl.cfg''':<br />
<pre><br />
-dUNICODERTL<br />
-Municodestrings<br />
</pre><br />
<br />
When used, this configuration file does 2 things:<br />
# It defines UNICODERTL. This can be used to make the difference (where needed) between the 2 rtls.<br />
# It sets the "string" type to UnicodeString.<br />
<br />
To compile the unicode RTL is is now sufficient to execute the following commands (replace ppcx64 with the compiler of your choice):<br />
<pre><br />
make -C rtl clean all SUB_TARGET=unicodertl PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C packages clean all SUB_TARGET=unicodertl PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C utils clean all SUB_TARGET=unicodertl PP=/path/to/fpc/3.3.1/ppcx64<br />
</pre><br />
To install, subsequently execute<br />
<pre><br />
make -C rtl install SUB_TARGET=unicodertl PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C packages install SUB_TARGET=unicodertl PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C utils install SUB_TARGET=unicodertl PP=/path/to/fpc/3.3.1/ppcx64<br />
</pre><br />
<br />
At this point, this will create a non-namespaced unicode rtl.<br />
<br />
To compile your own code with the unicode RTL, you must then of course specify the unicodertl subtarget:<br />
<pre><br />
fpc -tunicodertl yourproject.pas<br />
</pre><br />
<br />
== Compiling a namespaced RTL ==<br />
To compile a namespaced URL, it is sufficient to specify the ""FPC_DOTTEDUNITS=1"" define to the makefiles:<br />
<pre><br />
make -C rtl clean all FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C packages clean all FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C utils clean all FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
</pre><br />
To install, subsequently execute<br />
<pre><br />
make -C rtl install FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C packages install FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C utils install FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
</pre><br />
<br />
== Compiling the namespaced unicode RTL ==<br />
To compile a namespaced URL, it is sufficient to combine the techniques of the above 2 sections: specify the '''SUB_TARGET=unicodertl''' and the '''FPC_DOTTEDUNITS=1''' defines when calling make:<br />
<pre><br />
make -C rtl clean all SUB_TARGET=unicodertl FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C packages clean all SUB_TARGET=unicodertl FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C utils clean all SUB_TARGET=unicodertl FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
</pre><br />
To install, subsequently execute<br />
<pre><br />
make -C rtl install SUB_TARGET=unicodertl FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C packages install SUB_TARGET=unicodertl FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C utils install SUB_TARGET=unicodertl FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
</pre><br />
<br />
<br />
<br />
<br />
[[Category:RTL]]</div>Michaelhttps://wiki.freepascal.org/index.php?title=FPC_Unicode_RTL&diff=158349FPC Unicode RTL2024-03-05T09:26:26Z<p>Michael: /* Using namespaced units */</p>
<hr />
<div><br />
== The issue ==<br />
<br />
The Unicode RTL is part of an effort to create a more recent Delphi compatible RTL in Free Pascal.<br />
<br />
Currently, 2 points make creating code that will compile in Delphi and in Free Pascal difficult.<br />
* In the Delphi RTL/VCL, the string keyword means WideString (or UnicodeString): an array consisting of 2-byte characters.<br />
::In Free Pascal, String is still a single-byte character as it was before Delphi 2009..<br />
<br />
* In Delphi, units have a namespace: ''System.SysUtils'', ''VCL.Forms'' etc. <br />
::In Free Pascal, the unit names still conform to the Delphi 7 era.<br />
<br />
Free Pascal has backwards compatibility high in the list of priorities, so a complete switch from one to the other is not possible.<br />
<br />
== The solution ==<br />
<br />
2 RTLs and packages will be created from the same codebase:<br />
* The backwards compatible RTL (no namespaces, single-byte string)<br />
* The ''Unicode RTL'', which will be Delphi 2009 and upwards compatible as much as feasible.<br />
<br />
The default RTL will still be the Free Pascal, backwards compatible, RTL.<br />
<br />
=== Using unicode strings ===<br />
<br />
The Free Pascal codebase for the RTL, packages and utilities is cleaned up:<br />
<br />
* The compiler now defines 2 basic types: ''AnsiChar'' (1 byte) and ''UnicodeChar'' (2 bytes)<br />
* The system unit defines ''Char'' as an alias for one of the 2 types, using a define: '''UNICODERTL'''<br />
* The code of RTL and packages has been revised so the "string" identifier has been removed where needed.<br />
* In places where the code assumes an ''AnsiString'', the '''AnsiString''' string type is used.<br />
* In places where the code is agnostic of the actual string type the '''String''' keyword was left in place.<br />
* Similarly, ''Char'' has been replaced by ''AnsiChar'', ''PChar'' has been replaced by ''PAnsiChar''<br />
<br />
If you have code that must compile in both RTLs, you can use the following conditional compilation mechanism<br />
<pre><br />
{IF SIZEOF(CHAR)=2}<br />
// Unicode string code<br />
{$ELSE}<br />
// Ansistring string code<br />
{$ENDIF}<br />
</pre><br />
<br />
As of end of July 2023, this work is completed.<br />
<br />
Note that the compiler itself needs a single-byte rtl, compiling the compiler with the 2-byte RTL is not supported at this time.<br />
<br />
=== Using namespaced units ===<br />
<br />
The Free Pascal codebase is enhanced with namespaced units:<br />
<br />
* Using the system of include files, all available units will be made so that they exist in 2 versions: one namespaced, one not namespaced.<br />
<br />
Basically, the namespaced unit will look like<br />
<br />
<pre><br />
unit Api.Mysql57dyn;<br />
{$DEFINE FPC_DOTTEDUNITS}<br />
{$i mysql57dyn.pp}<br />
</pre><br />
as you can see, the not-namespaced unit '''mysql57dyn.pp''' is included, and it starts with:<br />
<pre><br />
{$IFNDEF FPC_DOTTEDUNITS}<br />
unit mysql57dyn;<br />
{$ENDIF FPC_DOTTEDUNITS}<br />
</pre><br />
<br />
The occasion has been used to make the unit names more consistent. <br />
While for many units, the name has been prefixed with the namespace, <br />
for equally many units, the name has been made more consistent.<br />
<br />
Depending on a define ''fpmake'' and the ''Makefiles'' will compile either the one-byte RTL or the Unicode RTL, never both together.<br />
<br />
=== What about the compiler itself? ===<br />
<br />
The compiler itself does not use unicode strings, and it does not use namespaced units. <br />
Therefore, if you wish to compile the compiler, you must still use the traditional Free Pascal RTL.<br />
<br />
== Compiling the Unicode RTL ==<br />
If you wish to use the 1-byte RTL, you don't need to do anything special: <br />
the makefiles will still by default create the backwards compatible RTL.<br />
<br />
The compilation of the unicode RTL rests on the use of [[FPC_Subtarget_Support|Subtarget support]].<br />
This means you can only create it using a version 3.3.1 or higher of FPC.<br />
<br />
The first step is to create a configuration file next to the standard free pascal config file, called '''fpc-unicodertl.cfg''':<br />
<pre><br />
-dUNICODERTL<br />
-Municodestrings<br />
</pre><br />
<br />
When used, this configuration file does 2 things:<br />
# It defines UNICODERTL. This can be used to make the difference (where needed) between the 2 rtls.<br />
# It sets the "string" type to UnicodeString.<br />
<br />
To compile the unicode RTL is is now sufficient to execute the following commands (replace ppcx64 with the compiler of your choice):<br />
<pre><br />
make -C rtl clean all SUB_TARGET=unicodertl PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C packages clean all SUB_TARGET=unicodertl PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C utils clean all SUB_TARGET=unicodertl PP=/path/to/fpc/3.3.1/ppcx64<br />
</pre><br />
To install, subsequently execute<br />
<pre><br />
make -C rtl install SUB_TARGET=unicodertl PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C packages install SUB_TARGET=unicodertl PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C utils install SUB_TARGET=unicodertl PP=/path/to/fpc/3.3.1/ppcx64<br />
</pre><br />
<br />
At this point, this will create a non-namespaced unicode rtl.<br />
<br />
To compile your own code with the unicode RTL, you must then of course specify the unicodertl subtarget:<br />
<pre><br />
fpc -tunicodertl yourproject.pas<br />
</pre><br />
<br />
== Compiling a namespaced RTL ==<br />
To compile a namespaced URL, it is sufficient to specify the ""FPC_DOTTEDUNITS=1"" define to the makefiles:<br />
<pre><br />
make -C rtl clean all FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C packages clean all FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C utils clean all FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
</pre><br />
To install, subsequently execute<br />
<pre><br />
make -C rtl install FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C packages install FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C utils install FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
</pre><br />
<br />
== Compiling the namespaced unicode RTL ==<br />
To compile a namespaced URL, it is sufficient to combine the techniques of the above 2 sections: specify the '''SUB_TARGET=unicodertl''' and the '''FPC_DOTTEDUNITS=1''' defines when calling make:<br />
<pre><br />
make -C rtl clean all SUB_TARGET=unicodertl FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C packages clean all SUB_TARGET=unicodertl FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C utils clean all SUB_TARGET=unicodertl FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
</pre><br />
To install, subsequently execute<br />
<pre><br />
make -C rtl install SUB_TARGET=unicodertl FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C packages install SUB_TARGET=unicodertl FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C utils install SUB_TARGET=unicodertl FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
</pre><br />
<br />
<br />
<br />
<br />
[[Category:RTL]]</div>Michaelhttps://wiki.freepascal.org/index.php?title=FPC_Unicode_RTL&diff=158348FPC Unicode RTL2024-03-05T09:24:30Z<p>Michael: /* Compiling the Unicode RTL */</p>
<hr />
<div><br />
== The issue ==<br />
<br />
The Unicode RTL is part of an effort to create a more recent Delphi compatible RTL in Free Pascal.<br />
<br />
Currently, 2 points make creating code that will compile in Delphi and in Free Pascal difficult.<br />
* In the Delphi RTL/VCL, the string keyword means WideString (or UnicodeString): an array consisting of 2-byte characters.<br />
::In Free Pascal, String is still a single-byte character as it was before Delphi 2009..<br />
<br />
* In Delphi, units have a namespace: ''System.SysUtils'', ''VCL.Forms'' etc. <br />
::In Free Pascal, the unit names still conform to the Delphi 7 era.<br />
<br />
Free Pascal has backwards compatibility high in the list of priorities, so a complete switch from one to the other is not possible.<br />
<br />
== The solution ==<br />
<br />
2 RTLs and packages will be created from the same codebase:<br />
* The backwards compatible RTL (no namespaces, single-byte string)<br />
* The ''Unicode RTL'', which will be Delphi 2009 and upwards compatible as much as feasible.<br />
<br />
The default RTL will still be the Free Pascal, backwards compatible, RTL.<br />
<br />
=== Using unicode strings ===<br />
<br />
The Free Pascal codebase for the RTL, packages and utilities is cleaned up:<br />
<br />
* The compiler now defines 2 basic types: ''AnsiChar'' (1 byte) and ''UnicodeChar'' (2 bytes)<br />
* The system unit defines ''Char'' as an alias for one of the 2 types, using a define: '''UNICODERTL'''<br />
* The code of RTL and packages has been revised so the "string" identifier has been removed where needed.<br />
* In places where the code assumes an ''AnsiString'', the '''AnsiString''' string type is used.<br />
* In places where the code is agnostic of the actual string type the '''String''' keyword was left in place.<br />
* Similarly, ''Char'' has been replaced by ''AnsiChar'', ''PChar'' has been replaced by ''PAnsiChar''<br />
<br />
If you have code that must compile in both RTLs, you can use the following conditional compilation mechanism<br />
<pre><br />
{IF SIZEOF(CHAR)=2}<br />
// Unicode string code<br />
{$ELSE}<br />
// Ansistring string code<br />
{$ENDIF}<br />
</pre><br />
<br />
As of end of July 2023, this work is completed.<br />
<br />
Note that the compiler itself needs a single-byte rtl, compiling the compiler with the 2-byte RTL is not supported at this time.<br />
<br />
=== Using namespaced units ===<br />
<br />
The Free Pascal codebase is enhanced with namespaced units:<br />
<br />
* Using the system of include files, all available units will be made so that they exist in 2 versions: one namespaced, one not namespaced.<br />
<br />
Basically, the namespaced unit will look like<br />
<br />
<pre><br />
unit Api.Mysql57dyn;<br />
{$DEFINE FPC_DOTTEDUNITS}<br />
{$i mysql57dyn.pp}<br />
</pre><br />
as you can see, the not-namespaced unit '''mysql57dyn.pp''' is included, and it starts with:<br />
<pre><br />
{$IFNDEF FPC_DOTTEDUNITS}<br />
unit mysql57dyn;<br />
{$ENDIF FPC_DOTTEDUNITS}<br />
</pre><br />
<br />
The occasion has been used to make the unit names more consistent. <br />
While for many units, the name has been prefixed with the namespace, <br />
for equally many units, the name has been made more consistent.<br />
<br />
Depending on a define ''fpmake'' and the ''Makefiles'' will compile either the one-byte RTL or the Unicode RTL, never both together.<br />
<br />
== Compiling the Unicode RTL ==<br />
If you wish to use the 1-byte RTL, you don't need to do anything special: <br />
the makefiles will still by default create the backwards compatible RTL.<br />
<br />
The compilation of the unicode RTL rests on the use of [[FPC_Subtarget_Support|Subtarget support]].<br />
This means you can only create it using a version 3.3.1 or higher of FPC.<br />
<br />
The first step is to create a configuration file next to the standard free pascal config file, called '''fpc-unicodertl.cfg''':<br />
<pre><br />
-dUNICODERTL<br />
-Municodestrings<br />
</pre><br />
<br />
When used, this configuration file does 2 things:<br />
# It defines UNICODERTL. This can be used to make the difference (where needed) between the 2 rtls.<br />
# It sets the "string" type to UnicodeString.<br />
<br />
To compile the unicode RTL is is now sufficient to execute the following commands (replace ppcx64 with the compiler of your choice):<br />
<pre><br />
make -C rtl clean all SUB_TARGET=unicodertl PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C packages clean all SUB_TARGET=unicodertl PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C utils clean all SUB_TARGET=unicodertl PP=/path/to/fpc/3.3.1/ppcx64<br />
</pre><br />
To install, subsequently execute<br />
<pre><br />
make -C rtl install SUB_TARGET=unicodertl PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C packages install SUB_TARGET=unicodertl PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C utils install SUB_TARGET=unicodertl PP=/path/to/fpc/3.3.1/ppcx64<br />
</pre><br />
<br />
At this point, this will create a non-namespaced unicode rtl.<br />
<br />
To compile your own code with the unicode RTL, you must then of course specify the unicodertl subtarget:<br />
<pre><br />
fpc -tunicodertl yourproject.pas<br />
</pre><br />
<br />
== Compiling a namespaced RTL ==<br />
To compile a namespaced URL, it is sufficient to specify the ""FPC_DOTTEDUNITS=1"" define to the makefiles:<br />
<pre><br />
make -C rtl clean all FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C packages clean all FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C utils clean all FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
</pre><br />
To install, subsequently execute<br />
<pre><br />
make -C rtl install FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C packages install FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C utils install FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
</pre><br />
<br />
== Compiling the namespaced unicode RTL ==<br />
To compile a namespaced URL, it is sufficient to combine the techniques of the above 2 sections: specify the '''SUB_TARGET=unicodertl''' and the '''FPC_DOTTEDUNITS=1''' defines when calling make:<br />
<pre><br />
make -C rtl clean all SUB_TARGET=unicodertl FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C packages clean all SUB_TARGET=unicodertl FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C utils clean all SUB_TARGET=unicodertl FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
</pre><br />
To install, subsequently execute<br />
<pre><br />
make -C rtl install SUB_TARGET=unicodertl FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C packages install SUB_TARGET=unicodertl FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C utils install SUB_TARGET=unicodertl FPC_DOTTEDUNITS=1 PP=/path/to/fpc/3.3.1/ppcx64<br />
</pre><br />
<br />
<br />
<br />
<br />
[[Category:RTL]]</div>Michaelhttps://wiki.freepascal.org/index.php?title=FPC_Unicode_RTL&diff=158347FPC Unicode RTL2024-03-05T09:19:33Z<p>Michael: /* Compiling the Unicode RTL */</p>
<hr />
<div><br />
== The issue ==<br />
<br />
The Unicode RTL is part of an effort to create a more recent Delphi compatible RTL in Free Pascal.<br />
<br />
Currently, 2 points make creating code that will compile in Delphi and in Free Pascal difficult.<br />
* In the Delphi RTL/VCL, the string keyword means WideString (or UnicodeString): an array consisting of 2-byte characters.<br />
::In Free Pascal, String is still a single-byte character as it was before Delphi 2009..<br />
<br />
* In Delphi, units have a namespace: ''System.SysUtils'', ''VCL.Forms'' etc. <br />
::In Free Pascal, the unit names still conform to the Delphi 7 era.<br />
<br />
Free Pascal has backwards compatibility high in the list of priorities, so a complete switch from one to the other is not possible.<br />
<br />
== The solution ==<br />
<br />
2 RTLs and packages will be created from the same codebase:<br />
* The backwards compatible RTL (no namespaces, single-byte string)<br />
* The ''Unicode RTL'', which will be Delphi 2009 and upwards compatible as much as feasible.<br />
<br />
The default RTL will still be the Free Pascal, backwards compatible, RTL.<br />
<br />
=== Using unicode strings ===<br />
<br />
The Free Pascal codebase for the RTL, packages and utilities is cleaned up:<br />
<br />
* The compiler now defines 2 basic types: ''AnsiChar'' (1 byte) and ''UnicodeChar'' (2 bytes)<br />
* The system unit defines ''Char'' as an alias for one of the 2 types, using a define: '''UNICODERTL'''<br />
* The code of RTL and packages has been revised so the "string" identifier has been removed where needed.<br />
* In places where the code assumes an ''AnsiString'', the '''AnsiString''' string type is used.<br />
* In places where the code is agnostic of the actual string type the '''String''' keyword was left in place.<br />
* Similarly, ''Char'' has been replaced by ''AnsiChar'', ''PChar'' has been replaced by ''PAnsiChar''<br />
<br />
If you have code that must compile in both RTLs, you can use the following conditional compilation mechanism<br />
<pre><br />
{IF SIZEOF(CHAR)=2}<br />
// Unicode string code<br />
{$ELSE}<br />
// Ansistring string code<br />
{$ENDIF}<br />
</pre><br />
<br />
As of end of July 2023, this work is completed.<br />
<br />
Note that the compiler itself needs a single-byte rtl, compiling the compiler with the 2-byte RTL is not supported at this time.<br />
<br />
=== Using namespaced units ===<br />
<br />
The Free Pascal codebase is enhanced with namespaced units:<br />
<br />
* Using the system of include files, all available units will be made so that they exist in 2 versions: one namespaced, one not namespaced.<br />
<br />
Basically, the namespaced unit will look like<br />
<br />
<pre><br />
unit Api.Mysql57dyn;<br />
{$DEFINE FPC_DOTTEDUNITS}<br />
{$i mysql57dyn.pp}<br />
</pre><br />
as you can see, the not-namespaced unit '''mysql57dyn.pp''' is included, and it starts with:<br />
<pre><br />
{$IFNDEF FPC_DOTTEDUNITS}<br />
unit mysql57dyn;<br />
{$ENDIF FPC_DOTTEDUNITS}<br />
</pre><br />
<br />
The occasion has been used to make the unit names more consistent. <br />
While for many units, the name has been prefixed with the namespace, <br />
for equally many units, the name has been made more consistent.<br />
<br />
Depending on a define ''fpmake'' and the ''Makefiles'' will compile either the one-byte RTL or the Unicode RTL, never both together.<br />
<br />
== Compiling the Unicode RTL ==<br />
If you wish to use the 1-byte RTL, you don't need to do anything special: <br />
the makefiles will still by default create the backwards compatible RTL.<br />
<br />
The compilation of the unicode RTL rests on the use of [[FPC_Subtarget_Support|Subtarget support]].<br />
This means you can only create it using a version 3.3.1 or higher of FPC.<br />
<br />
The first step is to create a configuration file next to the standard free pascal config file, called '''fpc-unicodertl.cfg''':<br />
<pre><br />
-dUNICODERTL<br />
-Municodestrings<br />
</pre><br />
<br />
When used, this configuration file does 2 things:<br />
# It defines UNICODERTL. This can be used to make the difference (where needed) between the 2 rtls.<br />
# It sets the "string" type to UnicodeString.<br />
<br />
To compile the unicode RTL is is now sufficient to execute the following commands (replace ppcx64 with the compiler of your choice):<br />
<pre><br />
make -C rtl clean all SUB_TARGET=unicodertl PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C packages clean all SUB_TARGET=unicodertl PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C utils clean all SUB_TARGET=unicodertl PP=/path/to/fpc/3.3.1/ppcx64<br />
</pre><br />
To install, subsequently execute<br />
<pre><br />
make -C rtl install SUB_TARGET=unicodertl PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C packages install SUB_TARGET=unicodertl PP=/path/to/fpc/3.3.1/ppcx64<br />
make -C utils install SUB_TARGET=unicodertl PP=/path/to/fpc/3.3.1/ppcx64<br />
</pre><br />
<br />
At this point, this will create a non-namespaced unicode rtl.<br />
<br />
To compile your own code with the unicode RTL, you must then of course specify the unicodertl subtarget:<br />
<pre><br />
fpc -tunicodertl yourproject.pas<br />
</pre><br />
<br />
<br />
[[Category:RTL]]</div>Michaelhttps://wiki.freepascal.org/index.php?title=FPC_Unicode_RTL&diff=158320FPC Unicode RTL2024-02-28T17:04:15Z<p>Michael: /* Compiling the Unicode RTL */</p>
<hr />
<div><br />
== The issue ==<br />
<br />
The Unicode RTL is part of an effort to create a more recent Delphi compatible RTL in Free Pascal.<br />
<br />
Currently, 2 points make creating code that will compile in Delphi and in Free Pascal difficult.<br />
* In the Delphi RTL/VCL, the string keyword means WideString (or UnicodeString): an array consisting of 2-byte characters.<br />
::In Free Pascal, String is still a single-byte character as it was before Delphi 2009..<br />
<br />
* In Delphi, units have a namespace: ''System.SysUtils'', ''VCL.Forms'' etc. <br />
::In Free Pascal, the unit names still conform to the Delphi 7 era.<br />
<br />
Free Pascal has backwards compatibility high in the list of priorities, so a complete switch from one to the other is not possible.<br />
<br />
== The solution ==<br />
<br />
2 RTLs and packages will be created from the same codebase:<br />
* The backwards compatible RTL (no namespaces, single-byte string)<br />
* The ''Unicode RTL'', which will be Delphi 2009 and upwards compatible as much as feasible.<br />
<br />
The default RTL will still be the Free Pascal, backwards compatible, RTL.<br />
<br />
=== Using unicode strings ===<br />
<br />
The Free Pascal codebase for the RTL, packages and utilities is cleaned up:<br />
<br />
* The compiler now defines 2 basic types: ''AnsiChar'' (1 byte) and ''UnicodeChar'' (2 bytes)<br />
* The system unit defines ''Char'' as an alias for one of the 2 types, using a define: '''UNICODERTL'''<br />
* The code of RTL and packages has been revised so the "string" identifier has been removed where needed.<br />
* In places where the code assumes an ''AnsiString'', the '''AnsiString''' string type is used.<br />
* In places where the code is agnostic of the actual string type the '''String''' keyword was left in place.<br />
* Similarly, ''Char'' has been replaced by ''AnsiChar'', ''PChar'' has been replaced by ''PAnsiChar''<br />
<br />
If you have code that must compile in both RTLs, you can use the following conditional compilation mechanism<br />
<pre><br />
{IF SIZEOF(CHAR)=2}<br />
// Unicode string code<br />
{$ELSE}<br />
// Ansistring string code<br />
{$ENDIF}<br />
</pre><br />
<br />
As of end of July 2023, this work is completed.<br />
<br />
Note that the compiler itself needs a single-byte rtl, compiling the compiler with the 2-byte RTL is not supported at this time.<br />
<br />
=== Using namespaced units ===<br />
<br />
The Free Pascal codebase is enhanced with namespaced units:<br />
<br />
* Using the system of include files, all available units will be made so that they exist in 2 versions: one namespaced, one not namespaced.<br />
<br />
Basically, the namespaced unit will look like<br />
<br />
<pre><br />
unit Api.Mysql57dyn;<br />
{$DEFINE FPC_DOTTEDUNITS}<br />
{$i mysql57dyn.pp}<br />
</pre><br />
as you can see, the not-namespaced unit '''mysql57dyn.pp''' is included, and it starts with:<br />
<pre><br />
{$IFNDEF FPC_DOTTEDUNITS}<br />
unit mysql57dyn;<br />
{$ENDIF FPC_DOTTEDUNITS}<br />
</pre><br />
<br />
The occasion has been used to make the unit names more consistent. <br />
While for many units, the name has been prefixed with the namespace, <br />
for equally many units, the name has been made more consistent.<br />
<br />
Depending on a define ''fpmake'' and the ''Makefiles'' will compile either the one-byte RTL or the Unicode RTL, never both together.<br />
<br />
== Compiling the Unicode RTL ==<br />
If you wish to use the 1-byte RTL, you don't need to do anything special: <br />
the makefiles will still by default create the backwards compatible RTL.<br />
<br />
The compilation of the unicode RTL rests on the use of [[FPC_Subtarget_Support|Subtarget support]].<br />
This means you can only create it using a version 3.3.1 or higher of FPC.<br />
<br />
The first step is to create a configuration file next to the standard free pascal config file, called '''fpc-unicodertl.cfg''':<br />
<pre><br />
-dUNICODERTL<br />
-Municodestrings<br />
</pre><br />
<br />
When used, this configuration file does 2 things:<br />
# It defines UNICODERTL. This can be used to make the difference (where needed) between the 2 rtls.<br />
# It sets the "string" type to UnicodeString.<br />
<br />
To compile the unicode RTL is is now sufficient to execute the following commands:<br />
<pre><br />
make -C rtl clean all SUB_TARGET=unicodertl<br />
make -C packages clean all SUB_TARGET=unicodertl<br />
make -C utils clean all SUB_TARGET=unicodertl<br />
</pre><br />
To install, subsequently execute<br />
<pre><br />
make -C rtl install SUB_TARGET=unicodertl<br />
make -C packages install SUB_TARGET=unicodertl<br />
make -C utils install SUB_TARGET=unicodertl<br />
</pre><br />
<br />
At this point, this will create a non-namespaced unicode rtl.<br />
<br />
To compile your own code with the unicode RTL, you must then of course specify the unicodertl subtarget:<br />
<pre><br />
fpc -tunicodertl yourproject.pas<br />
</pre><br />
<br />
<br />
[[Category:RTL]]</div>Michaelhttps://wiki.freepascal.org/index.php?title=Pas2JS_Version_Changes&diff=158291Pas2JS Version Changes2024-02-27T11:27:23Z<p>Michael: /* 3.0.1 */</p>
<hr />
<div>= Releases =<br />
<br />
== Next Version ==<br />
<br />
== 3.0.1 ==<br />
<br />
27th Feb 2024<br />
<br />
Changes:<br />
*New download server for the precompiled binaries: https://getpas2js.freepascal.org<br />
*Namespaces (unitnames with dotted prefixes):<br />
** added compiler option '''-FN<X>''': add ''<x>'' to namespaces. Namespaces with trailing ''-'' are removed. Delphi calls this flag "unit scope names".<br />
** The packages were extended to support namespaced version of units, e.g. units in packages/rtl are now in packages/rtl/src and the namespaced versions are in packages/rtl/namespaced<br />
** This requires updating the -Fu paths in your pas2js.cfg, see [[pas2js.cfg#Examples|pas2js.cfg Example]]<br />
* Removed submodule "compiler" and instead support "compiler" as copy, symlink or FPCDIR environment variable. See [[pas2js#GIT|Fetching pas2js source via git and compile]]<br />
* Many external JS classes updated and extended<br />
* FPC Wasm code can access the DOM and JS APIs through pas2js code: [[WebAssembly/DOM|WebAssembly/DOM]]<br />
* fixed marking ''library export function result'' sub elements as used<br />
* fixed parsing ''var'' section after ''class var'' section<br />
* fixed names of properties ''MultilineStringsTrimLeft'' and ''MultilineStringsEOLStyle''<br />
* fixed multilinestrings:<br />
** combos like `abc`#10<br />
** double backticks become, same as double apostrophs become one in string literals <br />
** apostroph<br />
* fixed '''anonymous procedure type'''<br />
* fixed '''anonymous record type'''<br />
* fixed searching '''TJSPromise''' in global scopes, while context is a dot scope<br />
* fixed typecast array literal to ''TJSArray''<br />
* added releasecreator, tool written in fpc to compile the compiler and tools<br />
* Support for datamodules in resources<br />
* Tool to import typescript declaration modules as external classes<br />
* Split Web unit into units usable in service workers and main browser window.<br />
* Many updates on the widgets, support for bulma-styled widgets<br />
* JSONRPC client support and tool to generate import based on ExtJS-styled API.<br />
* Add Debugcapture to send logging to server<br />
* Add testinsight client.<br />
<br />
===3.0.1 Incompatibilities===<br />
<br />
===Unitpaths of default packages in pas2js.cfg===<br />
<br />
* The default packages source paths have changed namespaced versions were added.<br />
* Remedy: Update the -Fu paths in your pas2js.cfg, see [[pas2js.cfg#Examples|pas2js.cfg Example]]<br />
<br />
== Version 2.2.0 ==<br />
<br />
22th Feb 2022<br />
<br />
== All changes of version 2.2.0 ==<br />
<br />
* moved from svn to gitlab<br />
* New command line option: -Ja<x>: Append JS file <x> to main JS file. E.g. -Jamap.js. Can be given multiple times. To remove a file name append a minus, e.g. -Jamap.js-.<br />
* Added RTTI ''TProcedureFlag'' '''pfSafeCall''' and '''pfAsync'''<br />
* pas2js now creates unique method pointers ('''@SomeMethod'''), e.g. the following code will now remove the ''@OnLoad'':<br />
xhr.addEventListener('load', @OnLoad);<br />
xhr.removeEventListener('load', @OnLoad);<br />
* Pascal '''Library'''<br />
** export for global functions and static methods<br />
** export for global variables<br />
* '''{$linklib}''' directive, see [[pas2js modules]]<br />
* new -T platform '''module'''<br />
* new -T platform '''electron'''<br />
* mark record fields as used when passing record to a jsvalue parameter<br />
* $mode Delphi support for generic overloads, e.g. ''TBird, TBird<T>, TBird<S,T>''. Can be used from a unit with mode ObjFPC too, although cannot yet be declared there.<br />
* fixed delay init specializations after loading impl sections<br />
* fixed specialize '''try except on''', issue 38795<br />
* fixed ''float / 0.0'' results at compiletime in ''infinity'' instead of div by zero, issue 38815<br />
* fixed ''low/high(aString)''<br />
* fixed typecast ''jsvalue'' to ''external class'' instance not object checking by default, only when object checks are enabled. For example ''TJSString(aJSValue).length''.<br />
* fixed emulate compile time assign integer constant of different type<br />
* fixed '''typeinfo''' ''Module, Attributes, ResultType'' and ''Params'' now have default value '''nil''', not ''undefined''.<br />
* fixed cloning multi dim static array on assign<br />
* fixed stack overflow on deep nested binary expressions<br />
* fixed releasing com interface fields on destroy<br />
* fixed class property getter for array property of static method<br />
* fixed find generic proc overload without params, issue 38796<br />
* fixed calling constructor of nested external class, issue 38858<br />
* fixed await() as aclass, issue 39028<br />
* fixed consistent error message on custom js file not found, issue 38978<br />
* fixed writing sourceMappingURL only if map file enabled, issue 39210<br />
* fixed Setlength(unicodestring) issue 39208<br />
* fixed call type helper on type helper read from pcu<br />
<br />
===2.2.0 Incompatibilities===<br />
<br />
====pas2js.cfg====<br />
<br />
* The binary packages' file ''pas2js.cfg'' now enables ''-Jc'' (concatenate all js) by default. You can disable this with ''-Jc-''.<br />
<br />
== Version 2.0.6 ==<br />
<br />
15th Apr 2021<br />
<br />
* fixed '''insert(item,array,pos)''' when ''array=nil''<br />
* fixed published field with anonymous array<br />
* fixed -O- and record const, issue 38683<br />
* fixed multi add '''a + ImplicitFuncCall + b'''<br />
* (generics) Add comparer version of TDictionary create.<br />
* (generics) Fix wrong comparison of objects, adjusted patch by Henrique Werlang (Issue 38748)<br />
* (db) Patch from Henrique Werlang to implement TDatasetField<br />
* (rtti) Patch from Henrique Werlang to implement getting method parameters info<br />
* (db) Fix in TDataSet.DefaultBytesToBlobData, index out of range<br />
* (sysutils) TStringBuilder implementation<br />
* (arrayutils) Start of array utils<br />
* (web) Clipboard support (bug ID 0038726)<br />
* (sysutils) Use TBoolStrs for Boolean.ToString helper<br />
* (jsondataset) Publish OnRecordResolved, OnLoadFail<br />
* (db) Implement TBlobField.DisplayValue<br />
* (classes) Add ExtractStrings<br />
* (classes) StringStream.ReadString/WritString. Fix TMemoryStream.LoadFromStream.<br />
* (classes) Correctly handle CR/LF in GetNextLineBreak in TStrings.<br />
* demos: Fix demo to work again with latest webwidget<br />
* demos: Fixed demorouter example<br />
* (packages) new flatpickr lib<br />
* (sysutils) provide suitable defaults for Long- and ShortTimeFormat<br />
* (web) Patch from Henrique Werlang to implement TJSCSSStyleDeclaration<br />
* (web) Patch from Henrique Werlang to implement TJSElement.Remove<br />
* (classes) correctly stream TStrings based properties<br />
* (db) Patch from Henrique Werlang to let TDatalink transmit events ony when active<br />
* (sysutils) Introduce FormatSettings<br />
<br />
== Version 2.0.4 ==<br />
<br />
26th Mar 2021<br />
<br />
* fixed wrong setting ''rtl.TObjectDestroy''<br />
* fixed no hint when published method hides ancestor method<br />
* fixed compileserver option '''--simpleserver=''' and '''-d''' relative path<br />
* fixed stack overflow on long string concatenations<br />
* fixed filer restore global shortrefs<br />
<br />
== Version 2.0.2 ==<br />
<br />
9th Mar 2021<br />
<br />
* fixed freeing temporary class interface, if it is nil.<br />
* removed obsolete ''TTypeInfoDynArray.DimCount''<br />
* fixed ''TTypeInfoStaticArray.Dims''<br />
* fixed ''obj as COMIntfType'', when ''obj'' is ''nil': for FPC and Delphi compatibility nil returns nil and does not raise an exception.<br />
* fixed checking statement after ''except-on''<br />
* fixed '''if then asm a;b end'''<br />
* fixed '''ord(integer)'''<br />
* fixed '''Include(SetOfIntegerRange, integer)'''<br />
* fixed omitting hint for not used property<br />
* fixed '''var a: (b,c);'''<br />
* fixed calling '''Instance.StaticMethod''' not using Instance<br />
* fixed fixed creating enum shortrefs for precompiled code for optimization ''EnumValues''<br />
<br />
== Version 2.0.0 ==<br />
<br />
11th Jan 2021<br />
<br />
[[Pas2JS_Version_Changes#All_changes_of_version_2.0.0|All changes of version 2.0.0]]<br />
<br />
* fixed ''TDictionary'' with procedural type<br />
* fixed ''TTypeInfoRecord.RecordType''<br />
<br />
== Version 2.0.0RC8 ==<br />
<br />
31th Dec 2020<br />
<br />
* fixed UTF-16 char literal ''#128..#255''<br />
* fixed using invalid UTF-16 but valid string ''#$DC00'b' ''<br />
* fixed checking class method modifiers match class interface (as in IUnknown)<br />
* fixed typecast specialized array to specialized type<br />
* fixed implicit call of specialized method<br />
* added separate hints '''4501 field "x" not used''' and '''4502 field "x" assigned but never used'''. Delphi/FPC do not have these hints, as they treat records as one memory block and can't omit fields. pas2js can omit fields.<br />
* The param in '''await(param)''' must now be an async function, to avoid accidentally calling the wrong function or not a function at all.<br />
* Allowing '''await(T,jsvalue)''', because jsvalue could be a promise.<br />
* fixed typecast implicit function call passing to arg, e.g. ''aFunc(aType(obj.bFunc))''<br />
* fixed delayed init specialized class interface<br />
<br />
== Version 2.0.0RC7 ==<br />
<br />
13th Dec 2020<br />
<br />
* fixed optimization ''shortrefglobals'' and ''enum value''<br />
* fixed filer storing unix line ending and writing precompiled code with platform line ending<br />
* fixed unit without implementatiom<br />
* fixed record member type<br />
<br />
== Version 2.0.0RC6 ==<br />
<br />
8th Dec 2020<br />
<br />
* the binary snapshot now use same directories as "make all". E.g. '''bin\i386-win32''' for the Windows 32bit executables.<br />
* the binary snapshot now contains the '''makestub''' utility<br />
* fixed filer, call type helper of unit, which unit implementation has not been parsed.<br />
* fixed catching load file exceptions and turn into regular errors<br />
* fixed generating typeinfo for classes with published members, but not referenced via typeinfo<br />
<br />
== Version 2.0.0RC5 ==<br />
<br />
4th Dec 2020<br />
<br />
* fixed skipping non fully specialized types<br />
* fixed filer, storing reference to ''await'' and ''debugger''<br />
* fixed filer, specialize signature of implementation of methods<br />
* fixed filer, skipping generic reference to generic type<br />
* fixed filer, reading inline specialize expression<br />
* fixed filer, checking signatures needing indirect units of implementation<br />
<br />
== Version 2.0.0RC4 ==<br />
<br />
30th Nov 2020<br />
<br />
* fixed '''await''' on '''as''' operator<br />
* fixed '''await(ProcArgument)'''<br />
* fixed hint ''Await needs a promise''<br />
* fixed calling '''async function''' with result type ''COM interface''<br />
* fixed checking '''await(T,callasyncfunc)'' type match<br />
* fixed '''async''' procedure modifier not needed in implementation of a procedure<br />
* added ''FormData'' js keyword<br />
* fixed ''shortrefglobals'' optimization of new/free instance fields<br />
* fixed crash on parser error in inline specialize expression, issue 38111<br />
* fixed typeinfo path of inline specialize type<br />
* fixed '''-OoShortRefGlobals'''<br />
* fixed error when using generic type without parameters<br />
* fixed shortrefglobals when unit initialization uses unit of otherwise empty implementation section<br />
<br />
== Version 2.0.0RC3 ==<br />
<br />
13th Nov 2020<br />
<br />
* fixed '''typeinfo unicodestring''' and '''widechar'''<br />
* fixed passing ''widechar'' to ''var argument char'' and ''unicodestring'' to ''string'' and vice versus.<br />
* rtl: system.pas: removed obsolete ''UnicodeString=string'' and ''WideChar=char'' type alias. They are normal compiler types.<br />
* fixed typecast integer to '''widechar'''<br />
* fixed '''ord(widechar)'''<br />
* added overload ''TryStrToInt64'' with ''int64'', ''TryStrToQWord'' with ''QWord'', ''TryStrToUInt64'' with ''UInt64''<br />
<br />
== Version 2.0.0RC2 ==<br />
<br />
11th Nov 2020<br />
<br />
* fixed ''shortrefglobals'' for minimal class interface, issue 38042<br />
* fixed disable optimization using fpc syntax e.g. '''-OoNoShortRefGlobals''', issue 3804<br />
* fixed ''shortrefglobals'' for procedure without args, issue 38043<br />
* '''-JRnone''' now skips resource directives<br />
<br />
== Version 2.0.0RC1 ==<br />
<br />
5th Nov 2020<br />
<br />
== All changes of version 2.0.0 ==<br />
<br />
* the binary snapshots now use same directories as "make all". E.g. bin\i386-win32 for the Windows 32bit executables.<br />
* [[pas2js_Generics|Generics]]<br />
* '''Attributes''':<br />
** '''Incompatibility''': '''$modeswitch ignoreattributes''' was removed<br />
** base class ''System.TCustomAttribute''<br />
** '''$modeswitch prefixedattributes''': enabled by default in ''$mode Delphi''<br />
** declare in front of any type, type member<br />
** the Delphi compiler attributes like ''ref, weak, volatile'', etc are not supported.<br />
** query attributes of a type:<br />
*** use either typinfo function '''GetRTTIAttributes(typeinfo(SomeType).Attributes)''':<br />
*** or use RTTI unit ''r:=TRTTIContext'', ''r.GetType(typeinfo(SomeType)).GetAttributes''<br />
* '''class constructors''':<br />
** for classes, records, class helpers, record helpers and type helpers.<br />
** Called in initialization section<br />
** Optimizer removes attributes if type is not used.<br />
* '''VarArg.Free''', e.g. ''procedure DoIt(var Arg: TObject); begin Arg.Free end;'' setting Arg to nil<br />
* range checking for type helpers<br />
* range checking for var/out arguments<br />
* fixed '''low/high(nativeint)''' for 53 significand bits instead of only 52 explicit bits, increasing high to ''$1fffffffffffff = 9007199254740991''<br />
* float literal: removing unneeded 0 in front of E e.g. 1.20E1 as 1.2E1<br />
* '''Overflow checks for integers''' -Co ''{$overflowchecks on}'' ''{$Q+}'' for integer operators +, -, *. Checks if result is outside nativeint and raises EIntOverflow.<br />
* '''class abstract''' modifier<br />
* ''type helper for classtype'', same as FPC<br />
* ''type helper for interfacetype'', no constructors, same as FPC<br />
* Dispatch messages:<br />
** method modifier '''message integer''' and '''message string'''<br />
** directive '''{$DispatchField fieldname}''' and '''{$DispatchStrField fieldname}'''<br />
Insert these directives in front of your dispatch methods to let the compiler check all methods with message modifiers if they pass a record with the right field.<br />
<syntaxhighlight lang="pascal"><br />
TMyComponent = class<br />
{$DispatchField Msg}<br />
procedure Dispatch(var aMessage); virtual;<br />
{$DispatchStrField MsgStr}<br />
procedure DispatchStr(var aMessage); virtual;<br />
end;<br />
TMouseDownMsg = record<br />
Id: integer; // Id instead of Msg, works in FPC, but not in pas2js<br />
x,y: integer;<br />
end;<br />
TMouseUpMsg = record<br />
MsgStr: string;<br />
X,Y: integer;<br />
end;<br />
TWinControl = class<br />
procedure MouseDownMsg(var Msg: TMouseDownMsg); message 3; // warning: Dispatch requires record field Msg<br />
procedure MouseUpMsg(var Msg: TMouseUpMsg); message 'up'; // ok, record with string field name MsgStr<br />
end;<br />
</syntaxhighlight><br />
* added rtti utility functions GetInterfaceProp, SetInterfaceProp, GetMethodProp, SetMethodProp<br />
* TStream with TBytes<br />
** TBytesStream<br />
* convert ord(const) to a const<br />
* '''Resource strings''':<br />
** Resource strings can now be written to file. This is controlled by the -Jr option, see the main wiki page for [[pas2js]].<br />
* '''TJSFunction(@obj.methodname)''' is now converted to ''classtype.methodname''<br />
* Constructors of external classes are now supported in four ways:<br />
** ''constructor New'' is translated to ''new ExtClass(params)''. Note the missing JS path.<br />
** ''constructor New; external name 'GlobalFunc' '' is translated to ''new GlobalFunc()''. Note the missing JS path.<br />
** ''constructor SomeName; external name '{}' '' is translated to ''{}'' - a basic, empty JS object<br />
** Otherwise it is translated to ''new ExtClass.FuncName(params)''<br />
* You can now specify a type for the procedure modifier ''varargs'': '''varargs of ''SomeType'' '''. For example<br />
<syntaxhighlight lang="pascal"><br />
procedure SumWords(); varargs of Word;<br />
...<br />
SumWords(1,2,3); // this works<br />
SumWords(1,98765); // this gives a range check error<br />
</syntaxhighlight><br />
* Srcmap for pju files<br />
* allowing ''using a unit twice'', with different names, e.g. ''uses ns.unit1, unit1;'' or ''uses foo in 'unit1.pas', unit1;''<br />
* option '''-Sj''' to allow/disallow typed const to be writable<br />
* option '''-im''' to show available modeswitches<br />
* option '''-M<modeswitch>''' to enable or disable a modeswitch, see option -im<br />
* typecasting unrelated classes now gives only a warning "Class types are not related" instead of an error, Reason: FPC/Delphi compatibility<br />
* mode ObjFPC now checks procedural types in procedure arguments by signature, reason: FPC compatibility. Note: FPC does that too in $mode delphi, pas2js only in mode ObjFPC.<br />
* type helper for '''bytebool, wordbool, longbool'''<br />
* ''ArrayOfChar:=String'' and pass ''string'' to ''ArrayOfChar''<br />
* '''safecall''' calling convention and rtl catch uncaught [[pas2js_exceptions|exceptions]].<br />
* [[pas2js_AsyncAWait|Async procedure modifier]] and await functions:<br />
** ''function await(AsyncFunctionOfResultT): T;'' // implicit promise<br />
** ''function await(aType; p: TJSPromise): aType;'' // explicit promise requires the resolved type<br />
** ''function await(aType; v: jsvalue): aType;'' // explicit optional promise requires the resolved type<br />
* Descending a Pascal class from a JS Function<br />
* The [[pas2js_makestub|makestub]] utility converts a Pascal import unit for importing Pascal classes to a unit that is compilable by Delphi<br />
* ''fcl-json'' JSON interface from FPC.<br />
* New units for Javascript libraries:<br />
** ''libjitsimeet'' interface to jitsi video conferencing. <br />
** ''libopentok'' interface to opentok video conferencing. <br />
** ''libkurento'' interface to kurento video conferencing. <br />
** ''libfullcalendar(4/5)'' interface to fullcalendar.io JS library<br />
** ''libdatatables'' interface to datatables.net JS library<br />
** ''pushjs'' interface to browser Push Notifications<br />
** ''libbootstrap'' interface to bootstrap classes.<br />
** ''gmaps'' interface to google maps interface.<br />
* added separate hints '''4501 field "x" not used''' and '''4502 field "x" assigned but never used'''. Delphi/FPC do not have these hints, as they treat records as one memory block and can't omit fields. pas2js can omit fields.<br />
* Optimizations:<br />
** '''-O2''' : Level 2 optimizations (Level 1 + not debugger friendly)<br />
** '''-OoShortRefGlobals[-]''': Insert a JS local var for each module, type and static function. Default enabled in ''-O2''.<br />
===2.0.0 Incompatibilities===<br />
====Signature for event handlers TEventListenerEvent and TJSEvent====<br />
The signature for event handlers has been corrected. The class TEventListenerEvent is now an alias for TJSEvent<br />
: That means that the 2 event handler types<br />
TJSEventHandler = reference to function(Event: TEventListenerEvent): boolean;<br />
TJSRawEventHandler = reference to Procedure(Event: TJSEvent);<br />
: are now equivalent.<br />
====TJSEvent type definition====<br />
The TJSEvent type definition has been corrected<br />
: The currentTarget and Target properties of TJSEvent are now of type TJSEventTarget, as they are in the official specs:<br />
property currentTarget : TJSEventTarget Read FCurrentTarget;<br />
property target : TJSEventTarget Read FTarget;<br />
: For convenience, a targetElement and CurrentTargetElement property have been added which are of type TJSElement:<br />
property currentTargetElement : TJSElement;<br />
property targetElement : TJSElement;<br />
====modeswitch ignoreattributes was removed====<br />
The workaround ''{$modeswitch ignoreattributes}'' was removed. Attributes are now implemented.<br />
<br />
== Version 1.4.34 ==<br />
<br />
28th Oct 2020<br />
<br />
* fixed passing in mode delphi a proc address to a proc type argument.<br />
* fixed searching pju file, when uses-in-file missing<br />
* fixed ''a div b'' for negative results<br />
* fixed ''aCurrency/bCurrency'' for negative results<br />
<br />
== Version 1.4.32 ==<br />
<br />
15th Oct 2020<br />
<br />
* fixed crash on class function<br />
* fixed array shrink using ''SetLength''<br />
* fixed ''try except on ExternalClass do ; end;''<br />
* fixed dynamic array function '''a:=concat(b);''' // marking b as referenced<br />
* fixed dynamic array function '''c:=concat(a,b);'''<br />
* fixed ''$ancestor'' of all root classes is ''null'' instead of ''undefined''<br />
* fixed ''rtl.spaceLeft'' return value<br />
<br />
== Version 1.4.30 ==<br />
<br />
8th July 2020<br />
<br />
* fixed assign record with field of dynamic array<br />
* fixed '''SysUtils.AnsiSameText''' comparing strings with umlauts.<br />
<br />
== Version 1.4.28 ==<br />
<br />
3rd Jul 2020<br />
<br />
* fixed '''system.inc()'''<br />
* fixed namespace search order<br />
** Reason: Delphi/FPC compatibility. <br />
** Old behaviour: search default namespace (aka prepend program namespace), prepend command line namespaces, no namespace (i.e. as written in uses section)<br />
** New behaviour: search no namespace (i.e. as written in uses section), prepend command line namespaces, prepend default namespace (aka program namespace)<br />
** For example program that uses "classes" and units classes.pas and system.classes.pas are in unit search path.<br />
* fixed ''try exit(value) finally read Result end''<br />
<br />
== Version 1.4.26 ==<br />
<br />
6th Jun 2020<br />
<br />
* fixed RTTI of record/class field with shared anonymous array, e.g. ''type t = record a,b:array of byte; end;''<br />
<br />
== Version 1.4.24 ==<br />
<br />
11th May 2020<br />
<br />
* fixed assign array<br />
<br />
== Version 1.4.22 ==<br />
<br />
10th May 2020<br />
<br />
* fixed allowing member with same name as an ancestor member in $mode delphi<br />
* fixed allow '''static''' directive repetition in method implementation<br />
* fixed type helper for '''NativeInt''' and '''NativeUInt'''<br />
* fixed type helper '''Self''' in nested procedure<br />
* fixed '''(i*i).helperfunc'''<br />
* fixed '''SetLength(array,..)''' using resize instead of clone, when not shared. Assign marks an array with a hidden property ''$pas2jsrefcnt''.<br />
<br />
== Version 1.4.20 ==<br />
<br />
11th April 2020<br />
* fixed stack overflow on long procedures<br />
* fixed class helper in with-do<br />
<br />
== Version 1.4.18 ==<br />
<br />
15th Dec 2019<br />
<br />
* access modifier '''constref''': works as ''const'', gives a warning for non records, arrays<br />
* omit not used resourcestrings<br />
* fixed sourcemap for Firefox<br />
<br />
== Version 1.4.16 ==<br />
<br />
15th Oct 2019<br />
<br />
* fixed helper for type alias type<br />
* fixed selecting last declared helper<br />
* replaced rtl.setArrayLength with faster non recursive version<br />
* fixed external static class method<br />
* fixed check for helper class method for external class must be static<br />
* fixed marking implicit call in property parameter<br />
<br />
== Version 1.4.14 ==<br />
<br />
30th Aug 2019<br />
<br />
* source map: when using -Jmabsolute -Jmsourceroot=file:// prepend the absolute source files with ''file://''. Needed by Firefox.<br />
* fixed longword bitwise operations ''not, and, or, xor, shl, shr'' for numbers ''> $7fffffff''<br />
* fixed creating relative paths without shared based directory, e.g. in source maps ''C:\foo\project1.js.map C:\bar\project1.pas''<br />
<br />
== Version 1.4.12 ==<br />
<br />
28th Aug 2019<br />
<br />
* fixed get method reference of Self inside anonymous method without self<br />
* fixed typecast nil to class, interface, dynamic array<br />
* fixed endless loop on ''type TArr = array of TArr''<br />
* no warning "function result not set" for fieldless record<br />
* fixed check for duplicate unit, when names differ<br />
* fixed ''ComInterfaceInstance is/as InterfaceType'' to use ''QueryInterface''<br />
* fixed passing dynamic array to open array var parameter<br />
<br />
== Version 1.4.10 ==<br />
<br />
10th Jul 2019<br />
<br />
* added separate error message duplicate published method<br />
* fixed allowing reintroduce published method<br />
* fixed ''high(dynarrayvar with expr)''<br />
* fixed ''class var a:t; b:t;''<br />
* fixed type helper in other unit<br />
<br />
== Version 1.4.8 ==<br />
<br />
24th June 2019<br />
* fixed var a: somearray = nil<br />
* fixed fixed assignment inside anonymous proc inside for-loop<br />
* fixed ArcTan definition (bug ID 35655)<br />
* setlength(arr) now always clone for FPC/Delphi compatibility. Formerly it merely resized the array.<br />
<br />
== Version 1.4.6 ==<br />
<br />
20th Apr 2019<br />
<br />
* fixed advanced records<br />
* fixed linux rtl.js<br />
<br />
== Version 1.4.4 ==<br />
<br />
19th Apr 2019<br />
<br />
* fixed duplicate identifier when redefining a procedure.<br />
* fixed escaping string literals in asm blocks<br />
<br />
== Version 1.4.2 ==<br />
<br />
11th Apr 2019<br />
<br />
* fixed optimization of NewInstance function<br />
* fixed filer class helper<br />
* fixed passing TExt.new as parameter<br />
* fixed writing workingdirectory<br />
* fixed advanced record constructor<br />
* handling environment options '''PAS2JS_OPTS'''<br />
* fixed nodejs ''GetEnvironmentVariable'' returning empty string for non existing variables<br />
<br />
== Version 1.4.0 ==<br />
<br />
24th Mar 2019<br />
* fixed supporting older node.js (<7.0.0) using ''Math.pow'' instead of newer exponential operator '''**'''.<br />
<br />
== Version 1.4.0RC7 ==<br />
<br />
16th Mar 2019<br />
* fixed accessing Self in anonymous function<br />
* fixed ''UntypedArg:=recordvar'' and ''RecordType(UntypedArg)''<br />
* an external method of a helper is treated like an external method of the helped type<br />
* updated examples<br />
* fixed hint method hides identifier with same signature<br />
* fixed hint argument not used, with array argument and only writing an element<br />
* fixed hint argument not used, with array argument passed as argument<br />
<br />
== Version 1.4.0RC6 ==<br />
<br />
8th Mar 2019<br />
<br />
* fixed passing ''class var'' to ''var'' argument<br />
* fixed reading precompiled units by default<br />
<br />
== Version 1.4.0RC5 ==<br />
<br />
6th Mar 2019<br />
<br />
* fixed overload var arg and type alias<br />
* added overload TryStrToFloat with type extended<br />
* nativeint '''shr''' int<br />
* nativeint '''shl''' int<br />
* no hint when hiding private method<br />
* fixed passing multiple -vm parameters<br />
* fixed include file search in module directoy<br />
* allow typecast external class to unrelated external class in ''$mode delphi'', e.g. TJSEventTarget(aJSWindow). Normally you need ''TJSEventTarget(TJSObject(aJSWindow))''.<br />
<br />
== Version 1.4.0RC4 ==<br />
<br />
3rd Mar 2019<br />
* fixed ''{$warn identifier error}''<br />
* fixed '''and/or/xor''' with ''nativeint''<br />
* warn on ''nativeint shl/shr int'' using only 32bit<br />
* fixed type helper call as arg<br />
* fixed ''(f*f).helpercall''<br />
* fixed info message ''macro name set to "value"''<br />
* ''make all'' now creates a default bin/targetcpu-targetos/pas2js.cfg, so that pas2js.exe works out-of-the box.<br />
<br />
== Version 1.4.0RC3 ==<br />
<br />
27th Feb 2019<br />
<br />
* renamed '''$modeswitch multiplescopehelpers''' to '''multihelpers''', same as FPC<br />
* fixed ''TAliasOfEnumType.EnumValue''<br />
* fixed emitting hints for not used units<br />
* fixed SetBufListSize<br />
<br />
== Version 1.4.0RC2 ==<br />
<br />
18th Feb 2019<br />
* fixed typecast jsvalue(anobject/interface), not doing getObject,<br />
* fixed ''obj.Free'' set to ''nil'' if already ''nil''<br />
* added '''unit websvg.pas''' providing API to SVG elements<br />
* fixed ''getdelimitedtext'', quoting was wrong<br />
* fixed array-of-const references in precompiled units<br />
* Added some missing routines in strutils (containstext, containsstr)<br />
<br />
== Version 1.4.0RC1 ==<br />
<br />
16th Feb 2019<br />
* Highlights:<br />
** class helpers<br />
** record helpers<br />
** type helpers<br />
** advanced records<br />
** array of const<br />
** added locate to JSONdataset, as well as lookup and support for lookup fields.<br />
** Added Indexes (sorting) to JSONDataset.<br />
<br />
* Incompatibilities:<br />
** pas2js now searches units first in the folder of the current module as Delphi does.<br />
** JSArguments declaration was changed from an array of jsvalue to TJSFunctionArguments.<br />
<br />
<br />
== All changes of version 1.4.0 ==<br />
<br />
*Pas2js supports class helpers, record helpers and type helpers since 1.3. The extend is only virtual, the helped type is kept untouched.<br />
**A '''class helper''' can "extend" Pascal classes and external JS classes.<br />
**A '''record helper''' can "extend" a record type. In $mode delphi a record helper can extend other types as well, see ''type helper''<br />
**A '''type helper''' can extend all base types like integer, string, char, boolean, double, currency, and some user types like enumeration, set, range and array types. It cannot extend interfaces or helpers.<br />
** Type helpers are available by default in ''$mode delphi'' and disabled in ''$mode objfpc''. You can enable them with '''{$modeswitch typehelpers}'''.<br />
** By default only one helper is active per type, same as in FPC/Delphi. If there are multiple helpers for the same type, the last helper in scope wins. A class with ancestors can have one active helper per ancestor type, so multiple helpers can be active, same as FPC/Delphi. Using '''{$modeswitch multihelpers}''' you can activate all helpers within scope.<br />
** Nested helpers (e.g. ''TDemo.TSub.THelper'') are elevated. Visibility is ignored. Same as FPC/Delphi.<br />
** Helpers cannot be forward defined (e.g. no ''THelper = helper;'').<br />
** Helpers must not have fields.<br />
** '''Class Var, Const, Type'''<br />
** '''Visibility''' : ''strict private .. published''<br />
** '''Function, procedure''': In class and record helpers ''Self'' is the class/record instance. For other types Self is a reference to the passed value.<br />
** '''Class function, class procedure''': Helpers for Pascal classes/records can add ''static'' and non static class functions. Helpers for external classes and other types can only add static class functions.<br />
** '''Constructor'''. Not for external classes. Works similar to construcors, i.e. ''THelpedClass.Create'' creates a new instance, while ''AnObj.Create'' calls the constructor function as normal method. Note that Delphi does not allow calling helper construcors as normal method.<br />
** no destructor<br />
** '''Property''' : getters/setters can refer to members of the helper, its ancestors and the helped class/record.<br />
** '''Class property''' : getter can be static or non static. Delphi/FPC only allows static.<br />
** '''Ancestors''' : Helpers can have an ancestor helper, but they do not have a shared root class, especially not ''TObject''.<br />
** '''no virtual, abstract, override'''. Delphi allows them, but 10.3 crashes when calling.<br />
** ''inherited'' inside a method of a class/record calls helper of ancestor. <br />
** ''inherited'' inside a helper depends on the $mode:<br />
*** ''$mode objfpc'' : ''inherited;'' and ''inherited Name(args);'' work the same and searches first in HelperForType, then in ancestor(s).<br />
*** ''$mode delphi: inherited;'' : skip ancestors and HelperForType, searches first in helper(s) of ancestor of HelperForType.<br />
*** ''$mode delphi: inherited name(args);'' : same as $mode objfpc first searches in HelperForType, then Ancestor(s)<br />
*** In any case if ''inherited;'' has no ancestor to call, it is silently ignored, while ''inherited Name;'' gives an error.<br />
** '''RTTI''': ''typeinfo(somehelper)'' returns a pointer to ''TTypeInfoHelper'' with ''Kind tkHelper''.<br />
** There are some special cases when using a '''type helper''' function/procedure on a value:<br />
*** ''function result'' : using a temporary variable<br />
*** ''const, const argument'' : When helper function tries to assign a value, pas2js raises a EPropReadOnly exception. FPC/Delphi use a temporary variable allowing the write.<br />
*** ''property'' : uses only the getter, ignoring the setter. This breaks OOP, as it allows to change fields without calling the setter. This is FPC/Delphi compatible.<br />
*** ''with value do ;'' : uses a temporary variable. Delphi/FPC do not support it.<br />
* built-in function '''concat''' ''(string1,string2,...)''<br />
* local types (declared inside functions) are now created in the global scope<br />
* added locate to JSONdataset, as well as lookup and support for lookup fields.<br />
* Added Indexes (sorting) to JSONDataset.<br />
* Added unit fpexprpars.pas, an expression parser unit (needed for dataset filtering...)<br />
* omit unnecessary brackets on associative operations (a||b)||(c||d), (a&&b)&&(c&&d), (a|b)|c, (a&b)&c, (a^b)^c, (a+b)+c, (a-b)-c, (a*b)*c<br />
* '''records are now created as ''Object'', instead of JS ''function'' '''<br />
** records now have hidden (not enumerable) functions ''$new, $assign, $clone, $eq''<br />
** passing records to ''var argument'' now passes the record directly instead of creating a temporary setter<br />
** '''Assigning a record''', e.g. ''aRecord:=value'', now copies the values, while keeping the JS object. This makes ''pointer of record'' Delphi/FPC compatible.<br />
* '''Advanced records''': enabled in $mode delphi, disabled im $mode objfpc, enable with '''{$modeswitch AdvancedRecords}'''<br />
** visibility private, strict private, public, default is public<br />
** methods, class methods (must be static like in FPC/Delphi), constructors<br />
** class vars<br />
** const<br />
** property, class property, array property, default array property<br />
** nested types<br />
** RTTI<br />
* Records can now have external fields with '[2]', '["a b"]'<br />
* In $mode objfpc forward class-of and pointer declarations can now refer to types even if there are other const/var/resourcestring sections in between. Same a FPC. For example:<br />
<syntaxhighlight lang="pascal"><br />
type <br />
TClassOfBird = class of TBird;<br />
const k = 1;<br />
type <br />
TBird = class end;<br />
</syntaxhighlight><br />
* '''lo(), hi()''' in $mode delphi returning the lo/hi byte, in $mode objfpc returning the lo/hi byte|word|longword.<br />
* char range with non ascii literals: 'Б'..'Я'<br />
* typecast char to word and other integers<br />
* added option -Jmabsolute to store absolute filenames in sourcemaps<br />
* '''JSArguments declaration was changed''' from an array of jsvalue to TJSFunctionArguments.<br />
* fixed expr[][] with default properties<br />
* fixed assigning class vars<br />
* pas2js now searches units first in the folder of the current module as Delphi does.<br />
* fixed case-of with non ascii literals<br />
* implemented '''ProcVar:=StaticClassMethod'''<br />
* implemented '''ProcVar:=ClassMethod''' inside static class method<br />
* class property getter/setter can now be static or non static.<br />
* '''array of const''':<br />
** Works the same: vtInteger, vtBoolean, vtPointer, vtObject, vtClass, vtWideChar, vtInterface, vtUnicodeString<br />
** longword is converted to vtNativeInt instead of mangling to vtInteger<br />
** vtExtended is double, Delphi/FPC: PExtended<br />
** vtCurrency is currency, Delphi/FPC: PCurrency<br />
** Not supported: vtChar, vtString, vtPChar, vtPWideChar, vtAnsiString, vtVariant, vtWideString, vtInt64, vtQWord<br />
** only in pas2js: vtNativeInt, vtJSValue<br />
* fixed ''o.ProcVar()'' when ProcVar is typeless property<br />
* fixed const evaluation float - currency<br />
* fixed reading #$00xx as widechar, bug 34923<br />
* fixed relative paths in srcmap in Windows<br />
* nicer error message on invalid set element type<br />
<br />
== Version 1.2.0 ==<br />
<br />
* 23th Dec 2018<br />
* SVN release tag is https://svn.freepascal.org/svn/projects/pas2js/tags/release_1_2_0<br />
* added '''dataabstract''': support for Remobjects Data Abstract: The TDAConnection and TDADataset classes<br />
* set rtl.js version to 10200<br />
* fixed parsing comment in $IFDEF, $IFNDEF, issue 34711<br />
* fixed searching unit<br />
<br />
== Version 1.2.0RC1 ==<br />
<br />
* 16th Dec 2018<br />
* SVN release tag is https://svn.freepascal.org/svn/projects/pas2js/tags/release_1_2_0RC1<br />
* '''Anonymous Functions''':<br />
<syntaxhighlight lang="pascal"><br />
type<br />
TRefProc = reference to procedure;<br />
TProc = procedure;<br />
procedure DoIt(arg: TRefProc);<br />
var <br />
ref: TRefProc;<br />
proc: TProc;<br />
begin<br />
ref:=procedure begin end; // assign to "reference of procedure" type<br />
ref:=procedure // note the omitted semicolon<br />
var i: integer; // var, types, const, local procedures<br />
begin<br />
end; <br />
DoIt(procedure begin end); // pass as argument<br />
refproc:=procedure assembler asm // embed JavaScript<br />
console.log("foo");<br />
end; <br />
// Note that typecasting to non "reference to" does not make a difference <br />
// because in JS all functions are closures:<br />
proc:=TProc(procedure begin end); <br />
end;<br />
</syntaxhighlight><br />
* added variable <i>rtl.version</i>, which corresponds to the compiler version Major*10000+Minor*100+Release<br />
* added option '''-JoCheckVersion''':<br />
** -JoCheckVersion- : do not add rtl version check, default.<br />
** -JoCheckVersion=main : insert rtl.checkVersion() into main.<br />
** -JoCheckVersion=system : insert rtl.checkVersion() into system unit.<br />
** -JoCheckVersion=unit : insert rtl.checkVersion() into every unit.<br />
* moved classtopas function to a class2pas unit, improved the interface so it uses a stringlist. Adapted the demo.<br />
* Fix System.Int() so it also works on IE (where Math.trunc is missing).<br />
* allow typecasting ''string(apointer)'' and ''pointer(astring)''<br />
* asm-block now skips Pascal comments //... and Pascal string literals with single quotes. It no longer stops at ''end'' in such comments and string literals.<br />
* Fix FormatFloat() rounding logic (actually FloatToDecimal)<br />
* Fix stringofchar for count<=0<br />
* Fix quotestring and add quotedstr<br />
* implemented special includes like '''{$i %date%}:'''<br />
** %date%: current date as string literal, '[yyyy/mm/dd]'<br />
** %time%: current time as string literal, 'hh:mm:ss' Note that the inclusion of %date% and %time% will not cause the compiler to recompile the unit every time it is used: the date and time will be the date and time when the unit was last compiled.<br />
** %line%: current source line number as string literal, e.g. '123'<br />
** %linenum%: current source line number as integer, e.g. ''123''<br />
** %currentroutine%: name of current routine as string literal<br />
** %pas2jstarget%, %pas2jstargetos%, %fpctarget%, %fpctargetos%: target os as string literal, e.g. 'Browser'<br />
** %pas2jstargetcpu%, %fpctargetcpu%: target cpu as string literal, e.g. 'ECMAScript5'<br />
** %pas2jsversion%, %fpcversion%: compiler version as string literal, e.g. '1.0.2'<br />
** If param is none of the above it will use the environment variable. Keep in mind that depending on the platform the name may be case sensitive. If there is no such variable an empty string is inserted.<br />
* implemented ''pred(char)'', ''succ(char)''<br />
* allow typecasting ''TypedPointer(UntypedPointer)''<br />
* allow assign ''UntypedPointer:=TypedPointer''<br />
* skip double quotes in asm-blocks, e.g. ''s = "end"+"'";''<br />
* added '''{$modeswitch OmitRTTI}''': treat class section 'published' as 'public' and ''typeinfo()'' does not work on symbols declared with this switch. This allows to easily disable generating RTTI and allows the optimizer to omit unused published properties.<br />
* added option '''-Jpcmd<command>''': Run postprocessor. For each generated js execute command passing the js as stdin and read the new js from stdout. This option can be added multiple times to call several postprocessors in succession. Quote the <command> to add options for the postprocessor. For an example see [[pas2js minifier|minifier]].<br />
* Added built-in procedure '''Debugger;''', which is converted to the JavaScript statement <i>debugger;</i>. If a debugger is running it will break on this line just like a break point.<br />
* Changed operator precedence level of '''is''' to same as '''and''', '''or''', '''xor'''. Same as fpc/delphi.<br />
* fixed assert to raise on false, bug 34643<br />
* built-in ''procedure '''val'''(const string; out enum; out int)''<br />
* added option ''-JoRTL-<x>=<y>'' to change the name of a autogenerated identifier. See the list of available identifiers with ''-iJ''.<br />
<br />
== Version 1.0.4 ==<br />
<br />
* 14th Nov 2018<br />
* SVN release tag is https://svn.freepascal.org/svn/projects/pas2js/tags/release_1_0_4<br />
* fixed calling ''destructor'' after exception in ''constructor''<br />
* fixed initializing static array of record<br />
* fixed parsing ''if expr then raise else''<br />
* fixed local record and enum types<br />
* fixed ''for e in set do''<br />
* fixed for-in of shared sets<br />
* fixed ''inc(classvar)''<br />
* fixed assigning ''class var'' of descendant classes<br />
* fixed error position on include file not found<br />
* fixed loading include file from cache<br />
* fixed range check of ''o.aString[index]'' and ''o.aArray[index]''<br />
* fixed Result:=inherited;<br />
* fixed escaping invalid UTF-16 in string literals<br />
* fixed not generating octal literals in ECMAScript5, it bites strict mode<br />
* fixed IsNaN on ECMAScript6<br />
* fixed error on method in record<br />
* fixed name clash published property and external<br />
* fixed ''str(aCurrency)''<br />
* catch ''ECompilerTerminate'' while parsing params<br />
* ''sLineBreak'' and ''LineEnding'' are now '''var''' under platform NodeJS<br />
<br />
== Version 1.0.3 ==<br />
<br />
* 28th Oct 2018<br />
* SVN release tag is https://svn.freepascal.org/svn/projects/pas2js/tags/release_1_0_3<br />
* fixed ''char(#10)''<br />
* fixed: allow array property accessor argument mismatch const/default for simple types, e.g.:<br />
function GetItems(const i: integer): byte;<br />
property Items[i: integer]: byte read GetItems;<br />
* fixed ''high(intvar)''<br />
* fixed WPO when using record constants<br />
* fixed ''include(FuncResultSet,enum)''<br />
* fixed ''if then <empty> else <something>;''<br />
* fixed ''p^.x:=''<br />
* fixed ''acurrency:=aninteger'' to become ''acurrency:=aninteger*10000''<br />
* fixed ''integer(acurrency)'' to become ''Math.floor(acurrency/10000)''<br />
* fixed calling ''$final'', clearing references on destroy<br />
* fixed not calling ''BeforeDestruction'' on exception in constructor<br />
* fixed ''$class'' be a property of the class, not the object<br />
* fixed local var modifier ''absolute'' in method<br />
* fixed using external const in const expression, e.g. ''const tau = 2*pi;''<br />
* fixed selecting procedure overload, preferring lossy int over int to float<br />
* fixed calling Free inside method<br />
* fixed System.Int() so it also works on IE (where Math.trunc is missing).<br />
* fixed FormatFloat() rounding logic (actually FloatToDecimal)<br />
* fixed stringofchar for count<=0<br />
* fixed quotestring and add quotedstr<br />
<br />
== Version 1.0.2 ==<br />
<br />
* 26 Sep 2018<br />
* SVN release tag is https://svn.freepascal.org/svn/projects/pas2js/tags/release_1_0_2<br />
* fixed multiple class interface maps<br />
<br />
== Version 1.0.1 ==<br />
<br />
* 19 Sep 2018<br />
* SVN release tag is https://svn.freepascal.org/svn/projects/pas2js/tags/release_1_0_1<br />
* fixed generating srcmap for precompiled javascript<br />
<br />
== Version 1.0.0 ==<br />
<br />
* 9 Aug 2018<br />
* SVN release tag is https://svn.freepascal.org/svn/projects/pas2js/tags/release_1_0_0<br />
* SVN fixes branch is https://svn.freepascal.org/svn/projects/pas2js/branches/fixes_1_0<br />
* fixed override method of class interface<br />
* fixed crash on checking body element of empty proc<br />
* use default source filename in pcu/pju files<br />
<br />
== Version 1.0.0rc1 ==<br />
<br />
* 24 Jul 2018<br />
* fixed ''TObject.Create()''<br />
* -vd shows stacktraces<br />
<br />
== Version 0.9.32 ==<br />
<br />
* 17 Jul 2018<br />
* fixed memory leaks and double frees<br />
<br />
== Version 0.9.31 ==<br />
<br />
* 10 Jul 2018<br />
* fixed aIntSet:=[0]<br />
* fixed crash on '''List.Items.Dummy'''<br />
* fixed some mem leaks<br />
* fixed -MDelphi + $mode objfpc + overloads withouts overload keyword<br />
* '''TGUIDString''' is now '''type string'''<br />
* RTL: added websockets<br />
<br />
== Version 0.9.30 ==<br />
<br />
* 4 Jul 2018<br />
* fixed calling COM interface _Release function for expressions.<br />
* fixed catching exception in pju variant of pas2js<br />
* split reserved words into two categories: the compiler now checks global JS identifiers like "Date" only for identifiers without path. That means a local variable ''Date'' will be renamed, a ''property Date'' will not, keeping the RTTI name of properties. Identifiers like ''apply'' are still renamed.<br />
* fixed property RTTI for alias type in other unit<br />
* fixed default value of integer variables, using 0 even if it is outside range. Reason: Delphi/FPC compatibility.<br />
<br />
== Version 0.9.29 ==<br />
<br />
* 29 Jun 2018<br />
* fixed pcu reading alias type<br />
* fixed analyzer: element needing typeinfo marks indirect elements as used normally<br />
* hint for text after final "end.", disable with $warn GARBAGE off<br />
* $warn BOUNDS_ERROR off: disable range check warnings at compile time<br />
* $warn MESSAGE_DIRECTIVE off: disable $message notes<br />
<br />
== Version 0.9.28 ==<br />
<br />
* 27 Jun 2018<br />
* fixed static array of char = stringlit+stringlit<br />
* fixed libpas2js disk full error<br />
* $warn directive: '''{$warn identifier on|off|default|error}''', identifier can be a message number as shown with -vq or one of the following. Note, that some hints like "Parameter %s not used" are currently using the enable state at the end of the module, not the state at the hint source position.<br />
** CONSTRUCTING_ABSTRACT: Constructing an instance of a class with abstract methods.<br />
** IMPLICIT_VARIANTS: Implicit use of the variants unit.<br />
** NO_RETVAL: Function result is not set<br />
** SYMBOL_DEPRECATED: Deprecated symbol<br />
** SYMBOL_EXPERIMENTAL: Experimental symbol<br />
** SYMBOL_LIBRARY<br />
** SYMBOL_PLATFORM: Platform-dependent symbol<br />
** SYMBOL_UNIMPLEMENTED: Unimplemented symbol<br />
** HIDDEN_VIRTUAL: method hides virtual method of ancestor<br />
<br />
== Version 0.9.27 ==<br />
<br />
* 26 Jun 2018<br />
* mode delphi: fixed passing static array to open array<br />
* allow assigning aTypeInfo:=pointer, needed by units with and without using unit typinfo<br />
<br />
== Version 0.9.26 ==<br />
<br />
* 25 Jun 2018<br />
* '''typecast function address to JS function''', e.g. TJSFunction(@IntToStr)<br />
* '''typecast function reference to JS function''', e.g. TJSFunction(OnClick)<br />
* '''typecast method address to JS function''', e.g. TJSFunction(@List.Sort). Note that a method address creates a function wrapper to bind the Self argument.<br />
* changed some types to type alias: TDateTime, TDate, TTime, Single, Real, Comp, UnicodeString, WideString. This only effects typinfo and some compiler error messages. Reason: Delphi/FPC compatibility.<br />
* In mode delphi dynamic array initializations must now use square brackets instead of round brackets. For example ''var a: array of integer = [1,2];''. Reason: Delphi compatibility.<br />
* Assignation using constant array. For instance '''Arr:=[1,2,3]''', where Arr is a dynamic array.<br />
* '''+ operator for arrays''': This concatenation operator is available using the new '''modeswitch arrayoperators''', which is enabled by default in mode delphi.<br />
* unit webgl updated<br />
* unit webaudio added<br />
* unit webbluetooth added<br />
* db unit: ftDataset field type added (not supported)<br />
* JSONDataset unit: TField.OldValue now works for TJSONDataset<br />
* '''webidl2pas''' tool added. A command line tool to create Pascal units from idl specs.<br />
* allow '''external record fields'''.<br />
* hint 5024 'Parameter "%s" not used' was split into two:<br />
** 4501 for virtual/override methods<br />
** 5024 for others<br />
<br />
== Version 0.9.25 ==<br />
<br />
* 7 Jun 2018<br />
* '''TComponent now supports IInterface'''<br />
* '''-o''' is now always '''relative to working directory''', even if -FU or -FE is given. Reason: FPC compatibility<br />
* fixed typeinfo(typeintegerrange)<br />
* fixed using interface ancestor methods<br />
* fixed 'make' building with fpc 3.0.4<br />
<br />
== Version 0.9.24 ==<br />
<br />
* 2 Jun 2018<br />
* fixed precompiled js formatting to same options as compiled js<br />
* fixed unit analyzer private method used by protected property<br />
* fixed class-of RTTI<br />
* fixed precompiled resolve pending scopes before pending units<br />
<br />
== Version 0.9.23 ==<br />
<br />
* 28 May 2018<br />
* added webgl demos from Ryan Joseph<br />
* '''for value in jsarray do''' - where jsarray is any external class with a matching ''length'' and default property. This enumerates similar to other arrays the values, not the index.<br />
* allow '''typecast array to TJSObject'''<br />
* allow '''typecast TJSObject to array'''<br />
* Unicode '''character constants outside of BMP''', e.g. #$10437<br />
* allow '''{$H+}''', error on {$H-}<br />
* added intrinsic procedure '''WriteStr(out s: string; params...)''', which works similar to ''str(param,s)'', except it can take any amount of parameters, which are concatenated.<br />
* added option '''-Sm''' to enable macro replacements<br />
<br />
== Version 0.9.22 ==<br />
<br />
* 17 May 2018<br />
* Fixed ''$00ff00''<br />
<br />
== Version 0.9.21 ==<br />
<br />
* 16 May 2018<br />
* added option '''-FE''': set the main output path, used for the main .js file, if there is no -o option or the -o option has no folder.<br />
* fixed WPO typeinfo of inherited property<br />
* for easier FPC integration the following message IDs were changed:<br />
** nVirtualMethodXHasLowerVisibility = 3250; // was 3050<br />
** nConstructingClassXWithAbstractMethodY = 4046; // was 3080<br />
** nNoMatchingImplForIntfMethodXFound = 5042; // was 3088<br />
** nSymbolXIsDeprecated = 5043; // was 3062<br />
** nSymbolXBelongsToALibrary = 5065; // was 3061<br />
** nSymbolXIsDeprecatedY = 5066; // 3063<br />
** nSymbolXIsNotPortable = 5076; // was 3058<br />
** nSymbolXIsNotImplemented = 5078; // was 3060<br />
** nSymbolXIsExperimental = 5079; // was 3059<br />
<br />
== Version 0.9.20 ==<br />
<br />
* 11 May 2018<br />
* fixed passing typecasted alias type to var parameter<br />
* forbid typecast rectordtype to other recordtype<br />
* remove leading zeroes in number literals<br />
* added '''namespace option -FN<x>''', '''marked -NS as obsolete'''. Reason: fpc compatibility.<br />
* added option '''-vz''' : write messages to stderr, -o. still uses stdout.<br />
* added option '''-ic''' : Write list of supported JS processors usable by -P<x><br />
* added option '''-io''' : Write list of supported optimizations usable by -Oo<x><br />
* added option '''-it''' : Write list of supported targets usable by -T<x><br />
* added option '''-SIcom''', '''-SIcorba''' interface style<br />
* added option '''-vv''' : Write pas2jsdebug.log with lots of debugging info<br />
* fixed option -va including option -vt<br />
* fixed combination of -Jc -o.<br />
* option -vt now writes used unit scopes<br />
* '''external class fields with brackets'''. e.g. ''X: nativeint external name '[0]' ''<br />
* autogenerated interface GUIDs now consider the unitname<br />
<br />
== Version 0.9.19 ==<br />
<br />
* 2 May 2018<br />
* '''type alias type''', e.g. ''type TCaption = type string;''<br />
* '''record const''', e.g. ''const p: TPoint = (x:1; y:2);''<br />
* '''{$WriteableConst on|off}''': treat typed constants as readonly, e.g. ''const i:byte=3;... i:=4;'' creates a compile time error.<br />
* forbid assignment of for-loop variable<br />
* '''nested classes'''<br />
* '''property specifier nodefault'''<br />
* '''default(type)''' returning the initial value of the type, e.g. default(recordtype).<br />
* '''external typed const''': e.g. ''const NaN: Double; external name 'NaN';''<br />
* '''case string of''' support for ranges<br />
* fixed typecast shortint(integer)<br />
<br />
== Version 0.9.18 ==<br />
<br />
* 26 Apr 2018<br />
* Fixed rcArrR in rtl.js<br />
<br />
== Version 0.9.17 ==<br />
<br />
* 25 Apr 2018<br />
* Fix recno calculation for TJSONDataset<br />
* Fix initializing next buffers in TDataset.<br />
* Implemented '''Currency''' as double, values are multiplied by 10000 and truncated, so a 2.7 is stored as 27000.<br />
* Implemented '''pointer of record'''. It's simply a reference.<br />
** ''p:=@r'' translates to ''p=r''<br />
** ''p^.x'' becomes ''p.x''<br />
** intrinsics new(PointerOfRecord), dispose(PointerOfRecord). dispose(p) sets p to null if possible.<br />
* '''enumerator for jsvalue''': e.g. ''var v: jsvalue; key: string; '''for key in jsvalue do''' '' translates to ''for (key in jsvalue){}''<br />
* '''enumerator for external class''': e.g. ''var o: TJSObject; key: string; for key in o do'' translates to ''for (key in o){}''<br />
* '''range checking $R+'''<br />
** compile time: warnings become errors<br />
** run time: int:=, int+=, enum:=, enum+=, intrange:=, intrange+=, enumrange:=, enumrange+=, char:=, charrange:=<br />
** run time: parameters: int, enum, intrange, enumrange, char, charrange<br />
** run time: array[index], string[index]<br />
* '''type cast integer to integer''', e.g. ''byte(aLongInt)''<br />
** with range checking enabled: error if outside range<br />
** without range checking: emulates the FPC/Delphi behaviour: e.g. ''byte(value)'' translates to ''value & 0xff'', ''shortint(value)'' translates to ''value & 0xff <<24 >>24''.<br />
* case-of statement: error on duplicate values<br />
* fixed error on int:=double<br />
<br />
== Version 0.9.16 ==<br />
<br />
* 21 Apr 2018<br />
* mode delphi: allow "ObjVar is IntfType" and "ObjVar as IntfType" with unrelated types.<br />
* TVirtualInterface - create an implementation at runtime. rtl unit rtti.pas<br />
* typecast a class type to JS Object, e.g. TJSObject(TObject)<br />
* typecast an interface type to JS Object, e.g. TJSObject(IUnknown)<br />
* typecast a record type to JS Object, e.g. TJSObject(TPoint)<br />
* <i>not jsvalue</i> is converted to <i>!jsvalue</i><br />
* "=" operator for records with static array fields<br />
* changed TGuid to record<br />
* TGUID record<br />
** GuidVar:='{guid}', StringVar:=GuidVar, GuidVar:=IntfTypeOrVar, GuidVar=IntfTypeOrVar, GuidVar=string<br />
** pass IntfTypeOrVar to GuidVar parameter<br />
* added new type TGuidString to system unit<br />
** GuidString:=IntfTypeOrVar, GuidString=IntfTypeOrVar<br />
** pass IntfTypeOrVar to GuidString parameter<br />
* added option -JoUseStrict, to enable or disable adding "use strict"<br />
<br />
== Version 0.9.15 ==<br />
<br />
* 8 Apr 2018<br />
* fixed crash when ancestor implements more interfaces than current class.<br />
<br />
== Version 0.9.14 ==<br />
<br />
* 8 Apr 2018<br />
* fixed duplicates in rtl/strutils.pas<br />
* fixed reference counts on reading element lists<br />
* implemented using function result variable in for-loop. e.g. <i>for Result:=...</i>, <i>for Result in ...</i><br />
* fixed <i>for string in arrayofstring do</i><br />
* fixed $scopedenums with anonymous enumtype. e.g. <i>type TSet = set of (A,B);</i><br />
* implemented class interfaces:<br />
** methods, properties, default property<br />
** {$interfaces com|corba|default}<br />
*** COM is default, default ancestor is IUnknown (mode delphi: IInterface), managed type, i.e. automatically reference counted via _AddRef, _Release, the checks for support call QueryInterface<br />
*** CORBA: lightweight, no automatic reference counting, no default ancestor, fast support checks.<br />
** inheriting<br />
** GUIDs are simple string literals, TGUID = string.<br />
** An interface without a GUID gets one autogenerated from its name and method names.<br />
** a class implementing an interface must not be external<br />
** a ClassType "supports" an interface, if it itself or one of its ancestors implements the interface. It does not automatically support an ancestor of the interface.<br />
** method resolution, <i>procedure IUnknown._AddRef = IncRef;</i><br />
** delegation: <i>property Name: interface|class read Field|Getter implements AnInterface;</i><br />
** is-operator: <br />
*** IntfVar is IntfType - types must be releated<br />
*** IntfVar is ClassType - types can be unrelated, class must not be external<br />
*** ObjVar is IntfType - can be unrelated<br />
** as-operator<br />
*** IntfVar as IntfType - types must be releated<br />
*** IntfVar as ClassType - types can be unrelated, nil returns nil, invalid raises EInvalidCast<br />
*** ObjVar as IntfType - mode delphi: types must be related, objfpc: can be unrelated, nil if not found, COM: uses _AddRef<br />
** typecast:<br />
*** IntfType(IntfVar) - must be related<br />
*** ClassType(IntfVar) - can be unrelated, nil if invalid<br />
*** IntfType(ObjVar) - mode delphi: must be related, objfpc: can be unrelated, nil if not found, COM: if ObjVar has delegate uses _AddRef<br />
*** TJSObject(intfvar)<br />
** Assign operator:<br />
*** IntfVar:=nil<br />
*** IntfVar:=IntfVar2 - IntfVar2 must be same type or a descendant<br />
*** IntfVar:=ObjVar - nil if unsupported<br />
*** jsvalue:=IntfVar<br />
** Assigned(IntfVar)<br />
** RTTI<br />
** $modeswitch ignoreinterfaces was removed<br />
** Not supported: array of interface, interface as record member<br />
<br />
== Version 0.9.13 ==<br />
<br />
* 21 Mar 2018<br />
* fixed keeping methods AfterConstruction, BeforeDestruction<br />
* fixed modeswitch ignoreinterfaces<br />
<br />
== Version 0.9.12 ==<br />
<br />
* 19 Mar 2018<br />
* fixed parsing procedure p(var a; b: t)<br />
* fixed checking duplicate implementation of unit interface procedure<br />
<br />
== Version 0.9.11 ==<br />
<br />
* 16 Mar 2018<br />
* fixed loading files encoded in non UTF-8, e.g. UTF-8 with BOM. This was a regression.<br />
<br />
== Version 0.9.10 ==<br />
<br />
* 13 Mar 2018<br />
* fixed renaming overloads of unit interface at end of interface, not at end of module. Needed for unit cycles.<br />
<br />
== Version 0.9.9 ==<br />
<br />
* 13 Mar 2018<br />
* Fixed libpas2js to use WorkingDir parameter instead of GetCurrentDir<br />
* Fixed static array clone function.<br />
<br />
== Version 0.9.8 ==<br />
<br />
* 9 Mar 2018<br />
* fixed optimizer keep overrides<br />
<br />
== Version 0.9.7 ==<br />
<br />
* 7 Mar 2018<br />
* fixed pass local variable ''v'' as argument to a var parameter.<br />
<br />
== Version 0.9.6 ==<br />
<br />
* 6 Mar 2018<br />
* static arrays are now cloned on assignment or when passed as argument to a function (no const, var, out)<br />
* Fixed array[enum..enum] of<br />
* pas2jslib: fixed checks of directoryexists to use cache<br />
* uses with <i>in</i>-filename: In <i>$mode delphi</i> the in-filenames are only allowed in the program and the unitname must fit the filename, e.g. <i>uses unit1 in 'sub/Unit1.pas'</i>. In <i>$mode objfpc</i> units can use in-filenames too and alias are allowed, e.g. <i>uses foo in 'bar.pas'</i>.<br />
<br />
== Version 0.9.5 ==<br />
<br />
* 12 Feb 2018<br />
* Error on duplicate forward class<br />
* Error on method class in other unit<br />
* Fixed index property override<br />
<br />
== Version 0.9.4 ==<br />
<br />
* 8 Feb 2018<br />
* Removed debug writeln, fixing Disk Full errors in libpas2js.<br />
* Nicer error messages on illegal qualifier.<br />
<br />
== Version 0.9.3 ==<br />
<br />
* 4 Feb 2018<br />
* Fixed number literals outside int64.<br />
* Shorten float numbers, e.g. 1.00000E+001 to 10<br />
* unexpected exception now sets ExitCode to 1<br />
<br />
== Version 0.9.2 ==<br />
<br />
* 4 Feb 2018<br />
* Fixed -constant, when constant is a negative number<br />
<br />
== Version 0.9.1 ==<br />
<br />
* 3 Feb 2018<br />
* Fixed class const evaluating expression.<br />
<br />
== Version 0.9.0 ==<br />
<br />
* 31 Jan 2018<br />
* Fixed srcmap header. It must be )]}' to work in Firefox. Added option -JmXSSIHeader to exclude or include the XSSI protection header.<br />
* Ignore procedure modifier "inline"<br />
* Char(int)<br />
* search units and include files case insensitive by default. Enable FPC like search with parameter -JoSearchLikeFPC.<br />
* Const in external classes:<br />
** ''const c: type = value, const c = value'' are translated to the value.<br />
** ''const c: type, class const c: type'' are treated like readonly variables.<br />
<br />
== Version 0.8.45 ==<br />
<br />
* 23 Jan 2018<br />
* is-operator: jsvalue is class-type, jsvalue is class-of-type<br />
* assertions: -Sa, $C+|-, $Assertions on|off, Assert(boolean), Assert(boolean,string)<br />
* object checks: -CR, $ObjectChecks on|off, check method calls, check object type casts<br />
* some bugfixes for alias types<br />
* multi dimensional static array const, e.g. array[1..2,3..4] of byte = ((5,6),(7,8))<br />
* fixed overloads when skipping class interface<br />
* fixed s[i]:= when s is a var parameter<br />
<br />
== Version 0.8.44 ==<br />
<br />
* 15 Jan 2018<br />
* State of directives $Hints|Notes|Warnings on|off at end of procedure is used for analyzer hints, e.g. "local variable x not used".<br />
* Fixed re-reading directories after Reset.<br />
<br />
== Version 0.8.43 ==<br />
<br />
* 4 Jan 2018 <br />
* Fixed -Fi include path<br />
* Read directories instead of checking every single file. Added hooks for ReadDir to libpas2js.<br />
<br />
== Version 0.8.42 ==<br />
<br />
* 25 Dec 2017<br />
* var absolute modifier for local variables<br />
* $scopedenums<br />
* $hint, $note, $warn, $error, $fatal, $message text<br />
* $message hint|note|warn|error|fatal text<br />
* $hints, $notes, $warnings on|off<br />
<br />
== Version 0.8.41 ==<br />
<br />
* 25 Dec 2017<br />
*Enumerators:<br />
** ordinal types: char, boolean, byte, ..., longword, enums, sets, static array, custom range<br />
** const set<br />
** variables: set, string, array<br />
** class GetEnumerator<br />
** It does not support operator enumerator, IEnumerator, member modifier enumerator.<br />
<br />
== Version 0.8.40 ==<br />
<br />
* File read callback for pas2jslib<br />
<br />
== Version 0.8.39 ==<br />
<br />
* 14 Dec 2017<br />
* fixed circular unit dependencies<br />
<br />
== Version 0.8.38 ==<br />
<br />
* 12 Dec 2017<br />
* support for * and ? in search paths<br />
* fixed converting a typecast to an alias proc type<br />
* fixed inherited-identifier-as-expr<br />
* emit warning method-hides-method-in-base-type only for virtual methods<br />
* reduced function hides identifier from level hint to info<br />
* fixed unit contnrs to always use mode objfpc.<br />
<br />
== Version 0.8.37 ==<br />
<br />
* 5 Dec 2017<br />
* Bugfixed a combination of overload/override<br />
<br />
== Version 0.8.36 ==<br />
<br />
* 5 Dec 2017<br />
* fixed missing brackets in binary expression and left side has a call (a-f(b)) / (c-d)<br />
<br />
== Version 0.8.35 ==<br />
<br />
* 20 Nov 2017<br />
* fixed a bug in the overload code<br />
<br />
== Version 0.8.34 ==<br />
<br />
* 19 Nov 2017<br />
* fixed skipping attributes behind procedure declarations.<br />
* Procedures/methods now properly hides procs with same name.<br />
* In mode delphi overloads now always require the 'overload' modifier.<br />
* In mode objfpc the modifier is required when using different scopes.<br />
* hints for hiding identifiers of other units.<br />
* implemented system.built-in-identifier.<br />
<br />
== Version 0.8.33 ==<br />
<br />
* 14 Nov 2017<br />
* srcmaps with included sources now ignores untranslatable local paths and simply uses the full local path.<br />
* custom enum ranges, e.g. TBlobType = ftBlob..ftBla<br />
* custom integer ranges, e.g. TSome = 1..5<br />
* custom char ranges<br />
* set of custom enum/integer/char ranges<br />
* the conversion of the for-to-do loop has changed. If the loop is never executed, the loop variable is not touched. And the start expression is now executed before the end expression.<br />
<br />
== Version 0.8.32 ==<br />
<br />
* 8 Nov 2017<br />
* some bug fixes for warnings<br />
<br />
== Version 0.8.31 ==<br />
<br />
* 29 Oct 2017<br />
* bugfix for implicit function calls of parameters of some built in functions.<br />
<br />
== Version 0.8.30 ==<br />
<br />
* 19 Oct 2017<br />
* nicer "can't find unit" position<br />
* fixed a crash parsing uses clause<br />
<br />
== Version 0.8.29 ==<br />
<br />
* 16 Oct 2017<br />
* bugfixes<br />
* it now supports directive $M alias $TypeInfo<br />
<br />
== Version 0.8.28 ==<br />
<br />
* fixed passing static array<br />
<br />
== Version 0.8.27 ==<br />
<br />
* 4 Oct 2017<br />
* implemented resourcestrings<br />
* implemented logical xor<br />
* fixed class-of-typealias<br />
* fixed property index modifier expression<br />
<br />
== Version 0.8.26 ==<br />
<br />
* 3 Oct 2017<br />
* fixed RTTI for static arrays<br />
* implemented property modifier index<br />
* implemented FuncName:=<br />
<br />
== Version 0.8.25 ==<br />
<br />
* 1 Oct 2017<br />
* bugfixes<br />
* a new modeswitch ignoreattributes to ignore attributes.<br />
<br />
== Version 0.8.24 ==<br />
<br />
* 28 Sep 2017<br />
* implemented multi dimensional SetLength<br />
* fixed keeping old values when using SetLength<br />
* fixed method override of override<br />
<br />
== Version 0.8.23 ==<br />
<br />
* 27 Sep 2017<br />
* property default value for sets<br />
* custom integer ranges, like TValueRelationship<br />
* typecast enums to integer type (same as ord function)<br />
* new modeswitch ignoreinterfaces to parse class interfaces, but neither resolve nor convert them. Using them will cause an error.<br />
<br />
== Version 0.8.22 ==<br />
<br />
* 24 Sep 2017<br />
* fixed loading dotted units<br />
* implemented property stored and default modifiers<br />
<br />
== Version 0.8.21 ==<br />
<br />
* 21 Sep 2017<br />
* fixed aString[index]:=<br />
* fixed analyzer to mark default values of arguments<br />
* many improvements for sourcemaps making step-over/into nicer in Chrome.<br />
* new tool fpc/packages/fcl-js/examples/srcmapdump to dump the produced sourcemap.<br />
* unicodestring and widechar are now declared by the compiler instead of system.pas<br />
<br />
== Version 0.8.20 ==<br />
<br />
* 14 Sep 2017<br />
* Static array const are now implemented. For example:<br />
* array['a'..'d'] of integer = (1,2,3,4);<br />
* array[1..3] of char = 'pas';<br />
<br />
== Version 0.8.19 ==<br />
<br />
* 12 Sep 2017<br />
* several bug fixes<br />
* started static arrays:<br />
**array[2..6] of char<br />
**array['a'..'z'] of char<br />
**array[boolean] of longint<br />
**array[byte] of string<br />
**array[enum] of longint<br />
**array[char] of boolean // Note that char is widechar!<br />
**low(), high()<br />
<br />
== Version 0.8.18 ==<br />
<br />
* 6 Sep 2017<br />
* Anonymous arrays in record members are now supported:<br />
<syntaxhighlight lang="pascal"><br />
TFloatRec = Record<br />
...<br />
Digits: Array Of Char;<br />
End;<br />
</syntaxhighlight><br />
<br />
== Version 0.8.17 ==<br />
<br />
* 3 Sep 2017<br />
* checks for semicolons between statements<br />
* fixed proc type of procedure in Delphi mode<br />
* implemented @@ operator for proc types in Delphi mode.<br />
* compile time evaluation, range and overflow checking for boolean, base integer types, enums, sets, custom integer ranges, char, widechar, string, single and double.<br />
<br />
== Version 0.8.16 ==<br />
<br />
* 28 Jul 2017<br />
* bugfix release.<br />
<br />
== Version 0.8.15 ==<br />
<br />
* 8 Jul 2017<br />
* compiler can now generate source maps when passing option -Jm<br />
<br />
== Version 0.8.14 ==<br />
<br />
* 17 May 2017<br />
* now supports TObject.Free.<br />
<br />
In Delphi/FPC obj.Free works even if obj is nil. In JavaScript this would crash. And to free memory JS requires to clear all references, which is not required in Delphi/FPC. Therefore the compiler adds code to check for null, call the destructor and sets the variable to null.<br />
<br />
It does not support freeing properties and function results. For example: List[i].Free; will give a compiler error. The property setter might create side<br />
effects, which would be incompatible to Delphi/FPC.<br />
<br />
== Version 0.8.13 ==<br />
<br />
* 11 May 2017<br />
* $IF<br />
* $ELSEIF<br />
* $IFOPT<br />
* $Error<br />
* $Warning,<br />
* $Note<br />
* $Hint<br />
* And in the config files it supports #IF, #IFDEF, #IFNDEF, #ELSEIF, #ELSE, #ENDIF.<br />
<br />
== Version 0.8.12 ==<br />
<br />
* 5 May 2017<br />
* dotted unit names and namespaces.<br />
<br />
== Version 0.8.11 ==<br />
<br />
* 23 Apr 2017 <br />
* dynamic arrays can now be initialized with a constant. Same syntax as static arrays: const a: array of string = ('one', 'two');<br />
* Classes can now be declared in the unit implementation.<br />
* Unit nodejs now has a console class TNJSConsole.<br />
* I added the fpcunit package. Successful tests already work. A fail is not yet caught.<br />
<br />
== Version 0.8.10 ==<br />
<br />
* 22 Apr 2017<br />
* you can now use "if aJSValue then", which works just like the JS "if(v)".<br />
* added ParamCount, ParamStr, GetEnvironment* functions. The default is not doing much.<br />
* new package fcl_base_pas2js, containing custapp and nodejsapp: - TCustomApplication is the known class from the FCL, but with abstract methods.<br />
* TNodeJSApplication is a TCustomApplication using nodejs to read command line params and environment variables.<br />
<br />
== Version 0.8.9 ==<br />
<br />
* 21 Apr 2017<br />
*The compiler now has the types 53bit NativeInt and 52bit NativeUInt. Keep in mind that there is still no range checking.<br />
<br />
Current aliases:<br />
<pre><br />
JSInteger = NativeInt;<br />
<br />
Integer = LongInt;<br />
Cardinal = LongWord;<br />
SizeInt = NativeInt;<br />
SizeUInt = NativeUInt;<br />
PtrInt = NativeInt;<br />
PtrUInt = NativeUInt;<br />
ValSInt = NativeInt;<br />
ValUInt = NativeUInt;<br />
ValReal = Double;<br />
Real = Double;<br />
Extended = Double;<br />
<br />
Int64 = NativeInt unimplemented;<br />
QWord = NativeUInt unimplemented;<br />
Single = Double unimplemented;<br />
Comp = Int64 unimplemented;<br />
<br />
UnicodeString = String;<br />
WideString = String;<br />
WideChar = char;<br />
</pre><br />
<br />
== Version 0.8.8 ==<br />
<br />
* 20 Apr 2017<br />
* bugfix release.<br />
<br />
== Version 0.8.7 ==<br />
<br />
* 18 Apr 2017<br />
* $mod: the current module<br />
* Self: in a method with nested functions this holds the class or class instance.<br />
* overloads are now chosen like FPC/Delphi not only by type, but also by precision. This means if there are several compatible overloads, and none fits exactly it will choose the next higher. Formerly it gave an error.<br />
* cardinal is no longer a base type, but longword is. Same as FPC.<br />
<br />
== Version 0.8.6 ==<br />
<br />
* 17 Apr 2017<br />
* bugfix release.<br />
<br />
== Version 0.8.5 ==<br />
<br />
* 15 Apr 2017<br />
* bugfix for the analyzer.<br />
* supports published array properties and published records.<br />
* array properties for external classes.<br />
<br />
== Version 0.8.4 ==<br />
<br />
* 14 Apr 2017<br />
* bugfix release.<br />
<br />
== Version 0.8.3 ==<br />
<br />
* 4 Apr 2017<br />
* pas2js now has code navigation in Lazarus<br />
<br />
= Trunk =<br />
<br />
= Navigation =<br />
* Back to [[pas2js]]<br />
* Back to [[lazarus pas2js integration]]<br />
<br />
[[Category:Pas2js]]</div>Michaelhttps://wiki.freepascal.org/index.php?title=Pas2JS_Version_Changes&diff=158290Pas2JS Version Changes2024-02-27T11:22:03Z<p>Michael: /* 3.0.1 */</p>
<hr />
<div>= Releases =<br />
<br />
== Next Version ==<br />
<br />
== 3.0.1 ==<br />
<br />
27th Feb 2024<br />
<br />
Changes:<br />
*New download server for the precompiled binaries: https://getpas2js.freepascal.org<br />
*Namespaces (unitnames with dotted prefixes):<br />
** added compiler option '''-FN<X>''': add ''<x>'' to namespaces. Namespaces with trailing ''-'' are removed. Delphi calls this flag "unit scope names".<br />
** The packages were extended to support namespaced version of units, e.g. units in packages/rtl are now in packages/rtl/src and the namespaced versions are in packages/rtl/namespaced<br />
** This requires updating the -Fu paths in your pas2js.cfg, see [[pas2js.cfg#Examples|pas2js.cfg Example]]<br />
* Removed submodule "compiler" and instead support "compiler" as copy, symlink or FPCDIR environment variable. See [[pas2js#GIT|Fetching pas2js source via git and compile]]<br />
* Many external JS classes updated and extended<br />
* FPC Wasm code can access the DOM and JS APIs through pas2js code: [[WebAssembly/DOM|WebAssembly/DOM]]<br />
* fixed marking ''library export function result'' sub elements as used<br />
* fixed parsing ''var'' section after ''class var'' section<br />
* fixed names of properties ''MultilineStringsTrimLeft'' and ''MultilineStringsEOLStyle''<br />
* fixed multilinestrings:<br />
** combos like `abc`#10<br />
** double backticks become, same as double apostrophs become one in string literals <br />
** apostroph<br />
* fixed '''anonymous procedure type'''<br />
* fixed '''anonymous record type'''<br />
* fixed searching '''TJSPromise''' in global scopes, while context is a dot scope<br />
* fixed typecast array literal to ''TJSArray''<br />
* added releasecreator, tool written in fpc to compile the compiler and tools<br />
* Support for datamodules in resources<br />
* Tool to import typescript declaration modules as external classes<br />
* Split Web unit into units usable in service workers and main browser window.<br />
* Many updates on the widgets, support for bulma-styled widgets<br />
* JSONRPC client support and tool to generate import based on ExtJS-styled API.<br />
<br />
===3.0.1 Incompatibilities===<br />
<br />
===Unitpaths of default packages in pas2js.cfg===<br />
<br />
* The default packages source paths have changed namespaced versions were added.<br />
* Remedy: Update the -Fu paths in your pas2js.cfg, see [[pas2js.cfg#Examples|pas2js.cfg Example]]<br />
<br />
== Version 2.2.0 ==<br />
<br />
22th Feb 2022<br />
<br />
== All changes of version 2.2.0 ==<br />
<br />
* moved from svn to gitlab<br />
* New command line option: -Ja<x>: Append JS file <x> to main JS file. E.g. -Jamap.js. Can be given multiple times. To remove a file name append a minus, e.g. -Jamap.js-.<br />
* Added RTTI ''TProcedureFlag'' '''pfSafeCall''' and '''pfAsync'''<br />
* pas2js now creates unique method pointers ('''@SomeMethod'''), e.g. the following code will now remove the ''@OnLoad'':<br />
xhr.addEventListener('load', @OnLoad);<br />
xhr.removeEventListener('load', @OnLoad);<br />
* Pascal '''Library'''<br />
** export for global functions and static methods<br />
** export for global variables<br />
* '''{$linklib}''' directive, see [[pas2js modules]]<br />
* new -T platform '''module'''<br />
* new -T platform '''electron'''<br />
* mark record fields as used when passing record to a jsvalue parameter<br />
* $mode Delphi support for generic overloads, e.g. ''TBird, TBird<T>, TBird<S,T>''. Can be used from a unit with mode ObjFPC too, although cannot yet be declared there.<br />
* fixed delay init specializations after loading impl sections<br />
* fixed specialize '''try except on''', issue 38795<br />
* fixed ''float / 0.0'' results at compiletime in ''infinity'' instead of div by zero, issue 38815<br />
* fixed ''low/high(aString)''<br />
* fixed typecast ''jsvalue'' to ''external class'' instance not object checking by default, only when object checks are enabled. For example ''TJSString(aJSValue).length''.<br />
* fixed emulate compile time assign integer constant of different type<br />
* fixed '''typeinfo''' ''Module, Attributes, ResultType'' and ''Params'' now have default value '''nil''', not ''undefined''.<br />
* fixed cloning multi dim static array on assign<br />
* fixed stack overflow on deep nested binary expressions<br />
* fixed releasing com interface fields on destroy<br />
* fixed class property getter for array property of static method<br />
* fixed find generic proc overload without params, issue 38796<br />
* fixed calling constructor of nested external class, issue 38858<br />
* fixed await() as aclass, issue 39028<br />
* fixed consistent error message on custom js file not found, issue 38978<br />
* fixed writing sourceMappingURL only if map file enabled, issue 39210<br />
* fixed Setlength(unicodestring) issue 39208<br />
* fixed call type helper on type helper read from pcu<br />
<br />
===2.2.0 Incompatibilities===<br />
<br />
====pas2js.cfg====<br />
<br />
* The binary packages' file ''pas2js.cfg'' now enables ''-Jc'' (concatenate all js) by default. You can disable this with ''-Jc-''.<br />
<br />
== Version 2.0.6 ==<br />
<br />
15th Apr 2021<br />
<br />
* fixed '''insert(item,array,pos)''' when ''array=nil''<br />
* fixed published field with anonymous array<br />
* fixed -O- and record const, issue 38683<br />
* fixed multi add '''a + ImplicitFuncCall + b'''<br />
* (generics) Add comparer version of TDictionary create.<br />
* (generics) Fix wrong comparison of objects, adjusted patch by Henrique Werlang (Issue 38748)<br />
* (db) Patch from Henrique Werlang to implement TDatasetField<br />
* (rtti) Patch from Henrique Werlang to implement getting method parameters info<br />
* (db) Fix in TDataSet.DefaultBytesToBlobData, index out of range<br />
* (sysutils) TStringBuilder implementation<br />
* (arrayutils) Start of array utils<br />
* (web) Clipboard support (bug ID 0038726)<br />
* (sysutils) Use TBoolStrs for Boolean.ToString helper<br />
* (jsondataset) Publish OnRecordResolved, OnLoadFail<br />
* (db) Implement TBlobField.DisplayValue<br />
* (classes) Add ExtractStrings<br />
* (classes) StringStream.ReadString/WritString. Fix TMemoryStream.LoadFromStream.<br />
* (classes) Correctly handle CR/LF in GetNextLineBreak in TStrings.<br />
* demos: Fix demo to work again with latest webwidget<br />
* demos: Fixed demorouter example<br />
* (packages) new flatpickr lib<br />
* (sysutils) provide suitable defaults for Long- and ShortTimeFormat<br />
* (web) Patch from Henrique Werlang to implement TJSCSSStyleDeclaration<br />
* (web) Patch from Henrique Werlang to implement TJSElement.Remove<br />
* (classes) correctly stream TStrings based properties<br />
* (db) Patch from Henrique Werlang to let TDatalink transmit events ony when active<br />
* (sysutils) Introduce FormatSettings<br />
<br />
== Version 2.0.4 ==<br />
<br />
26th Mar 2021<br />
<br />
* fixed wrong setting ''rtl.TObjectDestroy''<br />
* fixed no hint when published method hides ancestor method<br />
* fixed compileserver option '''--simpleserver=''' and '''-d''' relative path<br />
* fixed stack overflow on long string concatenations<br />
* fixed filer restore global shortrefs<br />
<br />
== Version 2.0.2 ==<br />
<br />
9th Mar 2021<br />
<br />
* fixed freeing temporary class interface, if it is nil.<br />
* removed obsolete ''TTypeInfoDynArray.DimCount''<br />
* fixed ''TTypeInfoStaticArray.Dims''<br />
* fixed ''obj as COMIntfType'', when ''obj'' is ''nil': for FPC and Delphi compatibility nil returns nil and does not raise an exception.<br />
* fixed checking statement after ''except-on''<br />
* fixed '''if then asm a;b end'''<br />
* fixed '''ord(integer)'''<br />
* fixed '''Include(SetOfIntegerRange, integer)'''<br />
* fixed omitting hint for not used property<br />
* fixed '''var a: (b,c);'''<br />
* fixed calling '''Instance.StaticMethod''' not using Instance<br />
* fixed fixed creating enum shortrefs for precompiled code for optimization ''EnumValues''<br />
<br />
== Version 2.0.0 ==<br />
<br />
11th Jan 2021<br />
<br />
[[Pas2JS_Version_Changes#All_changes_of_version_2.0.0|All changes of version 2.0.0]]<br />
<br />
* fixed ''TDictionary'' with procedural type<br />
* fixed ''TTypeInfoRecord.RecordType''<br />
<br />
== Version 2.0.0RC8 ==<br />
<br />
31th Dec 2020<br />
<br />
* fixed UTF-16 char literal ''#128..#255''<br />
* fixed using invalid UTF-16 but valid string ''#$DC00'b' ''<br />
* fixed checking class method modifiers match class interface (as in IUnknown)<br />
* fixed typecast specialized array to specialized type<br />
* fixed implicit call of specialized method<br />
* added separate hints '''4501 field "x" not used''' and '''4502 field "x" assigned but never used'''. Delphi/FPC do not have these hints, as they treat records as one memory block and can't omit fields. pas2js can omit fields.<br />
* The param in '''await(param)''' must now be an async function, to avoid accidentally calling the wrong function or not a function at all.<br />
* Allowing '''await(T,jsvalue)''', because jsvalue could be a promise.<br />
* fixed typecast implicit function call passing to arg, e.g. ''aFunc(aType(obj.bFunc))''<br />
* fixed delayed init specialized class interface<br />
<br />
== Version 2.0.0RC7 ==<br />
<br />
13th Dec 2020<br />
<br />
* fixed optimization ''shortrefglobals'' and ''enum value''<br />
* fixed filer storing unix line ending and writing precompiled code with platform line ending<br />
* fixed unit without implementatiom<br />
* fixed record member type<br />
<br />
== Version 2.0.0RC6 ==<br />
<br />
8th Dec 2020<br />
<br />
* the binary snapshot now use same directories as "make all". E.g. '''bin\i386-win32''' for the Windows 32bit executables.<br />
* the binary snapshot now contains the '''makestub''' utility<br />
* fixed filer, call type helper of unit, which unit implementation has not been parsed.<br />
* fixed catching load file exceptions and turn into regular errors<br />
* fixed generating typeinfo for classes with published members, but not referenced via typeinfo<br />
<br />
== Version 2.0.0RC5 ==<br />
<br />
4th Dec 2020<br />
<br />
* fixed skipping non fully specialized types<br />
* fixed filer, storing reference to ''await'' and ''debugger''<br />
* fixed filer, specialize signature of implementation of methods<br />
* fixed filer, skipping generic reference to generic type<br />
* fixed filer, reading inline specialize expression<br />
* fixed filer, checking signatures needing indirect units of implementation<br />
<br />
== Version 2.0.0RC4 ==<br />
<br />
30th Nov 2020<br />
<br />
* fixed '''await''' on '''as''' operator<br />
* fixed '''await(ProcArgument)'''<br />
* fixed hint ''Await needs a promise''<br />
* fixed calling '''async function''' with result type ''COM interface''<br />
* fixed checking '''await(T,callasyncfunc)'' type match<br />
* fixed '''async''' procedure modifier not needed in implementation of a procedure<br />
* added ''FormData'' js keyword<br />
* fixed ''shortrefglobals'' optimization of new/free instance fields<br />
* fixed crash on parser error in inline specialize expression, issue 38111<br />
* fixed typeinfo path of inline specialize type<br />
* fixed '''-OoShortRefGlobals'''<br />
* fixed error when using generic type without parameters<br />
* fixed shortrefglobals when unit initialization uses unit of otherwise empty implementation section<br />
<br />
== Version 2.0.0RC3 ==<br />
<br />
13th Nov 2020<br />
<br />
* fixed '''typeinfo unicodestring''' and '''widechar'''<br />
* fixed passing ''widechar'' to ''var argument char'' and ''unicodestring'' to ''string'' and vice versus.<br />
* rtl: system.pas: removed obsolete ''UnicodeString=string'' and ''WideChar=char'' type alias. They are normal compiler types.<br />
* fixed typecast integer to '''widechar'''<br />
* fixed '''ord(widechar)'''<br />
* added overload ''TryStrToInt64'' with ''int64'', ''TryStrToQWord'' with ''QWord'', ''TryStrToUInt64'' with ''UInt64''<br />
<br />
== Version 2.0.0RC2 ==<br />
<br />
11th Nov 2020<br />
<br />
* fixed ''shortrefglobals'' for minimal class interface, issue 38042<br />
* fixed disable optimization using fpc syntax e.g. '''-OoNoShortRefGlobals''', issue 3804<br />
* fixed ''shortrefglobals'' for procedure without args, issue 38043<br />
* '''-JRnone''' now skips resource directives<br />
<br />
== Version 2.0.0RC1 ==<br />
<br />
5th Nov 2020<br />
<br />
== All changes of version 2.0.0 ==<br />
<br />
* the binary snapshots now use same directories as "make all". E.g. bin\i386-win32 for the Windows 32bit executables.<br />
* [[pas2js_Generics|Generics]]<br />
* '''Attributes''':<br />
** '''Incompatibility''': '''$modeswitch ignoreattributes''' was removed<br />
** base class ''System.TCustomAttribute''<br />
** '''$modeswitch prefixedattributes''': enabled by default in ''$mode Delphi''<br />
** declare in front of any type, type member<br />
** the Delphi compiler attributes like ''ref, weak, volatile'', etc are not supported.<br />
** query attributes of a type:<br />
*** use either typinfo function '''GetRTTIAttributes(typeinfo(SomeType).Attributes)''':<br />
*** or use RTTI unit ''r:=TRTTIContext'', ''r.GetType(typeinfo(SomeType)).GetAttributes''<br />
* '''class constructors''':<br />
** for classes, records, class helpers, record helpers and type helpers.<br />
** Called in initialization section<br />
** Optimizer removes attributes if type is not used.<br />
* '''VarArg.Free''', e.g. ''procedure DoIt(var Arg: TObject); begin Arg.Free end;'' setting Arg to nil<br />
* range checking for type helpers<br />
* range checking for var/out arguments<br />
* fixed '''low/high(nativeint)''' for 53 significand bits instead of only 52 explicit bits, increasing high to ''$1fffffffffffff = 9007199254740991''<br />
* float literal: removing unneeded 0 in front of E e.g. 1.20E1 as 1.2E1<br />
* '''Overflow checks for integers''' -Co ''{$overflowchecks on}'' ''{$Q+}'' for integer operators +, -, *. Checks if result is outside nativeint and raises EIntOverflow.<br />
* '''class abstract''' modifier<br />
* ''type helper for classtype'', same as FPC<br />
* ''type helper for interfacetype'', no constructors, same as FPC<br />
* Dispatch messages:<br />
** method modifier '''message integer''' and '''message string'''<br />
** directive '''{$DispatchField fieldname}''' and '''{$DispatchStrField fieldname}'''<br />
Insert these directives in front of your dispatch methods to let the compiler check all methods with message modifiers if they pass a record with the right field.<br />
<syntaxhighlight lang="pascal"><br />
TMyComponent = class<br />
{$DispatchField Msg}<br />
procedure Dispatch(var aMessage); virtual;<br />
{$DispatchStrField MsgStr}<br />
procedure DispatchStr(var aMessage); virtual;<br />
end;<br />
TMouseDownMsg = record<br />
Id: integer; // Id instead of Msg, works in FPC, but not in pas2js<br />
x,y: integer;<br />
end;<br />
TMouseUpMsg = record<br />
MsgStr: string;<br />
X,Y: integer;<br />
end;<br />
TWinControl = class<br />
procedure MouseDownMsg(var Msg: TMouseDownMsg); message 3; // warning: Dispatch requires record field Msg<br />
procedure MouseUpMsg(var Msg: TMouseUpMsg); message 'up'; // ok, record with string field name MsgStr<br />
end;<br />
</syntaxhighlight><br />
* added rtti utility functions GetInterfaceProp, SetInterfaceProp, GetMethodProp, SetMethodProp<br />
* TStream with TBytes<br />
** TBytesStream<br />
* convert ord(const) to a const<br />
* '''Resource strings''':<br />
** Resource strings can now be written to file. This is controlled by the -Jr option, see the main wiki page for [[pas2js]].<br />
* '''TJSFunction(@obj.methodname)''' is now converted to ''classtype.methodname''<br />
* Constructors of external classes are now supported in four ways:<br />
** ''constructor New'' is translated to ''new ExtClass(params)''. Note the missing JS path.<br />
** ''constructor New; external name 'GlobalFunc' '' is translated to ''new GlobalFunc()''. Note the missing JS path.<br />
** ''constructor SomeName; external name '{}' '' is translated to ''{}'' - a basic, empty JS object<br />
** Otherwise it is translated to ''new ExtClass.FuncName(params)''<br />
* You can now specify a type for the procedure modifier ''varargs'': '''varargs of ''SomeType'' '''. For example<br />
<syntaxhighlight lang="pascal"><br />
procedure SumWords(); varargs of Word;<br />
...<br />
SumWords(1,2,3); // this works<br />
SumWords(1,98765); // this gives a range check error<br />
</syntaxhighlight><br />
* Srcmap for pju files<br />
* allowing ''using a unit twice'', with different names, e.g. ''uses ns.unit1, unit1;'' or ''uses foo in 'unit1.pas', unit1;''<br />
* option '''-Sj''' to allow/disallow typed const to be writable<br />
* option '''-im''' to show available modeswitches<br />
* option '''-M<modeswitch>''' to enable or disable a modeswitch, see option -im<br />
* typecasting unrelated classes now gives only a warning "Class types are not related" instead of an error, Reason: FPC/Delphi compatibility<br />
* mode ObjFPC now checks procedural types in procedure arguments by signature, reason: FPC compatibility. Note: FPC does that too in $mode delphi, pas2js only in mode ObjFPC.<br />
* type helper for '''bytebool, wordbool, longbool'''<br />
* ''ArrayOfChar:=String'' and pass ''string'' to ''ArrayOfChar''<br />
* '''safecall''' calling convention and rtl catch uncaught [[pas2js_exceptions|exceptions]].<br />
* [[pas2js_AsyncAWait|Async procedure modifier]] and await functions:<br />
** ''function await(AsyncFunctionOfResultT): T;'' // implicit promise<br />
** ''function await(aType; p: TJSPromise): aType;'' // explicit promise requires the resolved type<br />
** ''function await(aType; v: jsvalue): aType;'' // explicit optional promise requires the resolved type<br />
* Descending a Pascal class from a JS Function<br />
* The [[pas2js_makestub|makestub]] utility converts a Pascal import unit for importing Pascal classes to a unit that is compilable by Delphi<br />
* ''fcl-json'' JSON interface from FPC.<br />
* New units for Javascript libraries:<br />
** ''libjitsimeet'' interface to jitsi video conferencing. <br />
** ''libopentok'' interface to opentok video conferencing. <br />
** ''libkurento'' interface to kurento video conferencing. <br />
** ''libfullcalendar(4/5)'' interface to fullcalendar.io JS library<br />
** ''libdatatables'' interface to datatables.net JS library<br />
** ''pushjs'' interface to browser Push Notifications<br />
** ''libbootstrap'' interface to bootstrap classes.<br />
** ''gmaps'' interface to google maps interface.<br />
* added separate hints '''4501 field "x" not used''' and '''4502 field "x" assigned but never used'''. Delphi/FPC do not have these hints, as they treat records as one memory block and can't omit fields. pas2js can omit fields.<br />
* Optimizations:<br />
** '''-O2''' : Level 2 optimizations (Level 1 + not debugger friendly)<br />
** '''-OoShortRefGlobals[-]''': Insert a JS local var for each module, type and static function. Default enabled in ''-O2''.<br />
===2.0.0 Incompatibilities===<br />
====Signature for event handlers TEventListenerEvent and TJSEvent====<br />
The signature for event handlers has been corrected. The class TEventListenerEvent is now an alias for TJSEvent<br />
: That means that the 2 event handler types<br />
TJSEventHandler = reference to function(Event: TEventListenerEvent): boolean;<br />
TJSRawEventHandler = reference to Procedure(Event: TJSEvent);<br />
: are now equivalent.<br />
====TJSEvent type definition====<br />
The TJSEvent type definition has been corrected<br />
: The currentTarget and Target properties of TJSEvent are now of type TJSEventTarget, as they are in the official specs:<br />
property currentTarget : TJSEventTarget Read FCurrentTarget;<br />
property target : TJSEventTarget Read FTarget;<br />
: For convenience, a targetElement and CurrentTargetElement property have been added which are of type TJSElement:<br />
property currentTargetElement : TJSElement;<br />
property targetElement : TJSElement;<br />
====modeswitch ignoreattributes was removed====<br />
The workaround ''{$modeswitch ignoreattributes}'' was removed. Attributes are now implemented.<br />
<br />
== Version 1.4.34 ==<br />
<br />
28th Oct 2020<br />
<br />
* fixed passing in mode delphi a proc address to a proc type argument.<br />
* fixed searching pju file, when uses-in-file missing<br />
* fixed ''a div b'' for negative results<br />
* fixed ''aCurrency/bCurrency'' for negative results<br />
<br />
== Version 1.4.32 ==<br />
<br />
15th Oct 2020<br />
<br />
* fixed crash on class function<br />
* fixed array shrink using ''SetLength''<br />
* fixed ''try except on ExternalClass do ; end;''<br />
* fixed dynamic array function '''a:=concat(b);''' // marking b as referenced<br />
* fixed dynamic array function '''c:=concat(a,b);'''<br />
* fixed ''$ancestor'' of all root classes is ''null'' instead of ''undefined''<br />
* fixed ''rtl.spaceLeft'' return value<br />
<br />
== Version 1.4.30 ==<br />
<br />
8th July 2020<br />
<br />
* fixed assign record with field of dynamic array<br />
* fixed '''SysUtils.AnsiSameText''' comparing strings with umlauts.<br />
<br />
== Version 1.4.28 ==<br />
<br />
3rd Jul 2020<br />
<br />
* fixed '''system.inc()'''<br />
* fixed namespace search order<br />
** Reason: Delphi/FPC compatibility. <br />
** Old behaviour: search default namespace (aka prepend program namespace), prepend command line namespaces, no namespace (i.e. as written in uses section)<br />
** New behaviour: search no namespace (i.e. as written in uses section), prepend command line namespaces, prepend default namespace (aka program namespace)<br />
** For example program that uses "classes" and units classes.pas and system.classes.pas are in unit search path.<br />
* fixed ''try exit(value) finally read Result end''<br />
<br />
== Version 1.4.26 ==<br />
<br />
6th Jun 2020<br />
<br />
* fixed RTTI of record/class field with shared anonymous array, e.g. ''type t = record a,b:array of byte; end;''<br />
<br />
== Version 1.4.24 ==<br />
<br />
11th May 2020<br />
<br />
* fixed assign array<br />
<br />
== Version 1.4.22 ==<br />
<br />
10th May 2020<br />
<br />
* fixed allowing member with same name as an ancestor member in $mode delphi<br />
* fixed allow '''static''' directive repetition in method implementation<br />
* fixed type helper for '''NativeInt''' and '''NativeUInt'''<br />
* fixed type helper '''Self''' in nested procedure<br />
* fixed '''(i*i).helperfunc'''<br />
* fixed '''SetLength(array,..)''' using resize instead of clone, when not shared. Assign marks an array with a hidden property ''$pas2jsrefcnt''.<br />
<br />
== Version 1.4.20 ==<br />
<br />
11th April 2020<br />
* fixed stack overflow on long procedures<br />
* fixed class helper in with-do<br />
<br />
== Version 1.4.18 ==<br />
<br />
15th Dec 2019<br />
<br />
* access modifier '''constref''': works as ''const'', gives a warning for non records, arrays<br />
* omit not used resourcestrings<br />
* fixed sourcemap for Firefox<br />
<br />
== Version 1.4.16 ==<br />
<br />
15th Oct 2019<br />
<br />
* fixed helper for type alias type<br />
* fixed selecting last declared helper<br />
* replaced rtl.setArrayLength with faster non recursive version<br />
* fixed external static class method<br />
* fixed check for helper class method for external class must be static<br />
* fixed marking implicit call in property parameter<br />
<br />
== Version 1.4.14 ==<br />
<br />
30th Aug 2019<br />
<br />
* source map: when using -Jmabsolute -Jmsourceroot=file:// prepend the absolute source files with ''file://''. Needed by Firefox.<br />
* fixed longword bitwise operations ''not, and, or, xor, shl, shr'' for numbers ''> $7fffffff''<br />
* fixed creating relative paths without shared based directory, e.g. in source maps ''C:\foo\project1.js.map C:\bar\project1.pas''<br />
<br />
== Version 1.4.12 ==<br />
<br />
28th Aug 2019<br />
<br />
* fixed get method reference of Self inside anonymous method without self<br />
* fixed typecast nil to class, interface, dynamic array<br />
* fixed endless loop on ''type TArr = array of TArr''<br />
* no warning "function result not set" for fieldless record<br />
* fixed check for duplicate unit, when names differ<br />
* fixed ''ComInterfaceInstance is/as InterfaceType'' to use ''QueryInterface''<br />
* fixed passing dynamic array to open array var parameter<br />
<br />
== Version 1.4.10 ==<br />
<br />
10th Jul 2019<br />
<br />
* added separate error message duplicate published method<br />
* fixed allowing reintroduce published method<br />
* fixed ''high(dynarrayvar with expr)''<br />
* fixed ''class var a:t; b:t;''<br />
* fixed type helper in other unit<br />
<br />
== Version 1.4.8 ==<br />
<br />
24th June 2019<br />
* fixed var a: somearray = nil<br />
* fixed fixed assignment inside anonymous proc inside for-loop<br />
* fixed ArcTan definition (bug ID 35655)<br />
* setlength(arr) now always clone for FPC/Delphi compatibility. Formerly it merely resized the array.<br />
<br />
== Version 1.4.6 ==<br />
<br />
20th Apr 2019<br />
<br />
* fixed advanced records<br />
* fixed linux rtl.js<br />
<br />
== Version 1.4.4 ==<br />
<br />
19th Apr 2019<br />
<br />
* fixed duplicate identifier when redefining a procedure.<br />
* fixed escaping string literals in asm blocks<br />
<br />
== Version 1.4.2 ==<br />
<br />
11th Apr 2019<br />
<br />
* fixed optimization of NewInstance function<br />
* fixed filer class helper<br />
* fixed passing TExt.new as parameter<br />
* fixed writing workingdirectory<br />
* fixed advanced record constructor<br />
* handling environment options '''PAS2JS_OPTS'''<br />
* fixed nodejs ''GetEnvironmentVariable'' returning empty string for non existing variables<br />
<br />
== Version 1.4.0 ==<br />
<br />
24th Mar 2019<br />
* fixed supporting older node.js (<7.0.0) using ''Math.pow'' instead of newer exponential operator '''**'''.<br />
<br />
== Version 1.4.0RC7 ==<br />
<br />
16th Mar 2019<br />
* fixed accessing Self in anonymous function<br />
* fixed ''UntypedArg:=recordvar'' and ''RecordType(UntypedArg)''<br />
* an external method of a helper is treated like an external method of the helped type<br />
* updated examples<br />
* fixed hint method hides identifier with same signature<br />
* fixed hint argument not used, with array argument and only writing an element<br />
* fixed hint argument not used, with array argument passed as argument<br />
<br />
== Version 1.4.0RC6 ==<br />
<br />
8th Mar 2019<br />
<br />
* fixed passing ''class var'' to ''var'' argument<br />
* fixed reading precompiled units by default<br />
<br />
== Version 1.4.0RC5 ==<br />
<br />
6th Mar 2019<br />
<br />
* fixed overload var arg and type alias<br />
* added overload TryStrToFloat with type extended<br />
* nativeint '''shr''' int<br />
* nativeint '''shl''' int<br />
* no hint when hiding private method<br />
* fixed passing multiple -vm parameters<br />
* fixed include file search in module directoy<br />
* allow typecast external class to unrelated external class in ''$mode delphi'', e.g. TJSEventTarget(aJSWindow). Normally you need ''TJSEventTarget(TJSObject(aJSWindow))''.<br />
<br />
== Version 1.4.0RC4 ==<br />
<br />
3rd Mar 2019<br />
* fixed ''{$warn identifier error}''<br />
* fixed '''and/or/xor''' with ''nativeint''<br />
* warn on ''nativeint shl/shr int'' using only 32bit<br />
* fixed type helper call as arg<br />
* fixed ''(f*f).helpercall''<br />
* fixed info message ''macro name set to "value"''<br />
* ''make all'' now creates a default bin/targetcpu-targetos/pas2js.cfg, so that pas2js.exe works out-of-the box.<br />
<br />
== Version 1.4.0RC3 ==<br />
<br />
27th Feb 2019<br />
<br />
* renamed '''$modeswitch multiplescopehelpers''' to '''multihelpers''', same as FPC<br />
* fixed ''TAliasOfEnumType.EnumValue''<br />
* fixed emitting hints for not used units<br />
* fixed SetBufListSize<br />
<br />
== Version 1.4.0RC2 ==<br />
<br />
18th Feb 2019<br />
* fixed typecast jsvalue(anobject/interface), not doing getObject,<br />
* fixed ''obj.Free'' set to ''nil'' if already ''nil''<br />
* added '''unit websvg.pas''' providing API to SVG elements<br />
* fixed ''getdelimitedtext'', quoting was wrong<br />
* fixed array-of-const references in precompiled units<br />
* Added some missing routines in strutils (containstext, containsstr)<br />
<br />
== Version 1.4.0RC1 ==<br />
<br />
16th Feb 2019<br />
* Highlights:<br />
** class helpers<br />
** record helpers<br />
** type helpers<br />
** advanced records<br />
** array of const<br />
** added locate to JSONdataset, as well as lookup and support for lookup fields.<br />
** Added Indexes (sorting) to JSONDataset.<br />
<br />
* Incompatibilities:<br />
** pas2js now searches units first in the folder of the current module as Delphi does.<br />
** JSArguments declaration was changed from an array of jsvalue to TJSFunctionArguments.<br />
<br />
<br />
== All changes of version 1.4.0 ==<br />
<br />
*Pas2js supports class helpers, record helpers and type helpers since 1.3. The extend is only virtual, the helped type is kept untouched.<br />
**A '''class helper''' can "extend" Pascal classes and external JS classes.<br />
**A '''record helper''' can "extend" a record type. In $mode delphi a record helper can extend other types as well, see ''type helper''<br />
**A '''type helper''' can extend all base types like integer, string, char, boolean, double, currency, and some user types like enumeration, set, range and array types. It cannot extend interfaces or helpers.<br />
** Type helpers are available by default in ''$mode delphi'' and disabled in ''$mode objfpc''. You can enable them with '''{$modeswitch typehelpers}'''.<br />
** By default only one helper is active per type, same as in FPC/Delphi. If there are multiple helpers for the same type, the last helper in scope wins. A class with ancestors can have one active helper per ancestor type, so multiple helpers can be active, same as FPC/Delphi. Using '''{$modeswitch multihelpers}''' you can activate all helpers within scope.<br />
** Nested helpers (e.g. ''TDemo.TSub.THelper'') are elevated. Visibility is ignored. Same as FPC/Delphi.<br />
** Helpers cannot be forward defined (e.g. no ''THelper = helper;'').<br />
** Helpers must not have fields.<br />
** '''Class Var, Const, Type'''<br />
** '''Visibility''' : ''strict private .. published''<br />
** '''Function, procedure''': In class and record helpers ''Self'' is the class/record instance. For other types Self is a reference to the passed value.<br />
** '''Class function, class procedure''': Helpers for Pascal classes/records can add ''static'' and non static class functions. Helpers for external classes and other types can only add static class functions.<br />
** '''Constructor'''. Not for external classes. Works similar to construcors, i.e. ''THelpedClass.Create'' creates a new instance, while ''AnObj.Create'' calls the constructor function as normal method. Note that Delphi does not allow calling helper construcors as normal method.<br />
** no destructor<br />
** '''Property''' : getters/setters can refer to members of the helper, its ancestors and the helped class/record.<br />
** '''Class property''' : getter can be static or non static. Delphi/FPC only allows static.<br />
** '''Ancestors''' : Helpers can have an ancestor helper, but they do not have a shared root class, especially not ''TObject''.<br />
** '''no virtual, abstract, override'''. Delphi allows them, but 10.3 crashes when calling.<br />
** ''inherited'' inside a method of a class/record calls helper of ancestor. <br />
** ''inherited'' inside a helper depends on the $mode:<br />
*** ''$mode objfpc'' : ''inherited;'' and ''inherited Name(args);'' work the same and searches first in HelperForType, then in ancestor(s).<br />
*** ''$mode delphi: inherited;'' : skip ancestors and HelperForType, searches first in helper(s) of ancestor of HelperForType.<br />
*** ''$mode delphi: inherited name(args);'' : same as $mode objfpc first searches in HelperForType, then Ancestor(s)<br />
*** In any case if ''inherited;'' has no ancestor to call, it is silently ignored, while ''inherited Name;'' gives an error.<br />
** '''RTTI''': ''typeinfo(somehelper)'' returns a pointer to ''TTypeInfoHelper'' with ''Kind tkHelper''.<br />
** There are some special cases when using a '''type helper''' function/procedure on a value:<br />
*** ''function result'' : using a temporary variable<br />
*** ''const, const argument'' : When helper function tries to assign a value, pas2js raises a EPropReadOnly exception. FPC/Delphi use a temporary variable allowing the write.<br />
*** ''property'' : uses only the getter, ignoring the setter. This breaks OOP, as it allows to change fields without calling the setter. This is FPC/Delphi compatible.<br />
*** ''with value do ;'' : uses a temporary variable. Delphi/FPC do not support it.<br />
* built-in function '''concat''' ''(string1,string2,...)''<br />
* local types (declared inside functions) are now created in the global scope<br />
* added locate to JSONdataset, as well as lookup and support for lookup fields.<br />
* Added Indexes (sorting) to JSONDataset.<br />
* Added unit fpexprpars.pas, an expression parser unit (needed for dataset filtering...)<br />
* omit unnecessary brackets on associative operations (a||b)||(c||d), (a&&b)&&(c&&d), (a|b)|c, (a&b)&c, (a^b)^c, (a+b)+c, (a-b)-c, (a*b)*c<br />
* '''records are now created as ''Object'', instead of JS ''function'' '''<br />
** records now have hidden (not enumerable) functions ''$new, $assign, $clone, $eq''<br />
** passing records to ''var argument'' now passes the record directly instead of creating a temporary setter<br />
** '''Assigning a record''', e.g. ''aRecord:=value'', now copies the values, while keeping the JS object. This makes ''pointer of record'' Delphi/FPC compatible.<br />
* '''Advanced records''': enabled in $mode delphi, disabled im $mode objfpc, enable with '''{$modeswitch AdvancedRecords}'''<br />
** visibility private, strict private, public, default is public<br />
** methods, class methods (must be static like in FPC/Delphi), constructors<br />
** class vars<br />
** const<br />
** property, class property, array property, default array property<br />
** nested types<br />
** RTTI<br />
* Records can now have external fields with '[2]', '["a b"]'<br />
* In $mode objfpc forward class-of and pointer declarations can now refer to types even if there are other const/var/resourcestring sections in between. Same a FPC. For example:<br />
<syntaxhighlight lang="pascal"><br />
type <br />
TClassOfBird = class of TBird;<br />
const k = 1;<br />
type <br />
TBird = class end;<br />
</syntaxhighlight><br />
* '''lo(), hi()''' in $mode delphi returning the lo/hi byte, in $mode objfpc returning the lo/hi byte|word|longword.<br />
* char range with non ascii literals: 'Б'..'Я'<br />
* typecast char to word and other integers<br />
* added option -Jmabsolute to store absolute filenames in sourcemaps<br />
* '''JSArguments declaration was changed''' from an array of jsvalue to TJSFunctionArguments.<br />
* fixed expr[][] with default properties<br />
* fixed assigning class vars<br />
* pas2js now searches units first in the folder of the current module as Delphi does.<br />
* fixed case-of with non ascii literals<br />
* implemented '''ProcVar:=StaticClassMethod'''<br />
* implemented '''ProcVar:=ClassMethod''' inside static class method<br />
* class property getter/setter can now be static or non static.<br />
* '''array of const''':<br />
** Works the same: vtInteger, vtBoolean, vtPointer, vtObject, vtClass, vtWideChar, vtInterface, vtUnicodeString<br />
** longword is converted to vtNativeInt instead of mangling to vtInteger<br />
** vtExtended is double, Delphi/FPC: PExtended<br />
** vtCurrency is currency, Delphi/FPC: PCurrency<br />
** Not supported: vtChar, vtString, vtPChar, vtPWideChar, vtAnsiString, vtVariant, vtWideString, vtInt64, vtQWord<br />
** only in pas2js: vtNativeInt, vtJSValue<br />
* fixed ''o.ProcVar()'' when ProcVar is typeless property<br />
* fixed const evaluation float - currency<br />
* fixed reading #$00xx as widechar, bug 34923<br />
* fixed relative paths in srcmap in Windows<br />
* nicer error message on invalid set element type<br />
<br />
== Version 1.2.0 ==<br />
<br />
* 23th Dec 2018<br />
* SVN release tag is https://svn.freepascal.org/svn/projects/pas2js/tags/release_1_2_0<br />
* added '''dataabstract''': support for Remobjects Data Abstract: The TDAConnection and TDADataset classes<br />
* set rtl.js version to 10200<br />
* fixed parsing comment in $IFDEF, $IFNDEF, issue 34711<br />
* fixed searching unit<br />
<br />
== Version 1.2.0RC1 ==<br />
<br />
* 16th Dec 2018<br />
* SVN release tag is https://svn.freepascal.org/svn/projects/pas2js/tags/release_1_2_0RC1<br />
* '''Anonymous Functions''':<br />
<syntaxhighlight lang="pascal"><br />
type<br />
TRefProc = reference to procedure;<br />
TProc = procedure;<br />
procedure DoIt(arg: TRefProc);<br />
var <br />
ref: TRefProc;<br />
proc: TProc;<br />
begin<br />
ref:=procedure begin end; // assign to "reference of procedure" type<br />
ref:=procedure // note the omitted semicolon<br />
var i: integer; // var, types, const, local procedures<br />
begin<br />
end; <br />
DoIt(procedure begin end); // pass as argument<br />
refproc:=procedure assembler asm // embed JavaScript<br />
console.log("foo");<br />
end; <br />
// Note that typecasting to non "reference to" does not make a difference <br />
// because in JS all functions are closures:<br />
proc:=TProc(procedure begin end); <br />
end;<br />
</syntaxhighlight><br />
* added variable <i>rtl.version</i>, which corresponds to the compiler version Major*10000+Minor*100+Release<br />
* added option '''-JoCheckVersion''':<br />
** -JoCheckVersion- : do not add rtl version check, default.<br />
** -JoCheckVersion=main : insert rtl.checkVersion() into main.<br />
** -JoCheckVersion=system : insert rtl.checkVersion() into system unit.<br />
** -JoCheckVersion=unit : insert rtl.checkVersion() into every unit.<br />
* moved classtopas function to a class2pas unit, improved the interface so it uses a stringlist. Adapted the demo.<br />
* Fix System.Int() so it also works on IE (where Math.trunc is missing).<br />
* allow typecasting ''string(apointer)'' and ''pointer(astring)''<br />
* asm-block now skips Pascal comments //... and Pascal string literals with single quotes. It no longer stops at ''end'' in such comments and string literals.<br />
* Fix FormatFloat() rounding logic (actually FloatToDecimal)<br />
* Fix stringofchar for count<=0<br />
* Fix quotestring and add quotedstr<br />
* implemented special includes like '''{$i %date%}:'''<br />
** %date%: current date as string literal, '[yyyy/mm/dd]'<br />
** %time%: current time as string literal, 'hh:mm:ss' Note that the inclusion of %date% and %time% will not cause the compiler to recompile the unit every time it is used: the date and time will be the date and time when the unit was last compiled.<br />
** %line%: current source line number as string literal, e.g. '123'<br />
** %linenum%: current source line number as integer, e.g. ''123''<br />
** %currentroutine%: name of current routine as string literal<br />
** %pas2jstarget%, %pas2jstargetos%, %fpctarget%, %fpctargetos%: target os as string literal, e.g. 'Browser'<br />
** %pas2jstargetcpu%, %fpctargetcpu%: target cpu as string literal, e.g. 'ECMAScript5'<br />
** %pas2jsversion%, %fpcversion%: compiler version as string literal, e.g. '1.0.2'<br />
** If param is none of the above it will use the environment variable. Keep in mind that depending on the platform the name may be case sensitive. If there is no such variable an empty string is inserted.<br />
* implemented ''pred(char)'', ''succ(char)''<br />
* allow typecasting ''TypedPointer(UntypedPointer)''<br />
* allow assign ''UntypedPointer:=TypedPointer''<br />
* skip double quotes in asm-blocks, e.g. ''s = "end"+"'";''<br />
* added '''{$modeswitch OmitRTTI}''': treat class section 'published' as 'public' and ''typeinfo()'' does not work on symbols declared with this switch. This allows to easily disable generating RTTI and allows the optimizer to omit unused published properties.<br />
* added option '''-Jpcmd<command>''': Run postprocessor. For each generated js execute command passing the js as stdin and read the new js from stdout. This option can be added multiple times to call several postprocessors in succession. Quote the <command> to add options for the postprocessor. For an example see [[pas2js minifier|minifier]].<br />
* Added built-in procedure '''Debugger;''', which is converted to the JavaScript statement <i>debugger;</i>. If a debugger is running it will break on this line just like a break point.<br />
* Changed operator precedence level of '''is''' to same as '''and''', '''or''', '''xor'''. Same as fpc/delphi.<br />
* fixed assert to raise on false, bug 34643<br />
* built-in ''procedure '''val'''(const string; out enum; out int)''<br />
* added option ''-JoRTL-<x>=<y>'' to change the name of a autogenerated identifier. See the list of available identifiers with ''-iJ''.<br />
<br />
== Version 1.0.4 ==<br />
<br />
* 14th Nov 2018<br />
* SVN release tag is https://svn.freepascal.org/svn/projects/pas2js/tags/release_1_0_4<br />
* fixed calling ''destructor'' after exception in ''constructor''<br />
* fixed initializing static array of record<br />
* fixed parsing ''if expr then raise else''<br />
* fixed local record and enum types<br />
* fixed ''for e in set do''<br />
* fixed for-in of shared sets<br />
* fixed ''inc(classvar)''<br />
* fixed assigning ''class var'' of descendant classes<br />
* fixed error position on include file not found<br />
* fixed loading include file from cache<br />
* fixed range check of ''o.aString[index]'' and ''o.aArray[index]''<br />
* fixed Result:=inherited;<br />
* fixed escaping invalid UTF-16 in string literals<br />
* fixed not generating octal literals in ECMAScript5, it bites strict mode<br />
* fixed IsNaN on ECMAScript6<br />
* fixed error on method in record<br />
* fixed name clash published property and external<br />
* fixed ''str(aCurrency)''<br />
* catch ''ECompilerTerminate'' while parsing params<br />
* ''sLineBreak'' and ''LineEnding'' are now '''var''' under platform NodeJS<br />
<br />
== Version 1.0.3 ==<br />
<br />
* 28th Oct 2018<br />
* SVN release tag is https://svn.freepascal.org/svn/projects/pas2js/tags/release_1_0_3<br />
* fixed ''char(#10)''<br />
* fixed: allow array property accessor argument mismatch const/default for simple types, e.g.:<br />
function GetItems(const i: integer): byte;<br />
property Items[i: integer]: byte read GetItems;<br />
* fixed ''high(intvar)''<br />
* fixed WPO when using record constants<br />
* fixed ''include(FuncResultSet,enum)''<br />
* fixed ''if then <empty> else <something>;''<br />
* fixed ''p^.x:=''<br />
* fixed ''acurrency:=aninteger'' to become ''acurrency:=aninteger*10000''<br />
* fixed ''integer(acurrency)'' to become ''Math.floor(acurrency/10000)''<br />
* fixed calling ''$final'', clearing references on destroy<br />
* fixed not calling ''BeforeDestruction'' on exception in constructor<br />
* fixed ''$class'' be a property of the class, not the object<br />
* fixed local var modifier ''absolute'' in method<br />
* fixed using external const in const expression, e.g. ''const tau = 2*pi;''<br />
* fixed selecting procedure overload, preferring lossy int over int to float<br />
* fixed calling Free inside method<br />
* fixed System.Int() so it also works on IE (where Math.trunc is missing).<br />
* fixed FormatFloat() rounding logic (actually FloatToDecimal)<br />
* fixed stringofchar for count<=0<br />
* fixed quotestring and add quotedstr<br />
<br />
== Version 1.0.2 ==<br />
<br />
* 26 Sep 2018<br />
* SVN release tag is https://svn.freepascal.org/svn/projects/pas2js/tags/release_1_0_2<br />
* fixed multiple class interface maps<br />
<br />
== Version 1.0.1 ==<br />
<br />
* 19 Sep 2018<br />
* SVN release tag is https://svn.freepascal.org/svn/projects/pas2js/tags/release_1_0_1<br />
* fixed generating srcmap for precompiled javascript<br />
<br />
== Version 1.0.0 ==<br />
<br />
* 9 Aug 2018<br />
* SVN release tag is https://svn.freepascal.org/svn/projects/pas2js/tags/release_1_0_0<br />
* SVN fixes branch is https://svn.freepascal.org/svn/projects/pas2js/branches/fixes_1_0<br />
* fixed override method of class interface<br />
* fixed crash on checking body element of empty proc<br />
* use default source filename in pcu/pju files<br />
<br />
== Version 1.0.0rc1 ==<br />
<br />
* 24 Jul 2018<br />
* fixed ''TObject.Create()''<br />
* -vd shows stacktraces<br />
<br />
== Version 0.9.32 ==<br />
<br />
* 17 Jul 2018<br />
* fixed memory leaks and double frees<br />
<br />
== Version 0.9.31 ==<br />
<br />
* 10 Jul 2018<br />
* fixed aIntSet:=[0]<br />
* fixed crash on '''List.Items.Dummy'''<br />
* fixed some mem leaks<br />
* fixed -MDelphi + $mode objfpc + overloads withouts overload keyword<br />
* '''TGUIDString''' is now '''type string'''<br />
* RTL: added websockets<br />
<br />
== Version 0.9.30 ==<br />
<br />
* 4 Jul 2018<br />
* fixed calling COM interface _Release function for expressions.<br />
* fixed catching exception in pju variant of pas2js<br />
* split reserved words into two categories: the compiler now checks global JS identifiers like "Date" only for identifiers without path. That means a local variable ''Date'' will be renamed, a ''property Date'' will not, keeping the RTTI name of properties. Identifiers like ''apply'' are still renamed.<br />
* fixed property RTTI for alias type in other unit<br />
* fixed default value of integer variables, using 0 even if it is outside range. Reason: Delphi/FPC compatibility.<br />
<br />
== Version 0.9.29 ==<br />
<br />
* 29 Jun 2018<br />
* fixed pcu reading alias type<br />
* fixed analyzer: element needing typeinfo marks indirect elements as used normally<br />
* hint for text after final "end.", disable with $warn GARBAGE off<br />
* $warn BOUNDS_ERROR off: disable range check warnings at compile time<br />
* $warn MESSAGE_DIRECTIVE off: disable $message notes<br />
<br />
== Version 0.9.28 ==<br />
<br />
* 27 Jun 2018<br />
* fixed static array of char = stringlit+stringlit<br />
* fixed libpas2js disk full error<br />
* $warn directive: '''{$warn identifier on|off|default|error}''', identifier can be a message number as shown with -vq or one of the following. Note, that some hints like "Parameter %s not used" are currently using the enable state at the end of the module, not the state at the hint source position.<br />
** CONSTRUCTING_ABSTRACT: Constructing an instance of a class with abstract methods.<br />
** IMPLICIT_VARIANTS: Implicit use of the variants unit.<br />
** NO_RETVAL: Function result is not set<br />
** SYMBOL_DEPRECATED: Deprecated symbol<br />
** SYMBOL_EXPERIMENTAL: Experimental symbol<br />
** SYMBOL_LIBRARY<br />
** SYMBOL_PLATFORM: Platform-dependent symbol<br />
** SYMBOL_UNIMPLEMENTED: Unimplemented symbol<br />
** HIDDEN_VIRTUAL: method hides virtual method of ancestor<br />
<br />
== Version 0.9.27 ==<br />
<br />
* 26 Jun 2018<br />
* mode delphi: fixed passing static array to open array<br />
* allow assigning aTypeInfo:=pointer, needed by units with and without using unit typinfo<br />
<br />
== Version 0.9.26 ==<br />
<br />
* 25 Jun 2018<br />
* '''typecast function address to JS function''', e.g. TJSFunction(@IntToStr)<br />
* '''typecast function reference to JS function''', e.g. TJSFunction(OnClick)<br />
* '''typecast method address to JS function''', e.g. TJSFunction(@List.Sort). Note that a method address creates a function wrapper to bind the Self argument.<br />
* changed some types to type alias: TDateTime, TDate, TTime, Single, Real, Comp, UnicodeString, WideString. This only effects typinfo and some compiler error messages. Reason: Delphi/FPC compatibility.<br />
* In mode delphi dynamic array initializations must now use square brackets instead of round brackets. For example ''var a: array of integer = [1,2];''. Reason: Delphi compatibility.<br />
* Assignation using constant array. For instance '''Arr:=[1,2,3]''', where Arr is a dynamic array.<br />
* '''+ operator for arrays''': This concatenation operator is available using the new '''modeswitch arrayoperators''', which is enabled by default in mode delphi.<br />
* unit webgl updated<br />
* unit webaudio added<br />
* unit webbluetooth added<br />
* db unit: ftDataset field type added (not supported)<br />
* JSONDataset unit: TField.OldValue now works for TJSONDataset<br />
* '''webidl2pas''' tool added. A command line tool to create Pascal units from idl specs.<br />
* allow '''external record fields'''.<br />
* hint 5024 'Parameter "%s" not used' was split into two:<br />
** 4501 for virtual/override methods<br />
** 5024 for others<br />
<br />
== Version 0.9.25 ==<br />
<br />
* 7 Jun 2018<br />
* '''TComponent now supports IInterface'''<br />
* '''-o''' is now always '''relative to working directory''', even if -FU or -FE is given. Reason: FPC compatibility<br />
* fixed typeinfo(typeintegerrange)<br />
* fixed using interface ancestor methods<br />
* fixed 'make' building with fpc 3.0.4<br />
<br />
== Version 0.9.24 ==<br />
<br />
* 2 Jun 2018<br />
* fixed precompiled js formatting to same options as compiled js<br />
* fixed unit analyzer private method used by protected property<br />
* fixed class-of RTTI<br />
* fixed precompiled resolve pending scopes before pending units<br />
<br />
== Version 0.9.23 ==<br />
<br />
* 28 May 2018<br />
* added webgl demos from Ryan Joseph<br />
* '''for value in jsarray do''' - where jsarray is any external class with a matching ''length'' and default property. This enumerates similar to other arrays the values, not the index.<br />
* allow '''typecast array to TJSObject'''<br />
* allow '''typecast TJSObject to array'''<br />
* Unicode '''character constants outside of BMP''', e.g. #$10437<br />
* allow '''{$H+}''', error on {$H-}<br />
* added intrinsic procedure '''WriteStr(out s: string; params...)''', which works similar to ''str(param,s)'', except it can take any amount of parameters, which are concatenated.<br />
* added option '''-Sm''' to enable macro replacements<br />
<br />
== Version 0.9.22 ==<br />
<br />
* 17 May 2018<br />
* Fixed ''$00ff00''<br />
<br />
== Version 0.9.21 ==<br />
<br />
* 16 May 2018<br />
* added option '''-FE''': set the main output path, used for the main .js file, if there is no -o option or the -o option has no folder.<br />
* fixed WPO typeinfo of inherited property<br />
* for easier FPC integration the following message IDs were changed:<br />
** nVirtualMethodXHasLowerVisibility = 3250; // was 3050<br />
** nConstructingClassXWithAbstractMethodY = 4046; // was 3080<br />
** nNoMatchingImplForIntfMethodXFound = 5042; // was 3088<br />
** nSymbolXIsDeprecated = 5043; // was 3062<br />
** nSymbolXBelongsToALibrary = 5065; // was 3061<br />
** nSymbolXIsDeprecatedY = 5066; // 3063<br />
** nSymbolXIsNotPortable = 5076; // was 3058<br />
** nSymbolXIsNotImplemented = 5078; // was 3060<br />
** nSymbolXIsExperimental = 5079; // was 3059<br />
<br />
== Version 0.9.20 ==<br />
<br />
* 11 May 2018<br />
* fixed passing typecasted alias type to var parameter<br />
* forbid typecast rectordtype to other recordtype<br />
* remove leading zeroes in number literals<br />
* added '''namespace option -FN<x>''', '''marked -NS as obsolete'''. Reason: fpc compatibility.<br />
* added option '''-vz''' : write messages to stderr, -o. still uses stdout.<br />
* added option '''-ic''' : Write list of supported JS processors usable by -P<x><br />
* added option '''-io''' : Write list of supported optimizations usable by -Oo<x><br />
* added option '''-it''' : Write list of supported targets usable by -T<x><br />
* added option '''-SIcom''', '''-SIcorba''' interface style<br />
* added option '''-vv''' : Write pas2jsdebug.log with lots of debugging info<br />
* fixed option -va including option -vt<br />
* fixed combination of -Jc -o.<br />
* option -vt now writes used unit scopes<br />
* '''external class fields with brackets'''. e.g. ''X: nativeint external name '[0]' ''<br />
* autogenerated interface GUIDs now consider the unitname<br />
<br />
== Version 0.9.19 ==<br />
<br />
* 2 May 2018<br />
* '''type alias type''', e.g. ''type TCaption = type string;''<br />
* '''record const''', e.g. ''const p: TPoint = (x:1; y:2);''<br />
* '''{$WriteableConst on|off}''': treat typed constants as readonly, e.g. ''const i:byte=3;... i:=4;'' creates a compile time error.<br />
* forbid assignment of for-loop variable<br />
* '''nested classes'''<br />
* '''property specifier nodefault'''<br />
* '''default(type)''' returning the initial value of the type, e.g. default(recordtype).<br />
* '''external typed const''': e.g. ''const NaN: Double; external name 'NaN';''<br />
* '''case string of''' support for ranges<br />
* fixed typecast shortint(integer)<br />
<br />
== Version 0.9.18 ==<br />
<br />
* 26 Apr 2018<br />
* Fixed rcArrR in rtl.js<br />
<br />
== Version 0.9.17 ==<br />
<br />
* 25 Apr 2018<br />
* Fix recno calculation for TJSONDataset<br />
* Fix initializing next buffers in TDataset.<br />
* Implemented '''Currency''' as double, values are multiplied by 10000 and truncated, so a 2.7 is stored as 27000.<br />
* Implemented '''pointer of record'''. It's simply a reference.<br />
** ''p:=@r'' translates to ''p=r''<br />
** ''p^.x'' becomes ''p.x''<br />
** intrinsics new(PointerOfRecord), dispose(PointerOfRecord). dispose(p) sets p to null if possible.<br />
* '''enumerator for jsvalue''': e.g. ''var v: jsvalue; key: string; '''for key in jsvalue do''' '' translates to ''for (key in jsvalue){}''<br />
* '''enumerator for external class''': e.g. ''var o: TJSObject; key: string; for key in o do'' translates to ''for (key in o){}''<br />
* '''range checking $R+'''<br />
** compile time: warnings become errors<br />
** run time: int:=, int+=, enum:=, enum+=, intrange:=, intrange+=, enumrange:=, enumrange+=, char:=, charrange:=<br />
** run time: parameters: int, enum, intrange, enumrange, char, charrange<br />
** run time: array[index], string[index]<br />
* '''type cast integer to integer''', e.g. ''byte(aLongInt)''<br />
** with range checking enabled: error if outside range<br />
** without range checking: emulates the FPC/Delphi behaviour: e.g. ''byte(value)'' translates to ''value & 0xff'', ''shortint(value)'' translates to ''value & 0xff <<24 >>24''.<br />
* case-of statement: error on duplicate values<br />
* fixed error on int:=double<br />
<br />
== Version 0.9.16 ==<br />
<br />
* 21 Apr 2018<br />
* mode delphi: allow "ObjVar is IntfType" and "ObjVar as IntfType" with unrelated types.<br />
* TVirtualInterface - create an implementation at runtime. rtl unit rtti.pas<br />
* typecast a class type to JS Object, e.g. TJSObject(TObject)<br />
* typecast an interface type to JS Object, e.g. TJSObject(IUnknown)<br />
* typecast a record type to JS Object, e.g. TJSObject(TPoint)<br />
* <i>not jsvalue</i> is converted to <i>!jsvalue</i><br />
* "=" operator for records with static array fields<br />
* changed TGuid to record<br />
* TGUID record<br />
** GuidVar:='{guid}', StringVar:=GuidVar, GuidVar:=IntfTypeOrVar, GuidVar=IntfTypeOrVar, GuidVar=string<br />
** pass IntfTypeOrVar to GuidVar parameter<br />
* added new type TGuidString to system unit<br />
** GuidString:=IntfTypeOrVar, GuidString=IntfTypeOrVar<br />
** pass IntfTypeOrVar to GuidString parameter<br />
* added option -JoUseStrict, to enable or disable adding "use strict"<br />
<br />
== Version 0.9.15 ==<br />
<br />
* 8 Apr 2018<br />
* fixed crash when ancestor implements more interfaces than current class.<br />
<br />
== Version 0.9.14 ==<br />
<br />
* 8 Apr 2018<br />
* fixed duplicates in rtl/strutils.pas<br />
* fixed reference counts on reading element lists<br />
* implemented using function result variable in for-loop. e.g. <i>for Result:=...</i>, <i>for Result in ...</i><br />
* fixed <i>for string in arrayofstring do</i><br />
* fixed $scopedenums with anonymous enumtype. e.g. <i>type TSet = set of (A,B);</i><br />
* implemented class interfaces:<br />
** methods, properties, default property<br />
** {$interfaces com|corba|default}<br />
*** COM is default, default ancestor is IUnknown (mode delphi: IInterface), managed type, i.e. automatically reference counted via _AddRef, _Release, the checks for support call QueryInterface<br />
*** CORBA: lightweight, no automatic reference counting, no default ancestor, fast support checks.<br />
** inheriting<br />
** GUIDs are simple string literals, TGUID = string.<br />
** An interface without a GUID gets one autogenerated from its name and method names.<br />
** a class implementing an interface must not be external<br />
** a ClassType "supports" an interface, if it itself or one of its ancestors implements the interface. It does not automatically support an ancestor of the interface.<br />
** method resolution, <i>procedure IUnknown._AddRef = IncRef;</i><br />
** delegation: <i>property Name: interface|class read Field|Getter implements AnInterface;</i><br />
** is-operator: <br />
*** IntfVar is IntfType - types must be releated<br />
*** IntfVar is ClassType - types can be unrelated, class must not be external<br />
*** ObjVar is IntfType - can be unrelated<br />
** as-operator<br />
*** IntfVar as IntfType - types must be releated<br />
*** IntfVar as ClassType - types can be unrelated, nil returns nil, invalid raises EInvalidCast<br />
*** ObjVar as IntfType - mode delphi: types must be related, objfpc: can be unrelated, nil if not found, COM: uses _AddRef<br />
** typecast:<br />
*** IntfType(IntfVar) - must be related<br />
*** ClassType(IntfVar) - can be unrelated, nil if invalid<br />
*** IntfType(ObjVar) - mode delphi: must be related, objfpc: can be unrelated, nil if not found, COM: if ObjVar has delegate uses _AddRef<br />
*** TJSObject(intfvar)<br />
** Assign operator:<br />
*** IntfVar:=nil<br />
*** IntfVar:=IntfVar2 - IntfVar2 must be same type or a descendant<br />
*** IntfVar:=ObjVar - nil if unsupported<br />
*** jsvalue:=IntfVar<br />
** Assigned(IntfVar)<br />
** RTTI<br />
** $modeswitch ignoreinterfaces was removed<br />
** Not supported: array of interface, interface as record member<br />
<br />
== Version 0.9.13 ==<br />
<br />
* 21 Mar 2018<br />
* fixed keeping methods AfterConstruction, BeforeDestruction<br />
* fixed modeswitch ignoreinterfaces<br />
<br />
== Version 0.9.12 ==<br />
<br />
* 19 Mar 2018<br />
* fixed parsing procedure p(var a; b: t)<br />
* fixed checking duplicate implementation of unit interface procedure<br />
<br />
== Version 0.9.11 ==<br />
<br />
* 16 Mar 2018<br />
* fixed loading files encoded in non UTF-8, e.g. UTF-8 with BOM. This was a regression.<br />
<br />
== Version 0.9.10 ==<br />
<br />
* 13 Mar 2018<br />
* fixed renaming overloads of unit interface at end of interface, not at end of module. Needed for unit cycles.<br />
<br />
== Version 0.9.9 ==<br />
<br />
* 13 Mar 2018<br />
* Fixed libpas2js to use WorkingDir parameter instead of GetCurrentDir<br />
* Fixed static array clone function.<br />
<br />
== Version 0.9.8 ==<br />
<br />
* 9 Mar 2018<br />
* fixed optimizer keep overrides<br />
<br />
== Version 0.9.7 ==<br />
<br />
* 7 Mar 2018<br />
* fixed pass local variable ''v'' as argument to a var parameter.<br />
<br />
== Version 0.9.6 ==<br />
<br />
* 6 Mar 2018<br />
* static arrays are now cloned on assignment or when passed as argument to a function (no const, var, out)<br />
* Fixed array[enum..enum] of<br />
* pas2jslib: fixed checks of directoryexists to use cache<br />
* uses with <i>in</i>-filename: In <i>$mode delphi</i> the in-filenames are only allowed in the program and the unitname must fit the filename, e.g. <i>uses unit1 in 'sub/Unit1.pas'</i>. In <i>$mode objfpc</i> units can use in-filenames too and alias are allowed, e.g. <i>uses foo in 'bar.pas'</i>.<br />
<br />
== Version 0.9.5 ==<br />
<br />
* 12 Feb 2018<br />
* Error on duplicate forward class<br />
* Error on method class in other unit<br />
* Fixed index property override<br />
<br />
== Version 0.9.4 ==<br />
<br />
* 8 Feb 2018<br />
* Removed debug writeln, fixing Disk Full errors in libpas2js.<br />
* Nicer error messages on illegal qualifier.<br />
<br />
== Version 0.9.3 ==<br />
<br />
* 4 Feb 2018<br />
* Fixed number literals outside int64.<br />
* Shorten float numbers, e.g. 1.00000E+001 to 10<br />
* unexpected exception now sets ExitCode to 1<br />
<br />
== Version 0.9.2 ==<br />
<br />
* 4 Feb 2018<br />
* Fixed -constant, when constant is a negative number<br />
<br />
== Version 0.9.1 ==<br />
<br />
* 3 Feb 2018<br />
* Fixed class const evaluating expression.<br />
<br />
== Version 0.9.0 ==<br />
<br />
* 31 Jan 2018<br />
* Fixed srcmap header. It must be )]}' to work in Firefox. Added option -JmXSSIHeader to exclude or include the XSSI protection header.<br />
* Ignore procedure modifier "inline"<br />
* Char(int)<br />
* search units and include files case insensitive by default. Enable FPC like search with parameter -JoSearchLikeFPC.<br />
* Const in external classes:<br />
** ''const c: type = value, const c = value'' are translated to the value.<br />
** ''const c: type, class const c: type'' are treated like readonly variables.<br />
<br />
== Version 0.8.45 ==<br />
<br />
* 23 Jan 2018<br />
* is-operator: jsvalue is class-type, jsvalue is class-of-type<br />
* assertions: -Sa, $C+|-, $Assertions on|off, Assert(boolean), Assert(boolean,string)<br />
* object checks: -CR, $ObjectChecks on|off, check method calls, check object type casts<br />
* some bugfixes for alias types<br />
* multi dimensional static array const, e.g. array[1..2,3..4] of byte = ((5,6),(7,8))<br />
* fixed overloads when skipping class interface<br />
* fixed s[i]:= when s is a var parameter<br />
<br />
== Version 0.8.44 ==<br />
<br />
* 15 Jan 2018<br />
* State of directives $Hints|Notes|Warnings on|off at end of procedure is used for analyzer hints, e.g. "local variable x not used".<br />
* Fixed re-reading directories after Reset.<br />
<br />
== Version 0.8.43 ==<br />
<br />
* 4 Jan 2018 <br />
* Fixed -Fi include path<br />
* Read directories instead of checking every single file. Added hooks for ReadDir to libpas2js.<br />
<br />
== Version 0.8.42 ==<br />
<br />
* 25 Dec 2017<br />
* var absolute modifier for local variables<br />
* $scopedenums<br />
* $hint, $note, $warn, $error, $fatal, $message text<br />
* $message hint|note|warn|error|fatal text<br />
* $hints, $notes, $warnings on|off<br />
<br />
== Version 0.8.41 ==<br />
<br />
* 25 Dec 2017<br />
*Enumerators:<br />
** ordinal types: char, boolean, byte, ..., longword, enums, sets, static array, custom range<br />
** const set<br />
** variables: set, string, array<br />
** class GetEnumerator<br />
** It does not support operator enumerator, IEnumerator, member modifier enumerator.<br />
<br />
== Version 0.8.40 ==<br />
<br />
* File read callback for pas2jslib<br />
<br />
== Version 0.8.39 ==<br />
<br />
* 14 Dec 2017<br />
* fixed circular unit dependencies<br />
<br />
== Version 0.8.38 ==<br />
<br />
* 12 Dec 2017<br />
* support for * and ? in search paths<br />
* fixed converting a typecast to an alias proc type<br />
* fixed inherited-identifier-as-expr<br />
* emit warning method-hides-method-in-base-type only for virtual methods<br />
* reduced function hides identifier from level hint to info<br />
* fixed unit contnrs to always use mode objfpc.<br />
<br />
== Version 0.8.37 ==<br />
<br />
* 5 Dec 2017<br />
* Bugfixed a combination of overload/override<br />
<br />
== Version 0.8.36 ==<br />
<br />
* 5 Dec 2017<br />
* fixed missing brackets in binary expression and left side has a call (a-f(b)) / (c-d)<br />
<br />
== Version 0.8.35 ==<br />
<br />
* 20 Nov 2017<br />
* fixed a bug in the overload code<br />
<br />
== Version 0.8.34 ==<br />
<br />
* 19 Nov 2017<br />
* fixed skipping attributes behind procedure declarations.<br />
* Procedures/methods now properly hides procs with same name.<br />
* In mode delphi overloads now always require the 'overload' modifier.<br />
* In mode objfpc the modifier is required when using different scopes.<br />
* hints for hiding identifiers of other units.<br />
* implemented system.built-in-identifier.<br />
<br />
== Version 0.8.33 ==<br />
<br />
* 14 Nov 2017<br />
* srcmaps with included sources now ignores untranslatable local paths and simply uses the full local path.<br />
* custom enum ranges, e.g. TBlobType = ftBlob..ftBla<br />
* custom integer ranges, e.g. TSome = 1..5<br />
* custom char ranges<br />
* set of custom enum/integer/char ranges<br />
* the conversion of the for-to-do loop has changed. If the loop is never executed, the loop variable is not touched. And the start expression is now executed before the end expression.<br />
<br />
== Version 0.8.32 ==<br />
<br />
* 8 Nov 2017<br />
* some bug fixes for warnings<br />
<br />
== Version 0.8.31 ==<br />
<br />
* 29 Oct 2017<br />
* bugfix for implicit function calls of parameters of some built in functions.<br />
<br />
== Version 0.8.30 ==<br />
<br />
* 19 Oct 2017<br />
* nicer "can't find unit" position<br />
* fixed a crash parsing uses clause<br />
<br />
== Version 0.8.29 ==<br />
<br />
* 16 Oct 2017<br />
* bugfixes<br />
* it now supports directive $M alias $TypeInfo<br />
<br />
== Version 0.8.28 ==<br />
<br />
* fixed passing static array<br />
<br />
== Version 0.8.27 ==<br />
<br />
* 4 Oct 2017<br />
* implemented resourcestrings<br />
* implemented logical xor<br />
* fixed class-of-typealias<br />
* fixed property index modifier expression<br />
<br />
== Version 0.8.26 ==<br />
<br />
* 3 Oct 2017<br />
* fixed RTTI for static arrays<br />
* implemented property modifier index<br />
* implemented FuncName:=<br />
<br />
== Version 0.8.25 ==<br />
<br />
* 1 Oct 2017<br />
* bugfixes<br />
* a new modeswitch ignoreattributes to ignore attributes.<br />
<br />
== Version 0.8.24 ==<br />
<br />
* 28 Sep 2017<br />
* implemented multi dimensional SetLength<br />
* fixed keeping old values when using SetLength<br />
* fixed method override of override<br />
<br />
== Version 0.8.23 ==<br />
<br />
* 27 Sep 2017<br />
* property default value for sets<br />
* custom integer ranges, like TValueRelationship<br />
* typecast enums to integer type (same as ord function)<br />
* new modeswitch ignoreinterfaces to parse class interfaces, but neither resolve nor convert them. Using them will cause an error.<br />
<br />
== Version 0.8.22 ==<br />
<br />
* 24 Sep 2017<br />
* fixed loading dotted units<br />
* implemented property stored and default modifiers<br />
<br />
== Version 0.8.21 ==<br />
<br />
* 21 Sep 2017<br />
* fixed aString[index]:=<br />
* fixed analyzer to mark default values of arguments<br />
* many improvements for sourcemaps making step-over/into nicer in Chrome.<br />
* new tool fpc/packages/fcl-js/examples/srcmapdump to dump the produced sourcemap.<br />
* unicodestring and widechar are now declared by the compiler instead of system.pas<br />
<br />
== Version 0.8.20 ==<br />
<br />
* 14 Sep 2017<br />
* Static array const are now implemented. For example:<br />
* array['a'..'d'] of integer = (1,2,3,4);<br />
* array[1..3] of char = 'pas';<br />
<br />
== Version 0.8.19 ==<br />
<br />
* 12 Sep 2017<br />
* several bug fixes<br />
* started static arrays:<br />
**array[2..6] of char<br />
**array['a'..'z'] of char<br />
**array[boolean] of longint<br />
**array[byte] of string<br />
**array[enum] of longint<br />
**array[char] of boolean // Note that char is widechar!<br />
**low(), high()<br />
<br />
== Version 0.8.18 ==<br />
<br />
* 6 Sep 2017<br />
* Anonymous arrays in record members are now supported:<br />
<syntaxhighlight lang="pascal"><br />
TFloatRec = Record<br />
...<br />
Digits: Array Of Char;<br />
End;<br />
</syntaxhighlight><br />
<br />
== Version 0.8.17 ==<br />
<br />
* 3 Sep 2017<br />
* checks for semicolons between statements<br />
* fixed proc type of procedure in Delphi mode<br />
* implemented @@ operator for proc types in Delphi mode.<br />
* compile time evaluation, range and overflow checking for boolean, base integer types, enums, sets, custom integer ranges, char, widechar, string, single and double.<br />
<br />
== Version 0.8.16 ==<br />
<br />
* 28 Jul 2017<br />
* bugfix release.<br />
<br />
== Version 0.8.15 ==<br />
<br />
* 8 Jul 2017<br />
* compiler can now generate source maps when passing option -Jm<br />
<br />
== Version 0.8.14 ==<br />
<br />
* 17 May 2017<br />
* now supports TObject.Free.<br />
<br />
In Delphi/FPC obj.Free works even if obj is nil. In JavaScript this would crash. And to free memory JS requires to clear all references, which is not required in Delphi/FPC. Therefore the compiler adds code to check for null, call the destructor and sets the variable to null.<br />
<br />
It does not support freeing properties and function results. For example: List[i].Free; will give a compiler error. The property setter might create side<br />
effects, which would be incompatible to Delphi/FPC.<br />
<br />
== Version 0.8.13 ==<br />
<br />
* 11 May 2017<br />
* $IF<br />
* $ELSEIF<br />
* $IFOPT<br />
* $Error<br />
* $Warning,<br />
* $Note<br />
* $Hint<br />
* And in the config files it supports #IF, #IFDEF, #IFNDEF, #ELSEIF, #ELSE, #ENDIF.<br />
<br />
== Version 0.8.12 ==<br />
<br />
* 5 May 2017<br />
* dotted unit names and namespaces.<br />
<br />
== Version 0.8.11 ==<br />
<br />
* 23 Apr 2017 <br />
* dynamic arrays can now be initialized with a constant. Same syntax as static arrays: const a: array of string = ('one', 'two');<br />
* Classes can now be declared in the unit implementation.<br />
* Unit nodejs now has a console class TNJSConsole.<br />
* I added the fpcunit package. Successful tests already work. A fail is not yet caught.<br />
<br />
== Version 0.8.10 ==<br />
<br />
* 22 Apr 2017<br />
* you can now use "if aJSValue then", which works just like the JS "if(v)".<br />
* added ParamCount, ParamStr, GetEnvironment* functions. The default is not doing much.<br />
* new package fcl_base_pas2js, containing custapp and nodejsapp: - TCustomApplication is the known class from the FCL, but with abstract methods.<br />
* TNodeJSApplication is a TCustomApplication using nodejs to read command line params and environment variables.<br />
<br />
== Version 0.8.9 ==<br />
<br />
* 21 Apr 2017<br />
*The compiler now has the types 53bit NativeInt and 52bit NativeUInt. Keep in mind that there is still no range checking.<br />
<br />
Current aliases:<br />
<pre><br />
JSInteger = NativeInt;<br />
<br />
Integer = LongInt;<br />
Cardinal = LongWord;<br />
SizeInt = NativeInt;<br />
SizeUInt = NativeUInt;<br />
PtrInt = NativeInt;<br />
PtrUInt = NativeUInt;<br />
ValSInt = NativeInt;<br />
ValUInt = NativeUInt;<br />
ValReal = Double;<br />
Real = Double;<br />
Extended = Double;<br />
<br />
Int64 = NativeInt unimplemented;<br />
QWord = NativeUInt unimplemented;<br />
Single = Double unimplemented;<br />
Comp = Int64 unimplemented;<br />
<br />
UnicodeString = String;<br />
WideString = String;<br />
WideChar = char;<br />
</pre><br />
<br />
== Version 0.8.8 ==<br />
<br />
* 20 Apr 2017<br />
* bugfix release.<br />
<br />
== Version 0.8.7 ==<br />
<br />
* 18 Apr 2017<br />
* $mod: the current module<br />
* Self: in a method with nested functions this holds the class or class instance.<br />
* overloads are now chosen like FPC/Delphi not only by type, but also by precision. This means if there are several compatible overloads, and none fits exactly it will choose the next higher. Formerly it gave an error.<br />
* cardinal is no longer a base type, but longword is. Same as FPC.<br />
<br />
== Version 0.8.6 ==<br />
<br />
* 17 Apr 2017<br />
* bugfix release.<br />
<br />
== Version 0.8.5 ==<br />
<br />
* 15 Apr 2017<br />
* bugfix for the analyzer.<br />
* supports published array properties and published records.<br />
* array properties for external classes.<br />
<br />
== Version 0.8.4 ==<br />
<br />
* 14 Apr 2017<br />
* bugfix release.<br />
<br />
== Version 0.8.3 ==<br />
<br />
* 4 Apr 2017<br />
* pas2js now has code navigation in Lazarus<br />
<br />
= Trunk =<br />
<br />
= Navigation =<br />
* Back to [[pas2js]]<br />
* Back to [[lazarus pas2js integration]]<br />
<br />
[[Category:Pas2js]]</div>Michaelhttps://wiki.freepascal.org/index.php?title=pas2js&diff=158255pas2js2024-02-21T21:51:21Z<p>Michael: /* Releases */</p>
<hr />
<div>{{pas2js(pg)}}<br />
<br />
== Pas2js : What is it ? ==<br />
<br />
=== Compiler ===<br />
<br />
Pas2js is an open source [[Pascal]] to [[JavaScript]] transpiler. It parses Object Pascal and emits JavaScript.<br />
The JavaScript is currently of level ECMAScript 5 and should run in any browser or in Node.js (target "nodejs").<br />
It is available in 5 forms:<br />
* as a library <br />
* as a command-line program<br />
* as a webserver<br />
* as a node.js program<br />
* as a program running in the browser.<br />
<br />
It transpiles from actual Pascal source, it has no intermediate .ppu files. <br />
That means all sources must always be available.<br />
<br />
Through external class definitions, the compiler can use JavaScript classes:<br />
* All classes available in the JavaScript runtime, and in the browser are available <br/>through import units (comparable to the windows or unix units for the native compiler).<br />
* For Node.js, basic support for the nodejs runtime environment is available.<br />
* An import unit for jQuery is available (libjquery)<br />
<br />
As a non commercial open source project we are always searching for helping hands. If you want to contribute see [[Pas2js How to contribute|here]].<br />
<br />
This project is '''not''' related to a similar named project on github.<br />
<br />
=== RTL ===<br />
<br />
For the generated code to work, a small JavaScript file is needed: rtl.js. It defines an object rtl.<br />
This object will start the Object Pascal code if you include a call to rtl.run() in the [[HTML]] page.<br />
<br />
<syntaxhighlight lang="html4strict"><br />
<script type="application/javascript"><br />
rtl.run()<br />
</script><br />
</syntaxhighlight><br />
pas2js can automatically include this file in the generated output, like this:<br />
<pre><br />
pas2js -Jc -Jirtl.js -Tbrowser hello.pas<br />
</pre><br />
For nodejs, the compiler will insert the call to rtl.run() automatically at the end of the generated Javascript file.<br />
<br />
There is a basic Object Pascal RTL, several units from the FPC Packages are also available<br />
* system<br />
* sysutils<br />
* Math<br />
* strutils<br />
* rtlconst<br />
* classes<br />
* contnrs<br />
* DB (yes, TDataset)<br />
* fpcunit testsuite<br />
* custapp<br />
* restconnection<br />
* js (javascript system objects)<br />
* web (browser provided objects)<br />
* libjquery (jquery is available too)<br />
* nodejs (basic node runtime environment)<br />
* typinfo<br />
* objpas<br />
* browserconsole (support writeln)<br />
* dateutils<br />
* browserapp<br />
* nodejsapp<br />
<br />
== Where to get it ==<br />
<br />
The pas2js compiler and RTL are - naturally - open source and can be downloaded and used freely.<br />
<br />
=== Releases ===<br />
<br />
The releases contain binaries for '''Windows (32 and 64bit), Linux (64 bit) and macOS'''.<br />
<br />
Installation procedure:<br />
<br />
1. Download pas2js from: <br />
* https://getpas2js.freepascal.org/<br />
: Every version has a directory with the version number.<br />
: A list of changes can be found on the changelog page [[Pas2JS Version Changes]]<br />
<br />
2. Unpack it in folder of your choice. The example below uses '''C:\lazarus\pas2js\'''. The release contains three folders:<br />
* bin - contains the compiler as executable (pas2js or pas2js.exe), a pas2js.cfg, a library and some utilities.<br />
* demo - lots of examples<br />
* packages - the Pascal units of the RTL and other packages.<br />
* tools - html2form - HTML to pascal code converter program<br />
* utils - A script to create a pas2js.cfg: createconfig.pp<br />
<br />
<br />
:[[File:Pas2js-folder.png|Pas2js Folder]]<br />
<br />
3. To use pas2js into Lazarus IDE see: https://wiki.freepascal.org/lazarus_pas2js_integration<br />
<br />
=== GIT ===<br />
<br />
The sources are available on gitlab, and a read-only mirror exists on github.<br />
<br />
The makefile expects the sources of FPC to be present under the compiler directory.<br />
You can copy/clone the FPC sources there or set enviroment variable FPCDIR.<br />
Note that a symlink to the FPC sources will not work.<br />
<br />
Cloning pas2js and fpc git repos:<br />
<br />
<syntaxhighlight lang="bash"><br />
git clone https://gitlab.com/freepascal.org/fpc/pas2js.git pas2js<br />
cd pas2js<br />
git config --local pull.rebase true<br />
git clone https://gitlab.com/freepascal.org/fpc/source.git compiler<br />
cd compiler<br />
git config --local pull.rebase true<br />
</syntaxhighlight><br />
<br />
Updating local git repos:<br />
<br />
<syntaxhighlight lang="bash"><br />
cd pas2js<br />
git pull<br />
cd compiler<br />
git pull<br />
</syntaxhighlight><br />
<br />
Switching to the fixes branch:<br />
<br />
<syntaxhighlight lang="bash"><br />
cd pas2js<br />
git checkout fixes_3_0<br />
cd compiler<br />
git checkout pas2js/fixes_3_0<br />
</syntaxhighlight><br />
<br />
=== Building on Linux/macOS ===<br />
<br />
Change to the directory and build it with:<br />
<br />
<syntaxhighlight lang="bash"><br />
make clean all<br />
</syntaxhighlight><br />
<br />
This creates ''bin/$(TargetCPU)-$(TargetOS)/pas2js'' (Windows: pas2js.exe). For example on Linux 64bit it creates ''bin/x86_64-linux/pas2js'', while under Windows 64bit it creates ''bin\x86_64-win\pas2js.exe''.<br />
And a basic config file ''bin/x86_64-linux/pas2js.cfg''.<br />
<br />
=== Building on Windows ===<br />
<br />
Make sure that you use the ''make.exe'' from fpc, not the one from Delphi by setting the<br />
'''PATH''': For example if you installed the 32-bit version of fpc in<br />
''C:\YourPathOfFPC\3.2.2'':<br />
<br />
<syntaxhighlight lang="bash"><br />
set PATH=C:\YourPathOfFPC\3.2.2\bin\i386-win32;%PATH%<br />
</syntaxhighlight><br />
<br />
If you installed the 64-bit version of fpc in C:\YourPathOfFPC\3.2.2 use<br />
<br />
<syntaxhighlight lang="bash"><br />
set PATH=C:\YourPathOfFPC\3.2.2\bin\x86-64-win64;%PATH%<br />
</syntaxhighlight><br />
<br />
Then build with<br />
<br />
<syntaxhighlight lang="bash"><br />
make clean all<br />
</syntaxhighlight><br />
<br />
If you see "Error makefile ... Command syntax error" your "set PATH" was<br />
not correct.<br />
When make all has succesfully finished it created with a 32-bit fpc the executable<br />
''bin/i386-win32/pas2js.exe'' and a basic config file<br />
''bin/i386-win32/pas2js.cfg''.<br />
<br />
=== pas2js.cfg ===<br />
<br />
When you built via '''make''', it creates a '''pas2js.cfg''' in ''bin/$(TargetCPU)-$(TargetOS)/''.<br />
<br />
You can create a basic pas2js.cfg yourself by either using ''tools/createconfig/createconfig'' or manually:<br />
<br />
For more about pas2js.cfg see here: [[pas2js.cfg]]<br />
<br />
== How to use pas2js ==<br />
<br />
The command-line arguments are kept mostly the same as the FPC command-line arguments.<br />
Error messages are also in the same format.<br />
<br />
The compiler needs access to all sources, and so you need to specify the path to the sources of <br />
all used units. <br />
<br />
As for the FPC compiler, a configuration file is supported, which has the same syntax as the FPC config file. Note that the snapshots and svn version already contains a default pas2js.cfg with unit search paths (-Fu) for the rtl and fcl. See here how for details about the [[pas2js.cfg]].<br />
<br />
Basically, the command is the same as any FPC command line. The only thing that is different is the target: ''-Tbrowser'' or ''-Tnodeejs''<br />
<br />
Here is the complete list of [[pas2js command line arguments|command line arguments]].<br />
<br />
=== for the browser ===<br />
<br />
Consider the classical:<br />
<syntaxhighlight lang="pascal"><br />
program hello;<br />
<br />
begin<br />
Writeln('Hello, world!');<br />
end.<br />
</syntaxhighlight><br />
Yes, writeln is supported. Here is how to compile it:<br />
<br />
<pre><br />
pas2js -Jc -Jirtl.js -Tbrowser hello.pas<br />
</pre><br />
When compiled succesfully, the code can be run in the browser by opening a html file in the browser with the following content:<br />
<syntaxhighlight lang="html4strict"><br />
<html><br />
<head><br />
<meta charset="utf-8"/><br />
<script type="application/javascript" src="hello.js"></script><br />
</head><br />
<body><br />
<script type="application/javascript"><br />
rtl.run();<br />
</script><br />
</body><br />
</html><br />
</syntaxhighlight><br />
<br />
The files that are needed are:<br />
* hello.html<br />
* hello.js<br />
Whether hello.html is opened by double-clicking it in the explorer or put on a server and opened with an URL, is not relevant for the functioning.<br />
<br />
The output is visible in the browser's web developer console.<br />
By including the browserconsole unit, it will be visible in the browser page:<br />
<br />
<syntaxhighlight lang="pascal"><br />
program hello;<br />
<br />
uses browserconsole;<br />
<br />
begin<br />
Writeln('Hello, world!');<br />
end.<br />
</syntaxhighlight><br />
<br />
=== for NodeJS ===<br />
<br />
<pre><br />
pas2js -Tnodejs hello.pas<br />
</pre><br />
When compiled succesfully, the code can be run in node using the following command.<br />
<pre><br />
nodejs hello.js<br />
</pre><br />
<br />
=== for modules ===<br />
Pas2js supports compiling modules:<br />
<pre><br />
pas2js -Tmodule mymodule.pas<br />
</pre><br />
When compiled succesfully, the code can be used in a web page using the following tag:<br />
<pre><br />
<script type="module" src="mymodule.js"><script><br />
</pre><br />
<br />
More info can be found on the [[pas2js_modules|Modules page]]<br />
<br />
== Supported syntax elements ==<br />
<br />
A significant amount of Object Pascal syntax is supported, including RTTI.<br />
A more detailed list can be found in the [[Pas2js Transpiler]] file in the sources.<br />
<br />
*[[Mode_Delphi|Delphi]] and [[Mode_ObjFPC|ObjFPC]] mode<br />
*[[Program]], [[Unit]]s, namespaces<br />
*[[pas2js_modules|Library]] since 2.1.0<br />
*unit initialization, but not finalization<br />
*[[Var]], [[Const]], [[Type]]<br />
*string (unicodestring), char (widechar), [[Boolean]], [[Double]], [[Byte]], [[Shortint]], [[Word]], [[Smallint]], longword, [[Longint]], nativeint(int53), nativeuint(int52), currency<br />
*resourcestrings<br />
*[[Pointer]] (as a reference to a class, array, record, pointer of record, interface, but no pointer arithmetic)<br />
*[[Record]] (but no variant records), advanced records (since 1.3)<br />
*[[Function]]s, [[Procedure]]s, nested, anonymous functions (since 1.1)<br />
*function types, of object, reference to (closures)<br />
*function arguments: default, const, var, out<br />
*[[If]]-then-else<br />
*[[For]]-do<br />
*[[Repeat]]-until<br />
*[[While]]-do<br />
*[[With]]-do<br />
*try-finally<br />
*try-except<br />
*enums<br />
*sets<br />
*arrays static, dynamic, open, multi dimensionals, array of const<br />
*String like array operations: ''a:=[1,2,3]+[1,1];''<br />
*class type, visibility, virtual, override, abstract, overload, properties, class properties, class var, class const, constructor, destructor, class constructor (since 1.5)<br />
*class-of<br />
*nested classes<br />
*interfaces: CORBA, COM, delegations, method resolution, reference counting, TVirtualInterface<br />
*external classes, vars, const<br />
*class helpers, record helpers, type helpers (since 1.3)<br />
*Enumeration for..in..do<br />
*Type alias, e.g. type TTranslateString = type string;<br />
*RTTI<br />
*asm block for embedding JavaScript directly<br />
*compiler directives (e.g. $ifdef, $if, $define, $modeswitch, $R+)<br />
*compile time and run time range checking. Overflow checking since 1.5.<br />
*attributes (since 1.5)<br />
*[[pas2js_modules|$linklib]] directive to link [[pas2js_modules|modules]].<br />
*[[pas2js_Generics|generics]] (since 1.5)<br />
*[[pas2js_resources|Resources]] (since 1.5)<br />
<br />
There are some constructs that are naturally not supported and will never be supported:<br />
*Anything involving memory pointers and pointer arithmetic.<br />
*Variant records<br />
<br />
And there are some extra constructs unique to pas2js:<br />
* '''JSValue''' - a base type representing a JavaScript value.<br />
* function Str(X[,Y,Z...]): string - same as procedure Str, except as a function<br />
*[[pas2js_AsyncAWait|async/await]]<br />
<br />
== Planned language features ==<br />
<br />
Basically, the idea is to get the pas2js transpiler up to the same level as FPC or Delphi. <br />
That means the following needs to be added:<br />
* Extended RTTI<br />
* Operator Overloading<br />
* anonymous records, e.g. ''var a: array of record w: word; end;''<br />
* [[Pas2js_Package|Packages]]<br />
<br />
Needless to say, anything requiring direct memory access is not going to be supported.<br />
<br />
== Other unimplemented features ==<br />
<br />
*Array of interface<br />
*Enums with custom values<br />
*Finalization sections, class destructors<br />
*Futures<br />
*Global properties<br />
*Inline<br />
*Library<br />
*Objects<br />
*Pointer arithmetic<br />
*Record field interface<br />
*Variants<br />
<br />
== Lazarus integration of pas2js ==<br />
<br />
Lazarus understands the concept of external classes as used by pas2js, so code completion will work.<br />
<br />
Since Lazarus 1.9 the IDE can use pas2js.exe as a normal compiler.<br />
<br />
The integration is described here: [[lazarus pas2js integration]].<br />
It is still under construction, but deep integration with lazarus is planned.<br />
<br />
== Importing Javascript classes ==<br />
<br />
To import a javascript class, one writes a normal class definition that mimics the Javascript class.<br />
It is possible to use properties. Many examples can be found in the JS, web, nodejs and libjquery units.<br />
<br />
Here is a simple example:<br />
<br />
<syntaxhighlight lang="pascal"><br />
TJSFunction = class external name 'Function'(TJSObject)<br />
private<br />
Flength: NativeInt external name 'length';<br />
Fprototyp: TJSFunction external name 'prototyp';<br />
public<br />
name: String;<br />
property prototyp: TJSFunction read Fprototyp;<br />
property length: NativeInt read Flength;<br />
function apply(thisArg: TJSObject; const ArgArray: TJSValueDynArray): JSValue; varargs;<br />
function bind(thisArg: TJSObject): JSValue; varargs;<br />
function call(thisArg: TJSObject): JSValue; varargs;<br />
end;<br />
</syntaxhighlight><br />
<br />
This declares the <code>TJSFunction</code> object : in Javascript, functions are objects. <br />
* The "<code>external name 'Function'</code>" means that you declare a Javascript class where the Javascript name of the class is 'Function'.<br />
* The <code>(TJSObject)</code> means it descends from <code>TJSObject</code> also an external class. There does not need to be an ancestor type.<br />
* Fields are declared just as in Pascal.<br />
* To declare read-only fields, a trick can be used:</b> declare the field using an <var>external name "thename"</code> modifier, and declare a read-only property with the same name.<br>(see the length declaration)<br />
* <code>Varargs</code> can be used to indicate that a function accepts any number of arguments.<br />
* <code>JSValue</code> can be used to indicate an unknown type. <br/>It is more or less equivalent to a Variant.<br />
<br />
== Create simple JS objects with the new function ==<br />
<br />
Some JS-framework functions expect an JS object as parameter. Here is how to do that in Pascal using the ''new'' function from unit ''JS'':<br />
<br />
<syntaxhighlight lang="javascript"><br />
// JavaScript:<br />
DoIt({name:"Fred", id:3, size:4.3});<br />
</syntaxhighlight><br />
<br />
<syntaxhighlight lang="pascal"><br />
// Pascal;<br />
DoIt(new(['name','Fred', 'id',3, 'size',4.3]));<br />
</syntaxhighlight><br />
<br />
You can nest it to create sub objects:<br />
<br />
<syntaxhighlight lang="javascript"><br />
// JavaScript:<br />
DoIt({name:"Fred", size:{width:3,height:2}});<br />
</syntaxhighlight><br />
<br />
<syntaxhighlight lang="pascal"><br />
// Pascal;<br />
DoIt(new(['name','Fred', 'size',new(['width',3, 'height',2])]));<br />
</syntaxhighlight><br />
<br />
You can use TJSArray._of to create JS arrays on the fly:<br />
<br />
<syntaxhighlight lang="javascript"><br />
// JavaScript:<br />
DoIt({numbers:[1,2,3]});<br />
</syntaxhighlight><br />
<br />
<syntaxhighlight lang="pascal"><br />
// Pascal;<br />
DoIt(new(['numbers',TJSArray._of(1,2,3)]));<br />
</syntaxhighlight><br />
<br />
== Resource strings ==<br />
<br />
The pas2js transpiler can generate a JSON file (extension ''.jrs'') with all the resource strings in your program.<br />
<br />
This is a quite simple file. A JSON object exists for every unit, with each json property a resource string.<br />
<br />
<pre><br />
{<br />
"trs2" : {<br />
"ResUsed" : "This resourcestring is used",<br />
"ResUnUsed" : "This resourcestring is not used",<br />
"ImplResUsed" : "This implementation resourcestring is used"<br />
},<br />
"trs1" : {<br />
"MyString" : "The very nice string we will need to translate"<br />
}<br />
}<br />
</pre><br />
<br />
This file can be translated, and the translation file can be loaded using the '''rstranslate''' unit, part of the rtl.<br />
There are demo programs which demonstrate the use of this feature.<br />
<br />
The generating of this file is controlled by the '''-Jr''' option. It can take 3 possible arguments:<br />
# ''none'' This is the default, no file is generated.<br />
# ''unit'' one file per compiled unit will be generated. This file will contain all resource strings of the unit.<br />
# ''program'' one file is generated for the main file. This fill will contain all used resource strings for the main file and all the units it uses.<br />
<br />
If you compile a program, then the ''program'' option will generate a file with all the used resource strings in your program.<br />
<br />
The above example was generated using the command:<br />
<br />
<pre><br />
pas2js -Jrprogram trs1.pp -B<br />
</pre><br />
<br />
Note that the format is different from the format used by FPC:<br />
* Identifiers in the file are case sensitive: the names must be typed as they appear in the source file.<br />
* The strings are grouped per unit, this allows to load them fasters<br />
* The hash and bytes parts are missing, they make little sense in a Javascript context.<br />
<br />
== Exceptions ==<br />
<br />
Exceptions are translated to actual Javascript exceptions. The rtl.js has several mechanisms to deal with uncaught exceptions.<br />
The basic mechanism is setting the ''showUncaughtExceptions'' to true before calling rtl.run() in your html file:<br />
<br />
<pre><br />
<script type="application/javascript"><br />
rtl.showUncaughtExceptions=true;<br />
rtl.run();<br />
</script><br />
</pre> <br />
<br />
the browser will then use a ''window.alert()'' to show uncaught exceptions. <br />
<br />
More explanations can be found in [[pas2js_exceptions]]<br />
<br />
== Debugging ==<br />
<br />
The generated Javascript source code is of course visible and debuggable in the browser. <br />
<br />
Moreover, the transpiler can generate a source map, which means that you will be able to see and debug the Pascal code in the browser.<br />
(not everything will work, but many things do. This depends on the browser too.)<br />
<br />
A source map can be generated using the command-line parameter:<br />
<br />
<pre><br />
-Jm<br />
</pre><br />
<br />
The easiest is to include the Pascal sources in the source map:<br />
<br />
<pre><br />
-Jminclude<br />
</pre><br />
<br />
By default all source filenames are relative to .js.map. You can tell the compiler to store all file names relative to a specific local base directory:<br />
<br />
<pre><br />
-Jmbasedir=DirName<br />
</pre><br />
<br />
And you can store an URL in the map, so the browser will use URL/above-relative-file-name to get the source:<br />
<br />
<pre><br />
-Jmsourceroot=URL<br />
</pre><br />
<br />
== Porting from FPC/Delphi ==<br />
<br />
See [[Porting from FPC/Delphi to pas2js|here]] for tips and traps porting code from FPC and Delphi.<br />
<br />
Delphi cannot parse some of the constructs that exist in ''pas2js'' (namely: external classes). <br />
You can create stub declarations suitable for the Delphi parser with the [[pas2js makestub|stub creator]].<br />
<br />
== Bugs ==<br />
<br />
Please report bugs in the [https://bugs.freepascal.org FPC Bug Tracker] with category ''pas2js''. <br />
<br />
== Examples ==<br />
<br />
*Time Tracking Application: https://www.devstructor.com/demos/pas2js-time/source.zip (sources: https://www.devstructor.com/demos/pas2js-time/source.zip)<br />
*Drawing and animation on canvas: http://ragnemalm.se/images/santa/santa.html (sources: http://ragnemalm.se/images/santa/)<br />
*WebGL: https://github.com/genericptr/Pas2JS-WebGL#pas2js-webgl<br />
*Allegro Web Game: https://lainz.github.io/AllegroPas2JS-Demo-Game/index.html (sources: https://github.com/lainz/AllegroPas2JS-Demo-Game)<br />
* Pas2JS (freepascal) Compiler Tutorials on RetroNick's Programming Channel: https://youtube.com/playlist?list=PLdLUbKp49uouo9UMrBDvXIoJx6j084_ef<br />
<br />
== Lazarus Widgetset ==<br />
<br />
The ultimate goal is of course to have the LCL running in the web. Discussions on this topic are delegated to a separate page. [[pas2js_widgetsets]]<br />
<br />
== FAQ ==<br />
<br />
=== Why is a simple hello world program so big? ===<br />
<br />
This is mainly due to the used rtl.js. The rtl.js contains code for Pascal modules, classes, RTTI, sets, range checks, etc and is written with big WebApps in mind, not for scripts with a few lines of code.<br />
<br />
# You can use a Javascript [[pas2js minifier|minifier]] to reduce the created Javascript<br />
# You can create your own minified rtl.js by removing all functions you don't need. Eventually this will be done automatically by pas2js.<br />
<br />
=== Why are asm blocks bad? ===<br />
<br />
Asm blocks are useful for things you cannot do with pas2js. But there are some downsides:<br />
pas2js does not parse the JS. Neither does it check the syntax, nor does it know what Pascal identifiers the code is referencing. That means any identifier only accessed by the asm block will be removed by the pas2js' optimizer.<br />
<br />
Therefore always try to do it in Pascal. Remember you can typecast values to JSValue, objects to TJSObject, arrays to TJSArray, strings to TJSString, etc to use almost all JS features.<br />
<br />
=== Why not parse asm blocks? ===<br />
<br />
Any compiletime JS parser can only do a syntax check and parse only simple JS. But since simple JS can be better written in Pascal, it is somewhat pointless and has therefore low priority.<br />
<br />
=== What about optimization X? ===<br />
<br />
See here for [[Pas2js optimizations]]<br />
<br />
== See also ==<br />
<br />
* [[pas2js html2form]] - a small tool that converts an HTML file to a Pascal class.</div>Michaelhttps://wiki.freepascal.org/index.php?title=WebAssembly&diff=157547WebAssembly2023-10-22T10:18:57Z<p>Michael: /* Running in Web Browsers */</p>
<hr />
<div>= WebAssembly =<br />
<br />
WebAssembly (abbreviated Wasm) is a binary instruction format for a stack-based virtual machine. Wasm is designed as a portable compilation target for programming languages, enabling deployment on the web for client and server applications. See the [https://webassembly.org WebAssembly] website for more information.<br />
<br />
= Free Pascal and WebAssembly =<br />
<br />
FPC supports two Wasm compilation targets: WASI and embedded. See [[WebAssembly/Compiler]] on how to build and install FPC for Wasm.<br />
<br />
[https://wasi.dev WASI] - the WebAssembly System Interface - defines an API for operating system-like features, including files and filesystems, network sockets, clocks and random numbers. These features, when implemented in web browsers as well as standalone Wasm runtimes on desktops, servers, and serverless cloud computing units, are available to Pascal programs and libraries compiled by FPC to Wasm for the WASI target. <br />
<br />
The FPC WASI RTL consists of these units:<br />
* fcl-base<br />
* fcl-css<br />
* fcl-db<br />
* fcl-hash<br />
* fcl-js<br />
* fcl-json<br />
* fcl-mustache<br />
* fcl-passrc<br />
* fcl-registry<br />
* fcl-sdo<br />
* fcl-sound<br />
* fcl-stl<br />
* fcl-xml<br />
* hash<br />
* libtar<br />
* regexpr<br />
* rtl<br />
* rtl-extra<br />
* rtl-objpas<br />
* rtl-unicode<br />
* symbolic<br />
* tplylib<br />
* webidl<br />
<br />
The FPC Wasm embedded RTL consists of these units:<br />
* rtl<br />
* rtl-extra<br />
* tplylib<br />
<br />
With respect to the embedded target, there are presently (2022) early efforts to create Wasm-related standards for cross-device/platform/architecture embedded applications. <br />
<br />
Overall, FPC's Wasm support adds to FPC's already [https://www.freepascal.org/ extensive list of compilation targets], potentially allowing Pascal programs to run in even more environments than they already do.<br />
<br />
= Demos =<br />
<br />
== Running in Web Browsers ==<br />
In each demo, the driver program is transpiled from Pascal to Javascript using [[pas2js]], and the worker program/library is compiled from Pascal to Wasm using FPC WASI target.<br />
<br />
* [https://www.freepascal.org/~michael/pas2js-demos/wasienv/terminal/ Simulated terminal input and output]<br />
* [https://www.freepascal.org/~michael/pas2js-demos/wasienv/canvas/ Drawing on HTML canvas]<br />
* [https://github.com/PierceNg/wasm-demo/ Conway's Game of Life]<br />
<br />
The Free Pascal compiler itself run in the browser:<br />
[[File:fpcwasm-1.png]]<br />
<br />
== With Standalone Runtime ==<br />
<br />
Free Pascal's source tree contains [https://gitlab.com/freepascal.org/fpc/source/-/tree/main/packages/wasmtime/examples examples] embedding the [https://github.com/bytecodealliance/wasmtime wasmtime] standalone Wasm runtime in Pascal host programs.<br />
<br />
=See Also=<br />
* [[WebAssembly/Compiler]]<br />
* [[WebAssembly/Roadmap]]<br />
* [[WebAssembly/JS]]<br />
* [[WebAssembly/Files]]<br />
* [[WebAssembly/DOM]]<br />
* [[WebAssembly/Threads]]<br />
* [[WebAssembly/JS-Promise_Integration]]<br />
* [[WebAssembly/Reference types]]<br />
<br />
There is an external pet project to create a pascal interpreter, not related to Free Pascal:<br />
* [https://faizilham.github.io/making-budget-pascal-compiler Making a budget Pascal compiler to WebAssembly]<br />
<br />
[[Category:WebAssembly]]</div>Michaelhttps://wiki.freepascal.org/index.php?title=File:fpcwasm-1.png&diff=157546File:fpcwasm-1.png2023-10-22T10:17:01Z<p>Michael: FPC running in the browser</p>
<hr />
<div>== Summary ==<br />
FPC running in the browser</div>Michaelhttps://wiki.freepascal.org/index.php?title=FPC_Dotted_RTL&diff=156989FPC Dotted RTL2023-07-30T11:02:45Z<p>Michael: Created page with "== The project == The FPC distribution has support for creating a "dotted RTL". This is a set of units from RTL/Packages where all unit names are namespaced (dotted). The u..."</p>
<hr />
<div>== The project ==<br />
<br />
The FPC distribution has support for creating a "dotted RTL". <br />
This is a set of units from RTL/Packages where all unit names are namespaced (dotted).<br />
<br />
The units that are found in Delphi 2009 (and upwards) and FPC have the same name.<br />
For units that exist in FPC but not in Delphi, the occasion has been used to make the names more consistent.<br />
New namespaces have been chosen for all packages, and the last part of the unitname has been cleaned up.<br />
<br />
The uses clause of the units in the RTL and Packages have been modified so they refer to the correct unit<br />
<br />
This is managed entirely through makefiles and fpmake.<br />
<br />
Note that fpcmake (the older tool) has no knowledge of the dotted RTL, it does not need this knowledge.<br />
<br />
The files that are dotted reside in a subdirectory ''namespaced''. <br />
They set a define and include the non-dotted unit file.<br />
<br />
== Compiling ==<br />
Only the RTL and the packages can be compiled with dotted units. <br />
The creation of dotted units is managed through the FPC_DOTTEDUNITS define in the makefiles.<br />
<br />
To make the dotted rtl you must do, in the FPC dir<br />
<pre><br />
make -C rtl FPC_DOTTEDUNITS=1 clean all<br />
make -C packages FPC_DOTTEDUNITS=1 clean all<br />
</pre><br />
and a<br />
<pre><br />
make -C rtl FPC_DOTTEDUNITS=1 install<br />
make -C packages FPC_DOTTEDUNITS=1 install<br />
</pre><br />
afterwards.<br />
<br />
== Makefiles ==<br />
<br />
Here we explain how the makefiles manage the creation of dotted RTL/Packages.<br />
<br />
=== RTL ===<br />
The Makefile.fpc files in the RTL directory have been cleaned up.<br />
The observation was made that almost all targets are common to all platforms (logical, it is the RTL).<br />
What differs per target for each os are the dependencies and possibly some compiler options.<br />
<br />
So a file was made '''inc/Makefile.rtl''', which is used as an include file for the <br />
'''Makefile.fpc''' files in the OS-Specific directories. It is entirely parametrized.<br />
<br />
In the common '''Makefile.rtl''' the following definitions are made:<br />
* For each unit, a variable '''NAMEUNIT''' is defined. For example '''SYSTEMUNIT''' or '''WINDOWSUNIT'''.<br />
::Depending on the '''FPC_DOTTEDUNITS''', this will be the non-dotted or the dotted name.<br />
* For each unit, a '''NAME_DEPS''' variable is defined that specifies the dependencies for this unit.<br />
* In the '''prerules''' section of the os-specific '''Makefile.fpc''', you can define '''NAME_DEPS_OS''' and '''NAME_DEPS_CPU''' for OS and CPU specific dependencies. <br />
:: These defines will be taken into account in the target rules (see below)<br />
:: You should only use ''NAMEUNIT$(PPUEXT)'' when defining unit dependencies, to make sure the correct unit is taken.<br />
<br />
* For each unit, 2 targets are defined:<br />
<pre><br />
name$(PPUEXT)''' : $(NAME_DEPS) $(NAME_DEPS_OS) $(NAME_DEPS_CPU)<br />
$(COMPILER) $(NAME_OPTS) $<<br />
<br />
dottedname$(PPUEXT) : $(NAME_DEPS) $(NAME_DEPS_OS) $(NAME_DEPS_CPU)<br />
$(COMPILER) $(NAME_OPTS) $<<br />
</pre><br />
Depending on '''FPC_DOTTEDUNITS''', one of these 2 units will be compiled.<br />
<br />
The common targets have been removed from the OS-specific '''Makefile.fpc''' files, but OS-Specific make <br />
rules for os-specific targets remain in these OS-specific '''Makefile.fpc''' files:<br />
<br />
* The build units. For build units ('''buildrtl'''), the uses clause of the build unit is modified so it uses either dotted or non-dotted units.<br />
* Loaders. (assembler files)<br />
* Other os-specific files.<br />
<br />
To regenerate the OS-Specific Makefiles, you must include the '''inc/Makefile.rtl''' using the -x option.<br />
For example:<br />
<pre><br />
cd rtl/linux<br />
fpcmake -x ../inc/Makefile.rtl -Tlinux<br />
</pre><br />
<br />
The '''rtl/regenmakefiles.sh''' script does this for all directories below the RTL. <br />
The '''packages/regenmakefiles.sh''' script does this for all directories in the packages. <br />
<br />
<br />
=== Packages ===<br />
Noting that, since the use of fpmake, all package makefiles were in essence the same except for the package name<br />
a single makefile exists now in '''build/Makefile.pkg'''. <br />
<br />
This file is generated from '''build/Makefile.fpc''' and contains the rules to regenerate ''fpmake'' correctly. <br />
<br />
The package-specific Makefile.fpc has been removed.<br />
All package-level Makefiles have now been replaced with a 2-line Makefile:<br />
* a single line to set the package name.<br />
* a single line to include the '''build/Makefile.pkg'''<br />
<br />
All the rest is handled by '''fpmake''', see below.<br />
<br />
Every package directory now has a 'namespaces.lst' file which contains the mapping of non-dotted to dotted unit names (see below).<br />
it also contains some rule lines that specify how to map unit paths to include paths.<br />
<br />
== fpmake ==<br />
<br />
=== working principle ===<br />
fpmake could already perfectly handle dotted names. What was needed was a way to keep the current files with as little modifications as possible.<br />
For this reason, a system was devised where the non-dotted names of units were mapped to dotted unit names.<br />
<br />
2 changes have been made in fpmake to make this possible:<br />
<br />
* It now understands a ''transformations'' file. The transformations listed in this file are applied to all target and dependency definitions.<br />
This file can be specified with a property '''NameSpaceMap''' on the '''TPackage''' object. The name is relative to the package dir. <br />
<br />
* a '''--ns''' or '''--namespace''' option was added. When added, the tranformations listed in the '''NamespaceMap''' are applied to the targets.<br />
<br />
=== Transformations file ===<br />
The transformations file is a file containing rules. There are 2 kinds of lines<br />
* A filename transformation line<br />
<pre><br />
OldFile=NewFile<br />
</pre><br />
::for example<br />
<pre><br />
src/mysql56dyn.pp=namespaced/Api.Mysql56dyn.pp<br />
</pre><br />
* a path transformation line. This is of the form<br />
<pre><br />
{<X><OP>:<dir>}[=DestDir]<br />
</pre><br />
::Here ''X'' is the path to transform, it is one of<br />
::* '''s''' the source path<br />
::* '''i''' the include path<br />
::* '''u''' the unit path<br />
:: ''OP'' is the transformation operation to perform. It is one of<br />
::* '''*'' It replaces the complete specified directory ''dir'' with ''DestDir''<br />
::* '''-'' It removes the specified ''dir'' from the search path.<br />
::* '''+'' It adds the specified ''dir'' to the search path if it was not there yet.<br />
<br />
For example<br />
<pre><br />
{s*:src/}=namespaced/<br />
</pre><br />
will replace all '''src''' directories in source paths with '''namespaced'''<br />
<pre><br />
{i+:src/}<br />
</pre><br />
Will a dd ''src'' as a include file path.<br />
<br />
== Other utilities ==<br />
The utils/dotutils directory contain some utilities to help converting a project with non-dotted names to dotted names (or both)<br />
<br />
* '''genunitnames''' takes as input a list of tranformations (nondotted=dotted) and generates UNITNAME variables for use in a Makefile.<br />
<br />
* '''addnamespacetofpake'' will add a line NameSpaceMap:='namespaces.lst' to a fpmake program source. It attempts to add this in the correct location.<br />
<br />
* '''encloseunit''' enclodes standard input in a IFDEF block<br />
<pre><br />
{$IFDEF FPC_DOTTEDUNITS}<br />
{$ENDIF FPC_DOTTEDUNITS}<br />
</pre><br />
:: if your editor supports filtering a selection in a block, this can be used to quickly enclose a a block of lines in an ifdef<br />
<br />
* '''fixuses''' takes as a parameter a list of transformations (nondotted=dotted) to apply, and as standard input a uses line.<br />
it will then transform the uses clause to a form like this:<br />
<pre><br />
{$IFDEF FPC_DOTTEDUNITS}<br />
// dotted uses clause<br />
{$ELSE}<br />
// non-dotted uses clause<br />
{$ENDIF FPC_DOTTEDUNITS}<br />
</pre><br />
:: if your editor supports filtering a selection in a block, this can be used to quickly enclose a a block of lines in the above-mentioned form<br />
<br />
* '''makedottedfiles''' will read a list of units and transform them to use a uses clause in the following form:<br />
{$IFDEF FPC_DOTTEDUNITS}<br />
// dotted uses clause<br />
{$ELSE}<br />
// non-dotted uses clause<br />
{$ENDIF FPC_DOTTEDUNITS}<br />
The unit will then be written to a new file. It has various options which are listed with the '''-h''' command-line options.<br />
<br />
* '''prefixunits''' will read a single unit and transform it to use a uses clause in the following form:<br />
{$IFDEF FPC_DOTTEDUNITS}<br />
// dotted uses clause<br />
{$ELSE}<br />
// non-dotted uses clause<br />
{$ENDIF FPC_DOTTEDUNITS}<br />
The unit will then be written to a new file. It has various options which are listed with the '''-h''' command-line options.<br />
<br />
* '''proxyunit''' is a small program that takes 2 names (non-dotted and dotted) of units and writes a dotted unit file which <br />
sets the correct define and includes the original filen.<br />
<br />
* '''reworkmakefile''' reworks makefile rules: it replaces hardcoded unit names xyz in a rule with variable XYZUNIT.<br />
::(see genunitnames for how to create the variables)<br />
<br />
* '''replaceunitnames''' replaces unit names in a makefile with the '''$(NAMEUNIT)''' macro.<br />
<br />
* '''replaceword''' replaces a word with another word in a list of files.<br />
<br />
<br />
The following units do the actual work:<br />
<br />
* '''namespacetool''' is a unit used to generate the '''namespaces.lst''' files in the packages directory, based on a list of known aliases.<br />
* '''prefixer''' is the unit used in '''makedottedfiles''' which actually rewrites the uses clause of a unit.<br />
* '''rewritemakefile''' is the unit used in '''reworkmakfile''' which does the actual work.<br />
<br />
There is a '''readme.txt''' file with more explanations, and the '''known.txt''' file contains all transformations used in RTL and packages</div>Michaelhttps://wiki.freepascal.org/index.php?title=Release_engineering&diff=156959Release engineering2023-07-25T11:25:22Z<p>Michael: /* Version number of the fpmake files */</p>
<hr />
<div>This article discusses how to make a release of the FPC compiler on various platforms.<br />
<br />
== Migration of existing SVN checkout ==<br />
<br />
The existing checkout of the 'fixes_2_2' branch can be switched to the release tag using SVN command "switch", specifically its first variant (see below). However, it's recommended to build in exported sources, not in checked out version.<br />
<br />
~/fpc>>> svn sw --help<br />
switch (sw): Update the working copy to a different URL.<br />
usage: 1. switch URL [PATH]<br />
2. switch --relocate FROM TO [PATH...]<br />
<br />
1. Update the working copy to mirror a new URL within the<br />
repository.<br />
This behaviour is similar to 'svn update', and is the way to move<br />
a working copy to a branch or tag within the same repository.<br />
<br />
2. Rewrite working copy URL metadata to reflect a syntactic change<br />
only.<br />
This is used when repository's root URL changes (such as a scheme<br />
or hostname change) but your working copy still reflects the same<br />
directory within the same repository.<br />
<br />
== Create libgdb.a and or binutils ==<br />
<br />
* If you have problems building recent binutils or libgdb's on any *nix, and the error is related to intl.h or libintl.a, reconfigure using ../<srcdir>/configure --disable-nls (assuming you use a separate builddir)<br />
* Some cygwin hints:<br />
** ensure you've installed gcc, bison and flex<br />
** use <br><tt>./configure --disable-ide --disable-libgui --disable-install-libgui</tt><br> to configure<br />
<br />
== General notes about release building ==<br />
<br />
To create a build, you always have to start with compiler from the last previous major release (e.g. 2.0.0 for all 2.0.x and 2.2.0 releases, 2.2.0 for 2.2.x, etc.), or the last previous minor release (i.e. you can use 2.0.2 for building 2.0.4).<br />
<br />
== Convert the faq.adp to faq.htm and faq.txt ==<br />
<br />
The faq's in fpcbuild/install/doc are generated from the faq.adp in the html-repository. (It's a good idea too check if the faq.adp is still up-to-date before converting it.)<br />
To do the conversion, check out the html-repository and do a 'make all'. Then create the faq.htm and .txt by:<br />
<br />
./adp2html faq.adp -m external-master.adp -p maindir=http://www.freepascal.org/ -p x=.var > faq.htm<br />
w3m -dump faq.htm > faq.txt<br />
<br />
It could be that you have to install w3m first. If the conversions are succesfull update these files in the fpcbuild-repository.<br />
<br />
== OS/CPU specific release engineering == <br />
<br />
=== FreeBSD ===<br />
<br />
[[FreeBSD specific Release Engineering]]<br />
<br />
=== Linux ===<br />
<br />
Get sources, download the fpcbuild from ftp and extract it or use a command like:<br />
<br />
git clone --branch release_3_2_2 --depth 1 --recurse-submodules --remote-submodules --shallow-submodules https://gitlab.com/freepascal.org/fpc/build.git fpcbuild<br />
rm -rf fpcbuild/.git && rm -rf fpcbuild/fpcsrc/.git && rm -rf fpcbuild/fpcdocs/.git<br />
<br />
<br />
Versions '''3.0.x and below and some special targets''' are using libgdb inside the ide to be able to debug. For those versions you have to get libgdb for your CPU from ftp://ftp.freepascal.org/pub/fpc/contrib/libgdb/, extract it into <tt>fpcbuild/fpcsrc/</tt> preserving pathes. Before building please check for files '''libiberty.a''', '''libopcode.a''' and '''libbfd.a'''. These files are often installed in directories like /usr/lib. The compiler '''must not''' be able to find them! The reason is that otherwise the compiler might use the preinstalled ones instead of the ones you put in the libgdb directory, and the preinstalled ones are not compatible with libgdb.a. If the compiler finds and uses these libraries in /usr/lib, the IDE will crash on any debugging attempt.<br />
<br />
Get the most recent docs package from the ftp site, it's called doc-pdf.tar.gz and copy it into the <tt>fpcbuild/</tt> directory.<br />
<br />
Change into <tt>fpcbuild/</tt>. Now '''become root''', or use '''fakeroot''', then execute<br />
<br />
install/makepack<br />
<br />
==== Building an rpm ====<br />
<br />
To build an RPM, change into <tt>fpcbuild</tt> and execute<br />
<br />
make rpm<br />
<br />
the documentation will be built as well and that requires a working Tex installation. To prevent the documentation from being built, execute<br />
<br />
make rpm NODOCS=1<br />
<br />
==== Building a deb ====<br />
<br />
To build an Debian Package, please refer to [[Debian Packaging]] page. Here are quick hints :<br />
<br />
- Ensure that you have at least installed the following debian packages:<br />
dpkg-dev, fakeroot<br />
<br />
- Modify the <tt>fpcbuild/install/debian/changelog</tt> file adding the following<br />
fpc (x.y.z-b) unstable; urgency=low<br />
<br />
* release candidate build<br />
<br />
-- First Last <mail@address.ext> Thu, 07 Jul 2006 23:44:00 +0100<br />
<br />
where b is package building number. Normally if '''b''' = 0, then packages will be named substituting '''b''' by the building date, otherwise it will be conserved. But this is changed because b>0 is reserved for official Debian-builds. So in fact we should always use b=0. The value for b is only replaced by the date when SNAPSHOT=1. Please note that '''z''' could be a number but also a word like 2rc1<br />
<br />
- change into <tt>fpcbuild</tt> and execute<br />
<br />
make deb [GDBLIBDIR=<path/${OS_TARGET}/${CPU_TARGET}>]<br />
<br />
the documentation will be built as well and that requires a working Tex installation. To prevent the documentation from being built, execute<br />
<br />
make deb NODOCS=1<br />
<br />
=== Dos installer ===<br />
(See also [[go32v2 development]])<br />
<br />
The basis is the fpcbuild repository, with the last release compiler as starting compiler, as always.<br />
<br />
Most recent GDB for go32v2 is 6.1.1, you can fetch it from [ftp://freepascal.stack.nl/pub/fpc/contrib/libgdb/v6.1.1/ gdb 6.1.1]. Older targets have no architecture designation, so put it in fpcsrc/libgdb/go32v2<br />
<br />
Then do a make go32v2zip in the fpcbuild/ dir. On XP this takes a really long time......<br />
<br />
[b] Note this process will not work on Vista in the default configuration, since Vista only seems to allocate 16 or 32MB for DPMI use to a dosbox (and rumour is that W7 does too), which is too little. I've tried several of the workarounds, (see [[go32v2 development]]), but as of yet, to no avail.[/b]<br />
<br />
<br />
That is, the full procedure to build a release for go32v2 is, from fpcbuild directory:<br />
<br />
# <create the fpcsrc\libgdb\go32v2 directory and copy libgdb files there><br />
# make go32v2zip OPT="-dGDB_V601"<br />
# make sourcezip<br />
# make demozip<br />
# make docsrc<br />
# make utilities<br />
# <now we have long file names packages><br />
# make shortnames<br />
<br />
=== Windows Inno setup ===<br />
<br />
The situation for Windows is pretty much similar to makepack. However, instead of a script, [[Inno Setup]] is used. Note that this is the rough principle only. For real, official releases, probably more steps (make sure install/doc/whatsnew is up to date etc, proper SVN tag) must be observed.<br />
<br />
Steps to do once only:<br />
<br />
* install Inno Setup. For FPC 3.2.2 we are trialing version 5.6.1-unicode <br />
* If support for Win9x/Win ME is needed, install an Ansi version lower than 5.5.0 (see 5.5.0 section in [http://www.jrsoftware.org/files/is5-whatsnew.htm Inno changelog]) <br />
<br />
Steps per build:<br />
<br />
* checkout fpcbuild<br />
* export it to avoid lardering source zips with GIT dirs. (git can only export archives, but extracting on the fly with cygwin tar works: mkdir ../fpcexp and then git archive main |tar xC ../fpcexp )<br />
* make sure the last FPC release is first in your path (bootstrap)<br />
* <strike>copy libgdb to its location (fpcsrc/libgdb/win32) (see e.g. http:/www.stack.nl/~marcov/mingw ). For this test release I used mingw. Pass OPT='-dUSE_MINGW_GDB'" on the make inno commandline to to select the mingw debugger for the IDE. '''obsolete: starting with 3.2.0, IDE uses MI interface on Windows''' </strike> <br />
* get "doc-pdf.zip" from FTP in the relevant version. Put it in fpcbuild/<br />
* to build the installer I ran "make inno"<br />
* inno has options to speed up compression (multithreading), but these are not used yet.<br />
* .. _WAIT_ ... :-) <br />
<br />
Tips:<br />
<br />
* if due to atypical Windows configuration the iscc.exe installation script compiler can't be found (e.g. because your program files dir is not detected properly), pass it with ISCCPROG="g:\Program Files\Inno Setup 5\ISCC.exe"<br />
* the Inno script is in fpcbuild/install/fpc.ist and is postprocessed by fpcsubst to become fpc.iss passed to Inno. fpcsubst fixes the builddir, the exact versions and optionally translates and passes NODOCS to build a release without docs.<br />
<br />
Known Issues:<br />
* No help/docs for ide. (chms must be added, and maybe even preinstalled)<br />
* If a FPC install has been done before, the installer suggests the old install dir. (often the previous release).<br />
<br />
==== Windows to x86_64 cross compiler ====<br />
<br />
* Follow the same instructions as for Windows Inno setup, but instead of "make inno OPT=...", do a:<br />
make innox64<br />
<br />
==== Windows combined 32-bit and x86_64 cross compiler in a single package ====<br />
<br />
* Follow the same instructions as for Windows Inno setup, but instead of "make inno OPT=...", do a:<br />
make innox86x64<br />
<br />
==== Windows to Android cross compiler ====<br />
<br />
* Install the latest FPC release for Windows.<br />
* Install the Android NDK.<br />
** FPC 3.2 still supports the '''android-mips''' target, but '''mips''' support is no longer available since Android NDK r17. In order to build the setup package you need to download NDK r16b from https://developer.android.com/ndk/downloads/older_releases and unpack it to some folder. <br />
* Follow the same instructions as for Windows Inno setup, but instead of "make inno OPT=...", do:<br />
make innoandroid NDK=<Path to the NDK, like C:\Users\joost\AppData\Local\Android\Sdk\ndk\r16b><br />
* When finished you will get a setup file such as <code>fpc-3.2.0.i386-win32.cross.android.exe</code> in the top level folder of the fpcbuild's source tree.<br />
<br />
==== Windows to i8086-msdos cross compiler ====<br />
<br />
* Install the latest stable version of the Open Watcom C++ compiler for Windows. As of now, this is '''open-watcom-c-win32-1.9.exe'''.<br />
* Follow the same instructions as for Windows Inno setup, but instead of "make inno OPT=...", do a:<br />
make innomsdos<br />
* Compilation takes a very long time (3-7 hours, depending on CPU speed), so be patient. The reason for that is, we build fpc 20 times (5 memory models for 4 subarchs - 8086, 80186, 80286 and 80386), using smartlinking (for which, an external assembler is launched for each function in the rtl and packages, and launching a process is slow on windows).<br />
<br />
=== Darwin (Mac OS X) - Fink ===<br />
<br />
==== Files ====<br />
<br />
# fpc-config.info<br />
# fpc.info<br />
# fpc-cross-*<br />
# fpc-doc.info<br />
#fpc-sources.info (needed by lazarus)<br />
<br />
==== 32 bit vs 64 bit ====<br />
<br />
Contrary to fpc from disk images, fpc is built as 64 bit resulting in 64bit ppcx64 as default. The main reason is that it fits better to the presence of all the 64bit C libraries in fink. Nevertheless, 32bit is still available as cross-compiler as fpc-cross-i386-darwin.<br />
<br />
==== Bootstrap Compiler ====<br />
<br />
Building the fink packages is based on a bootstrap compiler. Whereas the official FPC releases still support 10.4 and later, starting with fpc 3.0.0 the package descriptions support only 10.7 and up. Therefore, only the 64-bit compiler and no universal compiler are required as bootstrap compiler. The 64-bit bootstrap compiler is build using strip and tar commands similar to below. The description below refers to fpc up to 2.6 and any system above 10.4.<br />
<br />
Separate bootstrap compilers for each cpu would be possible, but a universal bootstrap compiler has been choosen, since it makes the installation script simpler. The increased filesize (about twice the size of a single separate bootstrap compiler) of the bootstrap compiler is considered negligible compared to the size of the complete source tarball. Reverting this decision should be doable by well chosen names for the bootstrap compiler tar balls, such as fpc-%v.%m-darwin.bootstrap.tar.bz2, with %m being the cpu. The universal bootstrap compiler is created from the separate compilers using "lipo". The file size is reduced by applying "strip" on the binaries. Although it is possible to use the previous stable release of fpc as a bootstrap compiler, it is better to use the same version, because "make cycle" becomes faster, since only two instead of three cycles are performed.<br />
<br />
This is a typical sequence of commands to produce the tar ball of a universal bootstrap compiler on an IntelMac:<br />
<br />
make all PP=PATH_TO_A_LAST_VERSION_COMPILER<br />
cp compiler/ppc386 $HOME/Desktop<br />
make distclean<br />
make all CPU_TARGET=x86_64 PP=$HOME/Desktop/ppc386<br />
cp compiler/ppcx64 $HOME/Desktop<br />
make distclean<br />
make all CPU_TARGET=powerpc PP=$HOME/Desktop/ppc386<br />
cp compiler/ppcppc $HOME/Desktop<br />
cd $HOME/Desktop<br />
strip ppc386<br />
strip ppcx64<br />
strip ppcppc<br />
lipo -create ppc386 ppcx64 ppcppc -output ppcuniversal<br />
tar -cjf fpc-VERSION.universal-darwin.bootstrap.tar.bz2 ppcuniversal<br />
md5sum *.universal-darwin.bootstrap.tar.bz2<br />
<br />
==== Usually Required Adjustments for New Releases ====<br />
<br />
These fields in the file fpc.info usually need changes (examples from version 2.1.2, a beta version of 2.2):<br />
<br />
Version: 2.1.2<br />
Source: ftp://ftp.freepascal.org/pub/fpc/beta/%v/source/fpcbuild-%v.source.tar.gz<br />
Source-MD5: a2ee4db22301cdcbda07185a7b6679b2<br />
Source2: ftp://ftp.freepascal.org/pub/fpc/beta/%v/source/fpc-%v.universal-darwin.bootstrap.tar.bz2<br />
Source2-MD5: ca5e29e3683ff6d5caa491c0adf4635e<br />
<br />
The MD5 checksums can be obtained from the error message when fetching the sources with fink or with the terminal command md5sum.<br />
<br />
The fpc-doc.info file also needs according changes in the Source and Source-MD5 fields.<br />
<br />
==== History ====<br />
<br />
2.6.* more crosscompilers<br />
<br />
2.4.0 several crosscompilers (processors and systems) added. <br />
<br />
2.2.4 minor changes.<br />
<br />
2.2.2 extra package for the config file. cross compilers for win32 and linux. execution of tests enabled.<br />
<br />
2.2.1 interims version for lazarus 0.9.24<br />
<br />
2.2.0 first version with native Intel code<br />
<br />
2.0.4 first version in stable tree (powerpc and Rosetta emulation only)<br />
<br />
1.9.8 initial version in unstable tree<br />
<br />
=== Haiku ===<br />
<br />
[[Haiku specific Release Engineering]]<br />
<br />
== Documentation building and LaTeX limits ==<br />
<br />
A lot of TeTeX distributions are configured to never use more than a very small amount of memory. The values chosen are more of the 486 era (several MBs, while now 256MB is considered "entry level").<br />
<br />
The Free Pascal documentation is fairly large, and uses a lot of labels for convenient hyperlinked PDFs and thus hits this limit.<br />
<br />
This can be remedied by modiying the save_size line in texmf.conf to<br />
<br />
save_size=10000<br />
<br />
Usually, you can also do this by environment variable.<br />
<br />
export save_size=10000<br />
pdflatex rtl.tex<br />
<br />
== Packaging system ==<br />
<br />
See [[Packaging System and dividing FPC - Lazarus into packages]]<br />
<br />
== Building the official fpc-packages ==<br />
<br />
=== Major versions ===<br />
<br />
Major versions warrant some extra attention during the release process. Primarily the problem is that trunk is never really released from, and any branch to branch from it has to potential to have (many) hidden issues. Also during betas and release candidates, more issues are found for a major branch, since some features receive wide testing for the first time.<br />
<br />
However since 2.2.2, most release engineering work for the fixes branch is performed in trunk, and then merged back to fixes, and in practice this improved this a lot. This however mainly improved the quality. The release engineering from the branchpoint from trunk till release is typically still 6-8 months.<br />
<br />
Some points to consider:<br />
<br />
* Traditionally major versions have had a beta release before the first release candidate. <br />
* before branching a major branch, update all makefiles in trunk with a recent fpcmake. This avoids that when a rarely used package is updated, one gets an immense diff on the makefile.<br />
* This is the time to remove deprecated functions. See [[major version to do]]<br />
<br />
=== Create directories on ftp ===<br />
<br />
# Create the following structure on ftp: (check which platforms are released for this version)<br />
#* {version}<br />
#** docs<br />
#** source<br />
#*** separate<br />
#**** tar<br />
#**** zip<br />
#**** short<br />
#** arm-linux<br />
#** arm-wince<br />
#** i386-freebsd<br />
#** i386-go32v2<br />
#*** separate<br />
#** i386-linux<br />
#*** deb<br />
#*** rpm<br />
#** i386-netware<br />
#** i386-netwlibc<br />
#** i386-os2<br />
#*** separate<br />
#** i386-win32<br />
#** powerpc-linux<br />
#** powerpc-macos<br />
#** powerpc-morphos<br />
#** powerpc64-linux<br />
#** sparc-linux<br />
#** x86_64-linux<br />
#*** deb<br />
#*** rpm<br />
#** x86_64-win64<br />
# Copy the extra files (asld*.zip, gdb*.zip, make*.zip) in i386-os2\separate and i386-gov32v2\separate from previous release (unless updated with new versions)<br />
<br />
=== Update the version-number ===<br />
<br />
Make sure that fpcmake points to the relevant version for the branch you are running this for. (usually from fixes)<br />
<br />
==== Version number of the Makefiles ====<br />
<br />
For the final release, update the REQUIREDVERSION(2) in the toplevel Makefile.fpc to the new version and the last release.<br />
<br />
Update the version numbers in all Makefile.fpc files containing version=... (plus regenerate all corresponding Makefiles). Do this for the fpc and fpcbuild-repositories. This can be done using the updmkver script from within the root of both repositories. The FPC_DIR environment variable has to be set to the fpcsrc-path:<br />
export FPCDIR=....../fpcbuild/fpcsrc<br />
cd fpcbuild<br />
install/updmkver {version} <br />
cd ../fpc<br />
../fpcbuild/install/updmkver {version}<br />
Replace {version} with the version number, for example 2.2.4 or 2.2.4rc1<br />
<br />
==== Version number of the fpmake files ====<br />
Update the version numbers in all fpmake.pp files in the packages directory (toplevel and build dir). <br />
These files are normal code-files so replacing the version numbers can in principle only be done manually, but there is a script updfpmkver which finds all occurences of "Version:='xxx'" where xxx can be anything. Note that this will also update all dependencies to the specified version number.<br />
cd fpc<br />
../../fpcbuild/install/updfpmkver {version}<br />
Please check the results manually. The following command searches for all occurences of "version" in all fpmake.pp files<br />
find -name fpmake.pp -exec grep -i version {} ';'<br />
<br />
==== Version number in the source & documentation files ====<br />
<br />
The version number has to be updated in the following places. <br />
<br />
FPCBuild:<br />
* /install/doc/readme.txt<br />
* /install/doc/whatsnew.txt<br />
* /install/debian/changelog <br />
* /install/debian/controls contains versions too?<br />
* /install/doc/faq.htm (sections about latest version, on final release only)<br />
* /install/doc/faq.txt (sections about latest version, on final release only)<br />
FPCDocs: (there is only a trunk-version)<br />
* /docs/fpc.sty (macro fpcversion)<br />
FPC:<br />
* /installer/install.dat (header)<br />
* /installer/install.pas (installer version and copyright year)<br />
* /compiler/version.pas<br />
* packages/chm/src/chmbase.pas <strike>and chmcmd.lpr</strike> (now compiler macro)<br />
* check the year of copyright in compiler/msg/errore.msg<br />
* check the year of copyright in packages/ide/src/fpviews.pas<br />
<br />
=== Tag version ===<br />
<br />
If the changes of the version-numbers are committed, use the createbranch script in fpcbuild to create a 'release_{version}' tag in svn. Use underscores in the version, instead of dots!<br />
./createbranch.sh tags/release_3_0_4<br />
./createbranch.sh tags/release_3_0_4_rc1<br />
<br />
=== Create the source zips ===<br />
<br />
A.s. Before doing this, update whatsnew,readme and faq in the fixes branch, so that changes can be merged from fixes to rc1/final branch.<br />
<br />
Create all the source zips.<br />
<br />
Once the version is tagged the makesource script in fpcbuild/install can create the fpc-{version}.source.tar.gz and fpc-{version}.source.zip. To build the fpcbuild-{version}.tar.gz and fpcbuild-{version}.zip use the makefpcbuild script. Before you run the scripts go to a temporary directory and become root or use fakeroot. <br />
If you want to create the sourcefile from a specific branch, you can provide it using the -svnpath parameter<br />
For example:<br />
<br />
fakeroot<br />
fpcbuild/install/makesource 3.0.4<br />
fpcbuild/install/makefpcbuild -svnpath tags/release_3_0_4_rc1 3.0.4rc1<br />
<br />
The zips for the "source/short" directory are made on a DOS / OS/2 platform (or MS Windows with an additional parameter "OS_SOURCE=go32v2" for all three commands) by executing:<br />
<br />
make sourcezip "OS_TARGET=go32v2" NOGDB=1<br />
make sourcezip "OS_TARGET=os2" NOGDB=1<br />
make shortsrc<br />
<br />
The reason for multiple invocations of make sourcezip with different parameters is the fact that make sourcezip only build ZIP files for sources supported on the particular target platform by default. Since the short version of the source ZIP files is supposed to be used on OS/2 and GO32v2 targets only at the moment, these two platforms need to be listed explicitly as a general rule (obviously, slightly simpler version is possible when running it under OS/2 or native DOS, but the example above should work everywhere).<br />
<br />
Note, in 2.6.0 "make shortsrc" doesn't seem to work anymore. For 2.6.0 and 2.6.2 the following commands were used instead (and manually pushed "n" a few times)<br />
<br />
make renametoshort NOGDB=1 "OS_SOURCE=os2" "OS_TARGET=os2" PKGPRE=os2- PKGUNITSPRE=units- ZIPSUFFIX=.source ZIPSUFFIXSHORT=src<br />
make renametoshort NOGDB=1 "OS_SOURCE=go32v2" "OS_TARGET=go32v2" PKGPRE=go32v2- PKGUNITSPRE=units- ZIPSUFFIX=.source ZIPSUFFIXSHORT=src<br />
<br />
=== Create bootstrap compiler archives ===<br />
<br />
* darwin (fink)<br />
From ppc386 and ppcppc create ppcuniversal using lipo, create .tar.bz2 archive (full name: fpc-version.universal-darwin.bootstrap.tar.bz2) and place it in the source dir.<br />
<br />
<br />
=== Documentation ===<br />
<br />
Latex takes date/time formats from the locale. Make sure your linux distro/environment variables are set to e.g. the US locale to avoid non English month names in the docs. In my case, it was simply the matter of changing the locale in the Ubuntu GUI settings app, and latex adapted.<br />
<br />
<br />
Most formats: run <br />
<br />
make alldist<br />
<br />
in fpcdocs/<br />
<br />
CHM: run fixdocs.sh but edit it first to correct the location of the fpcsrc repo.<br />
<br />
== Release schedule ==<br />
<br />
* [[FPC Release Schedule]].<br />
<br />
== Testing a release ==<br />
<br />
In general:<br />
# check all zip/deb/rpm etc files<br />
# try the installer (if available)<br />
# make sure readme.txt & whatsnew.txt are for the current version<br />
# run all executables<br />
# make cycle with newly installed binaries and sources<br />
# run testsuite<br />
# IDE<br />
## open the installed hello.pp in IDE<br />
## make a minor change in the demo in IDE & save it<br />
## view documentation in IDE, traverse 2-3 pages (at least one with screenshots)<br />
## compile the demo file in IDE<br />
## run the demo within the IDE (debugger)<br />
# Documentation (open all files)<br />
## Check PDF documentation (if available)<br />
## Check HTML documentation (if available)<br />
## Check TXT documentation (if available)<br />
<br />
Target-specific:<br />
<br />
# GO32v2<br />
## dos???.zip installation<br />
## dos???full.zip installation (over the previously installed dos???.zip to simulate updates)<br />
# OS/2<br />
## os2???.zip installation<br />
## os2???full.zip installation (over the previously installed os2???.zip to simulate updates)<br />
# Win32<br />
## Run installer<br />
# x86_64-linux and i386-linux<br />
## Test a .rpm install<br />
## Test a .deb install<br />
# darwin (fink)<br />
## fink install fpc-config fpc<br />
## fink install fpc-doc<br />
## optional on Intel-Darwin: fink install fpc-cross-***<br />
<br />
== Testers template ==<br />
<br />
See [[Testers Template]].<br />
<br />
=== Previous releases ===<br />
<br />
{| class="wikitable"<br />
|-<br />
| [[Testers 3.2.2]] || [[Testers 3.2.0]] || [[Testers 3.0.4]] ||<br />
|-<br />
| [[Testers 2.6.4]] || [[Testers 2.6.2]] || [[Testers 2.6.0]] <br />
|-<br />
| [[Testers 2.4.4]] || [[Testers 2.4.2]] || [[Testers 2.4.0]]<br />
|-<br />
| [[Testers 2.2.4]] || [[Testers 2.0.4]] || <br />
|}<br />
[[Category:FPC release]]<br />
[[Category:FPC development]]<br />
[[Category:Release engineering]]</div>Michaelhttps://wiki.freepascal.org/index.php?title=Release_engineering&diff=156958Release engineering2023-07-25T11:20:31Z<p>Michael: /* Version number of the fpmake files */</p>
<hr />
<div>This article discusses how to make a release of the FPC compiler on various platforms.<br />
<br />
== Migration of existing SVN checkout ==<br />
<br />
The existing checkout of the 'fixes_2_2' branch can be switched to the release tag using SVN command "switch", specifically its first variant (see below). However, it's recommended to build in exported sources, not in checked out version.<br />
<br />
~/fpc>>> svn sw --help<br />
switch (sw): Update the working copy to a different URL.<br />
usage: 1. switch URL [PATH]<br />
2. switch --relocate FROM TO [PATH...]<br />
<br />
1. Update the working copy to mirror a new URL within the<br />
repository.<br />
This behaviour is similar to 'svn update', and is the way to move<br />
a working copy to a branch or tag within the same repository.<br />
<br />
2. Rewrite working copy URL metadata to reflect a syntactic change<br />
only.<br />
This is used when repository's root URL changes (such as a scheme<br />
or hostname change) but your working copy still reflects the same<br />
directory within the same repository.<br />
<br />
== Create libgdb.a and or binutils ==<br />
<br />
* If you have problems building recent binutils or libgdb's on any *nix, and the error is related to intl.h or libintl.a, reconfigure using ../<srcdir>/configure --disable-nls (assuming you use a separate builddir)<br />
* Some cygwin hints:<br />
** ensure you've installed gcc, bison and flex<br />
** use <br><tt>./configure --disable-ide --disable-libgui --disable-install-libgui</tt><br> to configure<br />
<br />
== General notes about release building ==<br />
<br />
To create a build, you always have to start with compiler from the last previous major release (e.g. 2.0.0 for all 2.0.x and 2.2.0 releases, 2.2.0 for 2.2.x, etc.), or the last previous minor release (i.e. you can use 2.0.2 for building 2.0.4).<br />
<br />
== Convert the faq.adp to faq.htm and faq.txt ==<br />
<br />
The faq's in fpcbuild/install/doc are generated from the faq.adp in the html-repository. (It's a good idea too check if the faq.adp is still up-to-date before converting it.)<br />
To do the conversion, check out the html-repository and do a 'make all'. Then create the faq.htm and .txt by:<br />
<br />
./adp2html faq.adp -m external-master.adp -p maindir=http://www.freepascal.org/ -p x=.var > faq.htm<br />
w3m -dump faq.htm > faq.txt<br />
<br />
It could be that you have to install w3m first. If the conversions are succesfull update these files in the fpcbuild-repository.<br />
<br />
== OS/CPU specific release engineering == <br />
<br />
=== FreeBSD ===<br />
<br />
[[FreeBSD specific Release Engineering]]<br />
<br />
=== Linux ===<br />
<br />
Get sources, download the fpcbuild from ftp and extract it or use a command like:<br />
<br />
git clone --branch release_3_2_2 --depth 1 --recurse-submodules --remote-submodules --shallow-submodules https://gitlab.com/freepascal.org/fpc/build.git fpcbuild<br />
rm -rf fpcbuild/.git && rm -rf fpcbuild/fpcsrc/.git && rm -rf fpcbuild/fpcdocs/.git<br />
<br />
<br />
Versions '''3.0.x and below and some special targets''' are using libgdb inside the ide to be able to debug. For those versions you have to get libgdb for your CPU from ftp://ftp.freepascal.org/pub/fpc/contrib/libgdb/, extract it into <tt>fpcbuild/fpcsrc/</tt> preserving pathes. Before building please check for files '''libiberty.a''', '''libopcode.a''' and '''libbfd.a'''. These files are often installed in directories like /usr/lib. The compiler '''must not''' be able to find them! The reason is that otherwise the compiler might use the preinstalled ones instead of the ones you put in the libgdb directory, and the preinstalled ones are not compatible with libgdb.a. If the compiler finds and uses these libraries in /usr/lib, the IDE will crash on any debugging attempt.<br />
<br />
Get the most recent docs package from the ftp site, it's called doc-pdf.tar.gz and copy it into the <tt>fpcbuild/</tt> directory.<br />
<br />
Change into <tt>fpcbuild/</tt>. Now '''become root''', or use '''fakeroot''', then execute<br />
<br />
install/makepack<br />
<br />
==== Building an rpm ====<br />
<br />
To build an RPM, change into <tt>fpcbuild</tt> and execute<br />
<br />
make rpm<br />
<br />
the documentation will be built as well and that requires a working Tex installation. To prevent the documentation from being built, execute<br />
<br />
make rpm NODOCS=1<br />
<br />
==== Building a deb ====<br />
<br />
To build an Debian Package, please refer to [[Debian Packaging]] page. Here are quick hints :<br />
<br />
- Ensure that you have at least installed the following debian packages:<br />
dpkg-dev, fakeroot<br />
<br />
- Modify the <tt>fpcbuild/install/debian/changelog</tt> file adding the following<br />
fpc (x.y.z-b) unstable; urgency=low<br />
<br />
* release candidate build<br />
<br />
-- First Last <mail@address.ext> Thu, 07 Jul 2006 23:44:00 +0100<br />
<br />
where b is package building number. Normally if '''b''' = 0, then packages will be named substituting '''b''' by the building date, otherwise it will be conserved. But this is changed because b>0 is reserved for official Debian-builds. So in fact we should always use b=0. The value for b is only replaced by the date when SNAPSHOT=1. Please note that '''z''' could be a number but also a word like 2rc1<br />
<br />
- change into <tt>fpcbuild</tt> and execute<br />
<br />
make deb [GDBLIBDIR=<path/${OS_TARGET}/${CPU_TARGET}>]<br />
<br />
the documentation will be built as well and that requires a working Tex installation. To prevent the documentation from being built, execute<br />
<br />
make deb NODOCS=1<br />
<br />
=== Dos installer ===<br />
(See also [[go32v2 development]])<br />
<br />
The basis is the fpcbuild repository, with the last release compiler as starting compiler, as always.<br />
<br />
Most recent GDB for go32v2 is 6.1.1, you can fetch it from [ftp://freepascal.stack.nl/pub/fpc/contrib/libgdb/v6.1.1/ gdb 6.1.1]. Older targets have no architecture designation, so put it in fpcsrc/libgdb/go32v2<br />
<br />
Then do a make go32v2zip in the fpcbuild/ dir. On XP this takes a really long time......<br />
<br />
[b] Note this process will not work on Vista in the default configuration, since Vista only seems to allocate 16 or 32MB for DPMI use to a dosbox (and rumour is that W7 does too), which is too little. I've tried several of the workarounds, (see [[go32v2 development]]), but as of yet, to no avail.[/b]<br />
<br />
<br />
That is, the full procedure to build a release for go32v2 is, from fpcbuild directory:<br />
<br />
# <create the fpcsrc\libgdb\go32v2 directory and copy libgdb files there><br />
# make go32v2zip OPT="-dGDB_V601"<br />
# make sourcezip<br />
# make demozip<br />
# make docsrc<br />
# make utilities<br />
# <now we have long file names packages><br />
# make shortnames<br />
<br />
=== Windows Inno setup ===<br />
<br />
The situation for Windows is pretty much similar to makepack. However, instead of a script, [[Inno Setup]] is used. Note that this is the rough principle only. For real, official releases, probably more steps (make sure install/doc/whatsnew is up to date etc, proper SVN tag) must be observed.<br />
<br />
Steps to do once only:<br />
<br />
* install Inno Setup. For FPC 3.2.2 we are trialing version 5.6.1-unicode <br />
* If support for Win9x/Win ME is needed, install an Ansi version lower than 5.5.0 (see 5.5.0 section in [http://www.jrsoftware.org/files/is5-whatsnew.htm Inno changelog]) <br />
<br />
Steps per build:<br />
<br />
* checkout fpcbuild<br />
* export it to avoid lardering source zips with GIT dirs. (git can only export archives, but extracting on the fly with cygwin tar works: mkdir ../fpcexp and then git archive main |tar xC ../fpcexp )<br />
* make sure the last FPC release is first in your path (bootstrap)<br />
* <strike>copy libgdb to its location (fpcsrc/libgdb/win32) (see e.g. http:/www.stack.nl/~marcov/mingw ). For this test release I used mingw. Pass OPT='-dUSE_MINGW_GDB'" on the make inno commandline to to select the mingw debugger for the IDE. '''obsolete: starting with 3.2.0, IDE uses MI interface on Windows''' </strike> <br />
* get "doc-pdf.zip" from FTP in the relevant version. Put it in fpcbuild/<br />
* to build the installer I ran "make inno"<br />
* inno has options to speed up compression (multithreading), but these are not used yet.<br />
* .. _WAIT_ ... :-) <br />
<br />
Tips:<br />
<br />
* if due to atypical Windows configuration the iscc.exe installation script compiler can't be found (e.g. because your program files dir is not detected properly), pass it with ISCCPROG="g:\Program Files\Inno Setup 5\ISCC.exe"<br />
* the Inno script is in fpcbuild/install/fpc.ist and is postprocessed by fpcsubst to become fpc.iss passed to Inno. fpcsubst fixes the builddir, the exact versions and optionally translates and passes NODOCS to build a release without docs.<br />
<br />
Known Issues:<br />
* No help/docs for ide. (chms must be added, and maybe even preinstalled)<br />
* If a FPC install has been done before, the installer suggests the old install dir. (often the previous release).<br />
<br />
==== Windows to x86_64 cross compiler ====<br />
<br />
* Follow the same instructions as for Windows Inno setup, but instead of "make inno OPT=...", do a:<br />
make innox64<br />
<br />
==== Windows combined 32-bit and x86_64 cross compiler in a single package ====<br />
<br />
* Follow the same instructions as for Windows Inno setup, but instead of "make inno OPT=...", do a:<br />
make innox86x64<br />
<br />
==== Windows to Android cross compiler ====<br />
<br />
* Install the latest FPC release for Windows.<br />
* Install the Android NDK.<br />
** FPC 3.2 still supports the '''android-mips''' target, but '''mips''' support is no longer available since Android NDK r17. In order to build the setup package you need to download NDK r16b from https://developer.android.com/ndk/downloads/older_releases and unpack it to some folder. <br />
* Follow the same instructions as for Windows Inno setup, but instead of "make inno OPT=...", do:<br />
make innoandroid NDK=<Path to the NDK, like C:\Users\joost\AppData\Local\Android\Sdk\ndk\r16b><br />
* When finished you will get a setup file such as <code>fpc-3.2.0.i386-win32.cross.android.exe</code> in the top level folder of the fpcbuild's source tree.<br />
<br />
==== Windows to i8086-msdos cross compiler ====<br />
<br />
* Install the latest stable version of the Open Watcom C++ compiler for Windows. As of now, this is '''open-watcom-c-win32-1.9.exe'''.<br />
* Follow the same instructions as for Windows Inno setup, but instead of "make inno OPT=...", do a:<br />
make innomsdos<br />
* Compilation takes a very long time (3-7 hours, depending on CPU speed), so be patient. The reason for that is, we build fpc 20 times (5 memory models for 4 subarchs - 8086, 80186, 80286 and 80386), using smartlinking (for which, an external assembler is launched for each function in the rtl and packages, and launching a process is slow on windows).<br />
<br />
=== Darwin (Mac OS X) - Fink ===<br />
<br />
==== Files ====<br />
<br />
# fpc-config.info<br />
# fpc.info<br />
# fpc-cross-*<br />
# fpc-doc.info<br />
#fpc-sources.info (needed by lazarus)<br />
<br />
==== 32 bit vs 64 bit ====<br />
<br />
Contrary to fpc from disk images, fpc is built as 64 bit resulting in 64bit ppcx64 as default. The main reason is that it fits better to the presence of all the 64bit C libraries in fink. Nevertheless, 32bit is still available as cross-compiler as fpc-cross-i386-darwin.<br />
<br />
==== Bootstrap Compiler ====<br />
<br />
Building the fink packages is based on a bootstrap compiler. Whereas the official FPC releases still support 10.4 and later, starting with fpc 3.0.0 the package descriptions support only 10.7 and up. Therefore, only the 64-bit compiler and no universal compiler are required as bootstrap compiler. The 64-bit bootstrap compiler is build using strip and tar commands similar to below. The description below refers to fpc up to 2.6 and any system above 10.4.<br />
<br />
Separate bootstrap compilers for each cpu would be possible, but a universal bootstrap compiler has been choosen, since it makes the installation script simpler. The increased filesize (about twice the size of a single separate bootstrap compiler) of the bootstrap compiler is considered negligible compared to the size of the complete source tarball. Reverting this decision should be doable by well chosen names for the bootstrap compiler tar balls, such as fpc-%v.%m-darwin.bootstrap.tar.bz2, with %m being the cpu. The universal bootstrap compiler is created from the separate compilers using "lipo". The file size is reduced by applying "strip" on the binaries. Although it is possible to use the previous stable release of fpc as a bootstrap compiler, it is better to use the same version, because "make cycle" becomes faster, since only two instead of three cycles are performed.<br />
<br />
This is a typical sequence of commands to produce the tar ball of a universal bootstrap compiler on an IntelMac:<br />
<br />
make all PP=PATH_TO_A_LAST_VERSION_COMPILER<br />
cp compiler/ppc386 $HOME/Desktop<br />
make distclean<br />
make all CPU_TARGET=x86_64 PP=$HOME/Desktop/ppc386<br />
cp compiler/ppcx64 $HOME/Desktop<br />
make distclean<br />
make all CPU_TARGET=powerpc PP=$HOME/Desktop/ppc386<br />
cp compiler/ppcppc $HOME/Desktop<br />
cd $HOME/Desktop<br />
strip ppc386<br />
strip ppcx64<br />
strip ppcppc<br />
lipo -create ppc386 ppcx64 ppcppc -output ppcuniversal<br />
tar -cjf fpc-VERSION.universal-darwin.bootstrap.tar.bz2 ppcuniversal<br />
md5sum *.universal-darwin.bootstrap.tar.bz2<br />
<br />
==== Usually Required Adjustments for New Releases ====<br />
<br />
These fields in the file fpc.info usually need changes (examples from version 2.1.2, a beta version of 2.2):<br />
<br />
Version: 2.1.2<br />
Source: ftp://ftp.freepascal.org/pub/fpc/beta/%v/source/fpcbuild-%v.source.tar.gz<br />
Source-MD5: a2ee4db22301cdcbda07185a7b6679b2<br />
Source2: ftp://ftp.freepascal.org/pub/fpc/beta/%v/source/fpc-%v.universal-darwin.bootstrap.tar.bz2<br />
Source2-MD5: ca5e29e3683ff6d5caa491c0adf4635e<br />
<br />
The MD5 checksums can be obtained from the error message when fetching the sources with fink or with the terminal command md5sum.<br />
<br />
The fpc-doc.info file also needs according changes in the Source and Source-MD5 fields.<br />
<br />
==== History ====<br />
<br />
2.6.* more crosscompilers<br />
<br />
2.4.0 several crosscompilers (processors and systems) added. <br />
<br />
2.2.4 minor changes.<br />
<br />
2.2.2 extra package for the config file. cross compilers for win32 and linux. execution of tests enabled.<br />
<br />
2.2.1 interims version for lazarus 0.9.24<br />
<br />
2.2.0 first version with native Intel code<br />
<br />
2.0.4 first version in stable tree (powerpc and Rosetta emulation only)<br />
<br />
1.9.8 initial version in unstable tree<br />
<br />
=== Haiku ===<br />
<br />
[[Haiku specific Release Engineering]]<br />
<br />
== Documentation building and LaTeX limits ==<br />
<br />
A lot of TeTeX distributions are configured to never use more than a very small amount of memory. The values chosen are more of the 486 era (several MBs, while now 256MB is considered "entry level").<br />
<br />
The Free Pascal documentation is fairly large, and uses a lot of labels for convenient hyperlinked PDFs and thus hits this limit.<br />
<br />
This can be remedied by modiying the save_size line in texmf.conf to<br />
<br />
save_size=10000<br />
<br />
Usually, you can also do this by environment variable.<br />
<br />
export save_size=10000<br />
pdflatex rtl.tex<br />
<br />
== Packaging system ==<br />
<br />
See [[Packaging System and dividing FPC - Lazarus into packages]]<br />
<br />
== Building the official fpc-packages ==<br />
<br />
=== Major versions ===<br />
<br />
Major versions warrant some extra attention during the release process. Primarily the problem is that trunk is never really released from, and any branch to branch from it has to potential to have (many) hidden issues. Also during betas and release candidates, more issues are found for a major branch, since some features receive wide testing for the first time.<br />
<br />
However since 2.2.2, most release engineering work for the fixes branch is performed in trunk, and then merged back to fixes, and in practice this improved this a lot. This however mainly improved the quality. The release engineering from the branchpoint from trunk till release is typically still 6-8 months.<br />
<br />
Some points to consider:<br />
<br />
* Traditionally major versions have had a beta release before the first release candidate. <br />
* before branching a major branch, update all makefiles in trunk with a recent fpcmake. This avoids that when a rarely used package is updated, one gets an immense diff on the makefile.<br />
* This is the time to remove deprecated functions. See [[major version to do]]<br />
<br />
=== Create directories on ftp ===<br />
<br />
# Create the following structure on ftp: (check which platforms are released for this version)<br />
#* {version}<br />
#** docs<br />
#** source<br />
#*** separate<br />
#**** tar<br />
#**** zip<br />
#**** short<br />
#** arm-linux<br />
#** arm-wince<br />
#** i386-freebsd<br />
#** i386-go32v2<br />
#*** separate<br />
#** i386-linux<br />
#*** deb<br />
#*** rpm<br />
#** i386-netware<br />
#** i386-netwlibc<br />
#** i386-os2<br />
#*** separate<br />
#** i386-win32<br />
#** powerpc-linux<br />
#** powerpc-macos<br />
#** powerpc-morphos<br />
#** powerpc64-linux<br />
#** sparc-linux<br />
#** x86_64-linux<br />
#*** deb<br />
#*** rpm<br />
#** x86_64-win64<br />
# Copy the extra files (asld*.zip, gdb*.zip, make*.zip) in i386-os2\separate and i386-gov32v2\separate from previous release (unless updated with new versions)<br />
<br />
=== Update the version-number ===<br />
<br />
Make sure that fpcmake points to the relevant version for the branch you are running this for. (usually from fixes)<br />
<br />
==== Version number of the Makefiles ====<br />
<br />
For the final release, update the REQUIREDVERSION(2) in the toplevel Makefile.fpc to the new version and the last release.<br />
<br />
Update the version numbers in all Makefile.fpc files containing version=... (plus regenerate all corresponding Makefiles). Do this for the fpc and fpcbuild-repositories. This can be done using the updmkver script from within the root of both repositories. The FPC_DIR environment variable has to be set to the fpcsrc-path:<br />
export FPCDIR=....../fpcbuild/fpcsrc<br />
cd fpcbuild<br />
install/updmkver {version} <br />
cd ../fpc<br />
../fpcbuild/install/updmkver {version}<br />
Replace {version} with the version number, for example 2.2.4 or 2.2.4rc1<br />
<br />
==== Version number of the fpmake files ====<br />
Update the version numbers in all Makefile.fpc files in the packages directory (toplevel and build dir). <br />
These files are normal code-files so replacing the version numbers can in principle only be done manually, but there is a script updfpmkver which finds all occurences of "Version:='xxx'" where xxx can be anything. Note that this will also update all dependencies to the specified version number.<br />
cd fpc<br />
../../fpcbuild/install/updfpmkver {version}<br />
Please check the results manually. The following command searches for all occurences of "version" in all fpmake.pp files<br />
find -name fpmake.pp -exec grep -i version {} ';'<br />
<br />
==== Version number in the source & documentation files ====<br />
<br />
The version number has to be updated in the following places. <br />
<br />
FPCBuild:<br />
* /install/doc/readme.txt<br />
* /install/doc/whatsnew.txt<br />
* /install/debian/changelog <br />
* /install/debian/controls contains versions too?<br />
* /install/doc/faq.htm (sections about latest version, on final release only)<br />
* /install/doc/faq.txt (sections about latest version, on final release only)<br />
FPCDocs: (there is only a trunk-version)<br />
* /docs/fpc.sty (macro fpcversion)<br />
FPC:<br />
* /installer/install.dat (header)<br />
* /installer/install.pas (installer version and copyright year)<br />
* /compiler/version.pas<br />
* packages/chm/src/chmbase.pas <strike>and chmcmd.lpr</strike> (now compiler macro)<br />
* check the year of copyright in compiler/msg/errore.msg<br />
* check the year of copyright in packages/ide/src/fpviews.pas<br />
<br />
=== Tag version ===<br />
<br />
If the changes of the version-numbers are committed, use the createbranch script in fpcbuild to create a 'release_{version}' tag in svn. Use underscores in the version, instead of dots!<br />
./createbranch.sh tags/release_3_0_4<br />
./createbranch.sh tags/release_3_0_4_rc1<br />
<br />
=== Create the source zips ===<br />
<br />
A.s. Before doing this, update whatsnew,readme and faq in the fixes branch, so that changes can be merged from fixes to rc1/final branch.<br />
<br />
Create all the source zips.<br />
<br />
Once the version is tagged the makesource script in fpcbuild/install can create the fpc-{version}.source.tar.gz and fpc-{version}.source.zip. To build the fpcbuild-{version}.tar.gz and fpcbuild-{version}.zip use the makefpcbuild script. Before you run the scripts go to a temporary directory and become root or use fakeroot. <br />
If you want to create the sourcefile from a specific branch, you can provide it using the -svnpath parameter<br />
For example:<br />
<br />
fakeroot<br />
fpcbuild/install/makesource 3.0.4<br />
fpcbuild/install/makefpcbuild -svnpath tags/release_3_0_4_rc1 3.0.4rc1<br />
<br />
The zips for the "source/short" directory are made on a DOS / OS/2 platform (or MS Windows with an additional parameter "OS_SOURCE=go32v2" for all three commands) by executing:<br />
<br />
make sourcezip "OS_TARGET=go32v2" NOGDB=1<br />
make sourcezip "OS_TARGET=os2" NOGDB=1<br />
make shortsrc<br />
<br />
The reason for multiple invocations of make sourcezip with different parameters is the fact that make sourcezip only build ZIP files for sources supported on the particular target platform by default. Since the short version of the source ZIP files is supposed to be used on OS/2 and GO32v2 targets only at the moment, these two platforms need to be listed explicitly as a general rule (obviously, slightly simpler version is possible when running it under OS/2 or native DOS, but the example above should work everywhere).<br />
<br />
Note, in 2.6.0 "make shortsrc" doesn't seem to work anymore. For 2.6.0 and 2.6.2 the following commands were used instead (and manually pushed "n" a few times)<br />
<br />
make renametoshort NOGDB=1 "OS_SOURCE=os2" "OS_TARGET=os2" PKGPRE=os2- PKGUNITSPRE=units- ZIPSUFFIX=.source ZIPSUFFIXSHORT=src<br />
make renametoshort NOGDB=1 "OS_SOURCE=go32v2" "OS_TARGET=go32v2" PKGPRE=go32v2- PKGUNITSPRE=units- ZIPSUFFIX=.source ZIPSUFFIXSHORT=src<br />
<br />
=== Create bootstrap compiler archives ===<br />
<br />
* darwin (fink)<br />
From ppc386 and ppcppc create ppcuniversal using lipo, create .tar.bz2 archive (full name: fpc-version.universal-darwin.bootstrap.tar.bz2) and place it in the source dir.<br />
<br />
<br />
=== Documentation ===<br />
<br />
Latex takes date/time formats from the locale. Make sure your linux distro/environment variables are set to e.g. the US locale to avoid non English month names in the docs. In my case, it was simply the matter of changing the locale in the Ubuntu GUI settings app, and latex adapted.<br />
<br />
<br />
Most formats: run <br />
<br />
make alldist<br />
<br />
in fpcdocs/<br />
<br />
CHM: run fixdocs.sh but edit it first to correct the location of the fpcsrc repo.<br />
<br />
== Release schedule ==<br />
<br />
* [[FPC Release Schedule]].<br />
<br />
== Testing a release ==<br />
<br />
In general:<br />
# check all zip/deb/rpm etc files<br />
# try the installer (if available)<br />
# make sure readme.txt & whatsnew.txt are for the current version<br />
# run all executables<br />
# make cycle with newly installed binaries and sources<br />
# run testsuite<br />
# IDE<br />
## open the installed hello.pp in IDE<br />
## make a minor change in the demo in IDE & save it<br />
## view documentation in IDE, traverse 2-3 pages (at least one with screenshots)<br />
## compile the demo file in IDE<br />
## run the demo within the IDE (debugger)<br />
# Documentation (open all files)<br />
## Check PDF documentation (if available)<br />
## Check HTML documentation (if available)<br />
## Check TXT documentation (if available)<br />
<br />
Target-specific:<br />
<br />
# GO32v2<br />
## dos???.zip installation<br />
## dos???full.zip installation (over the previously installed dos???.zip to simulate updates)<br />
# OS/2<br />
## os2???.zip installation<br />
## os2???full.zip installation (over the previously installed os2???.zip to simulate updates)<br />
# Win32<br />
## Run installer<br />
# x86_64-linux and i386-linux<br />
## Test a .rpm install<br />
## Test a .deb install<br />
# darwin (fink)<br />
## fink install fpc-config fpc<br />
## fink install fpc-doc<br />
## optional on Intel-Darwin: fink install fpc-cross-***<br />
<br />
== Testers template ==<br />
<br />
See [[Testers Template]].<br />
<br />
=== Previous releases ===<br />
<br />
{| class="wikitable"<br />
|-<br />
| [[Testers 3.2.2]] || [[Testers 3.2.0]] || [[Testers 3.0.4]] ||<br />
|-<br />
| [[Testers 2.6.4]] || [[Testers 2.6.2]] || [[Testers 2.6.0]] <br />
|-<br />
| [[Testers 2.4.4]] || [[Testers 2.4.2]] || [[Testers 2.4.0]]<br />
|-<br />
| [[Testers 2.2.4]] || [[Testers 2.0.4]] || <br />
|}<br />
[[Category:FPC release]]<br />
[[Category:FPC development]]<br />
[[Category:Release engineering]]</div>Michaelhttps://wiki.freepascal.org/index.php?title=FPC_Unicode_RTL&diff=156955FPC Unicode RTL2023-07-24T21:16:04Z<p>Michael: /* The solution */</p>
<hr />
<div><br />
== The issue ==<br />
<br />
The Unicode RTL is part of an effort to create a more recent Delphi compatible RTL in Free Pascal.<br />
<br />
Currently, 2 points make creating code that will compile in Delphi and in Free Pascal difficult.<br />
* In the Delphi RTL/VCL, the string keyword means WideString (or UnicodeString): an array consisting of 2-byte characters.<br />
::In Free Pascal, String is still a single-byte character as it was before Delphi 2009..<br />
<br />
* In Delphi, units have a namespace: ''System.SysUtils'', ''VCL.Forms'' etc. <br />
::In Free Pascal, the unit names still conform to the Delphi 7 era.<br />
<br />
Free Pascal has backwards compatibility high in the list of priorities, so a complete switch from one to the other is not possible.<br />
<br />
== The solution ==<br />
<br />
2 RTLs and packages will be created from the same codebase:<br />
* The backwards compatible RTL (no namespaces, single-byte string)<br />
* The ''Unicode RTL'', which will be Delphi 2009 and upwards compatible as much as feasible.<br />
<br />
The default RTL will still be the Free Pascal, backwards compatible, RTL.<br />
<br />
=== Using unicode strings ===<br />
<br />
The Free Pascal codebase for the RTL, packages and utilities is cleaned up:<br />
<br />
* The compiler now defines 2 basic types: ''AnsiChar'' (1 byte) and ''UnicodeChar'' (2 bytes)<br />
* The system unit defines ''Char'' as an alias for one of the 2 types, using a define: '''UNICODERTL'''<br />
* The code of RTL and packages has been revised so the "string" identifier has been removed where needed.<br />
* In places where the code assumes an ''AnsiString'', the '''AnsiString''' string type is used.<br />
* In places where the code is agnostic of the actual string type the '''String''' keyword was left in place.<br />
* Similarly, ''Char'' has been replaced by ''AnsiChar'', ''PChar'' has been replaced by ''PAnsiChar''<br />
<br />
If you have code that must compile in both RTLs, you can use the following conditional compilation mechanism<br />
<pre><br />
{IF SIZEOF(CHAR)=2}<br />
// Unicode string code<br />
{$ELSE}<br />
// Ansistring string code<br />
{$ENDIF}<br />
</pre><br />
<br />
As of end of July 2023, this work is completed.<br />
<br />
Note that the compiler itself needs a single-byte rtl, compiling the compiler with the 2-byte RTL is not supported at this time.<br />
<br />
=== Using namespaced units ===<br />
<br />
The Free Pascal codebase is enhanced with namespaced units:<br />
<br />
* Using the system of include files, all available units will be made so that they exist in 2 versions: one namespaced, one not namespaced.<br />
<br />
Basically, the namespaced unit will look like<br />
<br />
<pre><br />
unit Api.Mysql57dyn;<br />
{$DEFINE FPC_DOTTEDUNITS}<br />
{$i mysql57dyn.pp}<br />
</pre><br />
as you can see, the not-namespaced unit '''mysql57dyn.pp''' is included, and it starts with:<br />
<pre><br />
{$IFNDEF FPC_DOTTEDUNITS}<br />
unit mysql57dyn;<br />
{$ENDIF FPC_DOTTEDUNITS}<br />
</pre><br />
<br />
The occasion has been used to make the unit names more consistent. <br />
While for many units, the name has been prefixed with the namespace, <br />
for equally many units, the name has been made more consistent.<br />
<br />
Depending on a define ''fpmake'' and the ''Makefiles'' will compile either the one-byte RTL or the Unicode RTL, never both together.<br />
<br />
== Compiling the Unicode RTL ==<br />
If you wish to use the 1-byte RTL, you don't need to do anything special: <br />
the makefiles will still by default create the backwards compatible RTL.<br />
<br />
The compilation of the unicode RTL rests on the use of [[FPC_Subtarget_Support|Subtarget support]].<br />
<br />
The first step is to create a configuration file next to the standard free pascal config file, called '''fpc-unicodertl.cfg''':<br />
<pre><br />
-dUNICODERTL<br />
-Municodestrings<br />
</pre><br />
<br />
When used, this configuration file does 2 things:<br />
# It defines UNICODERTL. This can be used to make the difference (where needed) between the 2 rtls.<br />
# It sets the "string" type to UnicodeString.<br />
<br />
To compile the unicode RTL is is now sufficient to execute the following commands:<br />
<pre><br />
make -C rtl clean all SUB_TARGET=unicodertl<br />
make -C packages clean all SUB_TARGET=unicodertl<br />
make -C utils clean all SUB_TARGET=unicodertl<br />
</pre><br />
To install, subsequently execute<br />
<pre><br />
make -C rtl install SUB_TARGET=unicodertl<br />
make -C packages install SUB_TARGET=unicodertl<br />
make -C utils install SUB_TARGET=unicodertl<br />
</pre><br />
<br />
At this point, this will create a non-namespaced unicode rtl.<br />
<br />
To compile your own code with the unicode RTL, you must then of course specify the unicodertl subtarget:<br />
<pre><br />
fpc -tunicodertl yourproject.pas<br />
</pre></div>Michaelhttps://wiki.freepascal.org/index.php?title=FPC_Unicode_RTL&diff=156954FPC Unicode RTL2023-07-24T21:15:41Z<p>Michael: /* Compiling the Unicode RTL */</p>
<hr />
<div><br />
== The issue ==<br />
<br />
The Unicode RTL is part of an effort to create a more recent Delphi compatible RTL in Free Pascal.<br />
<br />
Currently, 2 points make creating code that will compile in Delphi and in Free Pascal difficult.<br />
* In the Delphi RTL/VCL, the string keyword means WideString (or UnicodeString): an array consisting of 2-byte characters.<br />
::In Free Pascal, String is still a single-byte character as it was before Delphi 2009..<br />
<br />
* In Delphi, units have a namespace: ''System.SysUtils'', ''VCL.Forms'' etc. <br />
::In Free Pascal, the unit names still conform to the Delphi 7 era.<br />
<br />
Free Pascal has backwards compatibility high in the list of priorities, so a complete switch from one to the other is not possible.<br />
<br />
== The solution ==<br />
<br />
2 RTLs and packages will be created from the same codebase:<br />
* The backwards compatible RTL (no namespaces, single-byte string)<br />
* The ''Unicode RTL'', which will be Delphi 2009 and upwards compatible as much as feasible.<br />
<br />
The default RTL will still be the backwards compatible RTL.<br />
<br />
=== Using unicode strings ===<br />
<br />
The Free Pascal codebase for the RTL, packages and utilities is cleaned up:<br />
<br />
* The compiler now defines 2 basic types: ''AnsiChar'' (1 byte) and ''UnicodeChar'' (2 bytes)<br />
* The system unit defines ''Char'' as an alias for one of the 2 types, using a define: '''UNICODERTL'''<br />
* The code of RTL and packages has been revised so the "string" identifier has been removed where needed.<br />
* In places where the code assumes an ''AnsiString'', the '''AnsiString''' string type is used.<br />
* In places where the code is agnostic of the actual string type the '''String''' keyword was left in place.<br />
* Similarly, ''Char'' has been replaced by ''AnsiChar'', ''PChar'' has been replaced by ''PAnsiChar''<br />
<br />
If you have code that must compile in both RTLs, you can use the following conditional compilation mechanism<br />
<pre><br />
{IF SIZEOF(CHAR)=2}<br />
// Unicode string code<br />
{$ELSE}<br />
// Ansistring string code<br />
{$ENDIF}<br />
</pre><br />
<br />
As of end of July 2023, this work is completed.<br />
<br />
Note that the compiler itself needs a single-byte rtl, compiling the compiler with the 2-byte RTL is not supported at this time.<br />
<br />
=== Using namespaced units ===<br />
<br />
The Free Pascal codebase is enhanced with namespaced units:<br />
<br />
* Using the system of include files, all available units will be made so that they exist in 2 versions: one namespaced, one not namespaced.<br />
<br />
Basically, the namespaced unit will look like<br />
<br />
<pre><br />
unit Api.Mysql57dyn;<br />
{$DEFINE FPC_DOTTEDUNITS}<br />
{$i mysql57dyn.pp}<br />
</pre><br />
as you can see, the not-namespaced unit '''mysql57dyn.pp''' is included, and it starts with:<br />
<pre><br />
{$IFNDEF FPC_DOTTEDUNITS}<br />
unit mysql57dyn;<br />
{$ENDIF FPC_DOTTEDUNITS}<br />
</pre><br />
<br />
The occasion has been used to make the unit names more consistent. <br />
While for many units, the name has been prefixed with the namespace, <br />
for equally many units, the name has been made more consistent.<br />
<br />
Depending on a define ''fpmake'' and the ''Makefiles'' will compile either the one-byte RTL or the Unicode RTL, never both together.<br />
<br />
== Compiling the Unicode RTL ==<br />
If you wish to use the 1-byte RTL, you don't need to do anything special: <br />
the makefiles will still by default create the backwards compatible RTL.<br />
<br />
The compilation of the unicode RTL rests on the use of [[FPC_Subtarget_Support|Subtarget support]].<br />
<br />
The first step is to create a configuration file next to the standard free pascal config file, called '''fpc-unicodertl.cfg''':<br />
<pre><br />
-dUNICODERTL<br />
-Municodestrings<br />
</pre><br />
<br />
When used, this configuration file does 2 things:<br />
# It defines UNICODERTL. This can be used to make the difference (where needed) between the 2 rtls.<br />
# It sets the "string" type to UnicodeString.<br />
<br />
To compile the unicode RTL is is now sufficient to execute the following commands:<br />
<pre><br />
make -C rtl clean all SUB_TARGET=unicodertl<br />
make -C packages clean all SUB_TARGET=unicodertl<br />
make -C utils clean all SUB_TARGET=unicodertl<br />
</pre><br />
To install, subsequently execute<br />
<pre><br />
make -C rtl install SUB_TARGET=unicodertl<br />
make -C packages install SUB_TARGET=unicodertl<br />
make -C utils install SUB_TARGET=unicodertl<br />
</pre><br />
<br />
At this point, this will create a non-namespaced unicode rtl.<br />
<br />
To compile your own code with the unicode RTL, you must then of course specify the unicodertl subtarget:<br />
<pre><br />
fpc -tunicodertl yourproject.pas<br />
</pre></div>Michaelhttps://wiki.freepascal.org/index.php?title=FPC_Unicode_RTL&diff=156953FPC Unicode RTL2023-07-24T21:14:48Z<p>Michael: /* The solution */</p>
<hr />
<div><br />
== The issue ==<br />
<br />
The Unicode RTL is part of an effort to create a more recent Delphi compatible RTL in Free Pascal.<br />
<br />
Currently, 2 points make creating code that will compile in Delphi and in Free Pascal difficult.<br />
* In the Delphi RTL/VCL, the string keyword means WideString (or UnicodeString): an array consisting of 2-byte characters.<br />
::In Free Pascal, String is still a single-byte character as it was before Delphi 2009..<br />
<br />
* In Delphi, units have a namespace: ''System.SysUtils'', ''VCL.Forms'' etc. <br />
::In Free Pascal, the unit names still conform to the Delphi 7 era.<br />
<br />
Free Pascal has backwards compatibility high in the list of priorities, so a complete switch from one to the other is not possible.<br />
<br />
== The solution ==<br />
<br />
2 RTLs and packages will be created from the same codebase:<br />
* The backwards compatible RTL (no namespaces, single-byte string)<br />
* The ''Unicode RTL'', which will be Delphi 2009 and upwards compatible as much as feasible.<br />
<br />
The default RTL will still be the backwards compatible RTL.<br />
<br />
=== Using unicode strings ===<br />
<br />
The Free Pascal codebase for the RTL, packages and utilities is cleaned up:<br />
<br />
* The compiler now defines 2 basic types: ''AnsiChar'' (1 byte) and ''UnicodeChar'' (2 bytes)<br />
* The system unit defines ''Char'' as an alias for one of the 2 types, using a define: '''UNICODERTL'''<br />
* The code of RTL and packages has been revised so the "string" identifier has been removed where needed.<br />
* In places where the code assumes an ''AnsiString'', the '''AnsiString''' string type is used.<br />
* In places where the code is agnostic of the actual string type the '''String''' keyword was left in place.<br />
* Similarly, ''Char'' has been replaced by ''AnsiChar'', ''PChar'' has been replaced by ''PAnsiChar''<br />
<br />
If you have code that must compile in both RTLs, you can use the following conditional compilation mechanism<br />
<pre><br />
{IF SIZEOF(CHAR)=2}<br />
// Unicode string code<br />
{$ELSE}<br />
// Ansistring string code<br />
{$ENDIF}<br />
</pre><br />
<br />
As of end of July 2023, this work is completed.<br />
<br />
Note that the compiler itself needs a single-byte rtl, compiling the compiler with the 2-byte RTL is not supported at this time.<br />
<br />
=== Using namespaced units ===<br />
<br />
The Free Pascal codebase is enhanced with namespaced units:<br />
<br />
* Using the system of include files, all available units will be made so that they exist in 2 versions: one namespaced, one not namespaced.<br />
<br />
Basically, the namespaced unit will look like<br />
<br />
<pre><br />
unit Api.Mysql57dyn;<br />
{$DEFINE FPC_DOTTEDUNITS}<br />
{$i mysql57dyn.pp}<br />
</pre><br />
as you can see, the not-namespaced unit '''mysql57dyn.pp''' is included, and it starts with:<br />
<pre><br />
{$IFNDEF FPC_DOTTEDUNITS}<br />
unit mysql57dyn;<br />
{$ENDIF FPC_DOTTEDUNITS}<br />
</pre><br />
<br />
The occasion has been used to make the unit names more consistent. <br />
While for many units, the name has been prefixed with the namespace, <br />
for equally many units, the name has been made more consistent.<br />
<br />
Depending on a define ''fpmake'' and the ''Makefiles'' will compile either the one-byte RTL or the Unicode RTL, never both together.<br />
<br />
== Compiling the Unicode RTL ==<br />
The compilation of the unicode RTL rests on the use of [[FPC_Subtarget_Support|Subtarget support]].<br />
<br />
The first step is to create a configuration file next to the standard free pascal config file, called '''fpc-unicodertl.cfg''':<br />
<pre><br />
-dUNICODERTL<br />
-Municodestrings<br />
</pre><br />
<br />
When used, this configuration file does 2 things:<br />
# It defines UNICODERTL. This can be used to make the difference (where needed) between the 2 rtls.<br />
# It sets the "string" type to UnicodeString.<br />
<br />
To compile the unicode RTL is is now sufficient to execute the following commands:<br />
<pre><br />
make -C rtl clean all SUB_TARGET=unicodertl<br />
make -C packages clean all SUB_TARGET=unicodertl<br />
make -C utils clean all SUB_TARGET=unicodertl<br />
</pre><br />
To install, subsequently execute<br />
<pre><br />
make -C rtl install SUB_TARGET=unicodertl<br />
make -C packages install SUB_TARGET=unicodertl<br />
make -C utils install SUB_TARGET=unicodertl<br />
</pre><br />
<br />
At this point, this will create a non-namespaced unicode rtl.<br />
<br />
To compile your own code with the unicode RTL, you must then of course specify the unicodertl subtarget:<br />
<pre><br />
fpc -tunicodertl yourproject.pas<br />
</pre></div>Michaelhttps://wiki.freepascal.org/index.php?title=FPC_Unicode_RTL&diff=156952FPC Unicode RTL2023-07-24T19:21:53Z<p>Michael: Created page with " == The issue == The Unicode RTL is part of an effort to create a more recent Delphi compatible RTL in Free Pascal. Currently, 2 points make creating code that will compile..."</p>
<hr />
<div><br />
== The issue ==<br />
<br />
The Unicode RTL is part of an effort to create a more recent Delphi compatible RTL in Free Pascal.<br />
<br />
Currently, 2 points make creating code that will compile in Delphi and in Free Pascal difficult.<br />
* In the Delphi RTL/VCL, the string keyword means WideString (or UnicodeString): an array consisting of 2-byte characters.<br />
::In Free Pascal, String is still a single-byte character as it was before Delphi 2009..<br />
<br />
* In Delphi, units have a namespace: ''System.SysUtils'', ''VCL.Forms'' etc. <br />
::In Free Pascal, the unit names still conform to the Delphi 7 era.<br />
<br />
Free Pascal has backwards compatibility high in the list of priorities, so a complete switch from one to the other is not possible.<br />
<br />
== The solution ==<br />
<br />
2 RTLs and packages will be created from the same codebase:<br />
- The backwards compatible RTL (no namespaces, single-byte string)<br />
- The ''Unicode RTL'', which will be Delphi 2009 and upwards compatible as much as feasible.<br />
<br />
=== Using unicode strings ===<br />
<br />
The Free Pascal codebase for the RTL, packages and utilities is cleaned up:<br />
<br />
* The compiler now defines 2 basic types: ''AnsiChar'' (1 byte) and ''UnicodeChar'' (2 bytes)<br />
* The system unit defines ''Char'' as an alias for one of the 2 types, using a define: '''UNICODERTL'''<br />
* The code of RTL and packages has been revised so the "string" identifier has been removed where needed.<br />
* In places where the code assumes an ''AnsiString'', the '''AnsiString''' string type is used.<br />
* In places where the code is agnostic of the actual string type the '''String''' keyword was left in place.<br />
* Similarly, ''Char'' has been replaced by ''AnsiChar'', ''PChar'' has been replaced by ''PAnsiChar''<br />
<br />
If you have code that must compile in both RTLs, you can use the following conditional compilation mechanism<br />
<pre><br />
{IF SIZEOF(CHAR)=2}<br />
// Unicode string code<br />
{$ELSE}<br />
// Ansistring string code<br />
{$ENDIF}<br />
</pre><br />
<br />
As of end of July 2023, this work is completed.<br />
<br />
Note that the compiler itself needs a single-byte rtl, compiling the compiler with the 2-byte RTL is not supported at this time.<br />
<br />
=== Using namespaced units ===<br />
<br />
The Free Pascal codebase is enhanced with namespaced units:<br />
<br />
* Using the system of include files, all available units will be made so that they exist in 2 versions: one namespaced, one not namespaced.<br />
<br />
Basically, the namespaced unit will look like<br />
<br />
<pre><br />
unit Api.Mysql57dyn;<br />
{$DEFINE FPC_DOTTEDUNITS}<br />
{$i mysql57dyn.pp}<br />
</pre><br />
as you can see, the not-namespaced unit '''mysql57dyn.pp''' is included, and it starts with:<br />
<pre><br />
{$IFNDEF FPC_DOTTEDUNITS}<br />
unit mysql57dyn;<br />
{$ENDIF FPC_DOTTEDUNITS}<br />
</pre><br />
<br />
The occasion has been used to make the unit names more consistent. <br />
While for many units, the name has been prefixed with the namespace, <br />
for equally many units, the name has been made more consistent.<br />
<br />
Depending on a define ''fpmake'' and the ''Makefiles'' will compile either the one-byte RTL or the Unicode RTL, never both together.<br />
<br />
== Compiling the Unicode RTL ==<br />
The compilation of the unicode RTL rests on the use of [[FPC_Subtarget_Support|Subtarget support]].<br />
<br />
The first step is to create a configuration file next to the standard free pascal config file, called '''fpc-unicodertl.cfg''':<br />
<pre><br />
-dUNICODERTL<br />
-Municodestrings<br />
</pre><br />
<br />
When used, this configuration file does 2 things:<br />
# It defines UNICODERTL. This can be used to make the difference (where needed) between the 2 rtls.<br />
# It sets the "string" type to UnicodeString.<br />
<br />
To compile the unicode RTL is is now sufficient to execute the following commands:<br />
<pre><br />
make -C rtl clean all SUB_TARGET=unicodertl<br />
make -C packages clean all SUB_TARGET=unicodertl<br />
make -C utils clean all SUB_TARGET=unicodertl<br />
</pre><br />
To install, subsequently execute<br />
<pre><br />
make -C rtl install SUB_TARGET=unicodertl<br />
make -C packages install SUB_TARGET=unicodertl<br />
make -C utils install SUB_TARGET=unicodertl<br />
</pre><br />
<br />
At this point, this will create a non-namespaced unicode rtl.<br />
<br />
To compile your own code with the unicode RTL, you must then of course specify the unicodertl subtarget:<br />
<pre><br />
fpc -tunicodertl yourproject.pas<br />
</pre></div>Michaelhttps://wiki.freepascal.org/index.php?title=FPC_Subtarget_Support&diff=156948FPC Subtarget Support2023-07-24T16:16:01Z<p>Michael: Subtarget initial explanation.</p>
<hr />
<div><br />
As of version 3.3.1, medio 2023, FPC has support for subtargets.<br />
<br />
== What are subtargets ==<br />
A subtarget is a named set of configuration options for the compiler which is applied during compilation and installation of the RTL, <br />
Packages and utils. The compiler itself can also be compiled with a subtarget if you so desire.<br />
<br />
This named set of configuration options is supplied as a configuration file much like the default configuration file (fpc.cfg).<br />
This file is read in addition to the regular configuration file, and must have a fixed name.<br />
<br />
For example, to create a subtarget 'myfeature', you must create a configuration file<br />
called '''fpc-myfeature.cfg'''. The configuration name must be lowercase in the filename.<br />
<br />
When compiling, you can select a subtarget on the command-line using the '''-t''' compiler option:<br />
<pre><br />
fpc -tmyfeature<br />
</pre><br />
Only 1 subtarget can be specified, if you specify a second, you will get an error.<br />
<br />
If so desired, you can combine subtargets into a new subtarget with the help of the #INCLUDE directive.<br />
<br />
In the subtarget definition file, you can put any options that you would specify on the command-line or in a configuration file. <br />
<br />
For example:<br />
<pre><br />
-dUNICODERTL<br />
-Municodestrings<br />
</pre><br />
<br />
This configuration will always be loaded, also in the case when you specify '''-n'''. So in case of the following command-line<br />
<pre><br />
fpc -n -tmyfeature<br />
</pre><br />
will not load ''fpc.cfg'', but will load ''fpc-myfeature.cfg''.<br />
<br />
When you specify a subtarget, besides loading the configuration file, the compiler does 3 other things:<br />
* The '''$fpctarget''' macro will become '''CPU-OS-SUBTARGETNAME'''. For example<br />
<pre><br />
x86_64-linux-myfeature<br />
</pre><br />
* It will define a macro '''FPC_SUBTARGET_SUBTARGETNAME''' , for example:<br />
<pre><br />
FPC_SUBTARGET_MYFEATURE<br />
</pre><br />
* It will define a macro '''FPC_SUBTARGET''' with value '''SUBTARGETNAME''' , for example:<br />
<pre><br />
FPC_SUBTARGET=myfeature<br />
</pre><br />
<br />
Because the '''$fpctarget''' macro changes value when you specify a subtarget, this has an effect on the search path:<br />
<br />
The default configuration file uses this macro to specify the unit path. <br />
As a result, the compiler will search in a different directory for units. <br />
<br />
For example for linux 64-bit, if you specify '''-tmyfeature''' Instead of looking for units in the default<br />
<pre><br />
/usr/local/lib/fpc/3.3.1/x86_64-linux<br />
</pre><br />
instead, it will search in directory<br />
<pre><br />
/usr/local/lib/fpc/3.3.1/x86_64-linux-myfeature<br />
</pre><br />
<br />
<br />
== Using subtargets ==<br />
<br />
=== Using subtargets in Makefiles ===<br />
To compile the FPC rtl and packages for a subtarget, you can specify the SUB_TARGET define<br />
<pre><br />
make SUB_TARGET=myfeature clean all<br />
</pre><br />
This has 2 effects:<br />
# The compiler is called with '''-tmyfeature''' <br />
# When doing an install, the subtarget name will be appended to the installation directory.<br />
<pre><br />
make SUB_TARGET=myfeature install<br />
</pre><br />
will (on linux) install into<br />
<pre><br />
/usr/local/lib/fpc/3.3.1/x86_64-linux-myfeature<br />
</pre><br />
<br />
=== Using subtargets in fpcmake ===<br />
<br />
The default fpcmake makefile generator creates now by default makefiles that understand the SUB_TARGET option.<br />
<br />
<br />
=== Using subtargets with fpmake ===<br />
<br />
The '''fpmake''' tool also understands the subtarget concept, you can set the subtarget with the '''-s''' option.<br />
<br />
The Free Pascal rtl/packages use the subtarget concept to create the unicode RTL <br />
(where ''string''=''unicodestring'') in parallel to the regular single-byte RTL (where string=ansistring or shortstring)</div>Michaelhttps://wiki.freepascal.org/index.php?title=release_3.2.4&diff=156904release 3.2.42023-07-15T10:54:10Z<p>Michael: /* Release preparations */</p>
<hr />
<div>=== Release Issues ===<br />
<br />
The issues page is [[Issues 3.2.4]] (from [[Issues Template]] )<br />
<br />
=== Release preparations ===<br />
<br />
# For major versions check [[Release engineering#Major versions|major versions to do]]<br />
# Send a mail to fpc-devel to announce that the fixes branch is frozen for the benefit of committers that are not on core (or do not read it regularly)<br />
# Agree on deadline for changes and date for release candidate building<br />
## Contact platform maintainers who are not subscribed to the core list and notify them about upcoming release and ask them for their inputs into the release schedule<br />
### Olivier Coursiere - Haiku<br />
### Karl-Michael Schindler - Mac OS X - fink<br />
## [[#FPC-3.2.4rc1]] deadline: <br />
## [[#FPC-3.2.4]] deadline: <br />
# Check the [[Detailed 3.2.4 Todo]] list for the particular release (should be linked from [[To Do lists]]) for status of individual todo items<br />
# Check status of [http://bugs.freepascal.org/roadmap_page.php bugs assigned to that particular release] in the bugtracker<br />
# New page in Wiki named "Release_3.2.4" for release procedure with steps needed and their status (based on [[Release Template]]), at the beginning consisting of (at least) RC1 and final release sections. If it is a final release add a link it to [[Releasing]]<br />
# Create new page in Wiki with issue log for documentation of issues encountered in release candidates and their status ("Issues_3.2.4" based on [[Issues Template]])<br />
# Move merged changes from [[User Changes Trunk]] to the appropriate [[User Changes x.y.z]] page, possibly adding changes that were merged but not added to the trunk page, plus update the reference to the changes in previous release from the page for trunk so that it refers the page with changes for the new release<br />
# Update the version number/svn revision of all bug reports in mantis for which the patches were merged but that have not yet been updated (for https://gitlab.com/freepascal.org/fpc/source/-/issues/?sort=created_date&state=opened&label_name%5B%5D=FixVersion%3A%3A3.3.1&first_page_size=20 )<br />
# Ask platform maintainers and [[External_maintainers|external maintainers]] about including their platforms/builds in the new release<br />
# Check and update all .msg files<br />
## errore.msg<br />
## errord.msg<br />
## errorf.msg<br />
## errorn.msg<br />
## errorr.msg<br />
## errorrw.msg<br />
## errorues.msg<br />
## errores.msg<br />
## errorct.msg<br />
## errorhe.msg<br />
## errorheu.msg<br />
## errorptd.msg<br />
## errorptw.msg<br />
## errorpli.msg<br />
## errorpl.msg<br />
## errorid.msg<br />
# Check tools<br />
## Check version of the above mentioned tools (GNU tools, helper DLLs, UPX, etc.), and decide whether it isn't time to update some of these tools. See [[helper tools]]<br />
## Repackage and upload additional tools where needed<br />
# Update whatsnew.txt (/install/doc/whatsnew.txt)<br />
# Find testers<br />
## Create a [[Testers_3.2.4|testers]] page in Wiki (based on [[Testers Template]])<br />
## Ask in fpc-devel list for volunteers interested in testing the individual platforms / builds and list them on the newly created page (they can add themselves)<br />
# Update path and file names in /install/macosx/*.info for the new version<br />
# Update path and file names in /install/fpc.ist for the new version<br />
# Finish all source file updates<br />
# convert /html/faq.fp to /install/doc/faq.htm and /install/doc/faq.txt ([[Release engineering#Convert_the_faq.adp_to_faq.htm_and_faq.txt|more info]])<br />
<br />
=== RC1 ===<br />
<br />
-- Below is a template for every version<br />
<br />
# New directories ([[Release engineering#Create_directories_on_ftp|more info]])<br />
## Create new directories on ftp (/pub/fpc/beta/X.Y.Z-rcN or /pub/fpc/dist/X.Y.Z and cpu-os under that) <br />
## Copy the extra files (asld*.zip, gdb*.zip, make*.zip) from previous release (unless updated with new versions)<br />
# Add new section for the upcoming build in /install/debian/changelog ([[Release engineering#Building_a_deb|more info]])<br />
# Create new branch in SVN (release_X_Y_Z_rcN or release_X_Y_Z) ([[Release engineering#Tag_version|more info]])<br />
# Update version number in release branch (and, if necessary also in main branch (trunk or fixes)) ([[Release engineering#Update_the_version-number|more info]])<br />
## /compiler/version.pas<br />
## /install/doc/readme.txt<br />
## /install/doc/whatsnew.txt<br />
## /installer/install.dat (header)<br />
## /installer/install.pas (installer version)<br />
## /docs/fpc.sty (macro fpcversion)<br />
## All Makefile.fpc files containing version=... (plus regenerate all corresponding Makefiles) ([[Release engineering#Version_number_of_the_Makefiles|more info]])<br />
## All version-numbers in fpmake.pp files ([[Release engineering#Version_number_of_the_fpmake_files|more info]])<br />
# Create and upload exported fpcbuild ([[Release engineering#Create_the_source_zips|more info]])<br />
## fpcbuild-%{version}.zip<br />
## fpcbuild-%{version}.tar.gz<br />
## fpc-%{version}-source.zip<br />
## fpc-%{version}-source.tar.gz<br />
# Create and upload the documentation ([[Release engineering#Documentation building and LaTeX limits|more info]])<br />
## doc-pdf.zip<br />
## doc-html.zip<br />
## <i>doc-htm.zip</i> (not included)<br />
## doc-txt.zip<br />
## doc-ps.zip<br />
## doc-pdf.tar.gz<br />
## doc-html.tar.gz<br />
## doc-ps.tar.gz<br />
# Create and upload source zips ([[Release engineering#Create_the_source_zips|more info]])<br />
## short name version for binary packages<br />
## docs source (including link for short name version)<br />
## long name version for binary packages<br />
# Create and upload binary releases (place the name of the person who agreed to build a release behind the name of the target below)<br />
#* i386-go32v2/basic zip (just binaries)<br />
#* i386-go32v2/full zip (including docs and sources)<br />
#* i386-os2/basic zip (just binaries)<br />
#* i386-os2/full zip (including docs and sources)<br />
#* i386-win32/exe<br />
#* x86_64-win64/exe<br />
#* arm-wince/exe (cross-release)<br />
#* arm-symbian (cross-release)<br />
#* i386-symbian (cross-release)<br />
#* arm-gba (cross-release)<br />
#* arm-nds (cross-release)<br />
#* powerpc-wii (cross-release)<br />
#* i386-freebsd/tgz<br />
#* i386-linux/tar ([[Release engineering#Linux|more info]])<br />
#* i386-linux/deb ([[Release engineering#Linux|more info]])<br />
#* i386-linux/rpm ([[Release engineering#Linux|more info]])<br />
#* x86_64-linux/tar ([[Release engineering#Linux|more info]])<br />
#* x86_64-linux/deb ([[Release engineering#Linux|more info]])<br />
#* x86_64-linux/rpm ([[Release engineering#Linux|more info]])<br />
#* powerpc-linux/tar ([[Release engineering#Linux|more info]])<br />
#* powerpc64-linux/tar ([[Release engineering#Linux|more info]])<br />
#* powerpc-macosx/dmg<br />
#* i386-macosx/dmg<br />
#* i386->powerpc-macosx/dmg<br />
#* i386->ios-macosx/dmg<br />
#* x86_64-macosx/.info for fink <br />
#* powerpc-macos<br />
#* sparc-linux/tar ([[Release engineering#Linux|more info]])<br />
#* sparc-linux/deb ([[Release engineering#Linux|more info]])<br />
#* arm-linux/tar (cross-release)<br />
#* powerpc-morphos<br />
#* powerpc-amiga<br />
#* i386-netware<br />
#* i386-netwlibc<br />
#* i386-haiku<br />
#* i386-sunos/tar<br />
#* sparc-sunos/tar<br />
# Get it tested<br />
## Ask dedicated testers for testing their platforms<br />
## Consider announcing availability of the new RC in fpc-devel list<br />
# Keep track of testing in [[Testers_x.x.x|the wiki]]<br />
<br />
-- End of template for every version<br />
<br />
=== RC2 ===<br />
<br />
# Section for new RC on release pages in Wiki<br />
## Release procedure<br />
## Issue log<br />
# Look at unmerged changes in fpc and fpcbuild since the last RC and consider/ask for necessity of their inclusion in the release<br />
<br />
-- Template from above<br />
<br />
=== Final release ===<br />
<br />
# Look at unmerged changes in fpc and fpcbuild since the last RC and consider/ask for necessity of their inclusion in the release (only cosmetic changes should be included, otherwise a new RC is needed instead of final release)<br />
# Check all bugreports marked fixed with the previous fixes version, or trunk if they apply to the release. (iow if the release packages the fix). If they are fixed, set their "fixed in version" setting to the release version, and update the "fixed in revision" to the revision the fix was merged to release_ or fixes_ branch.<br />
<br />
-- Template from above<br />
<br />
=== Going public ===<br />
<br />
# Make new version numbers (release plus next odd patch number for continuing fixes) available in bug tracker (don't forget to set releases to "released", or they won't be visible to users.)<br />
# Make new version numbers (release plus next odd patch number for continuing fixes) available in testsuite db<br />
# Make new files on FTP available to wide public<br />
## <i>update symlinks</i> (no symlinks any more?)<br />
## Move the releases older than 18 months to the olddist/<version> dir.<br />
## Publish files on SourceForge.net<br />
### Upload files to SourceForge.net and add them to new "releases" for individual platforms<br />
### Mark the latest whatsnew.txt file as a "Release info" file (using properties of that file in File Manager pages)<br />
### Select this release info file for the respective folders containing the new release<br />
### Check that the right files are selected as default for the individual platforms recognized by SourceForge.net (use the latest readme.txt as the default download for "All other")<br />
### Make new "releases" on SourceForge.net accessible for users (change status to "active")<br />
### Allow automated notifications on individual SourceForge.net file release pages to be sent<br />
# Submit darwin packages to fink<br />
# Update WWW pages<br />
## /html/news.fp<br />
## /html/down/* (links to all individual files & file sizes)<br />
## /html/download.fp (version number and list of platforms)<br />
## Search for the old version number (both with and without dots) in all files under /html/down/ (e.g. using grep) and fix where necessary<br />
## /html/fpc.fp<br />
## /html/faq.fp (things like "the latest version is ...")<br />
# Update docs linked from the WWW server (http://www.freepascal.org/docs.var) to those from the new release<br />
## Unpack the html docs to docs-html on the WWW server<br />
## Unpack the PDF files (without subdirectory) to docs-pdf on ftpmaster<br />
# Create new fixes branch (only after a major release - ?.?.0)<br />
## Update version number in the trunk branch (only after a major release - ?.?.0)<br />
### /compiler/version.pas<br />
### All Makefile.fpc files containing "version=..." (plus regenerate the corresponding Makefiles)<br />
# Update version number in the fixes branch (increase the patch to next odd number)<br />
## /compiler/version.pas<br />
## all Makefile.fpc files containing "version=..." (plus regenerate the corresponding Makefiles)<br />
# Check the WWW pages<br />
## make sure http://www.freepascal.org contains the new version already<br />
## read news.html<br />
## read fpc.html<br />
## read download.html and check links to individual files<br />
# Send announcement to our mailing lists<br />
# Post announcement on the community site<br />
# Post announcement on Sourceforge.net (only "Project Administrators" may do it)<br />
# Make sure that all unfixed issues encountered during RC testing and listed on dedicated page in Wiki are documented in bug tracker too<br />
# Revise / update /html/future.fp after major versions (?.?.0)<br />
# Remove unneeded RC builds from FTP<br />
# Add the version to the versioncheck in the topfile makefile.<br />
<br />
=== See also ===<br />
* [[Release engineering]]<br />
* [[Detailed Lazarus release template todo|comparable Lazarus document]]<br />
<br />
[[Category:FPC release]]<br />
[[Category:FPC development]]<br />
[[Category:Release engineering]]</div>Michaelhttps://wiki.freepascal.org/index.php?title=release_3.2.4&diff=156903release 3.2.42023-07-15T10:49:42Z<p>Michael: Created page with "=== Release Issues === The issues page is Issues 3.2.4 (from Issues Template ) === Release preparations === # For major versions check Release engineering#Maj..."</p>
<hr />
<div>=== Release Issues ===<br />
<br />
The issues page is [[Issues 3.2.4]] (from [[Issues Template]] )<br />
<br />
=== Release preparations ===<br />
<br />
# For major versions check [[Release engineering#Major versions|major versions to do]]<br />
# Send a mail to fpc-devel to announce that the fixes branch is frozen for the benefit of committers that are not on core (or do not read it regularly)<br />
# Agree on deadline for changes and date for release candidate building<br />
## Contact platform maintainers who are not subscribed to the core list and notify them about upcoming release and ask them for their inputs into the release schedule<br />
### Olivier Coursiere - Haiku<br />
### Karl-Michael Schindler - Mac OS X - fink<br />
## [[#FPC-x.y.zrc1]] deadline: <br />
## [[#FPC-x.y.z]] deadline: <br />
# Check the [[Detailed x.y.z Todo]] list for the particular release (should be linked from [[To Do lists]]) for status of individual todo items<br />
# Check status of [http://bugs.freepascal.org/roadmap_page.php bugs assigned to that particular release] in the bugtracker<br />
# New page in Wiki named "Release_x.y.z" for release procedure with steps needed and their status (based on [[Release Template]]), at the beginning consisting of (at least) RC1 and final release sections. If it is a final release add a link it to [[Releasing]]<br />
# Create new page in Wiki with issue log for documentation of issues encountered in release candidates and their status ("Issues_x.y.z" based on [[Issues Template]])<br />
# Move merged changes from [[User Changes Trunk]] to the appropriate [[User Changes x.y.z]] page, possibly adding changes that were merged but not added to the trunk page, plus update the reference to the changes in previous release from the page for trunk so that it refers the page with changes for the new release<br />
# Update the version number/svn revision of all bug reports in mantis for which the patches were merged but that have not yet been updated (for http://bugs.freepascal.org/changelog_page.php )<br />
# Ask platform maintainers and [[External_maintainers|external maintainers]] about including their platforms/builds in the new release<br />
# Check and update all .msg files<br />
## errore.msg<br />
## errord.msg<br />
## errorf.msg<br />
## errorn.msg<br />
## errorr.msg<br />
## errorrw.msg<br />
## errorues.msg<br />
## errores.msg<br />
## errorct.msg<br />
## errorhe.msg<br />
## errorheu.msg<br />
## errorptd.msg<br />
## errorptw.msg<br />
## errorpli.msg<br />
## errorpl.msg<br />
## errorid.msg<br />
# Check tools<br />
## Check version of the above mentioned tools (GNU tools, helper DLLs, UPX, etc.), and decide whether it isn't time to update some of these tools. See [[helper tools]]<br />
## Repackage and upload additional tools where needed<br />
# Update whatsnew.txt (/install/doc/whatsnew.txt)<br />
# Find testers<br />
## Create a [[Testers_x.y.z|testers]] page in Wiki (based on [[Testers Template]])<br />
## Ask in fpc-devel list for volunteers interested in testing the individual platforms / builds and list them on the newly created page (they can add themselves)<br />
# Update path and file names in /install/macosx/*.info for the new version<br />
# Update path and file names in /install/fpc.ist for the new version<br />
# Finish all source file updates<br />
# convert /html/faq.fp to /install/doc/faq.htm and /install/doc/faq.txt ([[Release engineering#Convert_the_faq.adp_to_faq.htm_and_faq.txt|more info]])<br />
<br />
=== RC1 ===<br />
<br />
-- Below is a template for every version<br />
<br />
# New directories ([[Release engineering#Create_directories_on_ftp|more info]])<br />
## Create new directories on ftp (/pub/fpc/beta/X.Y.Z-rcN or /pub/fpc/dist/X.Y.Z and cpu-os under that) <br />
## Copy the extra files (asld*.zip, gdb*.zip, make*.zip) from previous release (unless updated with new versions)<br />
# Add new section for the upcoming build in /install/debian/changelog ([[Release engineering#Building_a_deb|more info]])<br />
# Create new branch in SVN (release_X_Y_Z_rcN or release_X_Y_Z) ([[Release engineering#Tag_version|more info]])<br />
# Update version number in release branch (and, if necessary also in main branch (trunk or fixes)) ([[Release engineering#Update_the_version-number|more info]])<br />
## /compiler/version.pas<br />
## /install/doc/readme.txt<br />
## /install/doc/whatsnew.txt<br />
## /installer/install.dat (header)<br />
## /installer/install.pas (installer version)<br />
## /docs/fpc.sty (macro fpcversion)<br />
## All Makefile.fpc files containing version=... (plus regenerate all corresponding Makefiles) ([[Release engineering#Version_number_of_the_Makefiles|more info]])<br />
## All version-numbers in fpmake.pp files ([[Release engineering#Version_number_of_the_fpmake_files|more info]])<br />
# Create and upload exported fpcbuild ([[Release engineering#Create_the_source_zips|more info]])<br />
## fpcbuild-%{version}.zip<br />
## fpcbuild-%{version}.tar.gz<br />
## fpc-%{version}-source.zip<br />
## fpc-%{version}-source.tar.gz<br />
# Create and upload the documentation ([[Release engineering#Documentation building and LaTeX limits|more info]])<br />
## doc-pdf.zip<br />
## doc-html.zip<br />
## <i>doc-htm.zip</i> (not included)<br />
## doc-txt.zip<br />
## doc-ps.zip<br />
## doc-pdf.tar.gz<br />
## doc-html.tar.gz<br />
## doc-ps.tar.gz<br />
# Create and upload source zips ([[Release engineering#Create_the_source_zips|more info]])<br />
## short name version for binary packages<br />
## docs source (including link for short name version)<br />
## long name version for binary packages<br />
# Create and upload binary releases (place the name of the person who agreed to build a release behind the name of the target below)<br />
#* i386-go32v2/basic zip (just binaries)<br />
#* i386-go32v2/full zip (including docs and sources)<br />
#* i386-os2/basic zip (just binaries)<br />
#* i386-os2/full zip (including docs and sources)<br />
#* i386-win32/exe<br />
#* x86_64-win64/exe<br />
#* arm-wince/exe (cross-release)<br />
#* arm-symbian (cross-release)<br />
#* i386-symbian (cross-release)<br />
#* arm-gba (cross-release)<br />
#* arm-nds (cross-release)<br />
#* powerpc-wii (cross-release)<br />
#* i386-freebsd/tgz<br />
#* i386-linux/tar ([[Release engineering#Linux|more info]])<br />
#* i386-linux/deb ([[Release engineering#Linux|more info]])<br />
#* i386-linux/rpm ([[Release engineering#Linux|more info]])<br />
#* x86_64-linux/tar ([[Release engineering#Linux|more info]])<br />
#* x86_64-linux/deb ([[Release engineering#Linux|more info]])<br />
#* x86_64-linux/rpm ([[Release engineering#Linux|more info]])<br />
#* powerpc-linux/tar ([[Release engineering#Linux|more info]])<br />
#* powerpc64-linux/tar ([[Release engineering#Linux|more info]])<br />
#* powerpc-macosx/dmg<br />
#* i386-macosx/dmg<br />
#* i386->powerpc-macosx/dmg<br />
#* i386->ios-macosx/dmg<br />
#* x86_64-macosx/.info for fink <br />
#* powerpc-macos<br />
#* sparc-linux/tar ([[Release engineering#Linux|more info]])<br />
#* sparc-linux/deb ([[Release engineering#Linux|more info]])<br />
#* arm-linux/tar (cross-release)<br />
#* powerpc-morphos<br />
#* powerpc-amiga<br />
#* i386-netware<br />
#* i386-netwlibc<br />
#* i386-haiku<br />
#* i386-sunos/tar<br />
#* sparc-sunos/tar<br />
# Get it tested<br />
## Ask dedicated testers for testing their platforms<br />
## Consider announcing availability of the new RC in fpc-devel list<br />
# Keep track of testing in [[Testers_x.x.x|the wiki]]<br />
<br />
-- End of template for every version<br />
<br />
=== RC2 ===<br />
<br />
# Section for new RC on release pages in Wiki<br />
## Release procedure<br />
## Issue log<br />
# Look at unmerged changes in fpc and fpcbuild since the last RC and consider/ask for necessity of their inclusion in the release<br />
<br />
-- Template from above<br />
<br />
=== Final release ===<br />
<br />
# Look at unmerged changes in fpc and fpcbuild since the last RC and consider/ask for necessity of their inclusion in the release (only cosmetic changes should be included, otherwise a new RC is needed instead of final release)<br />
# Check all bugreports marked fixed with the previous fixes version, or trunk if they apply to the release. (iow if the release packages the fix). If they are fixed, set their "fixed in version" setting to the release version, and update the "fixed in revision" to the revision the fix was merged to release_ or fixes_ branch.<br />
<br />
-- Template from above<br />
<br />
=== Going public ===<br />
<br />
# Make new version numbers (release plus next odd patch number for continuing fixes) available in bug tracker (don't forget to set releases to "released", or they won't be visible to users.)<br />
# Make new version numbers (release plus next odd patch number for continuing fixes) available in testsuite db<br />
# Make new files on FTP available to wide public<br />
## <i>update symlinks</i> (no symlinks any more?)<br />
## Move the releases older than 18 months to the olddist/<version> dir.<br />
## Publish files on SourceForge.net<br />
### Upload files to SourceForge.net and add them to new "releases" for individual platforms<br />
### Mark the latest whatsnew.txt file as a "Release info" file (using properties of that file in File Manager pages)<br />
### Select this release info file for the respective folders containing the new release<br />
### Check that the right files are selected as default for the individual platforms recognized by SourceForge.net (use the latest readme.txt as the default download for "All other")<br />
### Make new "releases" on SourceForge.net accessible for users (change status to "active")<br />
### Allow automated notifications on individual SourceForge.net file release pages to be sent<br />
# Submit darwin packages to fink<br />
# Update WWW pages<br />
## /html/news.fp<br />
## /html/down/* (links to all individual files & file sizes)<br />
## /html/download.fp (version number and list of platforms)<br />
## Search for the old version number (both with and without dots) in all files under /html/down/ (e.g. using grep) and fix where necessary<br />
## /html/fpc.fp<br />
## /html/faq.fp (things like "the latest version is ...")<br />
# Update docs linked from the WWW server (http://www.freepascal.org/docs.var) to those from the new release<br />
## Unpack the html docs to docs-html on the WWW server<br />
## Unpack the PDF files (without subdirectory) to docs-pdf on ftpmaster<br />
# Create new fixes branch (only after a major release - ?.?.0)<br />
## Update version number in the trunk branch (only after a major release - ?.?.0)<br />
### /compiler/version.pas<br />
### All Makefile.fpc files containing "version=..." (plus regenerate the corresponding Makefiles)<br />
# Update version number in the fixes branch (increase the patch to next odd number)<br />
## /compiler/version.pas<br />
## all Makefile.fpc files containing "version=..." (plus regenerate the corresponding Makefiles)<br />
# Check the WWW pages<br />
## make sure http://www.freepascal.org contains the new version already<br />
## read news.html<br />
## read fpc.html<br />
## read download.html and check links to individual files<br />
# Send announcement to our mailing lists<br />
# Post announcement on the community site<br />
# Post announcement on Sourceforge.net (only "Project Administrators" may do it)<br />
# Make sure that all unfixed issues encountered during RC testing and listed on dedicated page in Wiki are documented in bug tracker too<br />
# Revise / update /html/future.fp after major versions (?.?.0)<br />
# Remove unneeded RC builds from FTP<br />
# Add the version to the versioncheck in the topfile makefile.<br />
<br />
=== See also ===<br />
* [[Release engineering]]<br />
* [[Detailed Lazarus release template todo|comparable Lazarus document]]<br />
<br />
[[Category:FPC release]]<br />
[[Category:FPC development]]<br />
[[Category:Release engineering]]</div>Michaelhttps://wiki.freepascal.org/index.php?title=IDE_Macros_in_paths_and_filenames&diff=156445IDE Macros in paths and filenames2023-05-18T08:57:01Z<p>Michael: /* ProjectGroups */</p>
<hr />
<div>{{IDE Macros in paths and filenames}}<br />
<br />
==Types of Macros==<br />
<br />
There are various types of macros:<br />
*'''IDE macros''': they can be used in almost all IDE fields, e.g. search paths, custom options, file names, run parameters. They are replaced with their value before calling external tools like the compiler or the debugger. They are case insensitive.<br />
*'''FPC symbols''': these are either defined (on) or undefined (off). They are passed via the command line option '''-d''', which can be set under ''Compiler Options / Custom Options''. For example ''-dDEBUG -dVerbose'' will define the FPC symbols DEBUG and Verbose, so you can use ''{$IFDEF Debug}''. They are case insensitive.<br />
*'''FPC macros''': they are e.g. specified via code like {$define MYFPCMACRO:=42}. An example of a predefined macro is FPC_FULLVERSION.<br />
*'''Build macros''': they are IDE macros with a limited scope. They are defined by projects and packages and are case insensitive.<br />
*Some IDE plugins have their own macros.<br />
<br />
==IDE macro format==<br />
<br />
IDE macros are used in the following format. Replace the ''macro-name'' part with one of the macros listed below.<br />
<br />
$(macro-name)<br />
<br />
For example: This "Unit Output directory" is often used for Lazarus Packages:<br />
<br />
lib/$(TargetCPU)-$(TargetOS)<br />
<br />
*under a x86 Linux 32-bit system that would equate to: '''lib/i386-linux'''<br />
*under a x86 Linux 64-bit system that would equate to: '''lib/x86_64-linux'''<br />
<br />
There are also some '''macro functions''' that use the following format:<br />
$macro_name(parameters)<br />
<br />
For example<br />
$Ext(unit1.pas)<br />
<br />
will give ''.pas''.<br />
<br />
<br />
'''''Windows:''''' Compiling to a RamDrive where each project gets its own unit directory (Project> Options> Unit Output Directory)<br />
<br />
R:\FPC\$NameOnly($(ProjFile))<br />
<br />
<br />
'''''MacOS:''''' A more complex example but very useful, when you want to compile on its name '''''$NameOnly($(ProjFile))''''' on a specific CPU target '''''-$(TargetCPU)''''' saving the compiled file on the package path '''''.app/Contents/MacOS/'''''<br />
<br />
$NameOnly($(ProjFile))-$(TargetCPU).app/Contents/MacOS/$NameOnly($(ProjFile))-$(TargetCPU)<br />
<br />
==General Purpose==<br />
* '''Col''' - current column in source editor<br />
* '''Row''' - current row in source editor (screen, can differ to byte position due to tabs and UTF-8)<br />
* '''CurToken''' - current token at the cursor in the source editor<br />
* '''EdFile''' - current filename in the source editor<br />
* '''Params''' - run parameters of the current project<br />
* '''Prompt''' - ask the user for a value. This is an interactive macro.<br />
* '''RunCmdLine''' - the command to launch the project<br />
* '''Save''' - save current file in source editor<br />
* '''SaveAll''' - save all<br />
* '''TargetCmdLine''' - the project executable (or host / i.e.: "$TargetFile") plus run parameters<br />
<br />
==Filename Parts==<br />
* '''Ext(filename)''' - macro function for ExtractFileExt. Example: will return .exe on Windows.<br />
* '''MakeDir(filename)''' - macro function for AppendPathDelim<br />
* '''MakeFile(filename)''' - macro function for ChompPathDelim<br />
* '''MakeExe(filename)''' - change file extension to .exe under Windows, nothing under Linux, BSD, macOS. When cross compiling it will create a file name for the target OS. To get the file name of the host OS use $MakeExe(ide,filename). To get the file name of a specific OS use $MakeExe(os,filename). The two parameter variant exists since 1.1.<br />
* '''MakeLib(filename)''' - change file extension to .dll under Windows, under Linux/BSD change to lowercase libname.so, under macOS to libname.so (since 0.9.29)<br />
* '''Name(filename)''' - macro function for ExtractFileName<br />
* '''NameOnly(filename)''' - macro function for ExtractFileNameOnly<br />
* '''Path(filename)''' - macro function for ExtractFilePath<br />
<br />
==Paths and Parts==<br />
* '''CompPath''' - compiler path. Before 1.3 it returned the value of the IDE option (''Tools / Options ...''). It cannot use the macros FPCVer, FPC_FULLVERSION, because these macros are retrieved from the compiler. You can use the macros TargetOS, TargetCPU, SrcOS '''only''' if you set them. You can use LazarusDir and Env macros. Since 1.3 the macro returns the compiler of the project. It returns the default IDE option value:<br />
** when using the parameter ''IDE'': $CompPath(IDE)<br />
** in the project compiler option itself<br />
** when the project compiler is disabled (''Build'', ''Compile'')<br />
** when the project compiler is not fpc or ppcsomething<br />
** when the IDE is built<br />
* '''ConfDir''' - directory where the IDE stores its config files (same as PrimaryConfigPath).<br />
* '''ExeExt''' - executable file extension for the operation system, independent of project's target OS. To get the extension for the current project target OS use $MakeExe().<br />
* '''FallbackOutputRoot''' - the directory where the IDE puts ppu files if the output directory of a package is not writable. Default: $(PrimaryConfigPath)/lib. Since 0.9.31.<br />
* '''FPCSrcDir''' - FPC source directory set in environment options<br />
* '''FPCMsgFile''' - compiler messages file set in the Lazarus environment options (since 0.9.31).<br />
* '''InstantFPCCache''' - path of the instantfpccache. Output of running ''instantfpc --get-cache'' (since 0.9.31).<br />
* '''LazarusDir''' - Lazarus source directory set in Lazarus environment options. No macros allowed.<br />
* '''Make''' - path to the make utility (gmake under BSD) (since 0.9.29)<br />
* '''PrimaryConfigPath''' - the directory of the IDE's configuration files (since 0.9.31). See '''SecondaryConfigPath'''.<br />
* '''ProjFile''' - the full filename of the main source of the current project (.lpr)<br />
* '''ProjIncPath''' - include path of project directory<br />
* '''ProjOutDir''' - path of project output directory (e.g. where the .ppu files are created) (since 0.9.27)<br />
* '''ProjPath''' - the project directory (the directory of the .lpi file)<br />
* '''ProjPublishDir''' - publishing directory of the current project<br />
* '''ProjSrcPath''' - source path of project directory<br />
* '''ProjUnitPath''' - unit path of project directory<br />
* '''Project(param)''' - macro function for various values:<br />
** '''Project(UnitPath)''' - unit path of project directory<br />
** '''Project(SrcPath)''' - source path of project directory<br />
** '''Project(IncPath)''' - include path of project directory<br />
** '''Project(InfoFile)''' - filename of the project information file (.lpi) (since r15287, 0.9.25)<br />
** '''Project(OutputDir)''' - directory where the project's ppu files are created (since 0.9.27)<br />
* '''Package macros''' - these can be used in the fields of a package. For example in the search paths of a package. To use them elsewhere give a package name as parameter.<br />
** '''$(PkgName)''' - in a package: gives the package name (since 0.9.31)<br />
** '''$PkgName(id)''' - macro function for the name of a package ID given as parameter (since 0.9.31)<br />
** '''$(PkgDir)''' - macro for the directory (location of the .lpk) of the package<br />
** '''$PkgDir(id)''' - macro function for the directory (location of the .lpk) of a package ID given as parameter<br />
** '''$PkgIncPath(id)''' - macro function for the include path of a package ID given as parameter<br />
** '''$PkgOutDir(id)''' - macro function for the output directory of a package (e.g. where the ppu files are created)<br />
** '''$PkgSrcPath(id)''' - macro function for the source path (unit path + src path) of a package ID given as parameter<br />
** '''$PkgUnitPath(id)''' - macro function for the unit path of a package ID given as parameter<br />
* '''SecondaryConfigPath''' - the directory of the IDE's configuration templates (since 0.9.31). See '''PrimaryConfigPath'''<br />
* '''TargetFile''' - the run file of the current project (e.g. the executable or the library, or the host application)<br />
* '''OutputFile''' - the output file of the current project (e.g. the executable or the library)<br />
* '''TestDir''' - Test directory set in the Lazarus environment options<br />
<br />
==Environment==<br />
* '''BuildMode''' - the name of the active build mode (since 1.1)<br />
* '''Env(name)''' - macro function for environment variables given to the IDE (not project nor debugger) (see [http://lazarus-ccr.sourceforge.net/docs/lcl/fileutil/getenvironmentvariableutf8.html GetEnvironmentVariableUTF8]) (since 0.9.27)<br />
* '''IDEBuildOptions''' - the extra options of the 'Configure Build Lazarus' dialog (since 0.9.29). In Makefile: empty.<br />
* '''LanguageID''' - IDE language, for example en for English, de for German<br />
* '''LanguageName''' - IDE language name, the translated name of the current language. For instance: Deutsch for German.<br />
* '''LazVer''' - Version string of the IDE (since 1.3).<br />
* '''FPCVer''' - FPC version (since 0.9.25). For example '2.4.2'. This version is fetched from the compiler $(CompPath), which path is set in the Lazarus environment options. '''FPCVer''' depends on project's compiler path.<br />
* '''FPC_FULLVERSION''' - FPC version as one number (since 1.3). For example ''20701''. This version is fetched from the compiler $(CompPath), which path is set in the Lazarus environment options. '''FPC_FullVersion''' depends on project's compiler path.<br />
* '''SrcOS''' - 'unix' for linux, darwin, bsd. 'win' for win32, win64, wince. Since 0.9.31: Use '''$SrcOS(SomeOS)''' to get the SrcOS of a specific OS, for example '''$SrcOS($TargetOS(IDE))''' to get the SrcOS of the IDE executable. '''SrcOS''' depends on ''TargetOS''.<br />
* '''TargetOS''' - Target OS of the current project. Since 0.9.31: Use '''$TargetOS(IDE)''' to get the OS of the IDE executable. If the project has not set the '''TargetOS''' the IDE uses the default platform of the project's compiler (1.3 and below uses as default the IDE's platform). In Makefile it is converted to ''%(OS_TARGET)''. <br />
* '''TargetCPU''' - similar to ''TargetOS''. In Makefile it is converted to ''%(OS_TARGET)''. <br />
* '''LCLWidgetType''' - LCL widgetset of the current project. In Makefile it is converted to ''%(LCL_PLATFORM)''.<br />
<br><br />
<br />
= Macros in IDE addons =<br />
<br />
Here is an incomplete list of macros added by IDE packages:<br />
<br />
== Pas2jsDsgn ==<br />
<br />
* '''Pas2JS''' - Pas2JS executable<br />
* '''Pas2JSBrowser''' - Pas2JS selected Browser executable<br />
* '''Pas2JSNodeJS''' - Pas2JS selected NodeJS excutable<br />
* '''Pas2JSProjectURL''' - Pas2JS current project URL<br />
<br />
== ProjectGroups ==<br />
<br />
* '''PGSrcPaths''' - source paths of all targets, i.e. projects, packages, etc. of the project group<br />
== Delphi compiler tool ==<br />
* '''DCC''' - The delphi compiler executable path, as set in the global settings.<br />
* '''DCCCONFIG''' If the 'Generate compiler configuration' settting is checked, this contains the generated delphi compiler configuration file, prepended with @. If the setting is not set, the macro will be empty.<br />
* '''DCCARGS''' The combined values of the global and project 'Extra compiler arguments' settings.<br />
* '''DCCCOMPILE''' This is equivalent to $(DCC) $(DCCCONFIG) $(DCCARGS).<br />
<br />
{{AutoCategory}}<br />
[[Category:Lazarus]]<br />
[[Category:IDE Macros]]</div>Michaelhttps://wiki.freepascal.org/index.php?title=Lazarus_Delphi_Compiler_Tool&diff=156437Lazarus Delphi Compiler Tool2023-05-15T19:44:34Z<p>Michael: /* Global Settings image */</p>
<hr />
<div>== Synopsis ==<br />
The Lazarus Delphi tool allows you to compile with the Delphi compiler instead of the FPC compiler.<br />
<br />
It defines a message parser which will allow you to click on a compiler message and be taken to the correct location in the sources.<br />
The filenames in compiler output can be converted from windows to unix notation, taking into account the Wine emulator drive configuration.<br />
<br />
It also allows to write a configuration file based on the FPC compiler options: Whenever the project is compiled, <br />
it writes a configuration file usable for the Delphi compiler, which you can include in the compiler command. <br />
The file has the same name as the '''.lpi''' file, with adifferent extension (configurable, default '''.conf''').<br />
<br />
== Installation == <br />
<br />
The package file '''components/compilers/delphi/lazdelphi.lpk''' needs to be installed.<br />
<br />
== Usage ==<br />
<br />
The package defines 4 macros:<br />
;DCC<br />
: The delphi compiler executable path, as set in the global settings.<br />
;DCCCONFIG<br />
: If the 'Generate compiler configuration' settting is checked, this contains the generated delphi compiler configuration file, prepended with @.<br />
: If the setting is not set, the macro will be empty.<br />
;DCCARGS<br />
: The combined values of the global and project 'Extra compiler arguments' settings.<br />
;DCCCOMPILE<br />
: This is equivalent to '''$(DCC) $(DCCCONFIG) $(DCCARGS)'''.<br />
<br />
These can be used in the pre compiler command: Here you must do 3 things;<br />
* specify the macro you wish in the ''Execute before'' command<br />
* Select the 'Delphi compiler' parser in the ''Execute before'' command<br />
* Disable calling the compiler<br />
<br />
A sample is visible in the following image <br />
<br />
[[File:delphicompilercommands.png]]<br />
<br />
== Global Settings == <br />
The following things can be set in the '''Tools -- Options''' menu:<br />
* '''Delphi compiler executable''' - the path to the delphi compiler.<br />
* '''Configuration file extension''' - the extension of the configuration file. <br />
* '''Map filenames from Windows to Unit notation''' on unix-like options, when set, any filenames in compiler output will be converted from Windows to Unix notation.<br />
* '''Additional compiler options''' - use this to specify delphi command-line options common to all Delphi projects, for example the location of the linker or the library path.<br />
<br />
[[File:idedelphisettings.png]]<br />
<br />
== Project settings ==<br />
<br />
The following things can be set in the '''Project options''' menu:<br />
<br />
* '''Generate Delphi config file based on FPC compiler options''' as the name says, when checked a configuration file will be generated for the project whenever it is compiled.<br />
* '''Additional compiler options''' - use this to specify delphi command-line options specific to the current project.<br />
<br />
[[File:projectdelphioptions.png]]</div>Michaelhttps://wiki.freepascal.org/index.php?title=File:idedelphisettings.png&diff=156436File:idedelphisettings.png2023-05-15T19:44:07Z<p>Michael: </p>
<hr />
<div></div>Michaelhttps://wiki.freepascal.org/index.php?title=Lazarus_Delphi_Compiler_Tool&diff=156435Lazarus Delphi Compiler Tool2023-05-15T19:43:21Z<p>Michael: /* Project settings image */</p>
<hr />
<div>== Synopsis ==<br />
The Lazarus Delphi tool allows you to compile with the Delphi compiler instead of the FPC compiler.<br />
<br />
It defines a message parser which will allow you to click on a compiler message and be taken to the correct location in the sources.<br />
The filenames in compiler output can be converted from windows to unix notation, taking into account the Wine emulator drive configuration.<br />
<br />
It also allows to write a configuration file based on the FPC compiler options: Whenever the project is compiled, <br />
it writes a configuration file usable for the Delphi compiler, which you can include in the compiler command. <br />
The file has the same name as the '''.lpi''' file, with adifferent extension (configurable, default '''.conf''').<br />
<br />
== Installation == <br />
<br />
The package file '''components/compilers/delphi/lazdelphi.lpk''' needs to be installed.<br />
<br />
== Usage ==<br />
<br />
The package defines 4 macros:<br />
;DCC<br />
: The delphi compiler executable path, as set in the global settings.<br />
;DCCCONFIG<br />
: If the 'Generate compiler configuration' settting is checked, this contains the generated delphi compiler configuration file, prepended with @.<br />
: If the setting is not set, the macro will be empty.<br />
;DCCARGS<br />
: The combined values of the global and project 'Extra compiler arguments' settings.<br />
;DCCCOMPILE<br />
: This is equivalent to '''$(DCC) $(DCCCONFIG) $(DCCARGS)'''.<br />
<br />
These can be used in the pre compiler command: Here you must do 3 things;<br />
* specify the macro you wish in the ''Execute before'' command<br />
* Select the 'Delphi compiler' parser in the ''Execute before'' command<br />
* Disable calling the compiler<br />
<br />
A sample is visible in the following image <br />
<br />
[[File:delphicompilercommands.png]]<br />
<br />
== Global Settings == <br />
The following things can be set in the '''Tools -- Options''' menu:<br />
* '''Delphi compiler executable''' - the path to the delphi compiler.<br />
* '''Configuration file extension''' - the extension of the configuration file. <br />
* '''Map filenames from Windows to Unit notation''' on unix-like options, when set, any filenames in compiler output will be converted from Windows to Unix notation.<br />
* '''Additional compiler options''' - use this to specify delphi command-line options common to all Delphi projects, for example the location of the linker or the library path.<br />
<br />
== Project settings ==<br />
<br />
The following things can be set in the '''Project options''' menu:<br />
<br />
* '''Generate Delphi config file based on FPC compiler options''' as the name says, when checked a configuration file will be generated for the project whenever it is compiled.<br />
* '''Additional compiler options''' - use this to specify delphi command-line options specific to the current project.<br />
<br />
[[File:projectdelphioptions.png]]</div>Michaelhttps://wiki.freepascal.org/index.php?title=File:projectdelphioptions.png&diff=156434File:projectdelphioptions.png2023-05-15T19:42:51Z<p>Michael: </p>
<hr />
<div></div>Michaelhttps://wiki.freepascal.org/index.php?title=Lazarus_Delphi_Compiler_Tool&diff=156433Lazarus Delphi Compiler Tool2023-05-15T19:41:52Z<p>Michael: /* Usage */</p>
<hr />
<div>== Synopsis ==<br />
The Lazarus Delphi tool allows you to compile with the Delphi compiler instead of the FPC compiler.<br />
<br />
It defines a message parser which will allow you to click on a compiler message and be taken to the correct location in the sources.<br />
The filenames in compiler output can be converted from windows to unix notation, taking into account the Wine emulator drive configuration.<br />
<br />
It also allows to write a configuration file based on the FPC compiler options: Whenever the project is compiled, <br />
it writes a configuration file usable for the Delphi compiler, which you can include in the compiler command. <br />
The file has the same name as the '''.lpi''' file, with adifferent extension (configurable, default '''.conf''').<br />
<br />
== Installation == <br />
<br />
The package file '''components/compilers/delphi/lazdelphi.lpk''' needs to be installed.<br />
<br />
== Usage ==<br />
<br />
The package defines 4 macros:<br />
;DCC<br />
: The delphi compiler executable path, as set in the global settings.<br />
;DCCCONFIG<br />
: If the 'Generate compiler configuration' settting is checked, this contains the generated delphi compiler configuration file, prepended with @.<br />
: If the setting is not set, the macro will be empty.<br />
;DCCARGS<br />
: The combined values of the global and project 'Extra compiler arguments' settings.<br />
;DCCCOMPILE<br />
: This is equivalent to '''$(DCC) $(DCCCONFIG) $(DCCARGS)'''.<br />
<br />
These can be used in the pre compiler command: Here you must do 3 things;<br />
* specify the macro you wish in the ''Execute before'' command<br />
* Select the 'Delphi compiler' parser in the ''Execute before'' command<br />
* Disable calling the compiler<br />
<br />
A sample is visible in the following image <br />
<br />
[[File:delphicompilercommands.png]]<br />
<br />
== Global Settings == <br />
The following things can be set in the '''Tools -- Options''' menu:<br />
* '''Delphi compiler executable''' - the path to the delphi compiler.<br />
* '''Configuration file extension''' - the extension of the configuration file. <br />
* '''Map filenames from Windows to Unit notation''' on unix-like options, when set, any filenames in compiler output will be converted from Windows to Unix notation.<br />
* '''Additional compiler options''' - use this to specify delphi command-line options common to all Delphi projects, for example the location of the linker or the library path.<br />
<br />
== Project settings ==<br />
The following things can be set in the '''Project options''' menu:<br />
* '''Generate Delphi config file based on FPC compiler options''' as the name says, when checked a configuration file will be generated for the project whenever it is compiled.<br />
* '''Additional compiler options''' - use this to specify delphi command-line options specific to the current project.</div>Michaelhttps://wiki.freepascal.org/index.php?title=File:delphicompilercommands.png&diff=156432File:delphicompilercommands.png2023-05-15T19:39:27Z<p>Michael: </p>
<hr />
<div></div>Michaelhttps://wiki.freepascal.org/index.php?title=Lazarus_Delphi_Compiler_Tool&diff=156431Lazarus Delphi Compiler Tool2023-05-15T19:37:55Z<p>Michael: Initial</p>
<hr />
<div>== Synopsis ==<br />
The Lazarus Delphi tool allows you to compile with the Delphi compiler instead of the FPC compiler.<br />
<br />
It defines a message parser which will allow you to click on a compiler message and be taken to the correct location in the sources.<br />
The filenames in compiler output can be converted from windows to unix notation, taking into account the Wine emulator drive configuration.<br />
<br />
It also allows to write a configuration file based on the FPC compiler options: Whenever the project is compiled, <br />
it writes a configuration file usable for the Delphi compiler, which you can include in the compiler command. <br />
The file has the same name as the '''.lpi''' file, with adifferent extension (configurable, default '''.conf''').<br />
<br />
== Installation == <br />
<br />
The package file '''components/compilers/delphi/lazdelphi.lpk''' needs to be installed.<br />
<br />
== Usage ==<br />
<br />
The package defines 4 macros:<br />
;DCC<br />
: The delphi compiler executable path, as set in the global settings.<br />
;DCCCONFIG<br />
: If the 'Generate compiler configuration' settting is checked, this contains the generated delphi compiler configuration file, prepended with @.<br />
: If the setting is not set, the macro will be empty.<br />
;DCCARGS<br />
: The combined values of the global and project 'Extra compiler arguments' settings.<br />
;DCCCOMPILE<br />
: This is equivalent to '''$(DCC) $(DCCCONFIG) $(DCCARGS)'''.<br />
<br />
These can be used in the pre compiler command.<br />
<br />
<br />
== Global Settings == <br />
The following things can be set in the '''Tools -- Options''' menu:<br />
* '''Delphi compiler executable''' - the path to the delphi compiler.<br />
* '''Configuration file extension''' - the extension of the configuration file. <br />
* '''Map filenames from Windows to Unit notation''' on unix-like options, when set, any filenames in compiler output will be converted from Windows to Unix notation.<br />
* '''Additional compiler options''' - use this to specify delphi command-line options common to all Delphi projects, for example the location of the linker or the library path.<br />
<br />
== Project settings ==<br />
The following things can be set in the '''Project options''' menu:<br />
* '''Generate Delphi config file based on FPC compiler options''' as the name says, when checked a configuration file will be generated for the project whenever it is compiled.<br />
* '''Additional compiler options''' - use this to specify delphi command-line options specific to the current project.</div>Michaelhttps://wiki.freepascal.org/index.php?title=SQLDBRestBridge&diff=155903SQLDBRestBridge2023-03-01T21:46:26Z<p>Michael: /* HTTP side */</p>
<hr />
<div>{{LanguageBar}}<br />
<br />
<br />
== Purpose ==<br />
<br />
More and more applications move to Web: today Pas2JS allows to program pascal for the web. <br />
<br />
Data needs to be stored on a server, and REST is the architecture of choice these days for doing so.<br />
Most often, the data ends up in a database. <br />
<br />
So, an easy way to make data available through a REST service is needed.<br />
<br />
The <code>SQLDBRestBridge</code> unit in ''fpc/packages/fcl-web/src/restbridge/sqldbrestbridge.pp'' offers a means to expose any database that can be accessed by SQLDB using a REST API.<br />
<br />
It is not meant as a general REST API framework, for this other frameworks exist. It is also not a RPC framework.<br />
<br />
The design is such that a complete database can be exposed using a single line of code, with reasonable default settings.<br />
<br />
=== What does it do ? ===<br />
<br />
Basically, <code>SQLDBRestBridge</code> can be used in a FCL-Web application to turn it into a REST server:<br />
<br />
The server will then accept the usual REST GET/POST/PUT/Delete commands and automatically <br />
translate these to the appropriate database CRUD (Create/Read/Update/Delete) statements.<br />
<br />
It can be used simply: one line of code is enough to expose a complete database in this way.<br />
<br />
Or it can be completely customized and fine tuned: The schema can be completely specified: <br />
all SQL statements can be specified, field lists can be defined, aliases can be given, business rules can be implemented.<br />
<br />
The resulting server can be used in a client/server setup (using pas2js as a client, for example) <br />
to serve data without needing to writing all the plumbing code needed in a REST server.<br />
<br />
=== What it does not do ? ===<br />
<br />
* This is a server-side technology. <br />
: To consume the data served by this component, you need to write a client. <br />
: No assumptions are made about the client, except that it knows how to execute HTTP requests, and that it understands one of the available data formats.<br />
* This does not expose objects as REST resources. <br />
: Using some tricks, this could be done, but this is not a design goal. <br />
: Eventually, all data ends up in a database, and this component uses a direct mechanism to achieve that.<br />
<br />
== Features ==<br />
<br />
=== SQL Database side. ===<br />
<br />
# Every REST resource is defined by up to 4 SQL statements, corresponding to the 4 CRUD operations.<br />
# The CRUD Statements can be auto generated on the fly, based on a table name and field definitions.<br />
# For every field, an alias can be provided.<br />
# The following client-side types are available, automatically mapped from the native database type:<br />
## String<br />
## 64-bit integer<br />
## 32-bit integer<br />
## Boolean<br />
## Date, Time, DateTime<br />
## Blob (base64-encoded)<br />
# Support for a sequence to generate IDs is built-in.<br />
# Full control over which operations (GET,POST,PUT,DELETE) are allowed.<br />
# Resources are collected in a schema.<br />
# Multiple schemas can be attached to the service.<br />
# Multiple databases (connections) can be defined.<br />
# A schema can be tied to a single connection, or connections can share a schemas (use case: a different connection per client).<br />
# Business processor components can be hooked to a resource, to make it easier to implement business logic.<br />
# SQL Statements can contain parameters, values for the parameters will be picked up from the request URL.<br />
# Support to get custom datasets.<br />
# Support for client-side provided SQL SELECT statements (optional, disabled by default)<br />
# Full support for configuration through an <code>.ini</code> file out of the box.<br />
<br />
=== HTTP side ===<br />
<br />
<ol><br />
<li>Authentication is handled using the HTTP protocol.</li><br />
<li>Basic authentication is included by default, but is completely pluggable.</li><br />
<li>Basic authentication can look up valid users in a database (by default the database being exposed)</li><br />
<li>Output format can be fixed or detected per request (<code>?fmt=format</code>). Detection based on content-type is also available.</li><br />
<li>list of fields to include in output can be specified in the URL:<br /><br />
<code>fl=field1,field2</code></li><br />
<li>Field list of fields to exclude from output can be specified in the URL:<br /><br />
<code>fe=field1,field2</code></li><br />
<li>Various output formats are available out of the box<br />
<ol><br />
<li>JSON (the default)</li><br />
<li>XML (a custom format)</li><br />
<li>CSV (for in and output)</li><br />
<li>CDS (Format used by Delphi <code>TClientDataset</code>)</li><br />
<li>Planned: ADO data packets (as used by MS Access)</li></ol><br />
</li><br />
<li>A factory pattern is used, new formats can be added at will.</li><br />
<li><p>Simple URL schemes. 2 basic schemes are available</p><br />
<pre class="text">BASEURL/Resource/<br />
BASEURL/Resource/ID</pre><br />
<p>or using the connection as prefix:</p><br />
<pre class="text">BASEURL/Connection/Resource/<br />
BASEURL/Connection/Resource/ID</pre></li><br />
<li><p>Support for introspection/discovery or metadata:</p><br />
<pre class="text">BASEURL/metadata/</pre><br />
<p>returns the list of available resources and their operation.</p><br />
<pre class="text">BASEURL/metadata/resourcename</pre><br />
returns the structure of the resource: fields, types, etc.</li><br />
<li><p><code>limit</code> and <code>offset</code> parameters for paging of results:</p><br />
<pre class="text">BASEURL/resourcename?limit=10<br />
BASEURL/resourcename?limit=10&amp;Offset=50</pre><br />
A maximum limit can be enforced. When the SQL statements support it, the limit and offset are translated to SQL fetch/offset clauses.</li><br />
<li><p>Sort order can be specified in the request URL, if the resource definition allows it, using <code>?sort=fieldname</code>. The ability to sort can be specified on a field basis.</p><br />
<pre class="text">BASEURL/resourcename?sort=MyField<br />
BASEURL/resourcename?sort=MyField%20desc</pre><br />
Multiple sort fields can be specified, separated by a comma.<br />
</li><br />
<li><p>Filtering can be specified on a field basis in the request URL, and the filter operation is translated to SQL Where:</p><br />
<br />
<pre class="text">BASEURL/resourcename?MyField=10<br />
BASEURL/resourcename?MyField_null=1<br />
BASEURL/resourcename?MyField_null=0<br />
BASEURL/resourcename?MyField_lt=10<br />
BASEURL/resourcename?MyField_lte=10<br />
BASEURL/resourcename?MyField_gt=10<br />
BASEURL/resourcename?MyField_gte=10</pre><br />
<p>is translated to a SQL where clause:</p><br />
<pre>(MyField=10)<br />
(MyField is null)<br />
(MyField is not null)<br />
(MyField&lt;10)<br />
(MyField_lte&lt;=10)<br />
(MyField&gt;10)<br />
(MyField&gt;=10)</pre><br />
The ability to filter on a field can be specified in the schema for each field.</li><br />
<li><p>The request can specify whether metadata should be included in the response:</p><br />
<pre class="text">BASEURL/resourcename?metadata=1</pre></li><br />
<li><p>The request can specify whether the result should be human-readable or not</p><br />
<pre class="text">BASEURL/resourcename?humanreadable=1</pre><br />
<p>If set to 1, the request result will be formatted. Not all formats support this.</p></li></ol><br />
<br />
== Available Components ==<br />
<br />
=== TSQLDBRestSchema ===<br />
<br />
Unit: ''fpc/packages/fcl-web/src/restbridge/sqldbrestschema.pp''<br />
<br />
Represents a REST schema : a list of available resources, with their allowed operations, fields definitions, SQL statements.<br />
A schema can be designed visually using a [[SQLDBRestSchemaEditor]] in a separate application or in the lazarus IDE.<br />
<br />
==== Properties ====<br />
<br />
* '''Resources''' A collection of resources. Each item is of type ''TSQLDBRestResource''<br />
* '''ConnectionName''' Set this to a connection name if you want all resources of this schema to use this connection.<br />
<br />
==== Methods ====<br />
<br />
* '''SaveToFile''' save the resource definitions to file (as JSON)<br />
<source lang="delphi">Procedure SaveToFile(Const aFileName : UTF8String);</source><br />
* '''SaveToStream''' save the resource definitions to stream (as JSON).<br />
<source lang="delphi">Procedure SaveToStream(Const aStream : TStream);</source><br />
* '''AsJSON''' return the resource definitions as a JSON object.</p><br />
<source lang="delphi">function AsJSON(const aPropName: UTF8String=''): TJSONData;</source><br />
If specified, '''aPropName''' is the name of the property below which all definitions are stored.<br />
* '''LoadFromFile''' Load the resource definitions from a JSON file.<br />
<source lang="delphi">Procedure LoadFromFile(Const aFileName : UTF8String);</source><br />
* '''LoadFromStream''' Load the resource definitions from a JSON file.<br />
<source lang="delphi">Procedure LoadFromStream(Const aStream : TStream);</source><br />
* '''FromJSON''' Load the resource definitions from a JSON file.<br />
<source lang="delphi">Procedure FromJSON(aData: TJSONData;const aPropName: UTF8String='');</source><br />
If specified, '''aPropName''' is the name of the property below which all definitions are located.<br />
* '''PopulateResourceFields''' create resource fields based on table name.<br />
<source lang="delphi">procedure PopulateResourceFields(aConn: TSQLConnection; aRes: TSQLDBRestResource; aMinFieldOpts : TRestFieldOptions = []);</source><br />
''PopulateResourceFields'' populates the field definitions in ''aRes'' by checking the table in database connection ''aConn''. Every created field gets at least ''aMinFieldOptions'' in its ''Options'' property.<br />
* '''PopulateResources''' creates a resource definition for each table in a database connection.<br />
<source lang="delphi">procedure PopulateResources(aConn: TSQLConnection; aTables: array of string; aMinFieldOpts: TRestFieldOptions= []);<br />
Procedure PopulateResources(aConn : TSQLConnection; aTables : TStrings = Nil; aMinFieldOpts : TRestFieldOptions = []);</source><br />
* ''PopulateResources'' retrieves the list of tables from ''aConn'', creates a resource definition for the table and calls ''PopulateResourceFields'' to fill the resource with fields. If ''aTables'' is specified, definitions will only be created for the tables in that list.<br />
<br />
=== TSQLDBRestDispatcher ===<br />
<br />
Unit: ''fpc/packages/fcl-web/src/restbridge/sqldbrestbridge.pp''<br />
<br />
==== Properties ====<br />
<br />
* '''Active''' (Boolean) Register or unregister HTTP routes.<br />
* '''Connections''' (TSQLDBRestConnectionList) List of database connections to connect to.<br />
* '''Schemas''' (TSQLDBRestSchemaList) List of REST schemas to serve<br />
* '''BasePath''' (UTF8String) Base URL for REST URLS.<br />
* '''DefaultConnection''' (UTF8String) Default connection to use if none is detected from request/schema<br />
* '''Strings''' (TRestStringsConfig Property) Input/Output strings configurations<br />
* '''OutputOptions''' (TRestOutputOptions) default Output options, modifiable by query. One or more of<br />
<br />
# ''ooMetadata'' Send metadata in request<br />
# ''ooSparse'' Do not send null values (if format allows it)<br />
# ''ooHumanReadable'' Pretty-print output.<br />
<br />
* '''InputFormat''' (string) Name of Input format to use for all requests.<br />
* '''OutputFormat''' (string) Name of Output format to use for all requests.<br />
* '''DispatchOptions''' (TRestDispatcherOptions) Dispatcher options. One or more of<br />
<br />
# ''rdoConnectionInURL'' Use the connection as a path element in the URL.<br />
# ''rdoExposeMetadata'' Expose the metadata URL.<br />
# ''rdoConnectionResource'' Expose the connection resource, allowing to manage connections through the REST protocol.<br />
# ''rdoCustomView'' allow the use of a customview URL (Select SQL specified in request)<br />
# ''rdoEmptyCorsDomainToOrigin'' if the CORDAllowedOrigins is empty, then the request server will be echoed to the client.<br />
# ''rdoHandleCORS'' Handle CORS preflight request.<br />
# ''rdoAccessCheckNeedsDB'' This controls when the access check is done for resources: before or after a connection with the database is made. If you need to make additional queries on a database to decide whether access is granted (such as checking ACLs in the Db) then this option should be enabled. <br />
* '''AdminUserIDs''' A list of user IDs (one per line) which are allowed to use the connection resource. If empty, all users can use it.<br />
* '''LogOptions''' Logging options. Logging happens through the OnLog event handler. This property controls which events are logged. The following values can be specified:<br />
# ''rloUser'' Include username in log messages, when available<br />
# ''rtloHTTP'' Log HTTP request (remote, URL)<br />
# ''rloResource'' Log resource requests (operation, resource)<br />
# ''rloConnection'' Log database connections (connect to database)<br />
# ''rloAuthentication'' Log authentication attempt<br />
# ''rloSQL'' Log SQL statements. (not on user-supplied connection)<br />
# ''rloResultStatus'' Log result status.<br />
<br />
* '''LogSQLOptions''' SQL Logging options. if rloSQL is specified, this option controls which SQLDB events are logged for new connections.<br />
* '''Authenticator''' (TRestAuthenticator) Authenticator for requests. If ''OnBasicAuthentication'' is set, this can be left empty.<br />
* '''EnforceLimit''' (Integer) If larger than zero, Enforce a limit on output results.<br />
* '''CORSAllowedOrigins''' (String) Comma separated list of Domains that are allowed to use this REST service. If empty, * will be returned in preflight request.<br />
* '''CORSMaxAge''' (Integer) Value for HTTP ''Access-Control-Max-Age'' header. If zero, the header is not sent.<br />
* '''CORSAllowCredentials''' (Boolean) value for HTTP header ''Access-Control-Allow-Credentials''. Set to false not to send the header<br />
<br />
==== Methods ====<br />
<br />
<ul><br />
<li><p>'''ExposeDatabase''' exposes a database as a REST service. This will creates a connection definition with the provided parameters and calls '''ExposeConnection''' with this definition.</p><br />
<source lang="delphi">Function ExposeDatabase(Const aType,aHostName,aDatabaseName,aUserName,aPassword : String; aTables : Array of String; aMinFieldOp<br />
Function ExposeDatabase(Const aType,aHostName,aDatabaseName,aUserName,aPassword : String; aTables : TStrings = nil; aMinFieldOpt</source><br />
The connection gets the name '''ConnectionN''', where N is a unique number, and the schema is named '''SchemaConnectionN'''. The Tables and aMinFieldOpt arguments are the same as in the ''PopulateResources'' call of '''TSQLDBRestSchema'''</li><br />
<li><p>'''ExposeConnection''' exposes a database (represented by ''aConnection'') as a REST service. This will create a schema with a resource definition.</p><br />
<source lang="delphi">Function ExposeConnection(Const aConnection : TSQLDBRestConnection; aTables : TStrings = nil; aMinFieldOpts : TRestFieldOptions</source><br />
<p>The Tables and aMinFieldOpt arguments are the same as in the ''PopulateResources'' call of '''TSQLDBRestSchema'''</p></li></ul><br />
<br />
=== TRestBasicAuthenticator ===<br />
<br />
Unit: ''fpc/packages/fcl-web/src/restbridge/sqldbrestauth.pp''<br />
<br />
This class implements HTTP Basic authentication for the SQLDB REST Dispatcher<br />
<br />
* AuthConnection (TSQLConnection) a SQL connection that will be used to run the SQL. By default the connection of the request is used. Set this if your users are in a separate database.<br />
* AuthenticateUserSQL (TStrings) an SQL Statement that will be executed on the connection (AuthConnection or connection of the request). This must contain 2 parameters '''userName''' and '''password''' and return a single field. This field will be used as '''UserID''' (available in the rest of the request flow.<br />
* DefaultUserName (UTF8String) a valid username, not in the database.<br />
* DefaultPassword (UTF8String) password of a default user.<br />
* DefaultUserID (UTF8String) the user ID reported if the default user is authenticated.<br />
* AuthenticationRealm : (UTF8String) Real sent in the '''WWW-Authenticate''' challenge to the client.<br />
* OnBasicAuthentication (event) triggered when basic authentication is requested. Here you can enter custom code to validate the user.<br />
<br />
=== TSQLDBRestModule ===<br />
<br />
Unit: ''fpc/packages/fcl-web/src/restbridge/sqldbrestmodule.pp''<br />
<br />
* This is a simple '''TWebModule''' descendant which is usable in Lazarus IDE. It has a single ''Dispatcher'' property which must be set to a '''TSQLDBRestDispatcher''' instance.<br />
<br />
=== TSQLDBRestResource ===<br />
<br />
Unit: ''fpc/packages/fcl-web/src/restbridge/sqldbrestschema.pp''<br />
<br />
This is a collection item, found in the 'Resources' property of the '''TSQLDBRestSchema'''. It represents a single REST resource.<br />
==== properties ====<br />
<br />
It has the following properties:<br />
<br />
* '''Fields''' (TSQLDBRestFieldList) A list of fields that will be included in the output, or can be supplied in the input.<br />
* '''Enabled''' (Boolean) Is this resource enabled ?<br />
* '''InMetadata''' (Boolean) Should this resource be shown in the metadata list ?<br />
* '''ConnectionName''' (UTF8String) Connection name to use for this resource. <br />
* '''TableName''' (UTF8String) Database table name. This must only be specified if the SQL is auto generated.<br />
* '''ResourceName''' (UTF8String) Name of this resource as exposed to the outside world.<br />
* '''AllowedOperations''' (TRestOperations) The operations allowed on this resources (Get/Put/Post/Delete/Options/Head)<br />
* '''SQLSelect''' (TStrings) SQL select statement for a GET request. Left empty, it is autogenerated based on the table name. The where clause uses the fields with the ''foInKey'' flag set for single resources.<br />
* '''SQLInsert''' (TStrings) SQL INSERT statement for a POST request. Left empty, it is autogenerated based on the table name. <br />
* '''SQLUpdate''' (TStrings) SQL UPDATE statement for a PUT request. Left empty, it is autogenerated based on the table name. The where clause uses the fields with the ''foInKey'' flag set.<br />
* '''SQLDelete''' (TStrings) SQL DELETE statement for a DELETE request. Left empty, it is autogenerated based on the table name. The where clause uses the fields with the ''foInKey'' flag set.<br />
* '''SQL'' an array of SQL statements, based on the previous ones.<br />
* '''BusinessProcessor''' (TSQLDBRestCustomBusinessProcessor) at runtime this contains the business processor for this resource (if any)<br />
<br />
==== Events ====<br />
<br />
The following events are available:<br />
<br />
* '''OnResourceAllowed''' (TSQLDBRestAllowResourceEvent) Called to check whether the user is allowed to access this resource.<br />
* '''OnAllowedOperations''' (TSQLDBRestAllowedOperationsEvent) Called to allow to fine-tune the allowed operations for the user.<br />
* '''OnGetDataset''' (TSQLDBRestGetDatasetEvent) You can return a custom dataset for GET operations. <br />
* '''OnCheckParams''' (TSQLDBRestCheckParamsEvent) You can check the INSERT/UPDATE/DELETE SQL Statement parameters in this request/<br />
* '''OnAllowRecord''' (TSQLDBRestAllowRecordEvent) Called for each record, you can ddecide whether the record should be included in the output.<br />
<br />
Note: when set, the corresponding event in the business processor is not triggered.<br />
<br />
==== Methods ====<br />
<br />
The following methods exist:<br />
Function GetDataset(aContext : TBaseRestContext; aFieldList : TRestFieldPairArray; aOrderBy : TRestFieldOrderPairArray; aLimit, aOffset : Int64) : TDataset;<br />
Get the custom dataset for this resource.<br />
function GenerateDefaultSQL(aKind: TSQLKind): UTF8String; virtual;<br />
Get the default SQL for this resource if none was specified.<br />
function GetFieldList(aListKind: TFieldListKind): UTF8String;<br />
Return a list of fields as a string, separated by a correct separator token <br />
function GetFieldArray(aListKind: TFieldListKind): TSQLDBRestFieldArray;<br />
Return a list of fields, similar to GetFieldList, but returns the raw fields.<br />
Function GetResolvedSQl(aKind : TSQLKind; Const AWhere : UTF8String; Const aOrderBy : UTF8String = ''; aLimit : UTF8String = '') : UTF8String;<br />
Return the actual SQL Statement that will be executed, with macros <br />
Procedure PopulateFieldsFromFieldDefs(Defs : TFieldDefs; aIndexFields : TStringArray; aProcessIdentifier : TProcessIdentifier; aMinFieldOpts : TRestFieldOptions);<br />
Populate the fields collection from a TFieldDefs collection.<br />
<br />
=== TSQLDBRestField ===<br />
Unit: ''fpc/packages/fcl-web/src/restbridge/sqldbrestschema.pp''<br />
<br />
The TSQLDBREstResource has a collection of fields (TSQLDBRestField) that determine the output fields of the REST resource<br />
<br />
It has the following properties;<br />
* FieldName (UTF8String Read FFieldName Write FFieldName;<br />
* PublicName (UTF8String Read GetPublicName Write FPublicName;<br />
* GeneratorName (String) name of a generator to privide a unique value.<br />
* FieldType (TRestFieldType) Data type of the exposed field.One of (the names speak for themselves)<br />
** rftInteger<br />
** rftLargeInt<br />
** rftFloat<br />
** rftDate<br />
** rftTime<br />
** rftDateTime<br />
** rftString<br />
** rftBoolean<br />
** rftBlob (sent as base64-encoded data)<br />
* NativeFieldType (TFieldType) Native database field type of this field.<br />
* Options (TRestFieldOptions) options for this field. One of more of:<br />
** foInKey This is a key field.<br />
** foInInsert The field can be inserted (if statement is autogenerated)<br />
** foInUpdate The field can be updated (if statement is autogenerated) <br />
** foRequired A field value is required.<br />
** foFilter Filtering is allowed on this field.<br />
** foOrderBy Ordering is allowed on this field. <br />
** foOrderByDesc Ordering (descendent) is allowed on this field. <br />
* Filters (TRestFieldFilters) Allowed filter expressions for this field. One or more of:<br />
** rfEqual<br />
** rfLessThan<br />
** rfGreaterThan<br />
** rfLessThanEqual<br />
** rfGreaterThanEqual<br />
** rfNull<br />
* MaxLen (integer) for string fields, the maximum allowed length of the field.<br />
<br />
=== TSQLDBRestBusinessProcessor ===<br />
<br />
Unit: ''fpc/packages/fcl-web/src/restbridge/sqldbrestschema.pp''<br />
<br />
This class serves to implement any business rules you want to attach to your rest resource.<br />
You can drop one TSQLDBRestBusinessProcessor instance per resource on a module, set the <br />
schema and resource name (a list of resource names is available in the Object Inspector) and implement the events.<br />
<br />
The following properties and events are available:<br />
* '''Schema''' : The schema in which the resource resides.<br />
* '''ResourceName''' The resource for which the business rules are valid.<br />
* '''OnGetDataset''' : Event called when you want to create a custom dataset. You must free the dataset yourself.<br />
* '''OnCheckParams''' : Event in which you can verify whether the parameters for insert/update/delete/select queries are OK.<br />
* '''OnAllowResource''' : Event to decide whether a property is allowed for a request. You can use this e.g. to forbid certain users from accessing a resource.<br />
* '''OnAllowedOperations''' : Event to decide whether a REST operation is allowed for a request. You can use this to forbid certain users from writing to a resource, but allow them to read.<br />
* '''OnAllowRecord''' : Called for each record which will be output. This can be used to prevent certain records from being streamed to the output. Note that if ''Limit'' is specified, this will not be taken into account, i.e. if the limit is 10, and you forbid 2 records from being streamed at this point, only 8 records will be returned.<br />
<br />
All calls get passed a TRestContext instance. This contains 2 properties and a method:<br />
Function GetVariable(Const aName : UTF8String; aSources : TVariableSources; Out aValue : UTF8String) : Boolean;<br />
Call this to get a HTTP Query variable, header,... The function returns true if the variable was found.<br />
Property UserID : UTF8String<br />
This will be set when calling.<br />
Property Data : TObject<br />
You can attach data to this if you want to. It will be kept for the duration of the request.<br />
You are responsible for freeing this data, though.<br />
<br />
== Special Resources ==<br />
<br />
=== metaData ===<br />
<br />
The ''/baseURL/metaData'' resource lists all the resources defined in the schema, together with the allowed operations.<br />
<br />
The usual formats and parameters are supported.<br />
<br />
=== metaData/resourceName ===<br />
<br />
The ''/baseURL/metaData/resourceName'' resource lists all the fields in the '''resourceName''' resource, together with the properties.<br />
<br />
The usual formats and parameters are supported for this resource.<br />
<br />
<br />
=== customview ===<br />
<br />
The customView resource is special. Its availability must be enabled using the ''Dispatcher'''s Options. When ''rdoCustomView'' is included in the options, the <br />
<br />
baseURL/customView<br />
<br />
URL becomes available. It allows the client to specify an SQL Select statement using the ''SQL'' parameter:<br />
<br />
baseURL/customView?SQL=select count(*) as thecount from person<br />
<br />
(you must encode the sql using the usual URI encoding mechanism, it is omitted for readability reasons here)<br />
The usual parameters for fieldlists, format are supported, but not the ''limit'' and ''offset'' parameters.<br />
<br />
The engine will check that only SELECT statements passed on. <br />
Nevertheless, this is an inherently less safe mechanism which should only be used in case of need.<br />
<br />
=== _connection ===<br />
<br />
This is a resource that allows you to manage the connections through REST. <br />
This can be useful in development environments, where you can simply create a single binary that does not need any configuration, <br />
the whole configuration can be done through REST, including the management of the available connections.<br />
<br />
Because this is security-wise a dangerous option to enable, it is disabled by default, and must be enabled explicitly with the ''rdoConnectionResource'' option of the dispatcher.<br />
<br />
Use cases are a development environment where this can be used to confiure the restserver from within the IDE. <br />
When moving to production, the option can be disabled, and only fixed and known connections will be allowed/<br />
<br />
== Available Output formats ==<br />
<br />
=== JSON (the default) ===<br />
<br />
* A simple JSON object encapsulating data, metadata and possibly error nodes.<br />
* rows are exported as JSON objects, field names are property names of the object.<br />
* Name: 'json'<br />
* Content-type: 'application/json'<br />
* Input and output.<br />
* Data by default under 'data'<br />
* Metadata by default under 'metaData'<br />
* Errors reported under 'error'<br />
* Property names are configurable in REST dispatcher.<br />
<br />
=== XML (a custom format) ===<br />
<br />
* A simple XML document encapsulating data, metadata and possibly error nodes, under a root element 'datapacket'<br />
* rows are exported as XML elements (named 'row') , the contents as text in the element.<br />
* Name: 'xml'<br />
* Content-type: 'text/xml'<br />
* Input and output.<br />
* Data by default under 'data'<br />
* Metadata by default under 'metadata'<br />
* Errors reported under 'error'<br />
* Element names are configurable in REST dispatcher.<br />
<br />
=== CSV ===<br />
<br />
* Simple comma-separated CSV list.<br />
* Name: 'csv'<br />
* Content-type: 'text/csv'<br />
* Input and output.<br />
* Separator: Comma<br />
* Quotes when needed.<br />
* Metadata means first line contains fieldnames.<br />
<br />
=== CDS ===<br />
<br />
* XML package using the XMLFormat used by Delphi <code>TClientDataset</code>.<br />
* Name: 'cds'<br />
* Content-type: 'text/csv'<br />
* Input and output.<br />
<br />
A Delphi demo program is provided.<br />
<br />
=== ADO ===<br />
<br />
* XML format as used by ADO recordsets (as used by MS Access)<br />
* Name: 'ado'<br />
* Input and output.<br />
<br />
== Ini file Support ==<br />
<br />
The following classes can load/save their configuration settings from/to an .ini file<br />
<br />
* TSQLDBRestDispatcher<br />
* TRestBasicAuthenticator<br />
* TSQLDBRestConnection<br />
* TRestStringsConfig <br />
<br />
The support for this is implemented in 2 units;<br />
* the sqldbauthini unit has a type helper for the TRestBasicAuthenticator class. <br />
* The sqldbrestini unit has the type helpers for TSQLDBRestDispatcher and TSQLDBRestConnection and TRestStringsConfig. <br />
<br />
The helpers implement LoadFromFile/SaveToFile methods, as well as LoadFromIni/SaveToIni methods.<br />
There are some options to control the level of depth.<br />
<br />
The schemas (if so required) are saved as JSON files in the same directory as the .ini file, using the name of the schema as the filename.<br />
<br />
== Lazarus Support ==<br />
<br />
Requires Lazarus 2.1+<br />
<br />
Lazarus support for the SQLDB REST Bridge is implemented in 2 packages under the '''components/sqldbrest''' directory:<br />
# The design/sqldbrestschemadesigner.lpk package.<br />
# The lazsqldbrest.lpk package.<br />
The latter package registers the '''TSQLDBRestDispatcher''', '''TSQLDBRestSchema''' and '''TRestBasicAuthenticator''' components on the component palette:<br />
The former includes the schema editor. They should be compiled and installed in the order presented here.<br />
<br />
[[File:sqldbrestcomponents.png]]<br />
<br />
Additionally it registers some component- and property editors. In particular the GUI schema editor can be called from the '''TSQLDBRestSchema''' component context menu.<br />
<br />
The GUI schema editor is included in the IDE, it is discussed in a separate page [[SQLDBRestSchemaEditor]]<br />
<br />
Further integration with Lazarus is planned:<br />
1. Let the IDE act as a REST server. (alternatively, add a tool with a menu entry under tools for easy configuration)<br />
<br />
Lazarus support can work with FPC 3.0.4. <br />
To make this work, the files can be copied from SVN or a 3.2 release to the lazarus components/sqldbrest/src directory. <br />
<br />
To this end, <br />
# create a directory '''src''' below the '''components/sqldbrest directory''' (where the package is located) <br />
# copy all files in directory<br />
fpc/packages/fcl-web/src/restbridge<br />
: to the new ''src'' directory<br />
lazarus/components/sqldbrest/src<br />
<br />
# compile the '''lazarus/components/sqldbrest/design/sqldbrestschemadesigner.lpk''' package. It has unitpath ../src, so it should find the files in the ''src'' directory.<br />
# compile the '''lazarus/components/sqldbrest/lazsqldbrest.lpk''' package.<br />
<br />
== Pas2JS Support ==<br />
The SQLDB Rest bridge will be integrated in the compile server that comes with pas2JS:<br />
This means that pas2js will come with a toll that<br />
* Can recompile your web project on the fly<br />
* Can serve files on disc<br />
* Can act as a REST server.<br />
So no actual server is needed during development.<br />
<br />
== Usage ==<br />
<br />
=== In a fcl-web application. ===<br />
<br />
The rest bridge was designed to be simple to use.<br />
<br />
==== Expose a single database, no authentication. ====<br />
<br />
Simple expose of a database. Run the following code in the startup of your program (for example, DoRun of the web application class, or startup code of the program)<br />
<br />
<source lang="delphi">FDisp:=TSQLDBRestDispatcher.Create(Self);<br />
FDisp.ExposeDatabase(<br />
'postgres','localhost','expensetracker','me','secret'<br />
,Nil,<br />
[foFilter,foInInsert,foInUpdate,foOrderByDesc]);<br />
FDisp.Active:=True; <br />
FDisp.SaveToFile('demo.ini');</source><br />
This exposes all tables of the database 'expenstracker', allows to filter,update and sort on all fields. The connection will be named 'Connection1', the schema 'SchemaConnection1'<br />
<br />
The configuration will be saved in a file called 'demo.ini'.<br /><br />
It can be reused to quickly set up a REST dispatcher.<br />
<br />
==== Expose single database, HTTP Basic authentication. ====<br />
<br />
Similar to the previous example, but with HTTP BASIC authentication for a single user:<br />
<br />
<source lang="delphi">FAuth:=TRestBasicAuthenticator.Create(Self);<br />
FAuth.DefaultUserName:='me';<br />
FAuth.DefaultPassword:='secret';<br />
FDisp:=TSQLDBRestDispatcher.Create(Self);<br />
FDisp.Authenticator:=Fauth;<br />
FDisp.ExposeDatabase(<br />
'postgres','localhost','expensetracker','me','secret'<br />
,Nil,<br />
[foFilter]);<br />
FDisp.Active:=True; </source><br />
This exposes all tables of the database 'expenstracker', allows to filter,update and sort on all fields. The connection will be named 'Connection1', the schema 'SchemaConnection1'. No updates are possible: the fields will not be in update/insert statements. Sorting is also not allowed.<br />
<br />
==== Expose single database, HTTP Basic authentication (2) ====<br />
<br />
Smilar to the previous example, but with HTTP BASIC authentication, using the database to authenticate a user:<br />
<br />
<source lang="delphi">FAuth:=TRestBasicAuthenticator.Create(Self);<br />
FAuth.AuthenticateUserSQL.Text:='select uID from users where (uLogin=:UserName) and (uPassword=:Password)';<br />
FDisp:=TSQLDBRestDispatcher.Create(Self);<br />
FDisp.Authenticator:=Fauth;<br />
FDisp.ExposeDatabase(<br />
'postgres','localhost','expensetracker','me','secret'<br />
,['projects','expenses'],<br />
[]);<br />
FDisp.Active:=True; </source><br />
Here only the 'projects' and 'expenses' tables are exposed, read-only.<br />
<br />
==== Using a Config file and schema files. ====<br />
<br />
Start a dispatcher, loading the file demo.ini. The dioSkipReadSchemas tells it not to load schema files, the schemas will be created from the connections.<br />
<br />
<source lang="delphi">FDisp:=TSQLDBRestDispatcher.Create(Self);<br />
FDisp.LoadFromFile('demo.ini',[dioSkipReadSchemas]);<br />
FDisp.Active:=True;</source><br />
The .ini file can be created using SaveToFile on a configured dispatcher instance.<br />
<br />
=== In the lazarus IDE. ===<br />
<br />
To work in the lazarus IDE with the SQLDB Rest bridge, you must install the '''lazsqldbrest''' package, which can be found in the directory components/sqldbrest.<br />
<br />
<br />
==== Using a datamodule ====<br />
<br />
In this approach, a datamodule is created that is in memory throughout the whole lifetime of the application (fcl-web application)<br />
<br />
<br />
# Create a HTTP server application or FCGI application. (a CGI will also work but is very inefficient)<br />
# Add a plain datamodule to the application.<br />
# Drop a TSQLDBRestSchema class from the 'FCL-Web' tab of the component palette<br />
# Edit the schema (property resources), or import it from file using the component editor context menu<br />
# Drop a TSQLDBRestDispatcher class from the 'FCL-Web' tab of the component palette<br />
# Edit the connections<br />
# Add an item to the Schemas property and point it to the TSQLDBRestSchema added previously <br />
# For HTTP Basic authentication, add a TRESTBAsicAuthenticator class, and set the TSQLDBRestDispatcher instance's Authentocator property to it. <br />
<br />
The end result should look more or less like this:<br />
<br />
[[File:restmodule.png]]<br />
<br />
That's it. The project is ready to run.<br />
<br />
==== Using a SQLDBRestdatamodule ====<br />
<br />
This approach is basically the same as the previous one.<br />
<br />
# Create a HTTP application<br />
# Under File - New, create a SQLDB Rest Bridge Module.<br />
# Drop a SQLDBRestDispatcher component on the module.<br />
# The Dispatcher property of the module should be set to the SQLDBRestDispatcher component.<br />
# Set up the component as required, as in the previous example.<br />
<br />
== Examples ==<br />
<br />
=== FPC ===<br />
* in FPC Packages, the fcl-web/examples/restbridge directory, there is a small example that serves a expenses tracker database.<br />
* The directory (delphiclient) below contains a small Delphi project that shows how to connect a TClientDataset to the SQLDB Rest bridge.<br />
: Design time view:<br />
: [[File:delphirestclientdesign.png]]<br />
: Run time view:<br />
: [[File:delphirestclient.png]]<br />
<br />
=== Lazarus ===<br />
<br />
Requires Lazarus 2.1+<br />
<br />
There are 2 server examples available, and several client examples.<br />
The client examples are all the same, they just use a different kind of ''TDataset'' to show the data coming from the server: the '''buf''', '''json''' and '''CSV''' formats are demonstrated in this way.<br />
<br />
==== Server examples ====<br />
<br />
* The lazarus/components/sqldbrest/demo/restbridge directory contains the same example program restserver.lpi, using a datamodule.<br />
* The lazarus/components/sqldbrest/demo/restmodule directory contains the same example program demorestmodule.lpi, using a SQLDB Rest Web datamodule.<br />
<br />
==== TBufDataset client example ====<br />
* The lazarus/components/sqldbrest/demo/bufclient directory contains a demo, that shows how to load data from a SQLDB REST bridge server in a TBUFDataset dataset. It uses the 'buf' format to do so.<br />
: [[File:sqldbrestbufclientdata.png]]<br />
<br />
: [[File:sqldbrestbufclientraw.png]]<br />
: it also demonstrates how to use the metadata resource of the server to list the available resources<br />
==== TJSONDataset client example ====<br />
<br />
* The lazarus/components/sqldbrest/demo/jsonclient directory contains a demo that is similar to the bufclient demo: <br />
: it shows how to load data from a SQLDB REST bridge server in a TBaseJSONDataset dataset, using the 'csv' format<br />
: [[File:sqldbrestjsonclientdata.png]]<br />
<br />
: [[File:sqldbrestjsonclientraw.png]]<br />
: Like the bufdataset demo, it also demonstrates how to use the metadata resource of the server to list the available resources<br />
<br />
==== TCSVDataset client example ====<br />
* The lazarus/components/sqldbrest/demo/csvclient directory contains a demo that is similar to the bufclient demo: <br />
: it shows how to load data from a SQLDB REST bridge server in a TCSVDataset dataset, using the 'csv' format<br />
<br />
=== Pas2JS ===<br />
<br />
Requires pas2js 1.5+<br />
<br />
* A similar application to the lazarus buffclient/jsonclient programs exists for pas2JS in pas2js/demo/restbridge/simple/restbridgeclient.lpi<br />
: [[File:sqldbrestbridgepas2js.png]]<br />
<br />
== TODO ==<br />
<br />
The following extensions are still planned:<br />
<br />
* Support for <code>?q=filterexpression</code> in URL filters.<br />
* Connection management API. (zero-config service)<br />
* Use HTTP credentials to connect to the database.<br />
* Unknown query params are now ignored. Allow to check for valid query parameters and raise error if unknown query param is encountered.<br />
<br />
[[Category:Databases]]</div>Michaelhttps://wiki.freepascal.org/index.php?title=Lazarus_InstantSearch&diff=154998Lazarus InstantSearch2022-12-31T17:56:43Z<p>Michael: Lazarus instant search help, first version</p>
<hr />
<div>== Intro ==<br />
The instantsearch package is a package to search within sources (or other sources of text)<br />
<br />
It provides an as-you-type search mechanism. <br />
See the 'View - Instantsearch' menu item (or CTRL-ALT-F).<br />
<br />
It uses [https://manticoresearch.com/ Manticore Search] to provide the<br />
search capabilities. Manticore search creates an index of the source files,<br />
which it then uses to provide you with search capabilities.<br />
<br />
== Installation ==<br />
<br />
=== Install ManticoreSearch ===<br />
<br />
Before you can use Lazarus InstantSearch, you must have Manticore Search<br />
installed. It can be installed locally, or on another computer.<br />
<br />
To install Manticore search, please see the instructions at <br />
[https://manual.manticoresearch.com/Installation]<br />
<br />
=== Install InstantSearch ===<br />
<br />
Using the package menu, install the '''lazinstantsearch''' package.<br />
You will need to recompile the IDE.<br />
<br />
=== Configure instantsearch. ===<br />
<br />
After installing the package, before you can use instantsearch, it needs to be configured: <br />
at least the location of the manticore search engine must be specified.<br />
<br />
Using Tools - options, select the 'Instant Search' item under the Environment<br />
option group.<br />
<br />
== Configuration ==<br />
The configuration is done using the 'Instant Search' item under the Environment option group.<br />
<br />
[[File:lazarus_instantsearch_options1.png|Options]]<br />
<br />
You must configure at least the following things:<br />
* Protocol - MySQL or HTTP<br />
* MySQL Client version - if you selected the MySQL protocol.<br />
<br />
You can leave hostname and port empty if you installed on the local machine<br />
using the default settings.<br />
<br />
Test the connection with the 'Test connection' button.<br />
<br />
If the connection is OK, set the index name to use, and use the 'Create<br />
Index' button to create the table used to store the search index.<br />
<br />
if the index already exists, you will be warned about this.<br />
<br />
When the index has been created (or was already created), <br />
the configuration dialog will check which source trees exist (normally<br />
none), and will offer to start indexing. This is done in the background.<br />
<br />
=== Configuring source trees ===<br />
<br />
By default, InstantSearch configures 4 source trees:<br />
* RTL : The RTL sources of FPC.<br />
* FCL : The packages sources of FPC.<br />
* Compiler : The FPC compiler sources <br />
* LCL : The lazarus LCL sources.<br />
<br />
You can define as much search trees as you want, using the buttons in the toolbar.<br />
You can use the buttons to refresh the indexes of a source tree.<br />
<br />
Note: when you change the source directory of FPC or rescan it, <br />
the RTL/FCL/Compiler trees will be re-indexed.<br />
<br />
[[File:lazarus_instantsearch_options2.png|Source tree definitions]]<br />
<br />
The 4 trees are configured and indexed automatically, a message will appear<br />
in the messages window when this happens.<br />
<br />
=== Indexing the current (active) project. ===<br />
The sources of the current project can also be searched, provided it has<br />
been indexed. This is a 2-step process:<br />
<br />
* Mark a project as indexable. This can be done using the ``Mark project as indexable``<br />
: popup menu item in the project inspector, or below the 'Project' menu in the main menu. <br />
<br />
* Actually index the project. The project is automatically indexed when you<br />
: mark it as indexable. <br />
: You can manually index a project at any time using the project menu item in the main menu, <br />
: or the popup item. <br />
<br />
== Searching ==<br />
To search, open the 'Instant search' window under 'View' (or press CTRL-Alt-F)<br />
<br />
If Instant Search was not not configured, you will get a warning and the IDE<br />
will offer to open the configuration dialog.<br />
<br />
The dialog will automatically copy the selection (provided it is not too big and does not contain CR/LF characters) <br />
to the search edit box and do a search with that. <br />
<br />
You can type in the search edit box at the top.<br />
As you type, the search results will be more refined or expanded.<br />
<br />
Each match is displayed with the line contents, and the filename+lineno.<br />
<br />
[[File:lazarus_instantsearch_searching.png|Searching]]<br />
<br />
Double click one of the lines to open the file at the selected location.<br />
<br />
If you have too many matches, you can check or uncheck some of the source<br />
trees in the top-right search bar.</div>Michaelhttps://wiki.freepascal.org/index.php?title=File:lazarus_instantsearch_searching.png&diff=154997File:lazarus instantsearch searching.png2022-12-31T17:53:40Z<p>Michael: </p>
<hr />
<div></div>Michaelhttps://wiki.freepascal.org/index.php?title=File:lazarus_instantsearch_options2.png&diff=154996File:lazarus instantsearch options2.png2022-12-31T17:52:56Z<p>Michael: </p>
<hr />
<div></div>Michaelhttps://wiki.freepascal.org/index.php?title=File:lazarus_instantsearch_options1.png&diff=154995File:lazarus instantsearch options1.png2022-12-31T17:50:19Z<p>Michael: </p>
<hr />
<div></div>Michaelhttps://wiki.freepascal.org/index.php?title=fphttpserver&diff=153952fphttpserver2022-08-24T07:28:50Z<p>Michael: /* Support for HTTPS */</p>
<hr />
<div>== fphttpserver Unit ==<br />
<br />
=== Intro ===<br />
The ''fphttpserver'' unit contains a standalone HTTP server component: ''TFPHTTPServer''. It has the following features:<br />
<br />
# Specify any port you want.<br />
# SSL capable. It generates a self-signed certificate if needed.<br />
# Various threading modes: none, fully threaded or using a thread pool.<br />
# Upgrade mechanism.<br />
# Event-driven.<br />
# Keeps connections (HTTP 1.1).<br />
<br />
You can drop this component on a form and handle requests.<br />
Note that this component does not do any routing of requests, for that, use the ''TFPHTTPApplication'' class (see below).<br />
<br />
=== Properties ===<br />
<br />
The following properties are available:<br />
;Active (boolean)<br />
: Set to true to start the server, set to false to stop the server.<br />
;Port (integer)<br />
: Port number to listen on. Default 80.<br />
;QueueSize (integer)<br />
: Queue size for the Accept() call.<br />
;Threaded (boolean)<br />
: Is the server threaded or not? <br />
: Deprecated in 3.3.1: use ThreadMode instead.<br />
;ThreadMode (tmNone, tmThread, tmThreadPool)<br />
: Choose how to use threads to process requests. Note that keeping connections open and no threading will not work very well.<br />
;AcceptIdleTimeout (integer)<br />
: Accepting new connections happens in a loop. <br />
: This timeout specifies the number of milliseconds to wait before Accept times out, at which point the OnAcceptIdle is called.<br />
: If zero, the accept call does not time out.<br />
;KeepConnections (boolean)<br />
: Allow to keep connections (HTTP 1.1).<br />
;KeepConnectionTimeout (integer)<br />
: Number of milliseconds to wait before closing an open (persistent) connection.<br />
;OnAllowConnect (event)<br />
: An event handler to decide whether you want to accept a connection or not. This is called before the request is parsed.<br />
;OnRequest (event)<br />
: An event handler to actually handle requests. <br />
: The signature of this method is the same as for all other fcl-web request handlers: you get a request and response object.<br />
;OnRequestError (event)<br />
: Triggered when an exception occurs during a request.<br />
;OnAcceptIdle (event)<br />
: Triggered when the Accept loop goes idle.<br />
<br />
=== Usage ===<br />
<br />
# Create the component in code (or drop on a form/datamodule in the Lazarus IDE). <br />
# Set the port number. <br />
# Create an ''OnRequest'' handler to handle requests.<br />
# At runtime, set the ''Active'' property to ''True''. This statement will not return till the server is stopped.<br />
<br />
=== Support for HTTPS ===<br />
Using HTTPS is just setting a property on ''TFPHTTPServer'':<br />
<br />
<syntaxhighlight lang="pascal"><br />
UseSSL := True;<br />
</syntaxhighlight><br />
<br />
And include one of the units that registers an SSL handler: ''opensslsockets'' or ''gnutlssockets''. <br />
<br />
You need to set your certificate details as well:<br />
<syntaxhighlight lang="pascal"><br />
fServer.UseSSL := fUseSSL;<br />
if fUseSSL then<br />
begin<br />
fServer.CertificateData.KeyPassword := fCertificatePassword;<br />
fServer.CertificateData.HostName := fCertificateHostName;<br />
fServer.CertificateData.Certificate.FileName := fCertificateFileName;<br />
fServer.CertificateData.PrivateKey.FileName := fCertificatePrivateKey;<br />
end;<br />
</syntaxhighlight><br />
If you do not set the certificate details, the HTTP server component will generate a temporary certificate,<br />
which may lead to a warning being displayed in the browser.<br />
<br />
This works as of FPC 3.2.2.<br />
<br />
== fphttapp & custhttpapp Units ==<br />
<br />
=== Intro ===<br />
The ''TFPHTTPServer'' does not route requests. It only sends them through the 'OnRequest' event handler.<br />
<br />
To integrate with the rest of fcl-web, instead use the ''THTTPApplication'' or ''TFPCustomHTTPApplication'' classes.<br />
These classes are descendents of TCustomApplication and handle everything from server setup to routing requests.<br />
<br />
The ''fphttpapp'' unit contains simply an initialized version of the ''THTTPApplication'' class.<br />
<br />
=== Properties ===<br />
<br />
In addition to the TCustomWebApplication (common ancestor for all kinds of web application: CGI, FastCGI, Apache Module etc.) the following properties are available:<br />
(they mostly map to the properties of the ''TFPHttpServer'' class)<br />
<br />
;Address (string)<br />
: Server address<br />
;Port (Word)<br />
: TCP/IP port to listen on<br />
;QueueSize (Word)<br />
: Max connections on queue (for Listen call)<br />
;OnAllowConnect (Event)<br />
: Called when deciding whether to accept a connection.<br />
;Threaded (Boolean)<br />
: Use a thread to handle a connection ?<br />
;LookupHostNames (Boolean)<br />
: Should addresses be matched to hostnames ? (expensive)<br />
;OnAcceptIdle (Event)<br />
: Event handler called when going Idle while waiting for a connection<br />
;AcceptIdleTimeout (integer)<br />
: If >0, when no new connection appeared after timeout, OnAcceptIdle is called.<br />
;UseSSL (Boolean)<br />
: Use SSL or not<br />
;HostName (String)<br />
: Hostname to use when using SSL<br />
;CertificateData (TCertificateData)<br />
: Access to certificate data<br />
<br />
=== Usage ===<br />
The following demonstrates the use of the ''TFPHTTPApplication'' class:<br />
<syntaxhighlight lang="pascal"><br />
program webserver;<br />
<br />
{$mode objfpc}{$H+}<br />
<br />
uses<br />
{$ifdef UNIX}<br />
cthreads, cmem,<br />
{$endif} <br />
fphttpapp, httpdefs, httproute;<br />
<br />
procedure route1(aReq: TRequest; aResp: TResponse);<br />
begin<br />
aResp.Content:='<html><body><h1>Route 1 The Default</h1></body></html>';<br />
end;<br />
<br />
procedure route2(aReq: TRequest; aResp: TResponse);<br />
begin<br />
aResp.Content:='<html><body><h1>Route 2</h1></body></html>';<br />
end;<br />
<br />
begin<br />
HTTPRouter.RegisterRoute('/', @route1);<br />
HTTPRouter.RegisterRoute('/2', @route2);<br />
Application.Port := 1999;<br />
Application.Threaded := true;<br />
Application.Initialize;<br />
Application.Run;<br />
end.<br />
</syntaxhighlight></div>Michaelhttps://wiki.freepascal.org/index.php?title=fphttpserver&diff=153951fphttpserver2022-08-24T07:27:47Z<p>Michael: /* Support for HTTPS */</p>
<hr />
<div>== fphttpserver Unit ==<br />
<br />
=== Intro ===<br />
The ''fphttpserver'' unit contains a standalone HTTP server component: ''TFPHTTPServer''. It has the following features:<br />
<br />
# Specify any port you want.<br />
# SSL capable. It generates a self-signed certificate if needed.<br />
# Various threading modes: none, fully threaded or using a thread pool.<br />
# Upgrade mechanism.<br />
# Event-driven.<br />
# Keeps connections (HTTP 1.1).<br />
<br />
You can drop this component on a form and handle requests.<br />
Note that this component does not do any routing of requests, for that, use the ''TFPHTTPApplication'' class (see below).<br />
<br />
=== Properties ===<br />
<br />
The following properties are available:<br />
;Active (boolean)<br />
: Set to true to start the server, set to false to stop the server.<br />
;Port (integer)<br />
: Port number to listen on. Default 80.<br />
;QueueSize (integer)<br />
: Queue size for the Accept() call.<br />
;Threaded (boolean)<br />
: Is the server threaded or not? <br />
: Deprecated in 3.3.1: use ThreadMode instead.<br />
;ThreadMode (tmNone, tmThread, tmThreadPool)<br />
: Choose how to use threads to process requests. Note that keeping connections open and no threading will not work very well.<br />
;AcceptIdleTimeout (integer)<br />
: Accepting new connections happens in a loop. <br />
: This timeout specifies the number of milliseconds to wait before Accept times out, at which point the OnAcceptIdle is called.<br />
: If zero, the accept call does not time out.<br />
;KeepConnections (boolean)<br />
: Allow to keep connections (HTTP 1.1).<br />
;KeepConnectionTimeout (integer)<br />
: Number of milliseconds to wait before closing an open (persistent) connection.<br />
;OnAllowConnect (event)<br />
: An event handler to decide whether you want to accept a connection or not. This is called before the request is parsed.<br />
;OnRequest (event)<br />
: An event handler to actually handle requests. <br />
: The signature of this method is the same as for all other fcl-web request handlers: you get a request and response object.<br />
;OnRequestError (event)<br />
: Triggered when an exception occurs during a request.<br />
;OnAcceptIdle (event)<br />
: Triggered when the Accept loop goes idle.<br />
<br />
=== Usage ===<br />
<br />
# Create the component in code (or drop on a form/datamodule in the Lazarus IDE). <br />
# Set the port number. <br />
# Create an ''OnRequest'' handler to handle requests.<br />
# At runtime, set the ''Active'' property to ''True''. This statement will not return till the server is stopped.<br />
<br />
=== Support for HTTPS ===<br />
Using HTTPS is just setting a property on ``TFPHTTPServer``:<br />
<br />
<syntaxhighlight lang="pascal"><br />
UseSSL := True;<br />
</syntaxhighlight><br />
<br />
And include one of the units that registers an SSL handler: ''opensslsockets'' or ''gnutlssockets''. <br />
<br />
You need to set your certificate details as well:<br />
<syntaxhighlight lang="pascal"><br />
fServer.UseSSL := fUseSSL;<br />
if fUseSSL then<br />
begin<br />
fServer.CertificateData.KeyPassword := fCertificatePassword;<br />
fServer.CertificateData.HostName := fCertificateHostName;<br />
fServer.CertificateData.Certificate.FileName := fCertificateFileName;<br />
fServer.CertificateData.PrivateKey.FileName := fCertificatePrivateKey;<br />
end;<br />
</syntaxhighlight><br />
If you do not set the certificate details, the HTTP server component will generate a temporary certificate,<br />
which may lead to a warning being displayed in the browser.<br />
<br />
This works as of FPC 3.2.2.<br />
<br />
== fphttapp & custhttpapp Units ==<br />
<br />
=== Intro ===<br />
The ''TFPHTTPServer'' does not route requests. It only sends them through the 'OnRequest' event handler.<br />
<br />
To integrate with the rest of fcl-web, instead use the ''THTTPApplication'' or ''TFPCustomHTTPApplication'' classes.<br />
These classes are descendents of TCustomApplication and handle everything from server setup to routing requests.<br />
<br />
The ''fphttpapp'' unit contains simply an initialized version of the ''THTTPApplication'' class.<br />
<br />
=== Properties ===<br />
<br />
In addition to the TCustomWebApplication (common ancestor for all kinds of web application: CGI, FastCGI, Apache Module etc.) the following properties are available:<br />
(they mostly map to the properties of the ''TFPHttpServer'' class)<br />
<br />
;Address (string)<br />
: Server address<br />
;Port (Word)<br />
: TCP/IP port to listen on<br />
;QueueSize (Word)<br />
: Max connections on queue (for Listen call)<br />
;OnAllowConnect (Event)<br />
: Called when deciding whether to accept a connection.<br />
;Threaded (Boolean)<br />
: Use a thread to handle a connection ?<br />
;LookupHostNames (Boolean)<br />
: Should addresses be matched to hostnames ? (expensive)<br />
;OnAcceptIdle (Event)<br />
: Event handler called when going Idle while waiting for a connection<br />
;AcceptIdleTimeout (integer)<br />
: If >0, when no new connection appeared after timeout, OnAcceptIdle is called.<br />
;UseSSL (Boolean)<br />
: Use SSL or not<br />
;HostName (String)<br />
: Hostname to use when using SSL<br />
;CertificateData (TCertificateData)<br />
: Access to certificate data<br />
<br />
=== Usage ===<br />
The following demonstrates the use of the ''TFPHTTPApplication'' class:<br />
<syntaxhighlight lang="pascal"><br />
program webserver;<br />
<br />
{$mode objfpc}{$H+}<br />
<br />
uses<br />
{$ifdef UNIX}<br />
cthreads, cmem,<br />
{$endif} <br />
fphttpapp, httpdefs, httproute;<br />
<br />
procedure route1(aReq: TRequest; aResp: TResponse);<br />
begin<br />
aResp.Content:='<html><body><h1>Route 1 The Default</h1></body></html>';<br />
end;<br />
<br />
procedure route2(aReq: TRequest; aResp: TResponse);<br />
begin<br />
aResp.Content:='<html><body><h1>Route 2</h1></body></html>';<br />
end;<br />
<br />
begin<br />
HTTPRouter.RegisterRoute('/', @route1);<br />
HTTPRouter.RegisterRoute('/2', @route2);<br />
Application.Port := 1999;<br />
Application.Threaded := true;<br />
Application.Initialize;<br />
Application.Run;<br />
end.<br />
</syntaxhighlight></div>Michaelhttps://wiki.freepascal.org/index.php?title=WebAssembly&diff=152066WebAssembly2022-05-23T16:21:31Z<p>Michael: /* See Also */</p>
<hr />
<div>= WebAssembly =<br />
<br />
WebAssembly (abbreviated Wasm) is a binary instruction format for a stack-based virtual machine. Wasm is designed as a portable compilation target for programming languages, enabling deployment on the web for client and server applications. See the [https://webassembly.org WebAssembly] website for more information.<br />
<br />
= Free Pascal and WebAssembly =<br />
<br />
FPC supports two Wasm compilation targets: WASI and embedded. See [[WebAssembly/Compiler]] on how to build and install FPC for Wasm.<br />
<br />
[https://wasi.dev WASI] - the WebAssembly System Interface - defines an API for operating system-like features, including files and filesystems, network sockets, clocks and random numbers. These features, when implemented in web browsers as well as standalone Wasm runtimes on desktops, servers, and serverless cloud computing units, are available to Pascal programs and libraries compiled by FPC to Wasm for the WASI target. <br />
<br />
The FPC WASI RTL consists of these units:<br />
* fcl-base<br />
* fcl-css<br />
* fcl-hash<br />
* fcl-registry<br />
* fcl-sound<br />
* fcl-stl<br />
* fcl-xml<br />
* hash<br />
* regexpr<br />
* rtl<br />
* rtl-extra<br />
* rtl-objpas<br />
* rtl-unicode<br />
* tplylib<br />
<br />
The FPC Wasm embedded RTL, in line with FPC's support for [[TARGET_Embedded|embedded targets]], consists of these units:<br />
* rtl<br />
* rtl-extra<br />
* tplylib<br />
<br />
With respect to the embedded target, there are presently (2022) early efforts to create Wasm-related standards for cross-device/platform/architecture embedded applications. <br />
<br />
Overall, FPC's Wasm support adds to FPC's already [https://www.freepascal.org/ extensive list of compilation targets], potentially allowing Pascal programs to run in even more environments than they already do.<br />
<br />
= Demos =<br />
<br />
== Running in Web Browsers ==<br />
In each demo, the driver program is transpiled from Pascal to Javascript using [[pas2js]], and the worker program/library is compiled from Pascal to Wasm using FPC WASI target.<br />
<br />
* [https://www.freepascal.org/~michael/pas2js-demos/wasienv/terminal/ Simulated terminal input and output]<br />
* [https://www.freepascal.org/~michael/pas2js-demos/wasienv/canvas/ Drawing on HTML canvas]<br />
* [https://github.com/PierceNg/wasm-demo/ Conway's Game of Life]<br />
<br />
== With Standalone Runtime ==<br />
<br />
Free Pascal's source tree contains [https://gitlab.com/freepascal.org/fpc/source/-/tree/main/packages/wasmtime/examples examples] embedding the [https://github.com/bytecodealliance/wasmtime wasmtime] standalone Wasm runtime in Pascal host programs.<br />
<br />
=See Also=<br />
* [[WebAssembly/Compiler]]<br />
* [[WebAssembly/Roadmap]]<br />
* [[WebAssembly/JS]]<br />
* [[WebAssembly/DOM]]<br />
* [[WebAssembly/Threads]]<br />
<br />
There is an external pet project to create a pascal interpreter, not related to Free Pascal:<br />
* [https://faizilham.github.io/making-budget-pascal-compiler Making a budget Pascal compiler to WebAssembly]<br />
<br />
[[Category:WebAssembly]]</div>Michaelhttps://wiki.freepascal.org/index.php?title=WebAssembly/Threads&diff=152065WebAssembly/Threads2022-05-23T16:20:51Z<p>Michael: /* Thread support */</p>
<hr />
<div>= Thread support =<br />
<br />
This page contains some collected informations on the features needed for thread support in WebAssembly (in the browser).<br />
<br />
Thread support consists of 2 parts:<br />
<br />
* Atomic instructions.<br />
* Actually starting a thread. <br />
<br />
<br />
== Atomic instructions ==<br />
<br />
[https://github.com/WebAssembly/threads/blob/master/proposals/threads/Overview.md The proposed specs]Â <br />
<br />
== Thread support ==<br />
<br />
Webassembly relies on the hosting environment to actually start threads.<br />
<br />
Some extra info: <br />
<br />
* [https://web.dev/webassembly-threads/ something like specs]<br />
* [https://rreverser.com/wasm-bindgen-rayon-demo/ A demo]<br />
* [https://wicg.github.io/file-system-access/ related]</div>Michaelhttps://wiki.freepascal.org/index.php?title=WebAssembly/Threads&diff=152064WebAssembly/Threads2022-05-23T16:17:13Z<p>Michael: Initial page</p>
<hr />
<div>= Thread support =<br />
<br />
== Atomic instructions ==<br />
<br />
<br />
<br />
== Thread support ==<br />
<br />
Some extra info: <br />
<br />
* [https://web.dev/webassembly-threads/ something like specs]<br />
* [https://rreverser.com/wasm-bindgen-rayon-demo/ A demo]<br />
* [https://wicg.github.io/file-system-access/ related]</div>Michaelhttps://wiki.freepascal.org/index.php?title=pas2js_designtime&diff=152052pas2js designtime2022-05-21T22:52:23Z<p>Michael: /* TDBSelectWidget */</p>
<hr />
<div>= Designtime support for Pas2JS Components =<br />
<br />
The ''pas2jscomponents.lpk'' package that comes with lazarus installs design-time support for pas2js webwidgets <br />
and design-time editing of components.<br />
<br />
== Installed functionality ==<br />
<br />
* there is a new file type 'HTML Fragment', this is akin to a 'Form' or 'Frame'.<br />
* There are several components that allow you to interact with the HTML.<br />
** THTMLElementActionList<br />
** TBootstrapModal<br />
** TBootstrapToastWidget<br />
** TTemplateLoader<br />
** TSQLDBRestConnection<br />
** TSQLDBRestDataset<br />
** TDBBootstraptableWidget<br />
** TDBLoopTableWidget<br />
** TDBSelectWidget<br />
<br />
The package also installs support for parsing HTML files and loading HTML id attributes from the html.<br />
Properties that need a HTML element ID, will display a dropdown with the discovered ID attributes.<br />
<br />
<br />
== HTML Fragment ==<br />
<br />
The HTML fragment is the HTML equivalent of a form in a native LCL application.<br />
An application can contain multiple HTML fragments, which can be shown at the same time or separately.<br />
<br />
You can add a new HTML fragment with the File-New dialog:<br />
<br />
[[File:htmlfragment.png]]<br />
<br />
This will start a new form, which looks like a datamodule in the IDE.<br />
<br />
After dropping some components on it, it will look for example like this in the designer:<br />
<br />
[[File:fragment-design.png]]<br />
<br />
The object inspector can be used to manipulate the properties, just as for a regular form.<br />
<br />
Note: <br />
You must add '''-JRjs''' to the custom compiler options of your project to include the form data in the application.<br />
Additionally, the ''p2jsres'' unit must be added to the uses clause of your program, so the resource data can be loaded when the program is run.<br />
<br />
The HTML for the fragment can be loaded in 3 ways:<br />
* Set the '''UseProjectHTMLFile''' property to ''True'' if you will only use the main html file of your project. No additional HTML will be loaded.<br />
* Set the '''TemplateName''' property to the name of a template to load.<br />
* Set the '''HTMLFilename''' property to the name of a HTML file to load. It will be loaded using the global template loader in unit ''rtl.TemplateLoader''<br />
<br />
The '''ParentID''' property determines under what HTML element in the main HTML page the HTML fragment will be loaded.<br />
<br />
The following events exist:<br />
<br />
* '''OnAllowUnrender''' is called when you wish to show another HTML fragment instead of this one. It is equivalent to '''OnCloseQuery''' in an LCL form.<br />
* '''OnCreate''' Called when the fragment is created. note that the HTML is not yet available.<br />
* '''OnDestroy''' Called when the fragment is destroyed.<br />
* '''OnHTMLLoaded''' Called when the HTML fragment has been loaded from the server.<br />
* '''OnRendered''' Called when the HTML fragment has been inserted in the DOM.<br />
* '''OnUnRendered''' Called when the HTML fragment has been removed from the DOM.<br />
<br />
<br />
== Installed components ==<br />
<br />
The ''pas2jscomponents'' package also installs some components.<br />
<br />
=== THTMLElementActionList ===<br />
<br />
The '''THTMLElementActionList''' component is similar to the Action list in design-time concept, but works differently at runtime:<br />
You can associate a '''THTMLElementAction''' with every element in the HTML fragment's HTML that has an ID, or you can use a CSS selector to let an action respresent a series of HTML Elements.<br />
<br />
You don't need to create these actions manually. In the context menu there is an item "Create actions for HTML tags"<br />
<br />
[[File:htmlelementactionlist.png]]<br />
<br />
This menu will pop up a wizard that finds all elements for which no action exists yet, and proposes to create an action:<br />
<br />
[[File:createhtmlactions.png]]<br />
<br />
If you check the ''Use Data-Aware Actions'' checkbox, then DB-Aware actions will be used.<br />
These can be used as button actions (to navigate in the data, insert/post/delete etc. etc)<br />
<br />
The action editor works similar to the LCL action list editor:<br />
<br />
[[File:elementactioneditor.png]]<br />
<br />
The main properties of an action are:<br />
<br />
* '''ElementID''' the ID of the element you want to control. <br />
* '''CSSSelector''' A css selector for thes element you want to control in case of multiple elements (e.g. to get all rows in a table use '''#tableid tr''')<br />
* '''Events''' a set of events to listen for. When the event is triggered, the '''OnExecute''' event handler is executed.<br />
* '''CustomEvents''' a space separated list of HTML to listen for, for events that do not appear in **Events**<br />
* '''PreventDefault''' can be set to '''True''' to prevent the default HTML action from happening.<br />
* '''StopPropagation''' can be set to '''True''' to prevent the event from ''bubbling'', i.e. propagating to parent elements.<br />
<br />
=== TBootstrapModal ===<br />
<br />
A component (similar to the LCL Dialog components) to show a modal dialog using Bootstrap. (you need to include the various bootstrap files in your project HTML file)<br />
<br />
The following properties exist:<br />
* '''ShowOnRender''' set to ''True'' if you wish to show the modal as soon as it is rendered (meaning, the HTML was generated).<br />
* '''BackDrop''' show a backdrop shadow over the rest of the HTML page.<br />
* '''KeyBoard''' Allow keyboard actions<br />
* '''Focus''' set focus to the modal.<br />
* '''Template''' the HTML for the modal.<br />
* '''TemplateName''' the name of a template in '''TempateLoader''' containing the modal HTML.<br />
* '''TemplateLoader''' a custom template loader. If not set, a global template loader is used.<br />
* '''References''' a collection of CSS Selectors which can be used to get a reference to elements in the modal. These can be used to retrieve entered values during the **OnHide** event handler..<br />
<br />
<br />
The following events exist:<br />
<br />
* '''OnHide''' event triggered when the modal is hidden.<br />
<br />
<br />
<br />
=== TBootstrapToastWidget ===<br />
<br />
The '''TBootstrapToastWidget''' allow you to show a small ''Toast'' message.<br />
<br />
It can show a toast embedded in the HTML file, or the HTML can be generated from the properties<br />
<br />
* '''Header''' a string with the HTML for the header tag.<br />
* '''SmallHeader''' a string with the HTML for the sub (smaller) header tag.<br />
* '''Body''' a string with the HTML for body of the modal.<br />
* '''HeaderImage''' an URL for the header image.<br />
* '''CloseButton''' set to ''True'' to add a close button to the dialog.<br />
* '''Contextual''' an enumerated which allows you to select one of the primary bootstrap color schemes.<br />
* '''HideDelay''' a number of milliseconds before the toast automatically disappears when ''AutoHide'' is ''True''.<br />
* '''AutoHide''' set to ''True'' to let the toast disappear automatically after ''HideDelay'' milliseconds.<br />
* '''Animate''' set to ''True'' to animate showing and hiding of the modal.<br />
* '''MinWidth''' minimum width for the modal.<br />
* '''UnrenderOnHide''' if set to ''True'' the HTML of the toast will be removed from the DOM when the toast is hidden.<br />
<br />
The following event exists:<br />
* '''OnHide''' triggered when the toast is hidden.<br />
<br />
=== TTemplateLoader ===<br />
<br />
This component can be used to load HTML fragments (in fact, any file) when the webapplication is run.<br />
<br />
When loaded, the templates are available in a named array ''Templates'' where the index is the name of a template.<br />
The list of templates to load can be specified in the ''PreloadTemplates'' property, a collection.<br />
<br />
The following properties exist:<br />
<br />
* '''BaseURL''' all filenames for templates are relative to this URL.<br />
* '''CheckResources''' When loading a template, check if a resource with the same name as the template exists. If yes, load the template from the resource.<br />
* '''PreloadTemplates''' List of templates to load as soon as the component is loaded from the form file.<br />
<br />
The following events exist:<br />
<br />
* '''OnLoad''' triggered when a template is loaded. The name of the loaded template is passed to the event handler.<br />
* '''OnLoadFail''' triggered when a template fails to load. The name of the loaded template is passed to the event handler.<br />
<br />
Because the loading happens asynchronous, the following method is useful:<br />
<br />
<syntaxhighlight lang="pascal"><br />
Procedure IfTemplate(const aName : String; aEvent : TTemplateNotifyEvent);<br />
</syntaxhighlight><br />
this method will check if template ''aName'' is loaded, and calls ''aEvent'' if it is. If it is not yet loaded, it will wait till the template is loaded and then call the event.<br />
<br />
Additional templates can be loaded with the following 2 calls:<br />
<syntaxhighlight lang="pascal"><br />
Procedure LoadTemplate(Const aName,aURL : String; aOnSuccess : TTemplateNotifyEvent = Nil; AOnFail : TTemplateErrorNotifyEvent= Nil);<br />
Procedure LoadTemplates(Const Templates : Array of String; aOnSuccess : TTemplateNotifyEvent = Nil; AOnFail : TTemplateErrorNotifyEvent= nil);<br />
</syntaxhighlight><br />
These methods will load a template, even if it was already loaded before. <br />
In case of the array, there must be an even number of elements, the odd elements are template names and the even elements are corresponding filenames.<br />
<br />
=== TSQLDBRestConnection ===<br />
=== TSQLDBRestDataset ===<br />
=== TDBBootstraptableWidget ===<br />
<br />
A widget that renders a bootstrap-table table based on a dataset.<br />
<br />
[https://bootstrap-table.com/ Bootstrap-Table can be downloaded here]<br />
<br />
It renders a read-only table with paging and search options, based on the properties set, and the data from a dataset:<br />
<br />
<br />
The component has the following properties:<br />
* '''StylingClasses''' a set of properties that affect how a column with a button is rendered. See below for the list of properties.<br />
* '''Columns''' A column with the columns to render in the table.<br />
* '''DataSource''' a reference to the dataset for which to render the table. The table is rendered when the dataset opens, it is unrendered when the dataset closes.<br />
* '''Options''' a set of general options for the table behaviour.<br />
* '''ViewOptions''' a set of options that determine the look-and-feel of the table.<br />
* '''PaginationOptions''' a set of options that govern the pagination mechanism of the table.<br />
* '''SearchOptions''' a set of options that control the search mechanism of the table.<br />
* '''SortOptions''' a set of options that control the sorting mechanism of the table.<br />
* '''DisplayReadOnly''' set all edit/delete buttons readonly.<br />
* '''AfterBodyDraw''' event triggered after the table body has been rendered.<br />
<br />
For each column to be rendered the following properties can be set:<br />
<br />
* '''FieldName''': The Fieldname for this column<br />
* '''Title''': The Title for this column<br />
* '''RenderMode''': The Render mode for the column: text, number, checkbox, button custom render<br />
* '''ButtonType''': When rendermode is rmButton, what button must be rendered.<br />
* '''ButtonIconClass''': When buttontype is btCustom, use the following class (in &lt;i class=""&gt;&lt;/i&gt;)<br />
* '''OnTransformValue''': Event called when rendermode is rmTransformValue<br />
* '''OnCustomFormat''': EVent called when rendermode is rmCustom<br />
* '''Width''': Column Width (in WidthUnits units)<br />
* '''WidthUnits''': Column Width (in CSS units)<br />
* '''CSSClassName''': a CSS Class name applied on cells for this column<br />
* '''CheckBoxClassName''': CSS Class name for this column if there is a check box.<br />
* '''Visible''': Visible column or not ?<br />
* '''Searchable''': A boolean that Indicates whether the column is searchable<br />
* '''Sortable''': A boolean that Indicates whether the column is sortable<br />
* ''' ButtonURL''': string URL to use when the button is clicked<br />
* '''ButtonURLTarget''': link element target attribute.<br />
<br />
The '''TStylingClasses''' has the following properties:<br />
<br />
* '''CheckBoxClass''' a space-separated list of classes to apply to a checkbox column.<br />
* '''ButtonClass''' a space-separated list of classes to apply to a button column.<br />
* '''InfoClass''' a space-separated list of classes to apply to a info button column.<br />
* '''EditClas''' a space-separated list of classes to apply to a edit button column.<br />
* '''ReadonlyEditClass''' a space-separated list of classes to apply to a read-only edit column.<br />
* '''DeleteClass''' a space-separated list of classes to apply to a delete button column.<br />
<br />
=== TDBLoopWidget ===<br />
<br />
A widget that renders a HTML template for every record in a dataset.<br />
The HTML templates can contain placeholders in the form {{FieldName}} which will be replaced with the field value of the dataset for that record.<br />
<br />
The '''Groups''' collection can be used to make groups based on the values in the dataset: when the group value changes, a new group is started and the header template for the group is rendered. When a group ended, a footer template is rendered for that group.<br />
<br />
The following properties exist:<br />
<br />
* '''HeaderTemplate''' The header template is rendered before starting the loop.<br />
* '''ItemTemplate''' The Item template is rendered for each record in the dataset.<br />
* '''FooterTemplate''' The footer template is rendered before starting the loop.<br />
* '''OnGetValue''' event called to get the value of a placeholder.<br />
* '''References''' use CSS selectors to get references to the nodes in the rendered content;<br />
* '''Datasource''' a reference to the data for which to render the loop.<br />
* '''OnFormatField''' an event to get a custom formatted version of a field.<br />
* '''Groups''' a collection of groups for which an expression, a footer and header template can be specified.<br />
* '''OnGetGroupValue''' to get a custom value for a group expression.<br />
<br />
=== TDBSelectWidget ===<br />
<br />
A widget which renders a html SELECT element based on data in a dataset.<br />
<br />
The following properties are available:<br />
<br />
* '''Datasource''' a reference to the data from which to generate the SELECT element.<br />
* '''ItemField''' the field whose value is used to create an OPTION element in the SELECT.<br />
* '''ValueField''' when set, the field whose value is used to set the '''value''' attribute of an OPTION element in the select.<br />
* '''NullIsNotValue''' if a field is null, no value is generated.<br />
* '''SelectedIndex''' set the selected item index.<br />
* '''Multiple''' allow multiselect.</div>Michaelhttps://wiki.freepascal.org/index.php?title=pas2js_designtime&diff=152051pas2js designtime2022-05-21T22:48:34Z<p>Michael: /* TDBLoopTableWidget */</p>
<hr />
<div>= Designtime support for Pas2JS Components =<br />
<br />
The ''pas2jscomponents.lpk'' package that comes with lazarus installs design-time support for pas2js webwidgets <br />
and design-time editing of components.<br />
<br />
== Installed functionality ==<br />
<br />
* there is a new file type 'HTML Fragment', this is akin to a 'Form' or 'Frame'.<br />
* There are several components that allow you to interact with the HTML.<br />
** THTMLElementActionList<br />
** TBootstrapModal<br />
** TBootstrapToastWidget<br />
** TTemplateLoader<br />
** TSQLDBRestConnection<br />
** TSQLDBRestDataset<br />
** TDBBootstraptableWidget<br />
** TDBLoopTableWidget<br />
** TDBSelectWidget<br />
<br />
The package also installs support for parsing HTML files and loading HTML id attributes from the html.<br />
Properties that need a HTML element ID, will display a dropdown with the discovered ID attributes.<br />
<br />
<br />
== HTML Fragment ==<br />
<br />
The HTML fragment is the HTML equivalent of a form in a native LCL application.<br />
An application can contain multiple HTML fragments, which can be shown at the same time or separately.<br />
<br />
You can add a new HTML fragment with the File-New dialog:<br />
<br />
[[File:htmlfragment.png]]<br />
<br />
This will start a new form, which looks like a datamodule in the IDE.<br />
<br />
After dropping some components on it, it will look for example like this in the designer:<br />
<br />
[[File:fragment-design.png]]<br />
<br />
The object inspector can be used to manipulate the properties, just as for a regular form.<br />
<br />
Note: <br />
You must add '''-JRjs''' to the custom compiler options of your project to include the form data in the application.<br />
Additionally, the ''p2jsres'' unit must be added to the uses clause of your program, so the resource data can be loaded when the program is run.<br />
<br />
The HTML for the fragment can be loaded in 3 ways:<br />
* Set the '''UseProjectHTMLFile''' property to ''True'' if you will only use the main html file of your project. No additional HTML will be loaded.<br />
* Set the '''TemplateName''' property to the name of a template to load.<br />
* Set the '''HTMLFilename''' property to the name of a HTML file to load. It will be loaded using the global template loader in unit ''rtl.TemplateLoader''<br />
<br />
The '''ParentID''' property determines under what HTML element in the main HTML page the HTML fragment will be loaded.<br />
<br />
The following events exist:<br />
<br />
* '''OnAllowUnrender''' is called when you wish to show another HTML fragment instead of this one. It is equivalent to '''OnCloseQuery''' in an LCL form.<br />
* '''OnCreate''' Called when the fragment is created. note that the HTML is not yet available.<br />
* '''OnDestroy''' Called when the fragment is destroyed.<br />
* '''OnHTMLLoaded''' Called when the HTML fragment has been loaded from the server.<br />
* '''OnRendered''' Called when the HTML fragment has been inserted in the DOM.<br />
* '''OnUnRendered''' Called when the HTML fragment has been removed from the DOM.<br />
<br />
<br />
== Installed components ==<br />
<br />
The ''pas2jscomponents'' package also installs some components.<br />
<br />
=== THTMLElementActionList ===<br />
<br />
The '''THTMLElementActionList''' component is similar to the Action list in design-time concept, but works differently at runtime:<br />
You can associate a '''THTMLElementAction''' with every element in the HTML fragment's HTML that has an ID, or you can use a CSS selector to let an action respresent a series of HTML Elements.<br />
<br />
You don't need to create these actions manually. In the context menu there is an item "Create actions for HTML tags"<br />
<br />
[[File:htmlelementactionlist.png]]<br />
<br />
This menu will pop up a wizard that finds all elements for which no action exists yet, and proposes to create an action:<br />
<br />
[[File:createhtmlactions.png]]<br />
<br />
If you check the ''Use Data-Aware Actions'' checkbox, then DB-Aware actions will be used.<br />
These can be used as button actions (to navigate in the data, insert/post/delete etc. etc)<br />
<br />
The action editor works similar to the LCL action list editor:<br />
<br />
[[File:elementactioneditor.png]]<br />
<br />
The main properties of an action are:<br />
<br />
* '''ElementID''' the ID of the element you want to control. <br />
* '''CSSSelector''' A css selector for thes element you want to control in case of multiple elements (e.g. to get all rows in a table use '''#tableid tr''')<br />
* '''Events''' a set of events to listen for. When the event is triggered, the '''OnExecute''' event handler is executed.<br />
* '''CustomEvents''' a space separated list of HTML to listen for, for events that do not appear in **Events**<br />
* '''PreventDefault''' can be set to '''True''' to prevent the default HTML action from happening.<br />
* '''StopPropagation''' can be set to '''True''' to prevent the event from ''bubbling'', i.e. propagating to parent elements.<br />
<br />
=== TBootstrapModal ===<br />
<br />
A component (similar to the LCL Dialog components) to show a modal dialog using Bootstrap. (you need to include the various bootstrap files in your project HTML file)<br />
<br />
The following properties exist:<br />
* '''ShowOnRender''' set to ''True'' if you wish to show the modal as soon as it is rendered (meaning, the HTML was generated).<br />
* '''BackDrop''' show a backdrop shadow over the rest of the HTML page.<br />
* '''KeyBoard''' Allow keyboard actions<br />
* '''Focus''' set focus to the modal.<br />
* '''Template''' the HTML for the modal.<br />
* '''TemplateName''' the name of a template in '''TempateLoader''' containing the modal HTML.<br />
* '''TemplateLoader''' a custom template loader. If not set, a global template loader is used.<br />
* '''References''' a collection of CSS Selectors which can be used to get a reference to elements in the modal. These can be used to retrieve entered values during the **OnHide** event handler..<br />
<br />
<br />
The following events exist:<br />
<br />
* '''OnHide''' event triggered when the modal is hidden.<br />
<br />
<br />
<br />
=== TBootstrapToastWidget ===<br />
<br />
The '''TBootstrapToastWidget''' allow you to show a small ''Toast'' message.<br />
<br />
It can show a toast embedded in the HTML file, or the HTML can be generated from the properties<br />
<br />
* '''Header''' a string with the HTML for the header tag.<br />
* '''SmallHeader''' a string with the HTML for the sub (smaller) header tag.<br />
* '''Body''' a string with the HTML for body of the modal.<br />
* '''HeaderImage''' an URL for the header image.<br />
* '''CloseButton''' set to ''True'' to add a close button to the dialog.<br />
* '''Contextual''' an enumerated which allows you to select one of the primary bootstrap color schemes.<br />
* '''HideDelay''' a number of milliseconds before the toast automatically disappears when ''AutoHide'' is ''True''.<br />
* '''AutoHide''' set to ''True'' to let the toast disappear automatically after ''HideDelay'' milliseconds.<br />
* '''Animate''' set to ''True'' to animate showing and hiding of the modal.<br />
* '''MinWidth''' minimum width for the modal.<br />
* '''UnrenderOnHide''' if set to ''True'' the HTML of the toast will be removed from the DOM when the toast is hidden.<br />
<br />
The following event exists:<br />
* '''OnHide''' triggered when the toast is hidden.<br />
<br />
=== TTemplateLoader ===<br />
<br />
This component can be used to load HTML fragments (in fact, any file) when the webapplication is run.<br />
<br />
When loaded, the templates are available in a named array ''Templates'' where the index is the name of a template.<br />
The list of templates to load can be specified in the ''PreloadTemplates'' property, a collection.<br />
<br />
The following properties exist:<br />
<br />
* '''BaseURL''' all filenames for templates are relative to this URL.<br />
* '''CheckResources''' When loading a template, check if a resource with the same name as the template exists. If yes, load the template from the resource.<br />
* '''PreloadTemplates''' List of templates to load as soon as the component is loaded from the form file.<br />
<br />
The following events exist:<br />
<br />
* '''OnLoad''' triggered when a template is loaded. The name of the loaded template is passed to the event handler.<br />
* '''OnLoadFail''' triggered when a template fails to load. The name of the loaded template is passed to the event handler.<br />
<br />
Because the loading happens asynchronous, the following method is useful:<br />
<br />
<syntaxhighlight lang="pascal"><br />
Procedure IfTemplate(const aName : String; aEvent : TTemplateNotifyEvent);<br />
</syntaxhighlight><br />
this method will check if template ''aName'' is loaded, and calls ''aEvent'' if it is. If it is not yet loaded, it will wait till the template is loaded and then call the event.<br />
<br />
Additional templates can be loaded with the following 2 calls:<br />
<syntaxhighlight lang="pascal"><br />
Procedure LoadTemplate(Const aName,aURL : String; aOnSuccess : TTemplateNotifyEvent = Nil; AOnFail : TTemplateErrorNotifyEvent= Nil);<br />
Procedure LoadTemplates(Const Templates : Array of String; aOnSuccess : TTemplateNotifyEvent = Nil; AOnFail : TTemplateErrorNotifyEvent= nil);<br />
</syntaxhighlight><br />
These methods will load a template, even if it was already loaded before. <br />
In case of the array, there must be an even number of elements, the odd elements are template names and the even elements are corresponding filenames.<br />
<br />
=== TSQLDBRestConnection ===<br />
=== TSQLDBRestDataset ===<br />
=== TDBBootstraptableWidget ===<br />
<br />
A widget that renders a bootstrap-table table based on a dataset.<br />
<br />
[https://bootstrap-table.com/ Bootstrap-Table can be downloaded here]<br />
<br />
It renders a read-only table with paging and search options, based on the properties set, and the data from a dataset:<br />
<br />
<br />
The component has the following properties:<br />
* '''StylingClasses''' a set of properties that affect how a column with a button is rendered. See below for the list of properties.<br />
* '''Columns''' A column with the columns to render in the table.<br />
* '''DataSource''' a reference to the dataset for which to render the table. The table is rendered when the dataset opens, it is unrendered when the dataset closes.<br />
* '''Options''' a set of general options for the table behaviour.<br />
* '''ViewOptions''' a set of options that determine the look-and-feel of the table.<br />
* '''PaginationOptions''' a set of options that govern the pagination mechanism of the table.<br />
* '''SearchOptions''' a set of options that control the search mechanism of the table.<br />
* '''SortOptions''' a set of options that control the sorting mechanism of the table.<br />
* '''DisplayReadOnly''' set all edit/delete buttons readonly.<br />
* '''AfterBodyDraw''' event triggered after the table body has been rendered.<br />
<br />
For each column to be rendered the following properties can be set:<br />
<br />
* '''FieldName''': The Fieldname for this column<br />
* '''Title''': The Title for this column<br />
* '''RenderMode''': The Render mode for the column: text, number, checkbox, button custom render<br />
* '''ButtonType''': When rendermode is rmButton, what button must be rendered.<br />
* '''ButtonIconClass''': When buttontype is btCustom, use the following class (in &lt;i class=""&gt;&lt;/i&gt;)<br />
* '''OnTransformValue''': Event called when rendermode is rmTransformValue<br />
* '''OnCustomFormat''': EVent called when rendermode is rmCustom<br />
* '''Width''': Column Width (in WidthUnits units)<br />
* '''WidthUnits''': Column Width (in CSS units)<br />
* '''CSSClassName''': a CSS Class name applied on cells for this column<br />
* '''CheckBoxClassName''': CSS Class name for this column if there is a check box.<br />
* '''Visible''': Visible column or not ?<br />
* '''Searchable''': A boolean that Indicates whether the column is searchable<br />
* '''Sortable''': A boolean that Indicates whether the column is sortable<br />
* ''' ButtonURL''': string URL to use when the button is clicked<br />
* '''ButtonURLTarget''': link element target attribute.<br />
<br />
The '''TStylingClasses''' has the following properties:<br />
<br />
* '''CheckBoxClass''' a space-separated list of classes to apply to a checkbox column.<br />
* '''ButtonClass''' a space-separated list of classes to apply to a button column.<br />
* '''InfoClass''' a space-separated list of classes to apply to a info button column.<br />
* '''EditClas''' a space-separated list of classes to apply to a edit button column.<br />
* '''ReadonlyEditClass''' a space-separated list of classes to apply to a read-only edit column.<br />
* '''DeleteClass''' a space-separated list of classes to apply to a delete button column.<br />
<br />
=== TDBLoopWidget ===<br />
<br />
A widget that renders a HTML template for every record in a dataset.<br />
The HTML templates can contain placeholders in the form {{FieldName}} which will be replaced with the field value of the dataset for that record.<br />
<br />
The '''Groups''' collection can be used to make groups based on the values in the dataset: when the group value changes, a new group is started and the header template for the group is rendered. When a group ended, a footer template is rendered for that group.<br />
<br />
The following properties exist:<br />
<br />
* '''HeaderTemplate''' The header template is rendered before starting the loop.<br />
* '''ItemTemplate''' The Item template is rendered for each record in the dataset.<br />
* '''FooterTemplate''' The footer template is rendered before starting the loop.<br />
* '''OnGetValue''' event called to get the value of a placeholder.<br />
* '''References''' use CSS selectors to get references to the nodes in the rendered content;<br />
* '''Datasource''' a reference to the data for which to render the loop.<br />
* '''OnFormatField''' an event to get a custom formatted version of a field.<br />
* '''Groups''' a collection of groups for which an expression, a footer and header template can be specified.<br />
* '''OnGetGroupValue''' to get a custom value for a group expression.<br />
<br />
=== TDBSelectWidget ===</div>Michaelhttps://wiki.freepascal.org/index.php?title=pas2js_designtime&diff=152050pas2js designtime2022-05-21T22:40:46Z<p>Michael: /* TDBBootstraptableWidget */</p>
<hr />
<div>= Designtime support for Pas2JS Components =<br />
<br />
The ''pas2jscomponents.lpk'' package that comes with lazarus installs design-time support for pas2js webwidgets <br />
and design-time editing of components.<br />
<br />
== Installed functionality ==<br />
<br />
* there is a new file type 'HTML Fragment', this is akin to a 'Form' or 'Frame'.<br />
* There are several components that allow you to interact with the HTML.<br />
** THTMLElementActionList<br />
** TBootstrapModal<br />
** TBootstrapToastWidget<br />
** TTemplateLoader<br />
** TSQLDBRestConnection<br />
** TSQLDBRestDataset<br />
** TDBBootstraptableWidget<br />
** TDBLoopTableWidget<br />
** TDBSelectWidget<br />
<br />
The package also installs support for parsing HTML files and loading HTML id attributes from the html.<br />
Properties that need a HTML element ID, will display a dropdown with the discovered ID attributes.<br />
<br />
<br />
== HTML Fragment ==<br />
<br />
The HTML fragment is the HTML equivalent of a form in a native LCL application.<br />
An application can contain multiple HTML fragments, which can be shown at the same time or separately.<br />
<br />
You can add a new HTML fragment with the File-New dialog:<br />
<br />
[[File:htmlfragment.png]]<br />
<br />
This will start a new form, which looks like a datamodule in the IDE.<br />
<br />
After dropping some components on it, it will look for example like this in the designer:<br />
<br />
[[File:fragment-design.png]]<br />
<br />
The object inspector can be used to manipulate the properties, just as for a regular form.<br />
<br />
Note: <br />
You must add '''-JRjs''' to the custom compiler options of your project to include the form data in the application.<br />
Additionally, the ''p2jsres'' unit must be added to the uses clause of your program, so the resource data can be loaded when the program is run.<br />
<br />
The HTML for the fragment can be loaded in 3 ways:<br />
* Set the '''UseProjectHTMLFile''' property to ''True'' if you will only use the main html file of your project. No additional HTML will be loaded.<br />
* Set the '''TemplateName''' property to the name of a template to load.<br />
* Set the '''HTMLFilename''' property to the name of a HTML file to load. It will be loaded using the global template loader in unit ''rtl.TemplateLoader''<br />
<br />
The '''ParentID''' property determines under what HTML element in the main HTML page the HTML fragment will be loaded.<br />
<br />
The following events exist:<br />
<br />
* '''OnAllowUnrender''' is called when you wish to show another HTML fragment instead of this one. It is equivalent to '''OnCloseQuery''' in an LCL form.<br />
* '''OnCreate''' Called when the fragment is created. note that the HTML is not yet available.<br />
* '''OnDestroy''' Called when the fragment is destroyed.<br />
* '''OnHTMLLoaded''' Called when the HTML fragment has been loaded from the server.<br />
* '''OnRendered''' Called when the HTML fragment has been inserted in the DOM.<br />
* '''OnUnRendered''' Called when the HTML fragment has been removed from the DOM.<br />
<br />
<br />
== Installed components ==<br />
<br />
The ''pas2jscomponents'' package also installs some components.<br />
<br />
=== THTMLElementActionList ===<br />
<br />
The '''THTMLElementActionList''' component is similar to the Action list in design-time concept, but works differently at runtime:<br />
You can associate a '''THTMLElementAction''' with every element in the HTML fragment's HTML that has an ID, or you can use a CSS selector to let an action respresent a series of HTML Elements.<br />
<br />
You don't need to create these actions manually. In the context menu there is an item "Create actions for HTML tags"<br />
<br />
[[File:htmlelementactionlist.png]]<br />
<br />
This menu will pop up a wizard that finds all elements for which no action exists yet, and proposes to create an action:<br />
<br />
[[File:createhtmlactions.png]]<br />
<br />
If you check the ''Use Data-Aware Actions'' checkbox, then DB-Aware actions will be used.<br />
These can be used as button actions (to navigate in the data, insert/post/delete etc. etc)<br />
<br />
The action editor works similar to the LCL action list editor:<br />
<br />
[[File:elementactioneditor.png]]<br />
<br />
The main properties of an action are:<br />
<br />
* '''ElementID''' the ID of the element you want to control. <br />
* '''CSSSelector''' A css selector for thes element you want to control in case of multiple elements (e.g. to get all rows in a table use '''#tableid tr''')<br />
* '''Events''' a set of events to listen for. When the event is triggered, the '''OnExecute''' event handler is executed.<br />
* '''CustomEvents''' a space separated list of HTML to listen for, for events that do not appear in **Events**<br />
* '''PreventDefault''' can be set to '''True''' to prevent the default HTML action from happening.<br />
* '''StopPropagation''' can be set to '''True''' to prevent the event from ''bubbling'', i.e. propagating to parent elements.<br />
<br />
=== TBootstrapModal ===<br />
<br />
A component (similar to the LCL Dialog components) to show a modal dialog using Bootstrap. (you need to include the various bootstrap files in your project HTML file)<br />
<br />
The following properties exist:<br />
* '''ShowOnRender''' set to ''True'' if you wish to show the modal as soon as it is rendered (meaning, the HTML was generated).<br />
* '''BackDrop''' show a backdrop shadow over the rest of the HTML page.<br />
* '''KeyBoard''' Allow keyboard actions<br />
* '''Focus''' set focus to the modal.<br />
* '''Template''' the HTML for the modal.<br />
* '''TemplateName''' the name of a template in '''TempateLoader''' containing the modal HTML.<br />
* '''TemplateLoader''' a custom template loader. If not set, a global template loader is used.<br />
* '''References''' a collection of CSS Selectors which can be used to get a reference to elements in the modal. These can be used to retrieve entered values during the **OnHide** event handler..<br />
<br />
<br />
The following events exist:<br />
<br />
* '''OnHide''' event triggered when the modal is hidden.<br />
<br />
<br />
<br />
=== TBootstrapToastWidget ===<br />
<br />
The '''TBootstrapToastWidget''' allow you to show a small ''Toast'' message.<br />
<br />
It can show a toast embedded in the HTML file, or the HTML can be generated from the properties<br />
<br />
* '''Header''' a string with the HTML for the header tag.<br />
* '''SmallHeader''' a string with the HTML for the sub (smaller) header tag.<br />
* '''Body''' a string with the HTML for body of the modal.<br />
* '''HeaderImage''' an URL for the header image.<br />
* '''CloseButton''' set to ''True'' to add a close button to the dialog.<br />
* '''Contextual''' an enumerated which allows you to select one of the primary bootstrap color schemes.<br />
* '''HideDelay''' a number of milliseconds before the toast automatically disappears when ''AutoHide'' is ''True''.<br />
* '''AutoHide''' set to ''True'' to let the toast disappear automatically after ''HideDelay'' milliseconds.<br />
* '''Animate''' set to ''True'' to animate showing and hiding of the modal.<br />
* '''MinWidth''' minimum width for the modal.<br />
* '''UnrenderOnHide''' if set to ''True'' the HTML of the toast will be removed from the DOM when the toast is hidden.<br />
<br />
The following event exists:<br />
* '''OnHide''' triggered when the toast is hidden.<br />
<br />
=== TTemplateLoader ===<br />
<br />
This component can be used to load HTML fragments (in fact, any file) when the webapplication is run.<br />
<br />
When loaded, the templates are available in a named array ''Templates'' where the index is the name of a template.<br />
The list of templates to load can be specified in the ''PreloadTemplates'' property, a collection.<br />
<br />
The following properties exist:<br />
<br />
* '''BaseURL''' all filenames for templates are relative to this URL.<br />
* '''CheckResources''' When loading a template, check if a resource with the same name as the template exists. If yes, load the template from the resource.<br />
* '''PreloadTemplates''' List of templates to load as soon as the component is loaded from the form file.<br />
<br />
The following events exist:<br />
<br />
* '''OnLoad''' triggered when a template is loaded. The name of the loaded template is passed to the event handler.<br />
* '''OnLoadFail''' triggered when a template fails to load. The name of the loaded template is passed to the event handler.<br />
<br />
Because the loading happens asynchronous, the following method is useful:<br />
<br />
<syntaxhighlight lang="pascal"><br />
Procedure IfTemplate(const aName : String; aEvent : TTemplateNotifyEvent);<br />
</syntaxhighlight><br />
this method will check if template ''aName'' is loaded, and calls ''aEvent'' if it is. If it is not yet loaded, it will wait till the template is loaded and then call the event.<br />
<br />
Additional templates can be loaded with the following 2 calls:<br />
<syntaxhighlight lang="pascal"><br />
Procedure LoadTemplate(Const aName,aURL : String; aOnSuccess : TTemplateNotifyEvent = Nil; AOnFail : TTemplateErrorNotifyEvent= Nil);<br />
Procedure LoadTemplates(Const Templates : Array of String; aOnSuccess : TTemplateNotifyEvent = Nil; AOnFail : TTemplateErrorNotifyEvent= nil);<br />
</syntaxhighlight><br />
These methods will load a template, even if it was already loaded before. <br />
In case of the array, there must be an even number of elements, the odd elements are template names and the even elements are corresponding filenames.<br />
<br />
=== TSQLDBRestConnection ===<br />
=== TSQLDBRestDataset ===<br />
=== TDBBootstraptableWidget ===<br />
<br />
A widget that renders a bootstrap-table table based on a dataset.<br />
<br />
[https://bootstrap-table.com/ Bootstrap-Table can be downloaded here]<br />
<br />
It renders a read-only table with paging and search options, based on the properties set, and the data from a dataset:<br />
<br />
<br />
The component has the following properties:<br />
* '''StylingClasses''' a set of properties that affect how a column with a button is rendered. See below for the list of properties.<br />
* '''Columns''' A column with the columns to render in the table.<br />
* '''DataSource''' a reference to the dataset for which to render the table. The table is rendered when the dataset opens, it is unrendered when the dataset closes.<br />
* '''Options''' a set of general options for the table behaviour.<br />
* '''ViewOptions''' a set of options that determine the look-and-feel of the table.<br />
* '''PaginationOptions''' a set of options that govern the pagination mechanism of the table.<br />
* '''SearchOptions''' a set of options that control the search mechanism of the table.<br />
* '''SortOptions''' a set of options that control the sorting mechanism of the table.<br />
* '''DisplayReadOnly''' set all edit/delete buttons readonly.<br />
* '''AfterBodyDraw''' event triggered after the table body has been rendered.<br />
<br />
For each column to be rendered the following properties can be set:<br />
<br />
* '''FieldName''': The Fieldname for this column<br />
* '''Title''': The Title for this column<br />
* '''RenderMode''': The Render mode for the column: text, number, checkbox, button custom render<br />
* '''ButtonType''': When rendermode is rmButton, what button must be rendered.<br />
* '''ButtonIconClass''': When buttontype is btCustom, use the following class (in &lt;i class=""&gt;&lt;/i&gt;)<br />
* '''OnTransformValue''': Event called when rendermode is rmTransformValue<br />
* '''OnCustomFormat''': EVent called when rendermode is rmCustom<br />
* '''Width''': Column Width (in WidthUnits units)<br />
* '''WidthUnits''': Column Width (in CSS units)<br />
* '''CSSClassName''': a CSS Class name applied on cells for this column<br />
* '''CheckBoxClassName''': CSS Class name for this column if there is a check box.<br />
* '''Visible''': Visible column or not ?<br />
* '''Searchable''': A boolean that Indicates whether the column is searchable<br />
* '''Sortable''': A boolean that Indicates whether the column is sortable<br />
* ''' ButtonURL''': string URL to use when the button is clicked<br />
* '''ButtonURLTarget''': link element target attribute.<br />
<br />
The '''TStylingClasses''' has the following properties:<br />
<br />
* '''CheckBoxClass''' a space-separated list of classes to apply to a checkbox column.<br />
* '''ButtonClass''' a space-separated list of classes to apply to a button column.<br />
* '''InfoClass''' a space-separated list of classes to apply to a info button column.<br />
* '''EditClas''' a space-separated list of classes to apply to a edit button column.<br />
* '''ReadonlyEditClass''' a space-separated list of classes to apply to a read-only edit column.<br />
* '''DeleteClass''' a space-separated list of classes to apply to a delete button column.<br />
<br />
=== TDBLoopTableWidget ===<br />
=== TDBSelectWidget ===</div>Michaelhttps://wiki.freepascal.org/index.php?title=pas2js_designtime&diff=152049pas2js designtime2022-05-21T22:18:42Z<p>Michael: /* TTemplateLoader */</p>
<hr />
<div>= Designtime support for Pas2JS Components =<br />
<br />
The ''pas2jscomponents.lpk'' package that comes with lazarus installs design-time support for pas2js webwidgets <br />
and design-time editing of components.<br />
<br />
== Installed functionality ==<br />
<br />
* there is a new file type 'HTML Fragment', this is akin to a 'Form' or 'Frame'.<br />
* There are several components that allow you to interact with the HTML.<br />
** THTMLElementActionList<br />
** TBootstrapModal<br />
** TBootstrapToastWidget<br />
** TTemplateLoader<br />
** TSQLDBRestConnection<br />
** TSQLDBRestDataset<br />
** TDBBootstraptableWidget<br />
** TDBLoopTableWidget<br />
** TDBSelectWidget<br />
<br />
The package also installs support for parsing HTML files and loading HTML id attributes from the html.<br />
Properties that need a HTML element ID, will display a dropdown with the discovered ID attributes.<br />
<br />
<br />
== HTML Fragment ==<br />
<br />
The HTML fragment is the HTML equivalent of a form in a native LCL application.<br />
An application can contain multiple HTML fragments, which can be shown at the same time or separately.<br />
<br />
You can add a new HTML fragment with the File-New dialog:<br />
<br />
[[File:htmlfragment.png]]<br />
<br />
This will start a new form, which looks like a datamodule in the IDE.<br />
<br />
After dropping some components on it, it will look for example like this in the designer:<br />
<br />
[[File:fragment-design.png]]<br />
<br />
The object inspector can be used to manipulate the properties, just as for a regular form.<br />
<br />
Note: <br />
You must add '''-JRjs''' to the custom compiler options of your project to include the form data in the application.<br />
Additionally, the ''p2jsres'' unit must be added to the uses clause of your program, so the resource data can be loaded when the program is run.<br />
<br />
The HTML for the fragment can be loaded in 3 ways:<br />
* Set the '''UseProjectHTMLFile''' property to ''True'' if you will only use the main html file of your project. No additional HTML will be loaded.<br />
* Set the '''TemplateName''' property to the name of a template to load.<br />
* Set the '''HTMLFilename''' property to the name of a HTML file to load. It will be loaded using the global template loader in unit ''rtl.TemplateLoader''<br />
<br />
The '''ParentID''' property determines under what HTML element in the main HTML page the HTML fragment will be loaded.<br />
<br />
The following events exist:<br />
<br />
* '''OnAllowUnrender''' is called when you wish to show another HTML fragment instead of this one. It is equivalent to '''OnCloseQuery''' in an LCL form.<br />
* '''OnCreate''' Called when the fragment is created. note that the HTML is not yet available.<br />
* '''OnDestroy''' Called when the fragment is destroyed.<br />
* '''OnHTMLLoaded''' Called when the HTML fragment has been loaded from the server.<br />
* '''OnRendered''' Called when the HTML fragment has been inserted in the DOM.<br />
* '''OnUnRendered''' Called when the HTML fragment has been removed from the DOM.<br />
<br />
<br />
== Installed components ==<br />
<br />
The ''pas2jscomponents'' package also installs some components.<br />
<br />
=== THTMLElementActionList ===<br />
<br />
The '''THTMLElementActionList''' component is similar to the Action list in design-time concept, but works differently at runtime:<br />
You can associate a '''THTMLElementAction''' with every element in the HTML fragment's HTML that has an ID, or you can use a CSS selector to let an action respresent a series of HTML Elements.<br />
<br />
You don't need to create these actions manually. In the context menu there is an item "Create actions for HTML tags"<br />
<br />
[[File:htmlelementactionlist.png]]<br />
<br />
This menu will pop up a wizard that finds all elements for which no action exists yet, and proposes to create an action:<br />
<br />
[[File:createhtmlactions.png]]<br />
<br />
If you check the ''Use Data-Aware Actions'' checkbox, then DB-Aware actions will be used.<br />
These can be used as button actions (to navigate in the data, insert/post/delete etc. etc)<br />
<br />
The action editor works similar to the LCL action list editor:<br />
<br />
[[File:elementactioneditor.png]]<br />
<br />
The main properties of an action are:<br />
<br />
* '''ElementID''' the ID of the element you want to control. <br />
* '''CSSSelector''' A css selector for thes element you want to control in case of multiple elements (e.g. to get all rows in a table use '''#tableid tr''')<br />
* '''Events''' a set of events to listen for. When the event is triggered, the '''OnExecute''' event handler is executed.<br />
* '''CustomEvents''' a space separated list of HTML to listen for, for events that do not appear in **Events**<br />
* '''PreventDefault''' can be set to '''True''' to prevent the default HTML action from happening.<br />
* '''StopPropagation''' can be set to '''True''' to prevent the event from ''bubbling'', i.e. propagating to parent elements.<br />
<br />
=== TBootstrapModal ===<br />
<br />
A component (similar to the LCL Dialog components) to show a modal dialog using Bootstrap. (you need to include the various bootstrap files in your project HTML file)<br />
<br />
The following properties exist:<br />
* '''ShowOnRender''' set to ''True'' if you wish to show the modal as soon as it is rendered (meaning, the HTML was generated).<br />
* '''BackDrop''' show a backdrop shadow over the rest of the HTML page.<br />
* '''KeyBoard''' Allow keyboard actions<br />
* '''Focus''' set focus to the modal.<br />
* '''Template''' the HTML for the modal.<br />
* '''TemplateName''' the name of a template in '''TempateLoader''' containing the modal HTML.<br />
* '''TemplateLoader''' a custom template loader. If not set, a global template loader is used.<br />
* '''References''' a collection of CSS Selectors which can be used to get a reference to elements in the modal. These can be used to retrieve entered values during the **OnHide** event handler..<br />
<br />
<br />
The following events exist:<br />
<br />
* '''OnHide''' event triggered when the modal is hidden.<br />
<br />
<br />
<br />
=== TBootstrapToastWidget ===<br />
<br />
The '''TBootstrapToastWidget''' allow you to show a small ''Toast'' message.<br />
<br />
It can show a toast embedded in the HTML file, or the HTML can be generated from the properties<br />
<br />
* '''Header''' a string with the HTML for the header tag.<br />
* '''SmallHeader''' a string with the HTML for the sub (smaller) header tag.<br />
* '''Body''' a string with the HTML for body of the modal.<br />
* '''HeaderImage''' an URL for the header image.<br />
* '''CloseButton''' set to ''True'' to add a close button to the dialog.<br />
* '''Contextual''' an enumerated which allows you to select one of the primary bootstrap color schemes.<br />
* '''HideDelay''' a number of milliseconds before the toast automatically disappears when ''AutoHide'' is ''True''.<br />
* '''AutoHide''' set to ''True'' to let the toast disappear automatically after ''HideDelay'' milliseconds.<br />
* '''Animate''' set to ''True'' to animate showing and hiding of the modal.<br />
* '''MinWidth''' minimum width for the modal.<br />
* '''UnrenderOnHide''' if set to ''True'' the HTML of the toast will be removed from the DOM when the toast is hidden.<br />
<br />
The following event exists:<br />
* '''OnHide''' triggered when the toast is hidden.<br />
<br />
=== TTemplateLoader ===<br />
<br />
This component can be used to load HTML fragments (in fact, any file) when the webapplication is run.<br />
<br />
When loaded, the templates are available in a named array ''Templates'' where the index is the name of a template.<br />
The list of templates to load can be specified in the ''PreloadTemplates'' property, a collection.<br />
<br />
The following properties exist:<br />
<br />
* '''BaseURL''' all filenames for templates are relative to this URL.<br />
* '''CheckResources''' When loading a template, check if a resource with the same name as the template exists. If yes, load the template from the resource.<br />
* '''PreloadTemplates''' List of templates to load as soon as the component is loaded from the form file.<br />
<br />
The following events exist:<br />
<br />
* '''OnLoad''' triggered when a template is loaded. The name of the loaded template is passed to the event handler.<br />
* '''OnLoadFail''' triggered when a template fails to load. The name of the loaded template is passed to the event handler.<br />
<br />
Because the loading happens asynchronous, the following method is useful:<br />
<br />
<syntaxhighlight lang="pascal"><br />
Procedure IfTemplate(const aName : String; aEvent : TTemplateNotifyEvent);<br />
</syntaxhighlight><br />
this method will check if template ''aName'' is loaded, and calls ''aEvent'' if it is. If it is not yet loaded, it will wait till the template is loaded and then call the event.<br />
<br />
Additional templates can be loaded with the following 2 calls:<br />
<syntaxhighlight lang="pascal"><br />
Procedure LoadTemplate(Const aName,aURL : String; aOnSuccess : TTemplateNotifyEvent = Nil; AOnFail : TTemplateErrorNotifyEvent= Nil);<br />
Procedure LoadTemplates(Const Templates : Array of String; aOnSuccess : TTemplateNotifyEvent = Nil; AOnFail : TTemplateErrorNotifyEvent= nil);<br />
</syntaxhighlight><br />
These methods will load a template, even if it was already loaded before. <br />
In case of the array, there must be an even number of elements, the odd elements are template names and the even elements are corresponding filenames.<br />
<br />
=== TSQLDBRestConnection ===<br />
=== TSQLDBRestDataset ===<br />
=== TDBBootstraptableWidget ===<br />
=== TDBLoopTableWidget ===<br />
=== TDBSelectWidget ===</div>Michaelhttps://wiki.freepascal.org/index.php?title=pas2js_designtime&diff=152048pas2js designtime2022-05-21T22:06:42Z<p>Michael: /* TBootstrapToastWidget */</p>
<hr />
<div>= Designtime support for Pas2JS Components =<br />
<br />
The ''pas2jscomponents.lpk'' package that comes with lazarus installs design-time support for pas2js webwidgets <br />
and design-time editing of components.<br />
<br />
== Installed functionality ==<br />
<br />
* there is a new file type 'HTML Fragment', this is akin to a 'Form' or 'Frame'.<br />
* There are several components that allow you to interact with the HTML.<br />
** THTMLElementActionList<br />
** TBootstrapModal<br />
** TBootstrapToastWidget<br />
** TTemplateLoader<br />
** TSQLDBRestConnection<br />
** TSQLDBRestDataset<br />
** TDBBootstraptableWidget<br />
** TDBLoopTableWidget<br />
** TDBSelectWidget<br />
<br />
The package also installs support for parsing HTML files and loading HTML id attributes from the html.<br />
Properties that need a HTML element ID, will display a dropdown with the discovered ID attributes.<br />
<br />
<br />
== HTML Fragment ==<br />
<br />
The HTML fragment is the HTML equivalent of a form in a native LCL application.<br />
An application can contain multiple HTML fragments, which can be shown at the same time or separately.<br />
<br />
You can add a new HTML fragment with the File-New dialog:<br />
<br />
[[File:htmlfragment.png]]<br />
<br />
This will start a new form, which looks like a datamodule in the IDE.<br />
<br />
After dropping some components on it, it will look for example like this in the designer:<br />
<br />
[[File:fragment-design.png]]<br />
<br />
The object inspector can be used to manipulate the properties, just as for a regular form.<br />
<br />
Note: <br />
You must add '''-JRjs''' to the custom compiler options of your project to include the form data in the application.<br />
Additionally, the ''p2jsres'' unit must be added to the uses clause of your program, so the resource data can be loaded when the program is run.<br />
<br />
The HTML for the fragment can be loaded in 3 ways:<br />
* Set the '''UseProjectHTMLFile''' property to ''True'' if you will only use the main html file of your project. No additional HTML will be loaded.<br />
* Set the '''TemplateName''' property to the name of a template to load.<br />
* Set the '''HTMLFilename''' property to the name of a HTML file to load. It will be loaded using the global template loader in unit ''rtl.TemplateLoader''<br />
<br />
The '''ParentID''' property determines under what HTML element in the main HTML page the HTML fragment will be loaded.<br />
<br />
The following events exist:<br />
<br />
* '''OnAllowUnrender''' is called when you wish to show another HTML fragment instead of this one. It is equivalent to '''OnCloseQuery''' in an LCL form.<br />
* '''OnCreate''' Called when the fragment is created. note that the HTML is not yet available.<br />
* '''OnDestroy''' Called when the fragment is destroyed.<br />
* '''OnHTMLLoaded''' Called when the HTML fragment has been loaded from the server.<br />
* '''OnRendered''' Called when the HTML fragment has been inserted in the DOM.<br />
* '''OnUnRendered''' Called when the HTML fragment has been removed from the DOM.<br />
<br />
<br />
== Installed components ==<br />
<br />
The ''pas2jscomponents'' package also installs some components.<br />
<br />
=== THTMLElementActionList ===<br />
<br />
The '''THTMLElementActionList''' component is similar to the Action list in design-time concept, but works differently at runtime:<br />
You can associate a '''THTMLElementAction''' with every element in the HTML fragment's HTML that has an ID, or you can use a CSS selector to let an action respresent a series of HTML Elements.<br />
<br />
You don't need to create these actions manually. In the context menu there is an item "Create actions for HTML tags"<br />
<br />
[[File:htmlelementactionlist.png]]<br />
<br />
This menu will pop up a wizard that finds all elements for which no action exists yet, and proposes to create an action:<br />
<br />
[[File:createhtmlactions.png]]<br />
<br />
If you check the ''Use Data-Aware Actions'' checkbox, then DB-Aware actions will be used.<br />
These can be used as button actions (to navigate in the data, insert/post/delete etc. etc)<br />
<br />
The action editor works similar to the LCL action list editor:<br />
<br />
[[File:elementactioneditor.png]]<br />
<br />
The main properties of an action are:<br />
<br />
* '''ElementID''' the ID of the element you want to control. <br />
* '''CSSSelector''' A css selector for thes element you want to control in case of multiple elements (e.g. to get all rows in a table use '''#tableid tr''')<br />
* '''Events''' a set of events to listen for. When the event is triggered, the '''OnExecute''' event handler is executed.<br />
* '''CustomEvents''' a space separated list of HTML to listen for, for events that do not appear in **Events**<br />
* '''PreventDefault''' can be set to '''True''' to prevent the default HTML action from happening.<br />
* '''StopPropagation''' can be set to '''True''' to prevent the event from ''bubbling'', i.e. propagating to parent elements.<br />
<br />
=== TBootstrapModal ===<br />
<br />
A component (similar to the LCL Dialog components) to show a modal dialog using Bootstrap. (you need to include the various bootstrap files in your project HTML file)<br />
<br />
The following properties exist:<br />
* '''ShowOnRender''' set to ''True'' if you wish to show the modal as soon as it is rendered (meaning, the HTML was generated).<br />
* '''BackDrop''' show a backdrop shadow over the rest of the HTML page.<br />
* '''KeyBoard''' Allow keyboard actions<br />
* '''Focus''' set focus to the modal.<br />
* '''Template''' the HTML for the modal.<br />
* '''TemplateName''' the name of a template in '''TempateLoader''' containing the modal HTML.<br />
* '''TemplateLoader''' a custom template loader. If not set, a global template loader is used.<br />
* '''References''' a collection of CSS Selectors which can be used to get a reference to elements in the modal. These can be used to retrieve entered values during the **OnHide** event handler..<br />
<br />
<br />
The following events exist:<br />
<br />
* '''OnHide''' event triggered when the modal is hidden.<br />
<br />
<br />
<br />
=== TBootstrapToastWidget ===<br />
<br />
The '''TBootstrapToastWidget''' allow you to show a small ''Toast'' message.<br />
<br />
It can show a toast embedded in the HTML file, or the HTML can be generated from the properties<br />
<br />
* '''Header''' a string with the HTML for the header tag.<br />
* '''SmallHeader''' a string with the HTML for the sub (smaller) header tag.<br />
* '''Body''' a string with the HTML for body of the modal.<br />
* '''HeaderImage''' an URL for the header image.<br />
* '''CloseButton''' set to ''True'' to add a close button to the dialog.<br />
* '''Contextual''' an enumerated which allows you to select one of the primary bootstrap color schemes.<br />
* '''HideDelay''' a number of milliseconds before the toast automatically disappears when ''AutoHide'' is ''True''.<br />
* '''AutoHide''' set to ''True'' to let the toast disappear automatically after ''HideDelay'' milliseconds.<br />
* '''Animate''' set to ''True'' to animate showing and hiding of the modal.<br />
* '''MinWidth''' minimum width for the modal.<br />
* '''UnrenderOnHide''' if set to ''True'' the HTML of the toast will be removed from the DOM when the toast is hidden.<br />
<br />
The following event exists:<br />
* '''OnHide''' triggered when the toast is hidden.<br />
<br />
=== TTemplateLoader ===<br />
=== TSQLDBRestConnection ===<br />
=== TSQLDBRestDataset ===<br />
=== TDBBootstraptableWidget ===<br />
=== TDBLoopTableWidget ===<br />
=== TDBSelectWidget ===</div>Michaelhttps://wiki.freepascal.org/index.php?title=pas2js_designtime&diff=152047pas2js designtime2022-05-21T20:44:13Z<p>Michael: Created page with "= Designtime support for Pas2JS Components = The ''pas2jscomponents.lpk'' package that comes with lazarus installs design-time support for pas2js webwidgets and design-time..."</p>
<hr />
<div>= Designtime support for Pas2JS Components =<br />
<br />
The ''pas2jscomponents.lpk'' package that comes with lazarus installs design-time support for pas2js webwidgets <br />
and design-time editing of components.<br />
<br />
== Installed functionality ==<br />
<br />
* there is a new file type 'HTML Fragment', this is akin to a 'Form' or 'Frame'.<br />
* There are several components that allow you to interact with the HTML.<br />
** THTMLElementActionList<br />
** TBootstrapModal<br />
** TBootstrapToastWidget<br />
** TTemplateLoader<br />
** TSQLDBRestConnection<br />
** TSQLDBRestDataset<br />
** TDBBootstraptableWidget<br />
** TDBLoopTableWidget<br />
** TDBSelectWidget<br />
<br />
The package also installs support for parsing HTML files and loading HTML id attributes from the html.<br />
Properties that need a HTML element ID, will display a dropdown with the discovered ID attributes.<br />
<br />
<br />
== HTML Fragment ==<br />
<br />
The HTML fragment is the HTML equivalent of a form in a native LCL application.<br />
An application can contain multiple HTML fragments, which can be shown at the same time or separately.<br />
<br />
You can add a new HTML fragment with the File-New dialog:<br />
<br />
[[File:htmlfragment.png]]<br />
<br />
This will start a new form, which looks like a datamodule in the IDE.<br />
<br />
After dropping some components on it, it will look for example like this in the designer:<br />
<br />
[[File:fragment-design.png]]<br />
<br />
The object inspector can be used to manipulate the properties, just as for a regular form.<br />
<br />
Note: <br />
You must add '''-JRjs''' to the custom compiler options of your project to include the form data in the application.<br />
Additionally, the ''p2jsres'' unit must be added to the uses clause of your program, so the resource data can be loaded when the program is run.<br />
<br />
The HTML for the fragment can be loaded in 3 ways:<br />
* Set the '''UseProjectHTMLFile''' property to ''True'' if you will only use the main html file of your project. No additional HTML will be loaded.<br />
* Set the '''TemplateName''' property to the name of a template to load.<br />
* Set the '''HTMLFilename''' property to the name of a HTML file to load. It will be loaded using the global template loader in unit ''rtl.TemplateLoader''<br />
<br />
The '''ParentID''' property determines under what HTML element in the main HTML page the HTML fragment will be loaded.<br />
<br />
The following events exist:<br />
<br />
* '''OnAllowUnrender''' is called when you wish to show another HTML fragment instead of this one. It is equivalent to '''OnCloseQuery''' in an LCL form.<br />
* '''OnCreate''' Called when the fragment is created. note that the HTML is not yet available.<br />
* '''OnDestroy''' Called when the fragment is destroyed.<br />
* '''OnHTMLLoaded''' Called when the HTML fragment has been loaded from the server.<br />
* '''OnRendered''' Called when the HTML fragment has been inserted in the DOM.<br />
* '''OnUnRendered''' Called when the HTML fragment has been removed from the DOM.<br />
<br />
<br />
== Installed components ==<br />
<br />
The ''pas2jscomponents'' package also installs some components.<br />
<br />
=== THTMLElementActionList ===<br />
<br />
The '''THTMLElementActionList''' component is similar to the Action list in design-time concept, but works differently at runtime:<br />
You can associate a '''THTMLElementAction''' with every element in the HTML fragment's HTML that has an ID, or you can use a CSS selector to let an action respresent a series of HTML Elements.<br />
<br />
You don't need to create these actions manually. In the context menu there is an item "Create actions for HTML tags"<br />
<br />
[[File:htmlelementactionlist.png]]<br />
<br />
This menu will pop up a wizard that finds all elements for which no action exists yet, and proposes to create an action:<br />
<br />
[[File:createhtmlactions.png]]<br />
<br />
If you check the ''Use Data-Aware Actions'' checkbox, then DB-Aware actions will be used.<br />
These can be used as button actions (to navigate in the data, insert/post/delete etc. etc)<br />
<br />
The action editor works similar to the LCL action list editor:<br />
<br />
[[File:elementactioneditor.png]]<br />
<br />
The main properties of an action are:<br />
<br />
* '''ElementID''' the ID of the element you want to control. <br />
* '''CSSSelector''' A css selector for thes element you want to control in case of multiple elements (e.g. to get all rows in a table use '''#tableid tr''')<br />
* '''Events''' a set of events to listen for. When the event is triggered, the '''OnExecute''' event handler is executed.<br />
* '''CustomEvents''' a space separated list of HTML to listen for, for events that do not appear in **Events**<br />
* '''PreventDefault''' can be set to '''True''' to prevent the default HTML action from happening.<br />
* '''StopPropagation''' can be set to '''True''' to prevent the event from ''bubbling'', i.e. propagating to parent elements.<br />
<br />
=== TBootstrapModal ===<br />
<br />
A component (similar to the LCL Dialog components) to show a modal dialog using Bootstrap. (you need to include the various bootstrap files in your project HTML file)<br />
<br />
The following properties exist:<br />
* '''ShowOnRender''' set to ''True'' if you wish to show the modal as soon as it is rendered (meaning, the HTML was generated).<br />
* '''BackDrop''' show a backdrop shadow over the rest of the HTML page.<br />
* '''KeyBoard''' Allow keyboard actions<br />
* '''Focus''' set focus to the modal.<br />
* '''Template''' the HTML for the modal.<br />
* '''TemplateName''' the name of a template in '''TempateLoader''' containing the modal HTML.<br />
* '''TemplateLoader''' a custom template loader. If not set, a global template loader is used.<br />
* '''References''' a collection of CSS Selectors which can be used to get a reference to elements in the modal. These can be used to retrieve entered values during the **OnHide** event handler..<br />
<br />
<br />
The following events exist:<br />
<br />
* '''OnHide''' event triggered when the modal is hidden.<br />
<br />
<br />
<br />
=== TBootstrapToastWidget ===<br />
=== TTemplateLoader ===<br />
=== TSQLDBRestConnection ===<br />
=== TSQLDBRestDataset ===<br />
=== TDBBootstraptableWidget ===<br />
=== TDBLoopTableWidget ===<br />
=== TDBSelectWidget ===</div>Michaelhttps://wiki.freepascal.org/index.php?title=File:elementactioneditor.png&diff=152046File:elementactioneditor.png2022-05-21T20:32:42Z<p>Michael: </p>
<hr />
<div></div>Michaelhttps://wiki.freepascal.org/index.php?title=File:createhtmlactions.png&diff=152045File:createhtmlactions.png2022-05-21T20:27:23Z<p>Michael: </p>
<hr />
<div></div>Michaelhttps://wiki.freepascal.org/index.php?title=File:htmlelementactionlist.png&diff=152044File:htmlelementactionlist.png2022-05-21T20:25:48Z<p>Michael: </p>
<hr />
<div></div>Michaelhttps://wiki.freepascal.org/index.php?title=File:fragment-design.png&diff=152043File:fragment-design.png2022-05-21T20:09:08Z<p>Michael: </p>
<hr />
<div></div>Michaelhttps://wiki.freepascal.org/index.php?title=File:htmlfragment.png&diff=152042File:htmlfragment.png2022-05-21T20:01:50Z<p>Michael: </p>
<hr />
<div></div>Michael