Changing the property prefixes |
Top Previous Next |
What is translated > Properties > Field properties > Changing the property prefixes For other compilers than C++Builder Delphi properties are replaced by a pair methods. If the default prefixes ReadProperty and WriteProperty are left, then it is very unlikely that there will be conflicts with existing names in the code. The situation is different when these prefixes are changed to preferred prefixes such as "get" and "set".
The first thing to note, however, is that the supplied C++ code for the Delphi RTL must also be adapted. This can be done simply by searching and replacing.
For the generation of the property code several cases have to be distinguished.
Let's assume that in the call the following methods are defined already:
function getName: String; procedure setIdent(AIdent: String); function getValue: String; procedure setValue(AValue: String); function getNote: String; procedure setNote(ANote: String);
1. There is no problem for for following property:
property Caption : String read FCaption write FCaption; -> System::String& getCaption() {return FCaption;} void setCaption(const System::String& Value){FCaption = Value;}
the newly created methods getCaption and setCaption didn't exist yet.
2. For the next property Name Delphi2Cpp will reuse the existing method getName, which also was used in the original Delphi code. Only the setName method has to be created newly.
property Name : String read getName write FName; -> void setName(const System::String& Value){FName = Value;}
Accordingly for:
property Ident : String read FIdent write setIdent; -> System::String& getIdent() {return FIdent;}
3: No new method has to be created, if all access methods exist already and they were used in the original Delphi code too:
property Value : String read getValue write setValue; ->
4. A problem arises, when the getter and setter methods that Delphi2Cpp generates exist already, but are not used in the original Delphi code:
property Note : String read FNote write FNote; -> System::String& getNote() {return FNote;} void setNote(const System::String& Value){FNote = Value;}
In this case Delphi2Cpp writes a warnings into the output, like:
//# conflict with existing procedure name or //# conflict with existing function name
By means of the list of identifiers either the case of the name of the existing method can be changed or the case of the property might be change, so that there will be no naming conflict any more.
|
This page belongs to the Delphi2Cpp Documentation |
Delphi2Cpp home Content |