mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-29 14:40:25 +02:00
webidl: wasmjob: rename conflicting arg names
This commit is contained in:
parent
f1a6d97765
commit
368289d5d8
@ -34,7 +34,7 @@ Type
|
|||||||
SrcFile: string;
|
SrcFile: string;
|
||||||
Resolved: TIDLDefinition;
|
Resolved: TIDLDefinition;
|
||||||
Constructor Create(APasName: String; D: TIDLBaseObject);
|
Constructor Create(APasName: String; D: TIDLBaseObject);
|
||||||
Property PasName: String read FPasName;
|
Property PasName: String read FPasName write FPasName;
|
||||||
end;
|
end;
|
||||||
TPasDataClass = class of TPasData;
|
TPasDataClass = class of TPasData;
|
||||||
|
|
||||||
@ -266,7 +266,7 @@ end;
|
|||||||
function TBaseWebIDLToPas.GetName(ADef: TIDLDefinition): String;
|
function TBaseWebIDLToPas.GetName(ADef: TIDLDefinition): String;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
If Assigned(ADef) and (TObject(ADef.Data) is TPasData) then
|
If Assigned(ADef) and (ADef.Data is TPasData) then
|
||||||
Result:=TPasData(ADef.Data).PasName
|
Result:=TPasData(ADef.Data).PasName
|
||||||
else
|
else
|
||||||
Result:=ADef.Name;
|
Result:=ADef.Name;
|
||||||
@ -560,6 +560,30 @@ Var
|
|||||||
L.Add(NewName,Def);
|
L.Add(NewName,Def);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure CheckRenameArgs(Func: TIDLFunctionDefinition);
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
Arg: TIDLArgumentDefinition;
|
||||||
|
ArgName: String;
|
||||||
|
ConflictDef: TIDLDefinition;
|
||||||
|
begin
|
||||||
|
for i:=0 to Func.Arguments.Count-1 do
|
||||||
|
begin
|
||||||
|
Arg:=Func.Argument[i];
|
||||||
|
ArgName:=GetName(Arg);
|
||||||
|
repeat
|
||||||
|
ConflictDef:=TIDLDefinition(L.Items[ArgName]);
|
||||||
|
if (ConflictDef=Nil) then break;
|
||||||
|
// name conflict -> rename
|
||||||
|
if ArgName[1]<>'a' then
|
||||||
|
ArgName:='a'+ArgName
|
||||||
|
else
|
||||||
|
ArgName:='_'+ArgName;
|
||||||
|
(Arg.Data as TPasData).PasName:=ArgName;
|
||||||
|
until false;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
D: TIDLDefinition;
|
D: TIDLDefinition;
|
||||||
begin
|
begin
|
||||||
@ -571,6 +595,9 @@ begin
|
|||||||
For D in ML Do
|
For D in ML Do
|
||||||
if (D is TIDLConstDefinition) then
|
if (D is TIDLConstDefinition) then
|
||||||
CheckRename(D);
|
CheckRename(D);
|
||||||
|
For D in ML Do
|
||||||
|
if D is TIDLFunctionDefinition then
|
||||||
|
CheckRenameArgs(TIDLFunctionDefinition(D));
|
||||||
finally
|
finally
|
||||||
L.Free;
|
L.Free;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user