Special Delphi units |
Top Previous Next |
Pretranslated C++ code > Delphi RTL/VCL > Special Delphi units It already has been explained that for other compilers than C++Builder the System.pas has to be treated in a special way. But it is recommended also to prepare some other files of the Delphi RTL. That are the API files, System.Types.pas. Users of Delphi2Cpp with valid Delphi license get the ready prepared pas-files together with the pre-translated RTL files.
System.pas
Because Delphi2Cpp provides ready prepared C++ substitutes for the System.pas and also an own System.pas is used to control the output generation, the original System.pas still is needed for the translation of the Delphi sources. Parts which are missing in the own System.pas are taken from here.
The Delphi2Cpp pre-processor cannot evaluate SizeOf expressions. The following condition:
{$IFDEF EXTENDEDIS10BYTES} {$IF SizeOf(Extended) <> SizeOf(TExtended80Rec)} {$MESSAGE ERROR 'TExtended80Rec has incorrect size'} {$ENDIF } {$ENDIF EXTENDEDIS10BYTES}
is therefore replaced by
{$IFDEF D2C} // d2c cannot check size {$ELSE} {$IF SizeOf(Extended) <> SizeOf(TExtended80Rec)} {$MESSAGE ERROR 'TExtended80Rec has incorrect size'} {$ENDIF } {$ENDIF}
and the identifiers D2C is defined in the project file for the Windows 64 bit result.
Several classes, most important TObject, aren't defined if the definition for SYSTEM_HPP_DEFINES_OBJECTS isn't set. But this definition doesn't suffice. If for example the NODEFINE directive for the string type is disabled, this will force Delphi2Cpp to insert the System namespace in header files before String: System::String. This is desired and applies to a lot of other NODEFINE directives in System.pas too.
If one tries to translate System.pas despite of the set definitions there remain some messages like:
{$MESSAGE ERROR 'Unknown platform'}
These parts have to be prepared too. These parts are in the implementation part however and do not harm, if System.pas only is used for the translation of other files.
API files
Though the API files, e.g. the Winapi--files for Windows, are needed for the translation of the other Delphi files, they mostly don't have to be translated themselves. Their purpose is just to provide the C++ API types and constants for Delphi. The C++ code, which is generated from the Delphi sources just should use the original types and constants. There are some special directives written into the Delphi code that let make the C++ Builder access the original API. Delphi2Cpp also uses these directives.
System.Types.pas
The NODEFINE directives here should be disabled. C++Builder defines these type in an extra C++ header. But for Delphi2Cpp translated code these definitions remain in System.Types.h.
System.Variants.pas/System.VarUtils.pas
Under Windows Delphi Variant is a reduplication of the VARIANT structure in OAldl.h. A C++ application should use the original Windows types..Until now Delphi2Cpp offers no special support for the conversion of Delphi code using Variants etc. However Delphi2Cpp supports TVarRec. Advice from users is welcome.
|
This page belongs to the Delphi2Cpp Documentation |
Delphi2Cpp home Content |