Extended "System.pas"

Top  Previous  Next

User interface > Translation options > Extended "System.pas"

 

"System.pas" is a source file of special importance in Delphi projects.Fundamental type definitions, procedures and functions are defined in the System unit, which is implicitly included in every unit. For example TObject is defined there. There are other intrinsic definitions like the Read, Write or Str function, which are accessible in each unit too. These intrinsic function are built into the Delphi compiler. Delphi2Cpp must know the signatures of such intrinsic functions and tries to find them in the System.pas. So the original incomplete System.pas either has to be replaced by an extended copy or a the original System.pas has to be supplemented by an additional source file.

 

In the options dialog you can set the name of such an additional System.pas extension file. However, if you use a complete replacement of the System.pas, as in the case, that you work with the pre-translated code, leave this field empty.

 

 

 

System_pas

 

 

 

Such an individual System.pas called d2c_system.pas is in the Source folder of the Delphi2Cpp installation.

 

If an individual System.pas is used, the specially treated RTL/VCL functions and some compile time functions (Abs, High, Low, Odd, Pred, Succ) might have to be defined in this file for types, that cannot be handled by the built-in translation alternatives. Such a case is the incrementation of values of enumerated types. Of course, these definitions are only needed, if such cases really appear in the source code.

 

Some examples are explained in the following topics:

 

procedure SetString

Memory management

procedures Inc and Dec

 

 

The overwritten System.pas gets always preprocessed, even if the option to do so is disabled for all other files.

 

 

Lookup algorithm

 

Delphi2Cpp looks up system types and functions etc. in following order::

 

1.Delphi2Cpp will look for declarations at first in your own System.pas, if it exists.
2.If the declaration is not found there, Delphi2Cpp will look in the System.pas of your Delphi installation, if the path to this file is set in the options.
3.If neither an own System.pas exists nor the path to the original System.pas is set, Delphi2Cpp simulates the most important parts of this file.

 

Mostly Delphi2Cpp cannot distinguish different elements with the same name. Delphi2Cpp takes just the first declaration it finds. If there are several functions with the same name the translator tries to match the declaration found first.

 

 

d2c_system.pas makes a lot of use of the (*_ ... _*) comments to insert pre-translated C++ code. The use of the predefined identifier Cpp normally isn't suitable for the overwritten System.pas, since the "{$else}"-branch with the Delphi declarations is removed from the preprocessor before the translator can read them.



This page belongs to the Delphi2Cpp Documentation

Delphi2Cpp home  Content