Substitutions in the preprocessor

Top  Previous  Next

User interface > Translation options > Substitutions > Substitutions in the preprocessor

 

A substitution table for the preprocessor can be shown and changed on the second register page of the option dialog.

 

Options_substitutions

 

If you click on the button "List of substitutions", the table is shown.

In the first column of the table the identifiers are listed, which shall be replaced by the preprocessor and in the second column identifiers are listed, which are inserted in the code instead of the found identifiers of the first column.

 

Dialog_substitutions

 

add_btn        add a new row

delete_btn        remover the actual row

ClearTable_btn        clear the whole table

 

The preprocessor recognizes text sections as identifiers, which start with a letter or a underlined and on which an arbitrarily number of letters, numbers or underlines can follow;  i.e. as well the real Delphi identifiers as the Delphi keywords.

 

The substitution of identifiers during the pre-processing of the code can fulfill two purposes:

 

1. a desired notation of the identifiers can be forced.

 

at the unification of the notations, the notation found by chance first usually is used as standard for all further equivalent identifiers in the Delphi code. By means of the substitution table a certain notation can be forced.

 

E.g. there is a member function of TStream called "Write". This function is declared in "classes.hpp" of the CBuilder. If this function is called in the translated  code, the name has to be written exactly as "Write", because C++ is case sensitive.

 

 

Stream.write(PChar(s)^, Length(s));

 

->

 

Stream->Write( S.c_str( ), S.Length( ) );

 

The same purpose is accomplished by use of the list of identifiers. The items of this list are overwritten by the items of the substitution table.

 

 

2. completely other names can be assigned to certain identifiers.

 

So e.g., Delphi function names could be replaced by different names of equivalent C++ functions.

 

 

 

 



This page belongs to the Delphi2Cpp Documentation

Delphi2Cpp home  Content