Support of 'Def' getter method for optional elements
This commit is contained in:
parent
3c9f47f80e
commit
5451a52cd2
@ -1223,7 +1223,11 @@ begin
|
|||||||
WriteNewLine;
|
WriteNewLine;
|
||||||
|
|
||||||
if writeOptional then
|
if writeOptional then
|
||||||
|
begin
|
||||||
sourceCode.Add(PropertyIntfMethodGetOptional);
|
sourceCode.Add(PropertyIntfMethodGetOptional);
|
||||||
|
if AProperty.PropertyType = ptSimple then
|
||||||
|
sourceCode.Add(PropertyIntfMethodGetOptionalOrDefault);
|
||||||
|
end;
|
||||||
|
|
||||||
if writeNil then
|
if writeNil then
|
||||||
sourceCode.Add(PropertyIntfMethodGetNil);
|
sourceCode.Add(PropertyIntfMethodGetNil);
|
||||||
@ -1311,6 +1315,9 @@ begin
|
|||||||
else
|
else
|
||||||
sourceCode.Add(PropertyImplMethodGetOptional[GetDelphiElementType(nodeType)]);
|
sourceCode.Add(PropertyImplMethodGetOptional[GetDelphiElementType(nodeType)]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
if AProperty.PropertyType = ptSimple then
|
||||||
|
sourceCode.Add(PropertyImplMethodGetOptionalOrDefault);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if writeNil then
|
if writeNil then
|
||||||
|
@ -155,25 +155,36 @@ const
|
|||||||
' Result := (inherited GetCurrent as %<DataType>:s);' + CrLf +
|
' Result := (inherited GetCurrent as %<DataType>:s);' + CrLf +
|
||||||
'end;' + CrLf;
|
'end;' + CrLf;
|
||||||
|
|
||||||
PropertyIntfMethodGetOptional = ' function GetHas%<PropertyName>:s: Boolean;';
|
PropertyIntfMethodGetOptional = ' function GetHas%<PropertyName>:s: Boolean;';
|
||||||
PropertyIntfMethodGetNil = ' function Get%<PropertyName>:sIsNil: Boolean;';
|
PropertyIntfMethodGetOptionalOrDefault = ' function %<PropertyName>:sDef(const ADefaultValue: %<DataType>:s = Default(%<DataType>:s)): %<DataType>:s;';
|
||||||
PropertyIntfMethodGetText = ' function Get%<PropertyName>:sText: WideString;';
|
PropertyIntfMethodGetNil = ' function Get%<PropertyName>:sIsNil: Boolean;';
|
||||||
PropertyIntfMethodGet = ' function Get%<PropertyName>:s: %<DataType>:s;';
|
PropertyIntfMethodGetText = ' function Get%<PropertyName>:sText: WideString;';
|
||||||
PropertyIntfMethodSetNil = ' procedure Set%<PropertyName>:sIsNil(const Value: Boolean);';
|
PropertyIntfMethodGet = ' function Get%<PropertyName>:s: %<DataType>:s;';
|
||||||
PropertyIntfMethodSetText = ' procedure Set%<PropertyName>:sText(const Value: WideString);';
|
PropertyIntfMethodSetNil = ' procedure Set%<PropertyName>:sIsNil(const Value: Boolean);';
|
||||||
PropertyIntfMethodSet = ' procedure Set%<PropertyName>:s(const Value: %<DataType>:s);';
|
PropertyIntfMethodSetText = ' procedure Set%<PropertyName>:sText(const Value: WideString);';
|
||||||
PropertyIntfMethodLoadFromStream = ' procedure Load%<PropertyName>:sFromStream(AStream: TStream);';
|
PropertyIntfMethodSet = ' procedure Set%<PropertyName>:s(const Value: %<DataType>:s);';
|
||||||
PropertyIntfMethodLoadFromFile = ' procedure Load%<PropertyName>:sFromFile(const AFileName: string);';
|
PropertyIntfMethodLoadFromStream = ' procedure Load%<PropertyName>:sFromStream(AStream: TStream);';
|
||||||
PropertyIntfMethodSaveToStream = ' procedure Save%<PropertyName>:sToStream(AStream: TStream);';
|
PropertyIntfMethodLoadFromFile = ' procedure Load%<PropertyName>:sFromFile(const AFileName: string);';
|
||||||
PropertyIntfMethodSaveToFile = ' procedure Save%<PropertyName>:sToFile(const AFileName: string);';
|
PropertyIntfMethodSaveToStream = ' procedure Save%<PropertyName>:sToStream(AStream: TStream);';
|
||||||
|
PropertyIntfMethodSaveToFile = ' procedure Save%<PropertyName>:sToFile(const AFileName: string);';
|
||||||
|
|
||||||
PropertyInterfaceOptional = ' property Has%<PropertyName>:s: Boolean read GetHas%<PropertyName>:s;';
|
PropertyInterfaceOptional = ' property Has%<PropertyName>:s: Boolean read GetHas%<PropertyName>:s;';
|
||||||
PropertyInterfaceNilReadOnly = ' property %<PropertyName>:sIsNil: Boolean read Get%<PropertyName>:sIsNil;';
|
PropertyInterfaceNilReadOnly = ' property %<PropertyName>:sIsNil: Boolean read Get%<PropertyName>:sIsNil;';
|
||||||
PropertyInterfaceNil = ' property %<PropertyName>:sIsNil: Boolean read Get%<PropertyName>:sIsNil write Set%<PropertyName>:sIsNil;';
|
PropertyInterfaceNil = ' property %<PropertyName>:sIsNil: Boolean read Get%<PropertyName>:sIsNil write Set%<PropertyName>:sIsNil;';
|
||||||
PropertyInterfaceTextReadOnly = ' property %<PropertyName>:sText: WideString read Get%<PropertyName>:sText;';
|
PropertyInterfaceTextReadOnly = ' property %<PropertyName>:sText: WideString read Get%<PropertyName>:sText;';
|
||||||
PropertyInterfaceReadOnly = ' property %<PropertyName>:s: %<DataType>:s read Get%<PropertyName>:s;';
|
PropertyInterfaceReadOnly = ' property %<PropertyName>:s: %<DataType>:s read Get%<PropertyName>:s;';
|
||||||
PropertyInterfaceText = ' property %<PropertyName>:sText: WideString read Get%<PropertyName>:sText write Set%<PropertyName>:sText;';
|
PropertyInterfaceText = ' property %<PropertyName>:sText: WideString read Get%<PropertyName>:sText write Set%<PropertyName>:sText;';
|
||||||
PropertyInterface = ' property %<PropertyName>:s: %<DataType>:s read Get%<PropertyName>:s write Set%<PropertyName>:s;';
|
PropertyInterface = ' property %<PropertyName>:s: %<DataType>:s read Get%<PropertyName>:s write Set%<PropertyName>:s;';
|
||||||
|
|
||||||
|
|
||||||
|
PropertyImplMethodGetOptionalOrDefault = 'function TXML%<Name>:s.%<PropertyName>:sDef(const ADefaultValue: %<DataType>:s): %<DataType>:s;' + CrLf +
|
||||||
|
'begin' + CrLf +
|
||||||
|
' if GetHas%<PropertySourceName>:s then' + CrLf +
|
||||||
|
' Result := Get%<PropertySourceName>:s' + CrLf +
|
||||||
|
' else' + CrLf +
|
||||||
|
' Result := ADefaultValue;' + CrLf +
|
||||||
|
'end;' + CrLf +
|
||||||
|
'' + CrLf;
|
||||||
|
|
||||||
PropertyImplMethodGetOptional: array[TDelphiElementType] of string =
|
PropertyImplMethodGetOptional: array[TDelphiElementType] of string =
|
||||||
(
|
(
|
||||||
|
Loading…
Reference in New Issue
Block a user