mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-21 08:09:33 +02:00
* Correct InvokenameFromAlias
This commit is contained in:
parent
ea64142bac
commit
bd08aa6197
@ -1921,12 +1921,28 @@ begin
|
||||
D.Data:=Result;
|
||||
AllocatePasName(TIDLArgumentDefinition(D).ArgumentType,ParentName+'_'+D.Name);
|
||||
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
|
||||
begin
|
||||
if (D is TIDLTypeDefDefinition)
|
||||
or (D is TIDLEnumDefinition)
|
||||
or ((D Is TIDLFunctionDefinition) and (foCallBack in TIDLFunctionDefinition(D).Options)) then
|
||||
begin
|
||||
if CN='' then
|
||||
CN:=ParentName+'Type';
|
||||
CN:=TypePrefix+CN;
|
||||
AddJSIdentifier(D);
|
||||
end;
|
||||
|
@ -558,6 +558,7 @@ function TWebIDLToPasWasmJob.GetInvokeNameFromTypeName(const aTypeName : TIDLStr
|
||||
|
||||
|
||||
begin
|
||||
Result:='';
|
||||
case aTypeName of
|
||||
'Boolean': Result:='InvokeJSBooleanResult';
|
||||
'ShortInt',
|
||||
@ -583,10 +584,14 @@ begin
|
||||
else
|
||||
if (aType is TIDLTypeDefDefinition) then
|
||||
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)
|
||||
else if TypeAliases.IndexOfName(GetName(aType))<>-1 then
|
||||
Result:=GetInvokeNameFromAliasName(aTypeName,aType);
|
||||
Result:=GetInvokeNameFromAliasName(aTypeName,aType)
|
||||
else
|
||||
Result:='InvokeJSObjectResult';
|
||||
if Result='' then
|
||||
Raise EConvertError.CreateFmt('Unable to determine invoke name from alias type %s',[aTypeName]);
|
||||
end
|
||||
|
@ -64,6 +64,7 @@ type
|
||||
procedure TestWJ_IntfFunction_ChromeOnlyNewObject;
|
||||
procedure TestWJ_IntfFunction_DictionaryResult;
|
||||
procedure TestWJ_IntfFunction_AliasResult;
|
||||
procedure TestWJ_IntfFunction_NestedUnionSequence;
|
||||
// Namespace attribute
|
||||
procedure TestWJ_NamespaceAttribute_Boolean;
|
||||
// maplike
|
||||
@ -1455,6 +1456,52 @@ begin
|
||||
]);
|
||||
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;
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user