1
0
mirror of synced 2024-11-14 19:13:50 +00:00

Fixed: safe NodeValue to String conversion

Fixed: NodeValue getter would treat it as a ChildNode instead (as did attributes)
Changed: use of generic collections instead of typecasts
This commit is contained in:
Mark van Renswoude 2014-10-28 14:22:41 +00:00
parent f3d8ef6968
commit 66dbd1738a
4 changed files with 89 additions and 125 deletions

View File

@ -2,11 +2,9 @@ unit DelphiXMLDataBindingGenerator;
interface interface
uses uses
Classes, System.Classes,
Contnrs, System.Generics.Collections,
XMLSchema, Xml.XMLSchema,
X2UtHashes,
DelphiXMLDataBindingResources, DelphiXMLDataBindingResources,
XMLDataBindingGenerator, XMLDataBindingGenerator,
@ -16,22 +14,12 @@ uses
type type
TGetFileNameEvent = procedure(Sender: TObject; const SchemaName: String; var Path, FileName: String) of object; TGetFileNameEvent = procedure(Sender: TObject; const SchemaName: String; var Path, FileName: String) of object;
TXMLSchemaList = TList<TXMLDataBindingSchema>;
TXMLSchemaList = class(TObjectList)
private
function GetItem(Index: Integer): TXMLDataBindingSchema;
procedure SetItem(Index: Integer; const Value: TXMLDataBindingSchema);
public
constructor Create;
property Items[Index: Integer]: TXMLDataBindingSchema read GetItem write SetItem; default;
end;
TDelphiXMLDataBindingGenerator = class(TXMLDataBindingGenerator) TDelphiXMLDataBindingGenerator = class(TXMLDataBindingGenerator)
private private
FProcessedItems: TX2OIHash; FProcessedItems: TList<TXMLDataBindingInterface>;
FUnitNames: TX2OSHash; FUnitNames: TDictionary<TXMLDataBindingSchema, String>;
FOnGetFileName: TGetFileNameEvent; FOnGetFileName: TGetFileNameEvent;
protected protected
@ -73,13 +61,13 @@ type
procedure WriteEnumerator(AWriter: TNamedFormatWriter; AItem: TXMLDataBindingInterface; ASection: TDelphiXMLSection); procedure WriteEnumerator(AWriter: TNamedFormatWriter; AItem: TXMLDataBindingInterface; ASection: TDelphiXMLSection);
function GetDelphiNodeType(AProperty: TXMLDataBindingProperty): TDelphiNodeType; function GetDelphiNodeType(AProperty: TXMLDataBindingProperty): TDelphiNodeType;
function GetDelphiElementType(AProperty: TXMLDataBindingProperty): TDelphiElementType; function GetDelphiElementType(ANodeType: TDelphiNodeType): TDelphiElementType;
function DataTypeConversion(const ADestination, ASource: String; ADataType: IXMLTypeDef; AAccessor: TDelphiAccessor; ANodeType: TDelphiNodeType; const ATargetNamespace: string; const ALinesBefore: String = ''): String; function DataTypeConversion(const ADestination, ASource: String; ADataType: IXMLTypeDef; AAccessor: TDelphiAccessor; ANodeType: TDelphiNodeType; const ATargetNamespace: string; const ALinesBefore: String = ''): String;
function XMLToNativeDataType(const ADestination, ASource: String; ADataType: IXMLTypeDef; ANodeType: TDelphiNodeType; const ATargetNamespace: string; const ALinesBefore: String = ''): String; function XMLToNativeDataType(const ADestination, ASource: String; ADataType: IXMLTypeDef; ANodeType: TDelphiNodeType; const ATargetNamespace: string; const ALinesBefore: String = ''): String;
function NativeDataTypeToXML(const ADestination, ASource: String; ADataType: IXMLTypeDef; ANodeType: TDelphiNodeType; const ATargetNamespace: string; const ALinesBefore: String = ''): String; function NativeDataTypeToXML(const ADestination, ASource: String; ADataType: IXMLTypeDef; ANodeType: TDelphiNodeType; const ATargetNamespace: string; const ALinesBefore: String = ''): String;
property ProcessedItems: TX2OIHash read FProcessedItems; property ProcessedItems: TList<TXMLDataBindingInterface> read FProcessedItems;
property UnitNames: TX2OSHash read FUnitNames; property UnitNames: TDictionary<TXMLDataBindingSchema, String> read FUnitNames;
public public
property OnGetFileName: TGetFileNameEvent read FOnGetFileName write FOnGetFileName; property OnGetFileName: TGetFileNameEvent read FOnGetFileName write FOnGetFileName;
end; end;
@ -116,12 +104,12 @@ begin
otMultiple: otMultiple:
begin begin
FUnitNames := TX2OSHash.Create; FUnitNames := TDictionary<TXMLDataBindingSchema, String>.Create;
try try
for schemaIndex := 0 to Pred(SchemaCount) do for schemaIndex := 0 to Pred(SchemaCount) do
begin begin
schema := Schemas[schemaIndex]; schema := Schemas[schemaIndex];
FUnitNames[schema] := DoGetFileName(schema.SchemaName); FUnitNames.Add(schema, DoGetFileName(schema.SchemaName));
end; end;
for schemaIndex := 0 to Pred(SchemaCount) do for schemaIndex := 0 to Pred(SchemaCount) do
@ -164,7 +152,7 @@ begin
['UsesClause', usesClause]); ['UsesClause', usesClause]);
WriteSection(unitWriter, dxsForward, ASchemaList); WriteSection(unitWriter, dxsForward, ASchemaList);
FProcessedItems := TX2OIHash.Create; FProcessedItems := TList<TXMLDataBindingInterface>.Create;
try try
FProcessedItems.Clear; FProcessedItems.Clear;
WriteSection(unitWriter, dxsInterface, ASchemaList); WriteSection(unitWriter, dxsInterface, ASchemaList);
@ -194,13 +182,13 @@ end;
function TDelphiXMLDataBindingGenerator.GenerateUsesClause(ASchemaList: TXMLSchemaList): String; function TDelphiXMLDataBindingGenerator.GenerateUsesClause(ASchemaList: TXMLSchemaList): String;
var var
includedSchemas: TObjectList; includedSchemas: TList<TXMLDataBindingSchema>;
procedure AddSchema(ASchema: TXMLDataBindingSchema); procedure AddSchema(ASchema: TXMLDataBindingSchema);
begin begin
if Assigned(ASchema) and if Assigned(ASchema) and
(includedSchemas.IndexOf(ASchema) = -1) and (not includedSchemas.Contains(ASchema)) and
(ASchemaList.IndexOf(ASchema) = -1) then (not ASchemaList.Contains(ASchema)) then
includedSchemas.Add(ASchema); includedSchemas.Add(ASchema);
end; end;
@ -212,12 +200,11 @@ var
interfaceItem: TXMLDataBindingInterface; interfaceItem: TXMLDataBindingInterface;
propertyIndex: Integer; propertyIndex: Integer;
propertyItem: TXMLDataBindingProperty; propertyItem: TXMLDataBindingProperty;
includeIndex: Integer;
begin begin
Result := ''; Result := '';
includedSchemas := TObjectList.Create(False); includedSchemas := TList<TXMLDataBindingSchema>.Create;
try try
{ Determine which items are used } { Determine which items are used }
for schemaIndex := 0 to Pred(ASchemaList.Count) do for schemaIndex := 0 to Pred(ASchemaList.Count) do
@ -247,11 +234,8 @@ begin
{ Build uses clause } { Build uses clause }
if includedSchemas.Count > 0 then if includedSchemas.Count > 0 then
begin begin
for includeIndex := 0 to Pred(includedSchemas.Count) do for schema in includedSchemas do
begin
schema := TXMLDataBindingSchema(includedSchemas[includeIndex]);
Result := Result + ' ' + ChangeFileExt(ExtractFileName(FUnitNames[schema]), '') + ',' + CrLf; Result := Result + ' ' + ChangeFileExt(ExtractFileName(FUnitNames[schema]), '') + ',' + CrLf;
end;
Result := Result + CrLf; Result := Result + CrLf;
end; end;
@ -525,7 +509,7 @@ end;
procedure TDelphiXMLDataBindingGenerator.WriteEnumerationConversions(AWriter: TNamedFormatWriter; ASection: TDelphiXMLSection; ASchemaList: TXMLSchemaList); procedure TDelphiXMLDataBindingGenerator.WriteEnumerationConversions(AWriter: TNamedFormatWriter; ASection: TDelphiXMLSection; ASchemaList: TXMLSchemaList);
var var
enumerations: TObjectList; enumerations: TList<TXMLDataBindingItem>;
schemaIndex: Integer; schemaIndex: Integer;
schema: TXMLDataBindingSchema; schema: TXMLDataBindingSchema;
itemIndex: Integer; itemIndex: Integer;
@ -539,7 +523,7 @@ begin
Exit; Exit;
enumerations := TObjectList.Create(False); enumerations := TList<TXMLDataBindingItem>.Create;
try try
for schemaIndex := 0 to Pred(ASchemaList.Count) do for schemaIndex := 0 to Pred(ASchemaList.Count) do
begin begin
@ -623,7 +607,8 @@ begin
{ In ye olde days this is where we checked if XMLDataBindingUtils was required. With the { In ye olde days this is where we checked if XMLDataBindingUtils was required. With the
introduction of the IXSDValidate, this is practically always the case. } introduction of the IXSDValidate, this is practically always the case. }
AWriter.WriteLine('uses'); AWriter.WriteLine('uses');
AWriter.WriteLine(' SysUtils;'); AWriter.WriteLine(' SysUtils,');
AWriter.WriteLine(' Variants;');
AWriter.WriteLine; AWriter.WriteLine;
end; end;
@ -677,13 +662,13 @@ begin
begin begin
{ Ensure the base item is completely defined first, Delphi doesn't allow { Ensure the base item is completely defined first, Delphi doesn't allow
inheritance with just a forward declaration. } inheritance with just a forward declaration. }
if ProcessedItems.Exists(AItem) then if ProcessedItems.Contains(AItem) then
exit; exit;
if Assigned(AItem.BaseItem) then if Assigned(AItem.BaseItem) then
WriteSchemaInterface(AWriter, AItem.BaseItem, ASection); WriteSchemaInterface(AWriter, AItem.BaseItem, ASection);
ProcessedItems[AItem] := 1; ProcessedItems.Add(AItem);
end; end;
@ -1140,7 +1125,7 @@ var
fieldName: String; fieldName: String;
writeStream: Boolean; writeStream: Boolean;
typeMapping: TTypeMapping; typeMapping: TTypeMapping;
elementType: TDelphiElementType; nodeType: TDelphiNodeType;
begin begin
Result := False; Result := False;
@ -1290,23 +1275,23 @@ begin
case AMember of case AMember of
dxmPropertyGet: dxmPropertyGet:
begin begin
elementType := GetDelphiElementType(AProperty); nodeType := GetDelphiNodeType(AProperty);
WriteNewLine; WriteNewLine;
if writeOptional then if writeOptional then
if AProperty.IsAttribute then if AProperty.IsAttribute then
sourceCode.Add(PropertyImplMethodGetOptionalAttr) sourceCode.Add(PropertyImplMethodGetOptionalAttr)
else else
sourceCode.Add(PropertyImplMethodGetOptional[elementType]); sourceCode.Add(PropertyImplMethodGetOptional[GetDelphiElementType(nodeType)]);
if writeNil then if writeNil then
sourceCode.Add(PropertyImplMethodGetNil[elementType]); sourceCode.Add(PropertyImplMethodGetNil[GetDelphiElementType(nodeType)]);
if writeTextProp then if writeTextProp then
if AProperty.IsAttribute then if AProperty.IsAttribute then
sourceCode.Add(PropertyImplMethodGetTextAttr) sourceCode.Add(PropertyImplMethodGetTextAttr)
else else
sourceCode.Add(PropertyImplMethodGetText[elementType]); sourceCode.Add(PropertyImplMethodGetText[GetDelphiElementType(nodeType)]);
sourceCode.Add('function TXML%<Name>:s.Get%<PropertyName>:s: %<DataType>:s;'); sourceCode.Add('function TXML%<Name>:s.Get%<PropertyName>:s: %<DataType>:s;');
@ -1321,7 +1306,7 @@ begin
sourceCode.Add(XMLToNativeDataType('Result', sourceCode.Add(XMLToNativeDataType('Result',
'%<PropertySourceName>:s', '%<PropertySourceName>:s',
TXMLDataBindingSimpleProperty(AProperty).DataType, TXMLDataBindingSimpleProperty(AProperty).DataType,
elementType, nodeType,
AProperty.TargetNamespace)); AProperty.TargetNamespace));
ptItem: ptItem:
@ -1366,17 +1351,17 @@ begin
dxmPropertySet: dxmPropertySet:
if not IsReadOnly(AProperty) then if not IsReadOnly(AProperty) then
begin begin
elementType := GetDelphiElementType(AProperty); nodeType := GetDelphiNodeType(AProperty);
WriteNewLine; WriteNewLine;
if writeNil then if writeNil then
sourceCode.Add(PropertyImplMethodSetNil[elementType]); sourceCode.Add(PropertyImplMethodSetNil[GetDelphiElementType(nodeType)]);
if writeTextProp then if writeTextProp then
if AProperty.IsAttribute then if AProperty.IsAttribute then
sourceCode.Add(PropertyImplMethodSetTextAttr) sourceCode.Add(PropertyImplMethodSetTextAttr)
else else
sourceCode.Add(PropertyImplMethodSetText[elementType]); sourceCode.Add(PropertyImplMethodSetText[GetDelphiElementType(nodeType)]);
sourceCode.Add('procedure TXML%<Name>:s.Set%<PropertyName>:s(const Value: %<DataType>:s);'); sourceCode.Add('procedure TXML%<Name>:s.Set%<PropertyName>:s(const Value: %<DataType>:s);');
value := '%<PropertySourceName>:s'; value := '%<PropertySourceName>:s';
@ -1384,7 +1369,7 @@ begin
if Assigned(propertyItem) and (propertyItem.ItemType = itEnumeration) then if Assigned(propertyItem) and (propertyItem.ItemType = itEnumeration) then
begin begin
sourceCode.Add(NativeDataTypeToXML(value, '%<PropertyItemName>:sValues[Value]', nil, sourceCode.Add(NativeDataTypeToXML(value, '%<PropertyItemName>:sValues[Value]', nil,
elementType, nodeType,
AProperty.TargetNamespace)); AProperty.TargetNamespace));
end else end else
begin begin
@ -1393,7 +1378,7 @@ begin
sourceCode.Add(NativeDataTypeToXML(value, 'Value', sourceCode.Add(NativeDataTypeToXML(value, 'Value',
TXMLDataBindingSimpleProperty(AProperty).DataType, TXMLDataBindingSimpleProperty(AProperty).DataType,
elementType, nodeType,
AProperty.TargetNamespace)); AProperty.TargetNamespace));
end; end;
@ -1403,11 +1388,11 @@ begin
dxmPropertyMethods: dxmPropertyMethods:
if writeStream then if writeStream then
begin begin
elementType := GetDelphiElementType(AProperty); nodeType := GetDelphiElementType(GetDelphiNodeType(AProperty));
sourceCode.Add(PropertyImplMethodLoadFromStream[elementType]); sourceCode.Add(PropertyImplMethodLoadFromStream[nodeType]);
sourceCode.Add(PropertyImplMethodLoadFromFile[elementType]); sourceCode.Add(PropertyImplMethodLoadFromFile[nodeType]);
sourceCode.Add(PropertyImplMethodSaveToStream[elementType]); sourceCode.Add(PropertyImplMethodSaveToStream[nodeType]);
sourceCode.Add(PropertyImplMethodSaveToFile[elementType]); sourceCode.Add(PropertyImplMethodSaveToFile[nodeType]);
end; end;
end; end;
end; end;
@ -1691,10 +1676,11 @@ begin
end; end;
function TDelphiXMLDataBindingGenerator.GetDelphiElementType(AProperty: TXMLDataBindingProperty): TDelphiElementType; function TDelphiXMLDataBindingGenerator.GetDelphiElementType(ANodeType: TDelphiNodeType): TDelphiElementType;
begin begin
Result := GetDelphiNodeType(AProperty); if ANodeType = dntElementNS then
if Result <> dntElementNS then Result := dntElementNS
else
Result := dntElement; Result := dntElement;
end; end;
@ -1783,25 +1769,6 @@ begin
end; end;
end; end;
{ TXMLSchemaList }
constructor TXMLSchemaList.Create;
begin
inherited Create(False);
end;
function TXMLSchemaList.GetItem(Index: Integer): TXMLDataBindingSchema;
begin
Result := TXMLDataBindingSchema(inherited GetItem(Index));
end;
procedure TXMLSchemaList.SetItem(Index: Integer; const Value: TXMLDataBindingSchema);
begin
inherited SetItem(Index, Value);
end;
end. end.

