Refactoring

Top  Previous  Next

User interface > Translation options > Refactoring

 

The refactoring dialog is reached from the button on the options dialog. The Dialog shows the list of refactoring items:

 

 

RefactoringList

 

Another dialog with the details of a refactoring item is shown, if a new item is added or an existing item is edited:

 

 

RefactoringMask

 

 

 

Variables, functions and constants which shall be changed are looked up according to the criteria, which are given by the control elements the on the left side of the dialog. At least the original name has to be specified, the other criteria are optional. On the right side of the dialogs the resulting properties can be set. Again at least a new name has to be set and the other properties are optional.

 

 

"Original name" and "New name"

 

The original name of a variable, function or constant in the Delphi source code will be changed to the new name in the C++ output. The input in the field is treated case insensitive in the same way as the source code by the pre-processor. If the identifier for the original name isn't contained in the list of notations, it's notation will be used for all notations of the identifier in the generated code.

 

 

"Original type is:"

 

 

The general kind of type of the variable, function or constant which shall be changed can be specified, to exclude all other kinds from this refactoring. If, as in the image above, "Min" is specified as a function, variables or constants with the name "Min" will not be changed. If all occurrences of "Min" shall be changed regardless of the kind, it can be set to "unspecified":

In contrast to the other fields in the dialog, the general kind of type cannot be changed and will remain the same in the output as in the source code.

 

 

 

"Original type" and "New type"

 

If "function" is selected "Original type" and "New type" are specifying the result type of the function. otherwise "Original type" and "New type" specify the type of an built-in type, if this item is selected. Normally the type should be identical, but there might be cases where it is desired to avoid or to force typecasts by means of a change of the result type.

 

For the new type also a free identifier can be set. For example there is no according type to "ULONG" or "unsigned long" in Delphi, but it may be needed in C++. Using this identifer you can refactor:

 

function _AddRef: Integer; stdcall;

 

to

 

   ULONG __stdcall AddRef()

 

 

 

"Original pointer" and "New pointer"

 

If the original type is a pointer the counter for the original pointer should be set accordingly. So the original pointer type will be recognized. But if the new type is defied as a pointer the value for the new type should remain Null. It has to be set to 1 only, if the new type is not a pointer, but the result shall be a pointer to the new type. For example:

 

PVSFixedFileInfo                        tagVS_FIXEDFILEINFO

1                                        1

 

=>

 

var

FI: PVSFixedFileInfo;

 

->

 

tagVS_FIXEDFILEINFO* FI = nullptr;

 

 

 

Generics

 

 

By use of the "Generics" option Delphi2Cpp II distinguishes between generic and non generic types. In the following example only the generic type is substituted:

 

 

uses System.Classes, System.Generics.Collections;

 

var

  L1 : TList;

  L2 : TList<Integer>;

 

->

 

  TList* L1 = nullptr;

  TList__1<int>* L2 = nullptr;

 

 

Original unit

 

The input in the field for the original unit is treated case insensitive in the same way as the source code by the pre-processor. The ".pas" extension hasn't to be appended. If there is a ".pas" extension, it will be removed.

 

 

New unit

 

Here the name of a header file can be set, where the new type is defined. If for example MyList.h is set, the following additional include directive is written into the output:

 

#include "MyList.h"

 

In contrast to the Original unit field, an extension is needed here. If needed, the new type is specified with the "Mylist" scope.

 

For C++Builder a ".hpp" extension is regarded as belonging to a C++ header, which automatically has been produced by the C++Builder compiler from an includet Delphi unit. Therefore the name of the file is not used for scope specification.

 

 

Remove original declaration

 

 

If this option is set the original declaration of the refactored type is omitted at the translation of the file where it was declared.

 

 

 

 

 

 

 

 

 

 

 



This page belongs to the DelphiXE2Cpp11 Documentation

DelphiXE2Cpp11 home  Content