* Handle "object" as argument type

This commit is contained in:
Michaël Van Canneyt 2024-04-12 15:02:47 +02:00
parent 51ffa2220e
commit e044aae4dc
2 changed files with 31 additions and 0 deletions

View File

@ -1029,6 +1029,7 @@ begin
'UnicodeString': GetFunc:='GetString';
'Variant': GetFunc:='GetVariant';
'TJOB_JSValue': GetFunc:='GetValue';
'IJSObject': GetFunc:='GetObject';
else
if (ArgType is TIDLInterfaceDefinition) or (ArgType is TIDLDictionaryDefinition) then
GetFunc:='GetObject('+GetName(ArgType)+') as '+ArgTypeName
@ -1088,6 +1089,7 @@ begin
'UnicodeString': GetFunc:='Result:=H.AllocString('+Call+');';
'Variant': GetFunc:='Result:=H.AllocVariant('+Call+');';
'TJOB_JSValue': GetFunc:='Result:=H.AllocJSValue('+Call+');';
'IJSObject' : GetFunc:='Result:=H.AllocIntf('+Call+');'
else
if ReturnDef is TIDLInterfaceDefinition then
GetFunc:='Result:=H.AllocIntf('+Call+');'

View File

@ -45,6 +45,8 @@ type
procedure TestWJ_IntfAttribute_ArrayBufferView;
procedure TestWJ_IntfAttribute_ChromeOnly;
procedure TestWJ_CallBackObject;
// todo procedure TestWJ_IntfAttribute_Any;
// functions
@ -684,6 +686,33 @@ begin
]);
end;
procedure TTestWebIDL2WasmJob.TestWJ_CallBackObject;
begin
WebIDLToPas.TypeAliases.Add('AudioWorkletProcessor=IJSObject');
TestWebIDL([
' callback constructor AudioWorkletProcessorConstructor = AudioWorkletProcessor (object options);'
],
[
'Type',
' // Forward class definitions',
' TAudioWorkletProcessorConstructor = function (options: IJSObject): IJSObject of object;',
'',
'implementation',
'',
'function JOBCallTAudioWorkletProcessorConstructor(const aMethod: TMethod; var H: TJOBCallbackHelper): PByte;',
' var',
' options: IJSObject;',
'begin',
' options:=H.GetObject;',
' Result:=H.AllocIntf(TAudioWorkletProcessorConstructor(aMethod)(options));',
'end;',
'',
'end.'
]);
end;
procedure TTestWebIDL2WasmJob.TestWJ_IntfFunction_Void;
begin
TestWebIDL([