* Sequence result support

This commit is contained in:
Michaël Van Canneyt 2024-04-10 18:54:01 +02:00
parent 05118c077f
commit dc7130d078
2 changed files with 54 additions and 1 deletions

View File

@ -1876,7 +1876,10 @@ begin
CN:=GetTypeName(TIDLSequenceTypeDefDefinition(D));
sDef:=FindGlobalDef(CN);
if (SDef=Nil) or (sDef.Data=Nil) then
Result:=CreatePasData(EscapeKeyWord(CN),D,true)
begin
Result:=CreatePasData(EscapeKeyWord(CN),D,true);
AddJSIdentifier(D);
end
else
Result:=ClonePasData(TPasData(sDef.Data),D);
D.Data:=Result;

View File

@ -58,6 +58,7 @@ type
procedure TestWJ_IntfFunction_ArrayBufferArg;
procedure TestWJ_IntfFunction_ArrayBufferViewArg;
procedure TestWJ_IntfFunction_SequenceResult;
procedure TestWJ_IntfFunction_GlobalSequenceResult;
// Namespace attribute
procedure TestWJ_NamespaceAttribute_Boolean;
// maplike
@ -1177,6 +1178,55 @@ begin
]);
end;
procedure TTestWebIDL2WasmJob.TestWJ_IntfFunction_GlobalSequenceResult;
begin
TestWebIDL([
'typedef sequence <long> LongSeq;',
'interface Attr {',
' LongSeq vibrate();',
'};',
''],
[
'Type',
'',
' // Forward class definitions',
' IJSAttr = interface;',
' TJSAttr = class;',
' TIntegerDynArray = IJSArray; // array of Integer',
'',
' { --------------------------------------------------------------------',
' TJSAttr',
' --------------------------------------------------------------------}',
'',
' IJSAttr = interface(IJSObject)',
' [''{AA94F48A-2BFB-3877-82A6-208CA4B2AF2A}'']',
' function vibrate: TIntegerDynArray;',
' end;',
'',
' TJSAttr = class(TJSObject,IJSAttr)',
' Private',
' Public',
' function vibrate: TIntegerDynArray;',
' class function Cast(const Intf: IJSObject): IJSAttr;',
' end;',
'',
'implementation',
'',
'function TJSAttr.vibrate: TIntegerDynArray;',
'begin',
' Result:=InvokeJSObjectResult(''vibrate'',[],TJSArray) as TIntegerDynArray;',
'end;',
'',
'class function TJSAttr.Cast(const Intf: IJSObject): IJSAttr;',
'begin',
' Result:=TJSAttr.JOBCast(Intf);',
'end;',
'',
'end.'
]);
end;
procedure TTestWebIDL2WasmJob.TestWJ_NamespaceAttribute_Boolean;
begin