mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-12 10:49:31 +02:00
webidl: pass variant args as const
This commit is contained in:
parent
922210eaa8
commit
73185e89e1
packages/webidl
@ -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;
|
||||
|
@ -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]);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user