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
|
||||||
|
@ -156,6 +156,7 @@ const
|
|||||||
'end;' + CrLf;
|
'end;' + CrLf;
|
||||||
|
|
||||||
PropertyIntfMethodGetOptional = ' function GetHas%<PropertyName>:s: Boolean;';
|
PropertyIntfMethodGetOptional = ' function GetHas%<PropertyName>:s: Boolean;';
|
||||||
|
PropertyIntfMethodGetOptionalOrDefault = ' function %<PropertyName>:sDef(const ADefaultValue: %<DataType>:s = Default(%<DataType>:s)): %<DataType>:s;';
|
||||||
PropertyIntfMethodGetNil = ' function Get%<PropertyName>:sIsNil: Boolean;';
|
PropertyIntfMethodGetNil = ' function Get%<PropertyName>:sIsNil: Boolean;';
|
||||||
PropertyIntfMethodGetText = ' function Get%<PropertyName>:sText: WideString;';
|
PropertyIntfMethodGetText = ' function Get%<PropertyName>:sText: WideString;';
|
||||||
PropertyIntfMethodGet = ' function Get%<PropertyName>:s: %<DataType>:s;';
|
PropertyIntfMethodGet = ' function Get%<PropertyName>:s: %<DataType>:s;';
|
||||||
@ -175,6 +176,16 @@ const
|
|||||||
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 =
|
||||||
(
|
(
|
||||||
{ dntElement }
|
{ dntElement }
|
||||||
|
Loading…
Reference in New Issue
Block a user