mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-16 05:59:28 +02:00
webidl: wasm-job: function Cast
This commit is contained in:
parent
97f4399936
commit
8d42a9df83
@ -116,6 +116,7 @@ type
|
||||
function WriteForwardClassDefs(aList: TIDLDefinitionList): Integer; virtual;
|
||||
function WriteInterfaceDefs(aList: TIDLDefinitionList): Integer; virtual;
|
||||
function WriteMethodDefs(aList: TIDLDefinitionList): Integer; virtual;
|
||||
function WriteUtilityMethods(Intf: TIDLInterfaceDefinition): Integer; virtual;
|
||||
function WriteTypeDefs(aList: TIDLDefinitionList): Integer; virtual;
|
||||
function WriteEnumDefs(aList: TIDLDefinitionList): Integer; virtual;
|
||||
function WriteConsts(aList: TIDLDefinitionList): Integer; virtual;
|
||||
@ -460,6 +461,13 @@ begin
|
||||
Inc(Result);
|
||||
end;
|
||||
|
||||
function TBaseWebIDLToPas.WriteUtilityMethods(Intf: TIDLInterfaceDefinition
|
||||
): Integer;
|
||||
begin
|
||||
Result:=0;
|
||||
if Intf=nil then ;
|
||||
end;
|
||||
|
||||
function TBaseWebIDLToPas.AddSequenceDef(ST: TIDLSequenceTypeDefDefinition
|
||||
): Boolean;
|
||||
|
||||
@ -547,7 +555,7 @@ end;
|
||||
function TBaseWebIDLToPas.WriteInterfaceDef(Intf: TIDLInterfaceDefinition): Boolean;
|
||||
|
||||
Var
|
||||
aClassName,aParentName: String;
|
||||
aClassName: String;
|
||||
Decl: String;
|
||||
ML: TIDLDefinitionList;
|
||||
|
||||
@ -588,6 +596,7 @@ begin
|
||||
Indent;
|
||||
WritePlainFields(ML);
|
||||
WriteMethodDefs(ML);
|
||||
WriteUtilityMethods(Intf);
|
||||
WriteProperties(ML);
|
||||
Undent;
|
||||
AddLn('end;');
|
||||
|
@ -69,6 +69,7 @@ type
|
||||
procedure GetOptions(L: TStrings; Full: boolean); override;
|
||||
function GetTypeName(const aTypeName: String; ForTypeDef: Boolean=False
|
||||
): String; override;
|
||||
function GetPasIntfName(Intf: TIDLDefinition): string;
|
||||
function GetInterfaceDefHead(Intf: TIDLInterfaceDefinition): String;
|
||||
override;
|
||||
function WriteOtherImplicitTypes(Intf: TIDLInterfaceDefinition; aMemberList: TIDLDefinitionList): Integer;
|
||||
@ -77,6 +78,8 @@ type
|
||||
function WritePrivateGetters(aList: TIDLDefinitionList): Integer; override;
|
||||
function WritePrivateSetters(aList: TIDLDefinitionList): Integer; override;
|
||||
function WriteProperties(aList: TIDLDefinitionList): Integer; override;
|
||||
function WriteUtilityMethods(Intf: TIDLInterfaceDefinition): Integer;
|
||||
override;
|
||||
// Definitions. Return true if a definition was written.
|
||||
function WritePrivateGetter(Attr: TIDLAttributeDefinition): boolean; virtual;
|
||||
function WritePrivateSetter(Attr: TIDLAttributeDefinition): boolean; virtual;
|
||||
@ -205,6 +208,11 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TWebIDLToPasWasmJob.GetPasIntfName(Intf: TIDLDefinition): string;
|
||||
begin
|
||||
Result:=ClassToPasIntfName(GetName(Intf));
|
||||
end;
|
||||
|
||||
function TWebIDLToPasWasmJob.GetInterfaceDefHead(Intf: TIDLInterfaceDefinition
|
||||
): String;
|
||||
var
|
||||
@ -217,7 +225,7 @@ begin
|
||||
aParentName:=GetTypeName(Intf.ParentName);
|
||||
if aParentName<>'' then
|
||||
Result:=Result+aParentName;
|
||||
aPasIntfName:=ClassToPasIntfName(GetName(Intf));
|
||||
aPasIntfName:=GetPasIntfName(Intf);
|
||||
Result:=Result+','+aPasIntfName+')';
|
||||
end;
|
||||
|
||||
@ -229,7 +237,7 @@ begin
|
||||
Result:=1;
|
||||
|
||||
// Pascal interface and ancestor
|
||||
aPasIntfName:=ClassToPasIntfName(GetName(Intf));
|
||||
aPasIntfName:=GetPasIntfName(Intf);
|
||||
|
||||
Decl:=aPasIntfName+' = interface';
|
||||
if Assigned(Intf.ParentInterface) then
|
||||
@ -243,13 +251,22 @@ begin
|
||||
end;
|
||||
AddLn(Decl);
|
||||
|
||||
|
||||
Indent;
|
||||
|
||||
// GUID
|
||||
AddLn('['''+ComputeGUID(Decl,aMemberList)+''']');
|
||||
|
||||
// private members
|
||||
WritePrivateGetters(aMemberList);
|
||||
WritePrivateSetters(aMemberList);
|
||||
|
||||
// type cast function Cast:
|
||||
AddLn('Function Cast(Intf: IJSObject): '+aPasIntfName+';');
|
||||
|
||||
// public members
|
||||
WriteMethodDefs(aMemberList);
|
||||
WriteProperties(aMemberList);
|
||||
|
||||
Undent;
|
||||
AddLn('end;');
|
||||
AddLn('');
|
||||
@ -291,6 +308,22 @@ begin
|
||||
inc(Result);
|
||||
end;
|
||||
|
||||
function TWebIDLToPasWasmJob.WriteUtilityMethods(Intf: TIDLInterfaceDefinition
|
||||
): Integer;
|
||||
var
|
||||
aClassName, aPasIntfName, Code: String;
|
||||
begin
|
||||
Result:=0;
|
||||
aClassName:=GetName(Intf);
|
||||
aPasIntfName:=GetPasIntfName(Intf);
|
||||
AddLn('Function Cast(Intf: IJSObject): '+aPasIntfName+';');
|
||||
Code:='Function '+aClassName+'.Cast(Intf: IJSObject): '+aPasIntfName+';'+sLineBreak;
|
||||
Code:=Code+'begin'+sLineBreak;
|
||||
Code:=Code+' Result:='+aClassName+'.CreateCast(Intf);'+sLineBreak;
|
||||
Code:=Code+'end;'+sLineBreak;
|
||||
IncludeImplementationCode.Add(Code);
|
||||
end;
|
||||
|
||||
function TWebIDLToPasWasmJob.WritePrivateGetter(Attr: TIDLAttributeDefinition
|
||||
): boolean;
|
||||
var
|
||||
|
Loading…
Reference in New Issue
Block a user