webidl: pass variant args as const

This commit is contained in:
mattias 2022-08-25 16:01:12 +02:00
parent 922210eaa8
commit 73185e89e1
2 changed files with 45 additions and 0 deletions
packages/webidl

View File

@ -1142,6 +1142,7 @@ begin
if (ArgType is TIDLFunctionDefinition)
or (ArgType is TIDLDictionaryDefinition)
or (ArgType is TIDLSequenceTypeDefDefinition)
or (ArgResolvedTypeName='Variant')
or (ArgResolvedTypeName='UnicodeString')
or (ArgResolvedTypeName='UTF8String') then
ArgName:='const '+ArgName;

View File

@ -45,6 +45,7 @@ type
procedure TestWJ_IntfFunction_Void;
procedure TestWJ_IntfFunction_SetEventHandler;
procedure TestWJ_IntfFunction_Promise;
procedure TestWJ_IntfFunction_ArgAny;
end;
function LinesToStr(Args: array of const): string;
@ -627,6 +628,49 @@ begin
'']);
end;
procedure TTestWebIDL2WasmJob.TestWJ_IntfFunction_ArgAny;
begin
TestWebIDL([
'interface Attr {',
' void append(any node);',
'};',
''],
['Type',
' // Forward class definitions',
' IJSAttr = interface;',
' TJSAttr = class;',
' { --------------------------------------------------------------------',
' TJSAttr',
' --------------------------------------------------------------------}',
'',
' IJSAttr = interface(IJSObject)',
' [''{AA94F48A-84D7-3FAA-A2A6-208CA4B2AF2A}'']',
' procedure append(const aNode: Variant);',
' end;',
'',
' TJSAttr = class(TJSObject,IJSAttr)',
' Private',
' Public',
' procedure append(const aNode: Variant);',
' class function Cast(Intf: IJSObject): IJSAttr;',
' end;',
'',
'implementation',
'',
'procedure TJSAttr.append(const aNode: Variant);',
'begin',
' InvokeJSNoResult(''append'',[aNode]);',
'end;',
'',
'class function TJSAttr.Cast(Intf: IJSObject): IJSAttr;',
'begin',
' Result:=TJSAttr.JOBCast(Intf);',
'end;',
'',
'end.',
'']);
end;
initialization
RegisterTests([TTestWebIDL2Wasmjob]);