mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-17 13:59:29 +02:00
webidl: parse stringifier;
This commit is contained in:
parent
cc3589d459
commit
d8196a6ffe
@ -189,6 +189,7 @@ Type
|
||||
TIDLInterfaceDefinition = Class(TIDLStructuredDefinition)
|
||||
private
|
||||
FHasSerializer: Boolean;
|
||||
FHasStringifier: Boolean;
|
||||
FIsInclude: Boolean;
|
||||
FIsMixin: Boolean;
|
||||
FParentInterface: TIDLInterfaceDefinition;
|
||||
@ -196,6 +197,7 @@ Type
|
||||
Function AsString (aFull : Boolean) : UTF8String; override;
|
||||
Property ParentInterface : TIDLInterfaceDefinition Read FParentInterface Write FParentInterface;
|
||||
Property HasSerializer : Boolean Read FHasSerializer Write FHasSerializer;
|
||||
Property HasStringifier : Boolean Read FHasStringifier Write FHasStringifier;
|
||||
// is this a mixin definition?
|
||||
Property IsMixin : Boolean Read FIsMixin Write FIsMixin;
|
||||
Property IsInclude : Boolean Read FIsInclude Write FIsInclude;
|
||||
|
@ -509,18 +509,27 @@ Var
|
||||
|
||||
begin
|
||||
tk:=GetToken;
|
||||
if tk in [tkReadOnly,tkAttribute] then
|
||||
case tk of
|
||||
tkReadOnly,tkAttribute:
|
||||
begin
|
||||
Result:=ParseAttribute(aParent);
|
||||
With TIDLAttributeDefinition(result) do
|
||||
With TIDLAttributeDefinition(Result) do
|
||||
Options:=Options+[aoStringifier];
|
||||
end
|
||||
end;
|
||||
tkSemiColon:
|
||||
begin
|
||||
// stringifier;
|
||||
Result:=TIDLAttributeDefinition(Context.Add(aParent,TIDLAttributeDefinition,''));
|
||||
With TIDLAttributeDefinition(Result) do
|
||||
Options:=Options+[aoStringifier];
|
||||
end;
|
||||
else
|
||||
begin
|
||||
Result:=ParseOperation(aParent);
|
||||
With TIDLFunctionDefinition(result) do
|
||||
With TIDLFunctionDefinition(Result) do
|
||||
Options:=Options+[foStringifier];
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TWebIDLParser.ParseIterable(aParent: TIDLBaseObject): TIDLIterableDefinition;
|
||||
@ -936,7 +945,13 @@ begin
|
||||
Result.HasSerializer:=True;
|
||||
SemicolonSeen:=M=Nil;
|
||||
end;
|
||||
tkStringifier : M:=ParseStringifier(Result.Members);
|
||||
tkStringifier :
|
||||
begin
|
||||
M:=ParseStringifier(Result.Members);
|
||||
Result.HasStringifier:=true;
|
||||
if CurrentToken=tkSemiColon then
|
||||
SemicolonSeen:=true;
|
||||
end;
|
||||
tkIterable : ParseIterable(Result.Members);
|
||||
else
|
||||
{
|
||||
|
@ -186,6 +186,7 @@ Type
|
||||
Procedure ParseSimpleAttributeLegacyNullToEmptyString;
|
||||
Procedure ParseSimpleStaticAttribute;
|
||||
Procedure ParseSimpleStringifierAttribute;
|
||||
Procedure ParseStringifierNoAttribute;
|
||||
Procedure ParseSimpleReadonlyAttribute;
|
||||
Procedure ParseSimpleInheritedAttribute;
|
||||
Procedure ParseSimpleReadonlyInheritedAttribute;
|
||||
@ -667,6 +668,19 @@ begin
|
||||
ParseAttribute('stringifier attribute short A','A','short',[aoStringifier]);
|
||||
end;
|
||||
|
||||
procedure TTestAttributeInterfaceParser.ParseStringifierNoAttribute;
|
||||
var
|
||||
Id: TIDLInterfaceDefinition;
|
||||
Def: TIDLAttributeDefinition;
|
||||
begin
|
||||
Id:=ParseInterFace('IA','',['stringifier']);
|
||||
AssertEquals('Correct class',TIDLAttributeDefinition,Id.Members[0].ClassType);
|
||||
Def:=Id.Members[0] as TIDLAttributeDefinition;
|
||||
AssertEquals('Attr name','',Def.Name);
|
||||
AssertNull('Have type',Def.AttributeType);
|
||||
AssertEquals('Attr options',[aoStringifier],Def.Options);
|
||||
end;
|
||||
|
||||
procedure TTestAttributeInterfaceParser.ParseSimpleReadonlyAttribute;
|
||||
begin
|
||||
ParseAttribute('readonly attribute short A','A','short',[aoReadOnly]);
|
||||
|
Loading…
Reference in New Issue
Block a user