View File

@ -509,7 +509,7 @@ const
{ tcDateTime } ' %<Destination>:s := XMLToDateTime(GetNodeValue, xdtDateTime);', { tcDateTime } ' %<Destination>:s := XMLToDateTime(GetNodeValue, xdtDateTime);',
{ tcDate } ' %<Destination>:s := XMLToDateTime(GetNodeValue, xdtDate);', { tcDate } ' %<Destination>:s := XMLToDateTime(GetNodeValue, xdtDate);',
{ tcTime } ' %<Destination>:s := XMLToDateTime(GetNodeValue, xdtTime);', { tcTime } ' %<Destination>:s := XMLToDateTime(GetNodeValue, xdtTime);',
{ tcString } ' %<Destination>:s := GetNodeValue;', { tcString } ' %<Destination>:s := VarToStr(GetNodeValue);',
{ tcBase64 } ' %<Destination>:s := Base64Decode(Trim(GetNodeValue));', { tcBase64 } ' %<Destination>:s := Base64Decode(Trim(GetNodeValue));',
{ tcNode } '' { tcNode } ''
), ),

View File

@ -4,9 +4,9 @@ unit XMLDataBindingGenerator;
interface interface
uses uses
Classes, System.Classes,
Contnrs, System.Generics.Collections,
XMLSchema; Xml.XMLSchema;
type type
TXMLDataBindingSchema = class; TXMLDataBindingSchema = class;
@ -40,7 +40,7 @@ type
FOutputType: TXMLDataBindingOutputType; FOutputType: TXMLDataBindingOutputType;
FSourceFileName: String; FSourceFileName: String;
FSchemas: TObjectList; FSchemas: TObjectList<TXMLDataBindingSchema>;
FOnPostProcessItem: TXMLDataBindingPostProcessItemEvent; FOnPostProcessItem: TXMLDataBindingPostProcessItemEvent;
@ -121,8 +121,8 @@ type
TXMLDataBindingSchema = class(TXMLDataBindingGeneratorItem) TXMLDataBindingSchema = class(TXMLDataBindingGeneratorItem)
private private
FIncludes: TObjectList; FIncludes: TObjectList<TXMLDataBindingSchema>;
FItems: TObjectList; FItems: TObjectList<TXMLDataBindingItem>;
FItemsGenerated: Boolean; FItemsGenerated: Boolean;
FSchemaDef: IXMLSchemaDef; FSchemaDef: IXMLSchemaDef;
FSchemaName: String; FSchemaName: String;
@ -199,7 +199,7 @@ type
private private
FInterfaceType: TXMLDataBindingInterfaceType; FInterfaceType: TXMLDataBindingInterfaceType;
FIsSequence: Boolean; FIsSequence: Boolean;
FProperties: TObjectList; FProperties: TObjectList<TXMLDataBindingProperty>;
FBaseName: String; FBaseName: String;
FBaseItem: TXMLDataBindingInterface; FBaseItem: TXMLDataBindingInterface;
@ -242,7 +242,7 @@ type
TXMLDataBindingEnumeration = class(TXMLDataBindingItem) TXMLDataBindingEnumeration = class(TXMLDataBindingItem)
private private
FMembers: TObjectList; FMembers: TObjectList<TXMLDataBindingEnumerationMember>;
FIsAttribute: Boolean; FIsAttribute: Boolean;
function GetMemberCount: Integer; function GetMemberCount: Integer;
@ -355,14 +355,12 @@ type
implementation implementation
uses uses
SysUtils, System.SysUtils,
Variants, System.Variants,
Windows, Winapi.Windows,
XMLDoc, Xml.XMLDoc,
XMLIntf, Xml.XMLIntf,
XMLSchemaTags, Xml.XMLSchemaTags;
X2UtHashes;
const const
@ -388,7 +386,7 @@ begin
inherited Create; inherited Create;
FIncludePaths := TStringList.Create; FIncludePaths := TStringList.Create;
FSchemas := TObjectList.Create(True); FSchemas := TObjectList<TXMLDataBindingSchema>.Create(True);
with TStringList(FIncludePaths) do with TStringList(FIncludePaths) do
begin begin
@ -1336,25 +1334,28 @@ end;
procedure TXMLDataBindingGenerator.ResolveNameConflicts; procedure TXMLDataBindingGenerator.ResolveNameConflicts;
type
TItemNamesDictionary = TObjectDictionary<String, TObjectList<TXMLDataBindingItem>>;
var var
itemNames: TX2SOHash; itemNames: TItemNamesDictionary;
procedure AddItem(AItem: TXMLDataBindingItem); procedure AddItem(AItem: TXMLDataBindingItem);
var var
hashName: String; hashName: String;
items: TObjectList; items: TObjectList<TXMLDataBindingItem>;
begin begin
{ LowerCase because XML is case-sensitive, but Delphi isn't. } { LowerCase because XML is case-sensitive, but Delphi isn't. }
hashName := LowerCase(AItem.Name); hashName := LowerCase(AItem.Name);
if not itemNames.Exists(hashName) then if not itemNames.ContainsKey(hashName) then
begin begin
items := TObjectList.Create(False); items := TObjectList<TXMLDataBindingItem>.Create(False);
itemNames[hashName] := items; itemNames.Add(hashName, items);
end else end else
items := TObjectList(itemNames[hashName]); items := itemNames[hashName];
items.Add(AItem); items.Add(AItem);
end; end;
@ -1397,14 +1398,14 @@ var
schemaIndex: Integer; schemaIndex: Integer;
schema: TXMLDataBindingSchema; schema: TXMLDataBindingSchema;
itemIndex: Integer; itemIndex: Integer;
items: TObjectList; items: TObjectList<TXMLDataBindingItem>;
item: TXMLDataBindingItem; item: TXMLDataBindingItem;
depth: Integer; depth: Integer;
newName: String; newName: String;
resolved: Boolean; resolved: Boolean;
begin begin
itemNames := TX2SOHash.Create(True); itemNames := TItemNamesDictionary.Create([doOwnsValues]);
try try
{ Gather names } { Gather names }
for schemaIndex := 0 to Pred(SchemaCount) do for schemaIndex := 0 to Pred(SchemaCount) do
@ -1422,25 +1423,21 @@ begin
{ Find conflicts } { Find conflicts }
itemNames.First; for items in itemNames.Values do
while itemNames.Next do
begin begin
items := TObjectList(itemNames.CurrentValue);
if items.Count > 1 then if items.Count > 1 then
begin begin
{ Attempt to rename items } { Attempt to rename items }
for itemIndex := Pred(items.Count) downto 0 do for itemIndex := Pred(items.Count) downto 0 do
begin begin
item := TXMLDataBindingItem(items[itemIndex]); item := items[itemIndex];
newName := item.Name; newName := item.Name;
resolved := False; resolved := False;
depth := 1; depth := 1;
while ResolveItemNameConflict(item, depth, newName) do while ResolveItemNameConflict(item, depth, newName) do
begin begin
if not itemNames.Exists(newName) then if not itemNames.ContainsKey(newName) then
begin begin
resolved := True; resolved := True;
break; break;
@ -1490,7 +1487,7 @@ var
memberIndex: Integer; memberIndex: Integer;
propertyIndex: Integer; propertyIndex: Integer;
propertyItem: TXMLDataBindingProperty; propertyItem: TXMLDataBindingProperty;
repeatingItems: TObjectList; repeatingItems: TObjectList<TXMLDataBindingProperty>;
typedSchemaItem: IXMLTypedSchemaItem; typedSchemaItem: IXMLTypedSchemaItem;
begin begin
@ -1537,7 +1534,7 @@ begin
interfaceItem := TXMLDataBindingInterface(AItem); interfaceItem := TXMLDataBindingInterface(AItem);
interfaceItem.CollectionItem := nil; interfaceItem.CollectionItem := nil;
repeatingItems := TObjectList.Create(False); repeatingItems := TObjectList<TXMLDataBindingProperty>.Create(False);
try try
for propertyIndex := 0 to Pred(interfaceItem.PropertyCount) do for propertyIndex := 0 to Pred(interfaceItem.PropertyCount) do
if interfaceItem.Properties[propertyIndex].IsRepeating then if interfaceItem.Properties[propertyIndex].IsRepeating then
@ -1549,7 +1546,7 @@ begin
(not Assigned(interfaceItem.BaseItem)) then (not Assigned(interfaceItem.BaseItem)) then
begin begin
{ Single repeating child, the item itself is a collection parent } { Single repeating child, the item itself is a collection parent }
interfaceItem.CollectionItem := TXMLDataBindingProperty(repeatingItems[0]); interfaceItem.CollectionItem := repeatingItems[0];
end else end else
begin begin
{ Multiple repeating children or this interface is a descendant, { Multiple repeating children or this interface is a descendant,
@ -1601,7 +1598,7 @@ end;
function TXMLDataBindingGenerator.GetSchemas(Index: Integer): TXMLDataBindingSchema; function TXMLDataBindingGenerator.GetSchemas(Index: Integer): TXMLDataBindingSchema;
begin begin
Result := TXMLDataBindingSchema(FSchemas[Index]); Result := FSchemas[Index];
end; end;
@ -1624,8 +1621,8 @@ constructor TXMLDataBindingSchema.Create(AOwner: TXMLDataBindingGenerator);
begin begin
inherited Create(AOwner); inherited Create(AOwner);
FIncludes := TObjectList.Create(False); FIncludes := TObjectList<TXMLDataBindingSchema>.Create(False);
FItems := TObjectList.Create(True); FItems := TObjectList<TXMLDataBindingItem>.Create(True);
end; end;
@ -1696,7 +1693,7 @@ end;
function TXMLDataBindingSchema.GetIncludes(Index: Integer): TXMLDataBindingSchema; function TXMLDataBindingSchema.GetIncludes(Index: Integer): TXMLDataBindingSchema;
begin begin
Result := TXMLDataBindingSchema(FIncludes[Index]); Result := FIncludes[Index];
end; end;
@ -1708,7 +1705,7 @@ end;
function TXMLDataBindingSchema.GetItems(Index: Integer): TXMLDataBindingItem; function TXMLDataBindingSchema.GetItems(Index: Integer): TXMLDataBindingItem;
begin begin
Result := TXMLDataBindingItem(FItems[Index]); Result := FItems[Index];
end; end;
@ -1775,7 +1772,7 @@ var
begin begin
inherited Create(AOwner, ASchemaItem, AName); inherited Create(AOwner, ASchemaItem, AName);
FProperties := TObjectList.Create(True); FProperties := TObjectList<TXMLDataBindingProperty>.Create(True);
FInterfaceType := GetInterfaceType(SchemaItem); FInterfaceType := GetInterfaceType(SchemaItem);
FIsSequence := False; FIsSequence := False;
@ -1821,7 +1818,7 @@ begin
propertyItem := Properties[propertyIndex]; propertyItem := Properties[propertyIndex];
if propertyItem = AOldItem then if propertyItem = AOldItem then
FProperties.Extract(AOldItem) FProperties.Extract(propertyItem)
else else
begin begin
if (AOldItem.ItemType = itSimpleTypeAlias) and if (AOldItem.ItemType = itSimpleTypeAlias) and
@ -1907,7 +1904,7 @@ end;
function TXMLDataBindingInterface.GetProperties(Index: Integer): TXMLDataBindingProperty; function TXMLDataBindingInterface.GetProperties(Index: Integer): TXMLDataBindingProperty;
begin begin
Result := TXMLDataBindingProperty(FProperties[Index]); Result := FProperties[Index];
end; end;
@ -1934,7 +1931,7 @@ var
begin begin
inherited Create(AOwner, ASchemaItem, AName); inherited Create(AOwner, ASchemaItem, AName);
FMembers := TObjectList.Create; FMembers := TObjectList<TXMLDataBindingEnumerationMember>.Create;
FIsAttribute := AIsAttribute; FIsAttribute := AIsAttribute;
for memberIndex := 0 to Pred(AEnumerations.Count) do for memberIndex := 0 to Pred(AEnumerations.Count) do
@ -1964,7 +1961,7 @@ end;
function TXMLDataBindingEnumeration.GetMembers(Index: Integer): TXMLDataBindingEnumerationMember; function TXMLDataBindingEnumeration.GetMembers(Index: Integer): TXMLDataBindingEnumerationMember;
begin begin
Result := TXMLDataBindingEnumerationMember(FMembers[Index]); Result := FMembers[Index];
end; end;

View File

@ -9,7 +9,7 @@
<ProjectVersion>13.4</ProjectVersion> <ProjectVersion>13.4</ProjectVersion>
<Base>True</Base> <Base>True</Base>
<Config Condition="'$(Config)'==''">Build</Config> <Config Condition="'$(Config)'==''">Build</Config>
<Platform Condition="'$(Platform)'==''">Win64</Platform> <Platform Condition="'$(Platform)'==''">Win32</Platform>
<TargetedPlatforms>3</TargetedPlatforms> <TargetedPlatforms>3</TargetedPlatforms>
<AppType>Application</AppType> <AppType>Application</AppType>
</PropertyGroup> </PropertyGroup>