mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 02:09:14 +02:00
* Support for enum return type
This commit is contained in:
parent
fd68d3bfbb
commit
43487dac24
@ -75,7 +75,7 @@ type
|
|||||||
FPasInterfaceSuffix: TIDLString;
|
FPasInterfaceSuffix: TIDLString;
|
||||||
function GetFunctionSuffix(aDef: TIDLFunctionDefinition; Overloads: TFPObjectList): String;
|
function GetFunctionSuffix(aDef: TIDLFunctionDefinition; Overloads: TFPObjectList): String;
|
||||||
function GetInvokeClassName(aResultDef: TIDLDefinition; aName: TIDLString; aDef: TIDLFunctionDefinition=nil): TIDLString;
|
function GetInvokeClassName(aResultDef: TIDLDefinition; aName: TIDLString; aDef: TIDLFunctionDefinition=nil): TIDLString;
|
||||||
function GetInvokeNameFromTypeName(aTypeName: TIDLString): TIDLString;
|
function GetInvokeNameFromTypeName(aTypeName: TIDLString; aType: TIDLDefinition): TIDLString;
|
||||||
|
|
||||||
Protected
|
Protected
|
||||||
function BaseUnits: String; override;
|
function BaseUnits: String; override;
|
||||||
@ -518,7 +518,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TWebIDLToPasWasmJob.GetInvokeNameFromTypeName(aTypeName : TIDLString): TIDLString;
|
function TWebIDLToPasWasmJob.GetInvokeNameFromTypeName(aTypeName : TIDLString; aType : TIDLDefinition): TIDLString;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
case aTypeName of
|
case aTypeName of
|
||||||
@ -543,7 +543,10 @@ begin
|
|||||||
Result:='InvokeJSNoResult';
|
Result:='InvokeJSNoResult';
|
||||||
end;
|
end;
|
||||||
else
|
else
|
||||||
Result:='InvokeJSObjectResult';
|
if aType is TIDLEnumDefinition then
|
||||||
|
Result:='InvokeJSUnicodeStringResult'
|
||||||
|
else
|
||||||
|
Result:='InvokeJSObjectResult';
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -591,7 +594,7 @@ begin
|
|||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
FuncName:=GetName(aDef);
|
FuncName:=GetName(aDef);
|
||||||
InvokeName:=GetInvokeNameFromTypeName(ResolvedReturnTypeName);
|
InvokeName:=GetInvokeNameFromTypeName(ResolvedReturnTypeName,Result);
|
||||||
case InvokeName of
|
case InvokeName of
|
||||||
'InvokeJSNoResult' :
|
'InvokeJSNoResult' :
|
||||||
begin
|
begin
|
||||||
|
@ -46,6 +46,7 @@ type
|
|||||||
procedure TestWJ_IntfFunction_SetEventHandler;
|
procedure TestWJ_IntfFunction_SetEventHandler;
|
||||||
procedure TestWJ_IntfFunction_Promise;
|
procedure TestWJ_IntfFunction_Promise;
|
||||||
procedure TestWJ_IntfFunction_ArgAny;
|
procedure TestWJ_IntfFunction_ArgAny;
|
||||||
|
procedure TestWJ_IntfFunction_EnumResult;
|
||||||
// Namespace attribute
|
// Namespace attribute
|
||||||
procedure TestWJ_NamespaceAttribute_Boolean;
|
procedure TestWJ_NamespaceAttribute_Boolean;
|
||||||
// maplike
|
// maplike
|
||||||
@ -688,6 +689,53 @@ begin
|
|||||||
'']);
|
'']);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TTestWebIDL2WasmJob.TestWJ_IntfFunction_EnumResult;
|
||||||
|
begin
|
||||||
|
TestWebIDL([
|
||||||
|
'enum E { ',
|
||||||
|
' "allowed", ',
|
||||||
|
' "disallowed" ',
|
||||||
|
'}; ',
|
||||||
|
'interface IE { ',
|
||||||
|
' E get(long a); ',
|
||||||
|
'};'
|
||||||
|
],[
|
||||||
|
'Type',
|
||||||
|
' // Forward class definitions',
|
||||||
|
' IJSIE = interface;',
|
||||||
|
' TJSIE = class;',
|
||||||
|
' TE = UnicodeString;',
|
||||||
|
' { --------------------------------------------------------------------',
|
||||||
|
' TJSIE',
|
||||||
|
' --------------------------------------------------------------------}',
|
||||||
|
' IJSIE = interface(IJSObject)',
|
||||||
|
' [''{04D06E4C-6063-3E89-A483-3296C9C8AA41}'']',
|
||||||
|
' function get(a: Integer) : TE;',
|
||||||
|
' end;',
|
||||||
|
'',
|
||||||
|
' TJSIE = class(TJSObject,IJSIE)',
|
||||||
|
' Private',
|
||||||
|
' Public',
|
||||||
|
' function get(a: Integer) : TE;',
|
||||||
|
' class function Cast(const Intf: IJSObject): IJSIE;',
|
||||||
|
' end;',
|
||||||
|
'',
|
||||||
|
'implementation',
|
||||||
|
'',
|
||||||
|
'function TJSIE.get(a: Integer) : TE;',
|
||||||
|
'begin',
|
||||||
|
' Result:=InvokeJSUnicodeStringResult(''get'',[a]);',
|
||||||
|
'end;',
|
||||||
|
'',
|
||||||
|
'class function TJSIE.Cast(const Intf: IJSObject): IJSIE;',
|
||||||
|
'begin',
|
||||||
|
' Result:=TJSIE.JOBCast(Intf);',
|
||||||
|
'end;',
|
||||||
|
'',
|
||||||
|
'end.'
|
||||||
|
]);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TTestWebIDL2WasmJob.TestWJ_NamespaceAttribute_Boolean;
|
procedure TTestWebIDL2WasmJob.TestWJ_NamespaceAttribute_Boolean;
|
||||||
begin
|
begin
|
||||||
TestWebIDL([
|
TestWebIDL([
|
||||||
|
Loading…
Reference in New Issue
Block a user