From 26c3882c43215d05d91e817f2ebc7fd4d69607d3 Mon Sep 17 00:00:00 2001 From: michael Date: Sat, 24 Aug 2019 09:52:04 +0000 Subject: [PATCH] * Allow aliases git-svn-id: trunk@42787 - --- packages/webidl/src/webidlparser.pp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/webidl/src/webidlparser.pp b/packages/webidl/src/webidlparser.pp index c38cd1e936..769e18bf28 100644 --- a/packages/webidl/src/webidlparser.pp +++ b/packages/webidl/src/webidlparser.pp @@ -29,6 +29,7 @@ Type TWebIDLContext = Class (TIDLBaseObject) private + FAliases: TStrings; FDefinitions: TIDLDefinitionList; FHash : TFPObjectHashTable; Protected @@ -50,6 +51,7 @@ Type Function Add(aClass : TIDLDefinitionClass; const AName : UTF8String) : TIDLDefinition; override; Function Add(aParent : TIDLBaseObject; aClass : TIDLDefinitionClass; const AName : UTF8String) : TIDLDefinition; virtual; Property Definitions : TIDLDefinitionList Read FDefinitions; + Property Aliases : TStrings Read FAliases Write FAliases; end; { TWebIDLParser } @@ -132,6 +134,7 @@ Resourcestring SErrTypeNotAllowed = 'Type "%s" not allowed in "%s" type.'; SErrDictionaryNotFound = 'Dictionary %s not found'; SErrInterfaceNotFound = 'Interface %s not found'; + SErrInterfaceNotFoundfor = 'Included Interface %s not found for %s'; { TWebIDLParser } @@ -1367,9 +1370,17 @@ begin Raise EWebIDLParser.CreateFmt(SErrInterfaceNotFound,[ID.Name]); II:=FindInterface(ID.IncludedInterface); If (II=Nil) then - Raise EWebIDLParser.CreateFmt(SErrInterfaceNotFound,[ID.Name]); - II.IsInclude:=True; - OI.Partials.Add(II); + begin + if Assigned(Aliases) and (Aliases.IndexOfName(ID.IncludedInterface)<>-1) then + OI.ParentName:=Aliases.Values[ID.IncludedInterface] + else + Raise EWebIDLParser.CreateFmt(SErrInterfaceNotFoundFor,[ID.IncludedInterface,ID.Name]); + end + else + begin + II.IsInclude:=True; + OI.Partials.Add(II); + end end; // if there is a single include, no members and no parent, make it a descendent For D in FDefinitions do