* Correct InvokenameFromAlias

This commit is contained in:
Michaël Van Canneyt 2024-04-11 16:16:21 +02:00
parent ea64142bac
commit bd08aa6197
3 changed files with 70 additions and 2 deletions

View File

@ -1921,12 +1921,28 @@ begin
D.Data:=Result; D.Data:=Result;
AllocatePasName(TIDLArgumentDefinition(D).ArgumentType,ParentName+'_'+D.Name); AllocatePasName(TIDLArgumentDefinition(D).ArgumentType,ParentName+'_'+D.Name);
end end
else if D Is TIDLUnionTypeDefDefinition then
begin
CN:=GetTypeName(TIDLUnionTypeDefDefinition(D));
sDef:=FindGlobalDef(CN);
if (SDef=Nil) or (sDef.Data=Nil) then
begin
Result:=CreatePasData(EscapeKeyWord(CN),D,true);
AddJSIdentifier(D);
end
else
Result:=ClonePasData(TPasData(sDef.Data),D);
D.Data:=Result;
AllocatePasNames((D as TIDLUnionTypeDefDefinition).Union,D.Name)
end
else else
begin begin
if (D is TIDLTypeDefDefinition) if (D is TIDLTypeDefDefinition)
or (D is TIDLEnumDefinition) or (D is TIDLEnumDefinition)
or ((D Is TIDLFunctionDefinition) and (foCallBack in TIDLFunctionDefinition(D).Options)) then or ((D Is TIDLFunctionDefinition) and (foCallBack in TIDLFunctionDefinition(D).Options)) then
begin begin
if CN='' then
CN:=ParentName+'Type';
CN:=TypePrefix+CN; CN:=TypePrefix+CN;
AddJSIdentifier(D); AddJSIdentifier(D);
end; end;

View File

@ -558,6 +558,7 @@ function TWebIDLToPasWasmJob.GetInvokeNameFromTypeName(const aTypeName : TIDLStr
begin begin
Result:='';
case aTypeName of case aTypeName of
'Boolean': Result:='InvokeJSBooleanResult'; 'Boolean': Result:='InvokeJSBooleanResult';
'ShortInt', 'ShortInt',
@ -583,10 +584,14 @@ begin
else else
if (aType is TIDLTypeDefDefinition) then if (aType is TIDLTypeDefDefinition) then
begin begin
if (TypeAliases.IndexOfName((aType as TIDLTypeDefDefinition).TypeName)<>-1) then if (TypeAliases.IndexOfName(aTypeName)<>-1) then
Result:=GetInvokeNameFromAliasName(aTypeName,aType)
else if (TypeAliases.IndexOfName((aType as TIDLTypeDefDefinition).TypeName)<>-1) then
Result:=GetInvokeNameFromAliasName((aType as TIDLTypeDefDefinition).TypeName,aType) Result:=GetInvokeNameFromAliasName((aType as TIDLTypeDefDefinition).TypeName,aType)
else if TypeAliases.IndexOfName(GetName(aType))<>-1 then else if TypeAliases.IndexOfName(GetName(aType))<>-1 then
Result:=GetInvokeNameFromAliasName(aTypeName,aType); Result:=GetInvokeNameFromAliasName(aTypeName,aType)
else
Result:='InvokeJSObjectResult';
if Result='' then if Result='' then
Raise EConvertError.CreateFmt('Unable to determine invoke name from alias type %s',[aTypeName]); Raise EConvertError.CreateFmt('Unable to determine invoke name from alias type %s',[aTypeName]);
end end

View File

@ -64,6 +64,7 @@ type
procedure TestWJ_IntfFunction_ChromeOnlyNewObject; procedure TestWJ_IntfFunction_ChromeOnlyNewObject;
procedure TestWJ_IntfFunction_DictionaryResult; procedure TestWJ_IntfFunction_DictionaryResult;
procedure TestWJ_IntfFunction_AliasResult; procedure TestWJ_IntfFunction_AliasResult;
procedure TestWJ_IntfFunction_NestedUnionSequence;
// Namespace attribute // Namespace attribute
procedure TestWJ_NamespaceAttribute_Boolean; procedure TestWJ_NamespaceAttribute_Boolean;
// maplike // maplike
@ -1455,6 +1456,52 @@ begin
]); ]);
end; end;
procedure TTestWebIDL2WasmJob.TestWJ_IntfFunction_NestedUnionSequence;
begin
TestWebIDL([
'interface Attr {',
' long roundRect((unrestricted double or DOMPointInit or sequence<(unrestricted double or DOMPointInit)>) radii);',
'};',
''],
[
'Type',
'',
' // Forward class definitions',
' IJSAttr = interface;',
' TJSAttr = class;',
'',
' { --------------------------------------------------------------------',
' TJSAttr',
' --------------------------------------------------------------------}',
'',
' IJSAttr = interface(IJSObject)',
' [''{AA94F48A-2BFB-3877-82A6-208CA4B2AF2A}'']',
' function vibrate: IJSFloat32Array;',
' end;',
'',
' TJSAttr = class(TJSObject,IJSAttr)',
' Private',
' Public',
' function vibrate: IJSFloat32Array;',
' class function Cast(const Intf: IJSObject): IJSAttr;',
' end;',
'',
'implementation',
'',
'function TJSAttr.vibrate: IJSFloat32Array;',
'begin',
' Result:=InvokeJSObjectResult(''vibrate'',[],TJSArray) as IJSFloat32Array;',
'end;',
'',
'class function TJSAttr.Cast(const Intf: IJSObject): IJSAttr;',
'begin',
' Result:=TJSAttr.JOBCast(Intf);',
'end;',
'',
'end.'
]);
end;
procedure TTestWebIDL2WasmJob.TestWJ_NamespaceAttribute_Boolean; procedure TTestWebIDL2WasmJob.TestWJ_NamespaceAttribute_Boolean;
begin begin