|
@@ -23,7 +23,7 @@ uses
|
|
|
|
|
|
Type
|
|
Type
|
|
|
|
|
|
- { TWebIDLToPas }
|
|
|
|
|
|
+ { TBaseWebIDLToPas }
|
|
|
|
|
|
{ TPasData }
|
|
{ TPasData }
|
|
|
|
|
|
@@ -35,10 +35,16 @@ Type
|
|
Property PasName : String read FPasName;
|
|
Property PasName : String read FPasName;
|
|
end;
|
|
end;
|
|
|
|
|
|
- TConversionOption = (coDictionaryAsClass,coUseNativeTypeAliases,coExternalConst,coExpandUnionTypeArgs,coaddOptionsToheader);
|
|
|
|
|
|
+ TConversionOption = (
|
|
|
|
+ coDictionaryAsClass,
|
|
|
|
+ coUseNativeTypeAliases,
|
|
|
|
+ coExternalConst,
|
|
|
|
+ coExpandUnionTypeArgs,
|
|
|
|
+ coAddOptionsToHeader
|
|
|
|
+ );
|
|
TConversionOptions = Set of TConversionOption;
|
|
TConversionOptions = Set of TConversionOption;
|
|
|
|
|
|
- TWebIDLToPas = Class(TPascalCodeGenerator)
|
|
|
|
|
|
+ TBaseWebIDLToPas = Class(TPascalCodeGenerator)
|
|
private
|
|
private
|
|
FClassPrefix: String;
|
|
FClassPrefix: String;
|
|
FClassSuffix: String;
|
|
FClassSuffix: String;
|
|
@@ -127,10 +133,11 @@ Type
|
|
procedure WriteIncludeInterfaceCode; virtual;
|
|
procedure WriteIncludeInterfaceCode; virtual;
|
|
Property Context : TWebIDLContext Read FContext;
|
|
Property Context : TWebIDLContext Read FContext;
|
|
Public
|
|
Public
|
|
- Constructor Create(Aowner : TComponent); override;
|
|
|
|
- Destructor Destroy; override;
|
|
|
|
- Procedure Execute;
|
|
|
|
- Published
|
|
|
|
|
|
+ constructor Create(Aowner : TComponent); override;
|
|
|
|
+ destructor Destroy; override;
|
|
|
|
+ procedure Execute; virtual;
|
|
|
|
+ procedure WriteOptions; virtual;
|
|
|
|
+ Public
|
|
Property InputFileName : String Read FInputFileName Write FInputFileName;
|
|
Property InputFileName : String Read FInputFileName Write FInputFileName;
|
|
Property OutputFileName : String Read FOutputFileName Write FOutputFileName;
|
|
Property OutputFileName : String Read FOutputFileName Write FOutputFileName;
|
|
Property Verbose : Boolean Read FVerbose Write FVerbose;
|
|
Property Verbose : Boolean Read FVerbose Write FVerbose;
|
|
@@ -145,6 +152,42 @@ Type
|
|
Property DictionaryClassParent : String Read FDictionaryClassParent Write FDictionaryClassParent;
|
|
Property DictionaryClassParent : String Read FDictionaryClassParent Write FDictionaryClassParent;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+ { TWebIDLToPas2js }
|
|
|
|
+
|
|
|
|
+ TWebIDLToPas2js = class(TBaseWebIDLToPas)
|
|
|
|
+ Published
|
|
|
|
+ Property InputFileName;
|
|
|
|
+ Property OutputFileName;
|
|
|
|
+ Property Verbose;
|
|
|
|
+ Property FieldPrefix;
|
|
|
|
+ Property ClassPrefix;
|
|
|
|
+ Property ClassSuffix;
|
|
|
|
+ Property Options;
|
|
|
|
+ Property WebIDLVersion;
|
|
|
|
+ Property TypeAliases;
|
|
|
|
+ Property IncludeInterfaceCode;
|
|
|
|
+ Property IncludeImplementationCode;
|
|
|
|
+ Property DictionaryClassParent;
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ { TWebIDLToPasWasmJob }
|
|
|
|
+
|
|
|
|
+ TWebIDLToPasWasmJob = class(TBaseWebIDLToPas)
|
|
|
|
+ Published
|
|
|
|
+ Property InputFileName;
|
|
|
|
+ Property OutputFileName;
|
|
|
|
+ Property Verbose;
|
|
|
|
+ Property FieldPrefix;
|
|
|
|
+ Property ClassPrefix;
|
|
|
|
+ Property ClassSuffix;
|
|
|
|
+ Property Options;
|
|
|
|
+ Property WebIDLVersion;
|
|
|
|
+ Property TypeAliases;
|
|
|
|
+ Property IncludeInterfaceCode;
|
|
|
|
+ Property IncludeImplementationCode;
|
|
|
|
+ Property DictionaryClassParent;
|
|
|
|
+ end;
|
|
|
|
+
|
|
implementation
|
|
implementation
|
|
|
|
|
|
uses typinfo;
|
|
uses typinfo;
|
|
@@ -156,27 +199,27 @@ begin
|
|
FPasName:=APasName;
|
|
FPasName:=APasName;
|
|
end;
|
|
end;
|
|
|
|
|
|
-{ TWebIDLToPas }
|
|
|
|
|
|
+{ TBaseWebIDLToPas }
|
|
|
|
|
|
-function TWebIDLToPas.CreateContext: TWebIDLContext;
|
|
|
|
|
|
+function TBaseWebIDLToPas.CreateContext: TWebIDLContext;
|
|
begin
|
|
begin
|
|
Result:=TWebIDLContext.Create(True);
|
|
Result:=TWebIDLContext.Create(True);
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.CreateScanner(S : TStream) : TWebIDLScanner;
|
|
|
|
|
|
+function TBaseWebIDLToPas.CreateScanner(S : TStream) : TWebIDLScanner;
|
|
|
|
|
|
begin
|
|
begin
|
|
Result:=TWebIDLScanner.Create(S);
|
|
Result:=TWebIDLScanner.Create(S);
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.CreateParser(aContext : TWebIDLContext;S : TWebIDLScanner) : TWebIDLParser;
|
|
|
|
|
|
+function TBaseWebIDLToPas.CreateParser(aContext : TWebIDLContext;S : TWebIDLScanner) : TWebIDLParser;
|
|
|
|
|
|
begin
|
|
begin
|
|
Result:=TWebIDLParser.Create(aContext,S);
|
|
Result:=TWebIDLParser.Create(aContext,S);
|
|
Result.Version:=FWebIDLVersion;
|
|
Result.Version:=FWebIDLVersion;
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TWebIDLToPas.Parse;
|
|
|
|
|
|
+procedure TBaseWebIDLToPas.Parse;
|
|
|
|
|
|
Var
|
|
Var
|
|
F : TFileStream;
|
|
F : TFileStream;
|
|
@@ -197,7 +240,7 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.GetName(ADef: TIDLDefinition): String;
|
|
|
|
|
|
+function TBaseWebIDLToPas.GetName(ADef: TIDLDefinition): String;
|
|
|
|
|
|
begin
|
|
begin
|
|
If Assigned(ADef) and (TObject(ADef.Data) is TPasData) then
|
|
If Assigned(ADef) and (TObject(ADef.Data) is TPasData) then
|
|
@@ -206,7 +249,7 @@ begin
|
|
Result:=ADef.Name;
|
|
Result:=ADef.Name;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.HaveConsts(aList: TIDLDefinitionList): Boolean;
|
|
|
|
|
|
+function TBaseWebIDLToPas.HaveConsts(aList: TIDLDefinitionList): Boolean;
|
|
|
|
|
|
Var
|
|
Var
|
|
D : TIDLDefinition;
|
|
D : TIDLDefinition;
|
|
@@ -218,7 +261,7 @@ begin
|
|
Exit(True);
|
|
Exit(True);
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.WritePrivateReadOnlyFields(aList: TIDLDefinitionList): Integer;
|
|
|
|
|
|
+function TBaseWebIDLToPas.WritePrivateReadOnlyFields(aList: TIDLDefinitionList): Integer;
|
|
|
|
|
|
Var
|
|
Var
|
|
D : TIDLDefinition;
|
|
D : TIDLDefinition;
|
|
@@ -233,7 +276,7 @@ begin
|
|
Inc(Result);
|
|
Inc(Result);
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.WriteProperties(aList: TIDLDefinitionList): Integer;
|
|
|
|
|
|
+function TBaseWebIDLToPas.WriteProperties(aList: TIDLDefinitionList): Integer;
|
|
|
|
|
|
Var
|
|
Var
|
|
D : TIDLDefinition;
|
|
D : TIDLDefinition;
|
|
@@ -248,7 +291,7 @@ begin
|
|
Inc(Result);
|
|
Inc(Result);
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.WriteConst(aConst: TIDLConstDefinition): Boolean;
|
|
|
|
|
|
+function TBaseWebIDLToPas.WriteConst(aConst: TIDLConstDefinition): Boolean;
|
|
|
|
|
|
Const
|
|
Const
|
|
ConstTypes : Array[TConstType] of String =
|
|
ConstTypes : Array[TConstType] of String =
|
|
@@ -273,7 +316,7 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.WriteConsts(aList: TIDLDefinitionList): Integer;
|
|
|
|
|
|
+function TBaseWebIDLToPas.WriteConsts(aList: TIDLDefinitionList): Integer;
|
|
|
|
|
|
Var
|
|
Var
|
|
D : TIDLDefinition;
|
|
D : TIDLDefinition;
|
|
@@ -289,7 +332,7 @@ begin
|
|
Undent;
|
|
Undent;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.WritePlainFields(aList: TIDLDefinitionList): Integer;
|
|
|
|
|
|
+function TBaseWebIDLToPas.WritePlainFields(aList: TIDLDefinitionList): Integer;
|
|
|
|
|
|
Var
|
|
Var
|
|
D : TIDLDefinition;
|
|
D : TIDLDefinition;
|
|
@@ -307,7 +350,7 @@ begin
|
|
Undent;
|
|
Undent;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.WriteDictionaryField(
|
|
|
|
|
|
+function TBaseWebIDLToPas.WriteDictionaryField(
|
|
aField: TIDLDictionaryMemberDefinition): Boolean;
|
|
aField: TIDLDictionaryMemberDefinition): Boolean;
|
|
|
|
|
|
Var
|
|
Var
|
|
@@ -327,7 +370,7 @@ begin
|
|
AddLn(Def);
|
|
AddLn(Def);
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.WriteDictionaryFields(aList: TIDLDefinitionList): Integer;
|
|
|
|
|
|
+function TBaseWebIDLToPas.WriteDictionaryFields(aList: TIDLDefinitionList): Integer;
|
|
|
|
|
|
Var
|
|
Var
|
|
D : TIDLDefinition;
|
|
D : TIDLDefinition;
|
|
@@ -343,7 +386,7 @@ begin
|
|
Undent;
|
|
Undent;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.WriteMethodDefs(aList: TIDLDefinitionList): Integer;
|
|
|
|
|
|
+function TBaseWebIDLToPas.WriteMethodDefs(aList: TIDLDefinitionList): Integer;
|
|
|
|
|
|
Var
|
|
Var
|
|
D : TIDLDefinition;
|
|
D : TIDLDefinition;
|
|
@@ -358,7 +401,7 @@ begin
|
|
Inc(Result);
|
|
Inc(Result);
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.AddSequenceDef(ST: TIDLSequenceTypeDefDefinition
|
|
|
|
|
|
+function TBaseWebIDLToPas.AddSequenceDef(ST: TIDLSequenceTypeDefDefinition
|
|
): Boolean;
|
|
): Boolean;
|
|
|
|
|
|
var
|
|
var
|
|
@@ -375,7 +418,7 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.WriteFunctionImplicitTypes(aList: TIDLDefinitionList): Integer;
|
|
|
|
|
|
+function TBaseWebIDLToPas.WriteFunctionImplicitTypes(aList: TIDLDefinitionList): Integer;
|
|
|
|
|
|
Var
|
|
Var
|
|
D,D2,D3 : TIDLDefinition;
|
|
D,D2,D3 : TIDLDefinition;
|
|
@@ -412,7 +455,7 @@ begin
|
|
AddLn('');
|
|
AddLn('');
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.WriteAttributeImplicitTypes(aList: TIDLDefinitionList
|
|
|
|
|
|
+function TBaseWebIDLToPas.WriteAttributeImplicitTypes(aList: TIDLDefinitionList
|
|
): Integer;
|
|
): Integer;
|
|
Var
|
|
Var
|
|
D : TIDLDefinition;
|
|
D : TIDLDefinition;
|
|
@@ -427,7 +470,7 @@ begin
|
|
Inc(Result);
|
|
Inc(Result);
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.WriteDictionaryMemberImplicitTypes(
|
|
|
|
|
|
+function TBaseWebIDLToPas.WriteDictionaryMemberImplicitTypes(
|
|
aList: TIDLDefinitionList): Integer;
|
|
aList: TIDLDefinitionList): Integer;
|
|
|
|
|
|
Var
|
|
Var
|
|
@@ -443,7 +486,7 @@ begin
|
|
Inc(Result);
|
|
Inc(Result);
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TWebIDLToPas.EnsureUniqueNames(ML : TIDLDefinitionList);
|
|
|
|
|
|
+procedure TBaseWebIDLToPas.EnsureUniqueNames(ML : TIDLDefinitionList);
|
|
|
|
|
|
Var
|
|
Var
|
|
L : TFPObjectHashTable;
|
|
L : TFPObjectHashTable;
|
|
@@ -506,7 +549,7 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.WriteInterfaceDef(Intf: TIDLInterfaceDefinition): Boolean;
|
|
|
|
|
|
+function TBaseWebIDLToPas.WriteInterfaceDef(Intf: TIDLInterfaceDefinition): Boolean;
|
|
|
|
|
|
Var
|
|
Var
|
|
CN,PN : String;
|
|
CN,PN : String;
|
|
@@ -556,7 +599,7 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.WriteDictionaryDef(aDict: TIDLDictionaryDefinition
|
|
|
|
|
|
+function TBaseWebIDLToPas.WriteDictionaryDef(aDict: TIDLDictionaryDefinition
|
|
): Boolean;
|
|
): Boolean;
|
|
|
|
|
|
Var
|
|
Var
|
|
@@ -591,7 +634,7 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-constructor TWebIDLToPas.Create(Aowner: TComponent);
|
|
|
|
|
|
+constructor TBaseWebIDLToPas.Create(Aowner: TComponent);
|
|
begin
|
|
begin
|
|
inherited Create(Aowner);
|
|
inherited Create(Aowner);
|
|
WebIDLVersion:=v2;
|
|
WebIDLVersion:=v2;
|
|
@@ -607,7 +650,7 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
-destructor TWebIDLToPas.Destroy;
|
|
|
|
|
|
+destructor TBaseWebIDLToPas.Destroy;
|
|
begin
|
|
begin
|
|
FreeAndNil(FIncludeInterfaceCode);
|
|
FreeAndNil(FIncludeInterfaceCode);
|
|
FreeAndNil(FIncludeImplementationCode);
|
|
FreeAndNil(FIncludeImplementationCode);
|
|
@@ -617,7 +660,7 @@ begin
|
|
inherited Destroy;
|
|
inherited Destroy;
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TWebIDLToPas.WriteImplementation;
|
|
|
|
|
|
+procedure TBaseWebIDLToPas.WriteImplementation;
|
|
|
|
|
|
Var
|
|
Var
|
|
S : String;
|
|
S : String;
|
|
@@ -629,7 +672,7 @@ begin
|
|
Addln('');
|
|
Addln('');
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.GetTypeName(aTypeDef : TIDLTypeDefDefinition; ForTypeDef : Boolean = False): String;
|
|
|
|
|
|
+function TBaseWebIDLToPas.GetTypeName(aTypeDef : TIDLTypeDefDefinition; ForTypeDef : Boolean = False): String;
|
|
|
|
|
|
begin
|
|
begin
|
|
if ATypeDef is TIDLSequenceTypeDefDefinition then
|
|
if ATypeDef is TIDLSequenceTypeDefDefinition then
|
|
@@ -646,7 +689,7 @@ begin
|
|
Result:=GetTypeName(aTypeDef.TypeName,ForTypeDef);
|
|
Result:=GetTypeName(aTypeDef.TypeName,ForTypeDef);
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.GetTypeName(const aTypeName: String; ForTypeDef: Boolean
|
|
|
|
|
|
+function TBaseWebIDLToPas.GetTypeName(const aTypeName: String; ForTypeDef: Boolean
|
|
): String;
|
|
): String;
|
|
|
|
|
|
|
|
|
|
@@ -710,7 +753,7 @@ begin
|
|
Result:=TN;
|
|
Result:=TN;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.WritePrivateReadOnlyField(aAttr: TIDLAttributeDefinition
|
|
|
|
|
|
+function TBaseWebIDLToPas.WritePrivateReadOnlyField(aAttr: TIDLAttributeDefinition
|
|
): Boolean;
|
|
): Boolean;
|
|
|
|
|
|
begin
|
|
begin
|
|
@@ -718,7 +761,7 @@ begin
|
|
Result:=true;
|
|
Result:=true;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.WriteField(aAttr: TIDLAttributeDefinition): Boolean;
|
|
|
|
|
|
+function TBaseWebIDLToPas.WriteField(aAttr: TIDLAttributeDefinition): Boolean;
|
|
|
|
|
|
Var
|
|
Var
|
|
Def,TN,N : String;
|
|
Def,TN,N : String;
|
|
@@ -742,7 +785,7 @@ begin
|
|
AddLn(Def);
|
|
AddLn(Def);
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.WriteReadonlyProperty(aAttr: TIDLAttributeDefinition
|
|
|
|
|
|
+function TBaseWebIDLToPas.WriteReadonlyProperty(aAttr: TIDLAttributeDefinition
|
|
): Boolean;
|
|
): Boolean;
|
|
|
|
|
|
Var
|
|
Var
|
|
@@ -759,7 +802,7 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
-function TWebIDLToPas.WriteForwardClassDef(D: TIDLStructuredDefinition): Boolean;
|
|
|
|
|
|
+function TBaseWebIDLToPas.WriteForwardClassDef(D: TIDLStructuredDefinition): Boolean;
|
|
|
|
|
|
begin
|
|
begin
|
|
Result:=not D.IsPartial;
|
|
Result:=not D.IsPartial;
|
|
@@ -767,7 +810,7 @@ begin
|
|
AddLn('%s = Class;',[GetName(D)]);
|
|
AddLn('%s = Class;',[GetName(D)]);
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.WriteForwardClassDefs(aList: TIDLDefinitionList): Integer;
|
|
|
|
|
|
+function TBaseWebIDLToPas.WriteForwardClassDefs(aList: TIDLDefinitionList): Integer;
|
|
|
|
|
|
Var
|
|
Var
|
|
D : TIDLDefinition;
|
|
D : TIDLDefinition;
|
|
@@ -786,14 +829,14 @@ begin
|
|
Inc(Result);
|
|
Inc(Result);
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TWebIDLToPas.WriteSequenceDef(aDef : TIDLSequenceTypeDefDefinition);
|
|
|
|
|
|
+procedure TBaseWebIDLToPas.WriteSequenceDef(aDef : TIDLSequenceTypeDefDefinition);
|
|
|
|
|
|
begin
|
|
begin
|
|
Addln('%s = array of %s;',[GetName(aDef),GetTypeName(aDef.ElementType)])
|
|
Addln('%s = array of %s;',[GetName(aDef),GetTypeName(aDef.ElementType)])
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
-procedure TWebIDLToPas.WriteUnionDef(aDef : TIDLUnionTypeDefDefinition);
|
|
|
|
|
|
+procedure TBaseWebIDLToPas.WriteUnionDef(aDef : TIDLUnionTypeDefDefinition);
|
|
|
|
|
|
Var
|
|
Var
|
|
S : UTF8String;
|
|
S : UTF8String;
|
|
@@ -811,13 +854,13 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
-procedure TWebIDLToPas.WritePromiseDef(aDef : TIDLPromiseTypeDefDefinition);
|
|
|
|
|
|
+procedure TBaseWebIDLToPas.WritePromiseDef(aDef : TIDLPromiseTypeDefDefinition);
|
|
|
|
|
|
begin
|
|
begin
|
|
AddLn('%s = TJSPromise;',[GetName(aDef)]);
|
|
AddLn('%s = TJSPromise;',[GetName(aDef)]);
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TWebIDLToPas.WriteAliasTypeDef(aDef : TIDLTypeDefDefinition);
|
|
|
|
|
|
+procedure TBaseWebIDLToPas.WriteAliasTypeDef(aDef : TIDLTypeDefDefinition);
|
|
|
|
|
|
Var
|
|
Var
|
|
TN : String;
|
|
TN : String;
|
|
@@ -827,7 +870,7 @@ begin
|
|
AddLn('%s = %s;',[GetName(aDef),TN]);
|
|
AddLn('%s = %s;',[GetName(aDef),TN]);
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.WriteTypeDef(aDef: TIDLTypeDefDefinition): Boolean;
|
|
|
|
|
|
+function TBaseWebIDLToPas.WriteTypeDef(aDef: TIDLTypeDefDefinition): Boolean;
|
|
|
|
|
|
begin
|
|
begin
|
|
Result:=True;
|
|
Result:=True;
|
|
@@ -843,7 +886,7 @@ begin
|
|
WriteAliasTypeDef(aDef);
|
|
WriteAliasTypeDef(aDef);
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.WriteRecordDef(aDef: TIDLRecordDefinition): Boolean;
|
|
|
|
|
|
+function TBaseWebIDLToPas.WriteRecordDef(aDef: TIDLRecordDefinition): Boolean;
|
|
|
|
|
|
Var
|
|
Var
|
|
KT,VT : String;
|
|
KT,VT : String;
|
|
@@ -865,7 +908,7 @@ begin
|
|
AddLn('end;');
|
|
AddLn('end;');
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.WriteTypeDefs(aList: TIDLDefinitionList): Integer;
|
|
|
|
|
|
+function TBaseWebIDLToPas.WriteTypeDefs(aList: TIDLDefinitionList): Integer;
|
|
|
|
|
|
Var
|
|
Var
|
|
D : TIDLDefinition;
|
|
D : TIDLDefinition;
|
|
@@ -880,14 +923,14 @@ begin
|
|
Inc(Result);
|
|
Inc(Result);
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.WriteEnumDef(aDef: TIDLEnumDefinition): Boolean;
|
|
|
|
|
|
+function TBaseWebIDLToPas.WriteEnumDef(aDef: TIDLEnumDefinition): Boolean;
|
|
|
|
|
|
begin
|
|
begin
|
|
Result:=True;
|
|
Result:=True;
|
|
AddLn('%s = String;',[GetName(aDef)]);
|
|
AddLn('%s = String;',[GetName(aDef)]);
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.WriteEnumDefs(aList: TIDLDefinitionList): Integer;
|
|
|
|
|
|
+function TBaseWebIDLToPas.WriteEnumDefs(aList: TIDLDefinitionList): Integer;
|
|
|
|
|
|
Var
|
|
Var
|
|
D : TIDLDefinition;
|
|
D : TIDLDefinition;
|
|
@@ -902,7 +945,7 @@ begin
|
|
Inc(Result);
|
|
Inc(Result);
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.GetArguments(aList: TIDLDefinitionList;
|
|
|
|
|
|
+function TBaseWebIDLToPas.GetArguments(aList: TIDLDefinitionList;
|
|
ForceBrackets: Boolean): String;
|
|
ForceBrackets: Boolean): String;
|
|
|
|
|
|
Var
|
|
Var
|
|
@@ -929,7 +972,7 @@ Type
|
|
// Additional arguments can never be added to a partial list...
|
|
// Additional arguments can never be added to a partial list...
|
|
TIDLPartialDefinitionList = Class(TIDLDefinitionList);
|
|
TIDLPartialDefinitionList = Class(TIDLDefinitionList);
|
|
|
|
|
|
-function TWebIDLToPas.CloneNonPartialArgumentList(aList: TFPObjectlist;
|
|
|
|
|
|
+function TBaseWebIDLToPas.CloneNonPartialArgumentList(aList: TFPObjectlist;
|
|
ADest: TFPObjectlist; AsPartial: Boolean): integer;
|
|
ADest: TFPObjectlist; AsPartial: Boolean): integer;
|
|
|
|
|
|
Var
|
|
Var
|
|
@@ -964,7 +1007,7 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TWebIDLToPas.AddArgumentToOverloads(aList: TFPObjectlist; AName,ATypeName : String);
|
|
|
|
|
|
+procedure TBaseWebIDLToPas.AddArgumentToOverloads(aList: TFPObjectlist; AName,ATypeName : String);
|
|
|
|
|
|
Var
|
|
Var
|
|
I : Integer;
|
|
I : Integer;
|
|
@@ -986,7 +1029,7 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TWebIDLToPas.AddArgumentToOverloads(aList: TFPObjectlist; adef: TIDLArgumentDefinition);
|
|
|
|
|
|
+procedure TBaseWebIDLToPas.AddArgumentToOverloads(aList: TFPObjectlist; adef: TIDLArgumentDefinition);
|
|
|
|
|
|
Var
|
|
Var
|
|
I : Integer;
|
|
I : Integer;
|
|
@@ -1009,7 +1052,7 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TWebIDLToPas.AddUnionOverloads(aList: TFPObjectlist; AName : String; UT : TIDLUnionTypeDefDefinition);
|
|
|
|
|
|
+procedure TBaseWebIDLToPas.AddUnionOverloads(aList: TFPObjectlist; AName : String; UT : TIDLUnionTypeDefDefinition);
|
|
|
|
|
|
Var
|
|
Var
|
|
L,L2 : TFPObjectList;
|
|
L,L2 : TFPObjectList;
|
|
@@ -1056,7 +1099,7 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.CheckUnionTypeDefinition(D: TIDLDefinition
|
|
|
|
|
|
+function TBaseWebIDLToPas.CheckUnionTypeDefinition(D: TIDLDefinition
|
|
): TIDLUnionTypeDefDefinition;
|
|
): TIDLUnionTypeDefDefinition;
|
|
|
|
|
|
begin
|
|
begin
|
|
@@ -1071,7 +1114,7 @@ begin
|
|
end
|
|
end
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TWebIDLToPas.AddOverloads(aList: TFPObjectlist;
|
|
|
|
|
|
+procedure TBaseWebIDLToPas.AddOverloads(aList: TFPObjectlist;
|
|
adef: TIDLFunctionDefinition; aIdx: Integer);
|
|
adef: TIDLFunctionDefinition; aIdx: Integer);
|
|
|
|
|
|
Var
|
|
Var
|
|
@@ -1097,7 +1140,7 @@ begin
|
|
AddOverloads(aList,aDef,aIdx+1);
|
|
AddOverloads(aList,aDef,aIdx+1);
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.GetOverloads(aDef: TIDLFunctionDefinition): TFPObjectlist;
|
|
|
|
|
|
+function TBaseWebIDLToPas.GetOverloads(aDef: TIDLFunctionDefinition): TFPObjectlist;
|
|
|
|
|
|
begin
|
|
begin
|
|
Result:=TFPObjectList.Create;
|
|
Result:=TFPObjectList.Create;
|
|
@@ -1110,7 +1153,7 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.WriteFunctionTypeDefinition(aDef: TIDLFunctionDefinition): Boolean;
|
|
|
|
|
|
+function TBaseWebIDLToPas.WriteFunctionTypeDefinition(aDef: TIDLFunctionDefinition): Boolean;
|
|
|
|
|
|
Var
|
|
Var
|
|
FN,RT,Args : String;
|
|
FN,RT,Args : String;
|
|
@@ -1128,7 +1171,7 @@ begin
|
|
AddLn('%s = function %s: %s;',[FN,Args,RT])
|
|
AddLn('%s = function %s: %s;',[FN,Args,RT])
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.WriteFunctionDefinition(aDef: TIDLFunctionDefinition): Boolean;
|
|
|
|
|
|
+function TBaseWebIDLToPas.WriteFunctionDefinition(aDef: TIDLFunctionDefinition): Boolean;
|
|
|
|
|
|
Var
|
|
Var
|
|
FN,RT,Suff,Args : String;
|
|
FN,RT,Suff,Args : String;
|
|
@@ -1173,7 +1216,7 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.WriteCallBackDefs(aList: TIDLDefinitionList): Integer;
|
|
|
|
|
|
+function TBaseWebIDLToPas.WriteCallBackDefs(aList: TIDLDefinitionList): Integer;
|
|
|
|
|
|
Var
|
|
Var
|
|
D : TIDLDefinition;
|
|
D : TIDLDefinition;
|
|
@@ -1189,7 +1232,7 @@ begin
|
|
Inc(Result);
|
|
Inc(Result);
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.WriteDictionaryDefs(aList: TIDLDefinitionList): Integer;
|
|
|
|
|
|
+function TBaseWebIDLToPas.WriteDictionaryDefs(aList: TIDLDefinitionList): Integer;
|
|
|
|
|
|
Var
|
|
Var
|
|
D : TIDLDefinition;
|
|
D : TIDLDefinition;
|
|
@@ -1205,7 +1248,7 @@ begin
|
|
Inc(Result);
|
|
Inc(Result);
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.WriteInterfaceDefs(aList: TIDLDefinitionList): Integer;
|
|
|
|
|
|
+function TBaseWebIDLToPas.WriteInterfaceDefs(aList: TIDLDefinitionList): Integer;
|
|
|
|
|
|
Var
|
|
Var
|
|
D : TIDLDefinition;
|
|
D : TIDLDefinition;
|
|
@@ -1221,7 +1264,7 @@ begin
|
|
Inc(Result);
|
|
Inc(Result);
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TWebIDLToPas.Getoptions(L : TStrings);
|
|
|
|
|
|
+procedure TBaseWebIDLToPas.Getoptions(L : TStrings);
|
|
|
|
|
|
Var
|
|
Var
|
|
S : String;
|
|
S : String;
|
|
@@ -1252,7 +1295,7 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TWebIDLToPas.AddOptionsToHeader;
|
|
|
|
|
|
+procedure TBaseWebIDLToPas.AddOptionsToHeader;
|
|
|
|
|
|
Var
|
|
Var
|
|
L : TStrings;
|
|
L : TStrings;
|
|
@@ -1266,7 +1309,7 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TWebIDLToPas.WriteIncludeInterfaceCode;
|
|
|
|
|
|
+procedure TBaseWebIDLToPas.WriteIncludeInterfaceCode;
|
|
|
|
|
|
Var
|
|
Var
|
|
S : String;
|
|
S : String;
|
|
@@ -1276,12 +1319,12 @@ begin
|
|
Addln(S);
|
|
Addln(S);
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TWebIDLToPas.WritePascal;
|
|
|
|
|
|
+procedure TBaseWebIDLToPas.WritePascal;
|
|
|
|
|
|
begin
|
|
begin
|
|
CreateUnitClause;
|
|
CreateUnitClause;
|
|
CreateHeader;
|
|
CreateHeader;
|
|
- if coaddOptionsToheader in Options then
|
|
|
|
|
|
+ if coAddOptionsToHeader in Options then
|
|
AddOptionsToHeader;
|
|
AddOptionsToHeader;
|
|
EnsureSection(csType);
|
|
EnsureSection(csType);
|
|
Indent;
|
|
Indent;
|
|
@@ -1300,20 +1343,20 @@ begin
|
|
Source.SaveToFile(OutputFileName);
|
|
Source.SaveToFile(OutputFileName);
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.BaseUnits: String;
|
|
|
|
|
|
+function TBaseWebIDLToPas.BaseUnits: String;
|
|
|
|
|
|
begin
|
|
begin
|
|
Result:='SysUtils, JS'
|
|
Result:='SysUtils, JS'
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.CreatePasName(aName: String): TPasData;
|
|
|
|
|
|
+function TBaseWebIDLToPas.CreatePasName(aName: String): TPasData;
|
|
|
|
|
|
begin
|
|
begin
|
|
Result:=TPasData.Create(EscapeKeyWord(aName));
|
|
Result:=TPasData.Create(EscapeKeyWord(aName));
|
|
FPasNameList.Add(Result);
|
|
FPasNameList.Add(Result);
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TWebIDLToPas.AllocatePasName(D: TIDLDefinition; ParentName: String): TPasData;
|
|
|
|
|
|
+function TBaseWebIDLToPas.AllocatePasName(D: TIDLDefinition; ParentName: String): TPasData;
|
|
|
|
|
|
Var
|
|
Var
|
|
CN : String;
|
|
CN : String;
|
|
@@ -1350,25 +1393,25 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TWebIDLToPas.SetTypeAliases(AValue: TStrings);
|
|
|
|
|
|
+procedure TBaseWebIDLToPas.SetTypeAliases(AValue: TStrings);
|
|
begin
|
|
begin
|
|
if FTypeAliases=AValue then Exit;
|
|
if FTypeAliases=AValue then Exit;
|
|
FTypeAliases.Assign(AValue);
|
|
FTypeAliases.Assign(AValue);
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TWebIDLToPas.SetIncludeInterfaceCode(AValue: TStrings);
|
|
|
|
|
|
+procedure TBaseWebIDLToPas.SetIncludeInterfaceCode(AValue: TStrings);
|
|
begin
|
|
begin
|
|
if FIncludeInterfaceCode=AValue then Exit;
|
|
if FIncludeInterfaceCode=AValue then Exit;
|
|
FIncludeInterfaceCode.Assign(AValue);
|
|
FIncludeInterfaceCode.Assign(AValue);
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TWebIDLToPas.SetIncludeImplementationCode(AValue: TStrings);
|
|
|
|
|
|
+procedure TBaseWebIDLToPas.SetIncludeImplementationCode(AValue: TStrings);
|
|
begin
|
|
begin
|
|
if FIncludeImplementationCode=AValue then Exit;
|
|
if FIncludeImplementationCode=AValue then Exit;
|
|
FIncludeImplementationCode.Assign(AValue);
|
|
FIncludeImplementationCode.Assign(AValue);
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TWebIDLToPas.AllocatePasNames(aList : TIDLDefinitionList; ParentName: String = '');
|
|
|
|
|
|
+procedure TBaseWebIDLToPas.AllocatePasNames(aList : TIDLDefinitionList; ParentName: String = '');
|
|
|
|
|
|
var
|
|
var
|
|
D : TIDLDefinition;
|
|
D : TIDLDefinition;
|
|
@@ -1379,7 +1422,7 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
-procedure TWebIDLToPas.ProcessDefinitions;
|
|
|
|
|
|
+procedure TBaseWebIDLToPas.ProcessDefinitions;
|
|
|
|
|
|
begin
|
|
begin
|
|
FContext.AppendPartials;
|
|
FContext.AppendPartials;
|
|
@@ -1387,9 +1430,15 @@ begin
|
|
AllocatePasNames(FContext.Definitions);
|
|
AllocatePasNames(FContext.Definitions);
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TWebIDLToPas.Execute;
|
|
|
|
|
|
+procedure TBaseWebIDLToPas.Execute;
|
|
|
|
|
|
begin
|
|
begin
|
|
|
|
+ if Verbose then
|
|
|
|
+ begin
|
|
|
|
+ WriteOptions;
|
|
|
|
+ DoLog('');
|
|
|
|
+ end;
|
|
|
|
+
|
|
FContext:=CreateContext;
|
|
FContext:=CreateContext;
|
|
try
|
|
try
|
|
FContext.Aliases:=Self.TypeAliases;
|
|
FContext.Aliases:=Self.TypeAliases;
|
|
@@ -1403,5 +1452,37 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TBaseWebIDLToPas.WriteOptions;
|
|
|
|
+
|
|
|
|
+ function CodeInfo(Src: TStrings): string;
|
|
|
|
+ begin
|
|
|
|
+ Result:='';
|
|
|
|
+ if Src.Count=0 then
|
|
|
|
+ exit;
|
|
|
|
+ Result:=Result+IntToStr(Src.Count)+' lines';
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+var
|
|
|
|
+ i: Integer;
|
|
|
|
+begin
|
|
|
|
+ DoLog('Options of '+ClassName+':');
|
|
|
|
+ DoLog('Verbose='+BoolToStr(Verbose,true));
|
|
|
|
+ DoLog('InputFileName='+InputFileName);
|
|
|
|
+ DoLog('OutputFileName='+OutputFileName);
|
|
|
|
+ DoLog('WebIDLVersion='+GetEnumName(TypeInfo(TWebIDLVersion),ord(WebIDLVersion)));
|
|
|
|
+ DoLog('FieldPrefix='+FieldPrefix);
|
|
|
|
+ DoLog('ClassPrefix='+ClassPrefix);
|
|
|
|
+ DoLog('ClassSuffix='+ClassSuffix);
|
|
|
|
+ DoLog('DictionaryClassParent='+DictionaryClassParent);
|
|
|
|
+ if TypeAliases.Count>0 then
|
|
|
|
+ for i:=0 to TypeAliases.Count-1 do
|
|
|
|
+ DoLog('TypeAliases['+IntToStr(i)+']='+TypeAliases[i])
|
|
|
|
+ else
|
|
|
|
+ DoLog('TypeAliases=');
|
|
|
|
+ DoLog('IncludeInterfaceCode='+CodeInfo(IncludeInterfaceCode));
|
|
|
|
+ DoLog('IncludeImplementationCode='+CodeInfo(IncludeImplementationCode));
|
|
|
|
+ //Property Options : TConversionOptions Read FOptions Write FOptions;
|
|
|
|
+end;
|
|
|
|
+
|
|
end.
|
|
end.
|
|
|
|
|