mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 11:09:19 +02:00
webidl: INputStream, OutputStream, set default unitname, wasmjob: variants
This commit is contained in:
parent
bdc4297811
commit
90df440df3
@ -68,6 +68,8 @@ type
|
|||||||
FDictionaryClassParent: String;
|
FDictionaryClassParent: String;
|
||||||
FFieldPrefix: String;
|
FFieldPrefix: String;
|
||||||
FGlobalVars: TStrings;
|
FGlobalVars: TStrings;
|
||||||
|
FInputStream: TStream;
|
||||||
|
FOutputStream: TStream;
|
||||||
FTypePrefix: String;
|
FTypePrefix: String;
|
||||||
FGetterPrefix: String;
|
FGetterPrefix: String;
|
||||||
FIncludeImplementationCode: TStrings;
|
FIncludeImplementationCode: TStrings;
|
||||||
@ -84,6 +86,7 @@ type
|
|||||||
procedure SetGlobalVars(const AValue: TStrings);
|
procedure SetGlobalVars(const AValue: TStrings);
|
||||||
procedure SetIncludeImplementationCode(AValue: TStrings);
|
procedure SetIncludeImplementationCode(AValue: TStrings);
|
||||||
procedure SetIncludeInterfaceCode(AValue: TStrings);
|
procedure SetIncludeInterfaceCode(AValue: TStrings);
|
||||||
|
procedure SetOutputFileName(const AValue: String);
|
||||||
procedure SetTypeAliases(AValue: TStrings);
|
procedure SetTypeAliases(AValue: TStrings);
|
||||||
Protected
|
Protected
|
||||||
procedure TrimList(List: TStrings); virtual;
|
procedure TrimList(List: TStrings); virtual;
|
||||||
@ -179,7 +182,9 @@ type
|
|||||||
function IsKeyWord(const S: String): Boolean; override;
|
function IsKeyWord(const S: String): Boolean; override;
|
||||||
Public
|
Public
|
||||||
Property InputFileName: String Read FInputFileName Write FInputFileName;
|
Property InputFileName: String Read FInputFileName Write FInputFileName;
|
||||||
Property OutputFileName: String Read FOutputFileName Write FOutputFileName;
|
Property InputStream: TStream Read FInputStream Write FInputStream;
|
||||||
|
Property OutputFileName: String Read FOutputFileName Write SetOutputFileName;
|
||||||
|
Property OutputStream: TStream Read FOutputStream Write FOutputStream;
|
||||||
Property Verbose: Boolean Read FVerbose Write FVerbose;
|
Property Verbose: Boolean Read FVerbose Write FVerbose;
|
||||||
Property FieldPrefix: String Read FFieldPrefix Write FFieldPrefix;
|
Property FieldPrefix: String Read FFieldPrefix Write FFieldPrefix;
|
||||||
Property ClassPrefix: String Read FClassPrefix Write FClassPrefix;
|
Property ClassPrefix: String Read FClassPrefix Write FClassPrefix;
|
||||||
@ -260,7 +265,10 @@ begin
|
|||||||
P:=Nil;
|
P:=Nil;
|
||||||
ms:=TMemoryStream.Create;
|
ms:=TMemoryStream.Create;
|
||||||
try
|
try
|
||||||
ms.LoadFromFile(InputFileName);
|
if InputStream<>nil then
|
||||||
|
ms.CopyFrom(InputStream,InputStream.Size-InputStream.Position)
|
||||||
|
else
|
||||||
|
ms.LoadFromFile(InputFileName);
|
||||||
ms.Position:=0;
|
ms.Position:=0;
|
||||||
S:=CreateScanner(ms);
|
S:=CreateScanner(ms);
|
||||||
S.CurFile:=InputFileName;
|
S.CurFile:=InputFileName;
|
||||||
@ -1514,6 +1522,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TBaseWebIDLToPas.WritePascal;
|
procedure TBaseWebIDLToPas.WritePascal;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
Line: String;
|
||||||
begin
|
begin
|
||||||
CreateUnitClause;
|
CreateUnitClause;
|
||||||
CreateHeader;
|
CreateHeader;
|
||||||
@ -1533,7 +1544,16 @@ begin
|
|||||||
AddLn('implementation');
|
AddLn('implementation');
|
||||||
WriteImplementation;
|
WriteImplementation;
|
||||||
AddLn('end.');
|
AddLn('end.');
|
||||||
Source.SaveToFile(OutputFileName);
|
if OutputStream<>nil then
|
||||||
|
begin
|
||||||
|
for i:=0 to Source.Count-1 do
|
||||||
|
begin
|
||||||
|
Line:=Source[i]+sLineBreak;
|
||||||
|
OutputStream.Write(Line[1],length(Line));
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Source.SaveToFile(OutputFileName);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TBaseWebIDLToPas.CreatePasData(aName: String; D: TIDLBaseObject;
|
function TBaseWebIDLToPas.CreatePasData(aName: String; D: TIDLBaseObject;
|
||||||
@ -1836,6 +1856,22 @@ begin
|
|||||||
FIncludeInterfaceCode.Assign(AValue);
|
FIncludeInterfaceCode.Assign(AValue);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TBaseWebIDLToPas.SetOutputFileName(const AValue: String);
|
||||||
|
var
|
||||||
|
aName, Ext: String;
|
||||||
|
begin
|
||||||
|
if FOutputFileName=AValue then Exit;
|
||||||
|
FOutputFileName:=AValue;
|
||||||
|
if OutputUnitName='' then
|
||||||
|
begin
|
||||||
|
aName:=ExtractFileName(AValue);
|
||||||
|
Ext:=ExtractFileExt(AName);
|
||||||
|
if Ext<>'' then
|
||||||
|
aName:=LeftStr(aName,length(aName)-length(Ext));
|
||||||
|
OutputUnitName:=aName;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TBaseWebIDLToPas.SetIncludeImplementationCode(AValue: TStrings);
|
procedure TBaseWebIDLToPas.SetIncludeImplementationCode(AValue: TStrings);
|
||||||
begin
|
begin
|
||||||
if FIncludeImplementationCode=AValue then Exit;
|
if FIncludeImplementationCode=AValue then Exit;
|
||||||
|
@ -500,6 +500,7 @@ begin
|
|||||||
'Double': InvokeName:='InvokeJSDoubleResult';
|
'Double': InvokeName:='InvokeJSDoubleResult';
|
||||||
'UTF8String': InvokeName:='InvokeJSUTF8StringResult';
|
'UTF8String': InvokeName:='InvokeJSUTF8StringResult';
|
||||||
'UnicodeString': InvokeName:='InvokeJSUnicodeStringResult';
|
'UnicodeString': InvokeName:='InvokeJSUnicodeStringResult';
|
||||||
|
'Variant': InvokeName:='InvokeJSVariantResult';
|
||||||
'TJOB_JSValue': InvokeName:='InvokeJSValueResult';
|
'TJOB_JSValue': InvokeName:='InvokeJSValueResult';
|
||||||
'void','undefined':
|
'void','undefined':
|
||||||
begin
|
begin
|
||||||
@ -700,6 +701,7 @@ begin
|
|||||||
'Double': GetFunc:='GetDouble';
|
'Double': GetFunc:='GetDouble';
|
||||||
'UTF8String',
|
'UTF8String',
|
||||||
'UnicodeString': GetFunc:='GetString';
|
'UnicodeString': GetFunc:='GetString';
|
||||||
|
'Variant': GetFunc:='GetVariant';
|
||||||
'TJOB_JSValue': GetFunc:='GetValue';
|
'TJOB_JSValue': GetFunc:='GetValue';
|
||||||
else
|
else
|
||||||
if ArgType is TIDLInterfaceDefinition then
|
if ArgType is TIDLInterfaceDefinition then
|
||||||
@ -751,6 +753,7 @@ begin
|
|||||||
'Double': GetFunc:='Result:=H.AllocDouble('+Call+');';
|
'Double': GetFunc:='Result:=H.AllocDouble('+Call+');';
|
||||||
'UTF8String': GetFunc:='Result:=H.AllocString('+Call+');';
|
'UTF8String': GetFunc:='Result:=H.AllocString('+Call+');';
|
||||||
'UnicodeString': GetFunc:='Result:=H.AllocString('+Call+');';
|
'UnicodeString': GetFunc:='Result:=H.AllocString('+Call+');';
|
||||||
|
'Variant': GetFunc:='Result:=H.AllocVariant('+Call+');';
|
||||||
'TJOB_JSValue': GetFunc:='Result:=H.AllocJSValue('+Call+');';
|
'TJOB_JSValue': GetFunc:='Result:=H.AllocJSValue('+Call+');';
|
||||||
else
|
else
|
||||||
if ReturnDef is TIDLInterfaceDefinition then
|
if ReturnDef is TIDLInterfaceDefinition then
|
||||||
@ -812,6 +815,7 @@ begin
|
|||||||
'Double': ReadFuncName:='ReadJSPropertyDouble';
|
'Double': ReadFuncName:='ReadJSPropertyDouble';
|
||||||
'UTF8String': ReadFuncName:='ReadJSPropertyUTF8String';
|
'UTF8String': ReadFuncName:='ReadJSPropertyUTF8String';
|
||||||
'UnicodeString': ReadFuncName:='ReadJSPropertyUnicodeString';
|
'UnicodeString': ReadFuncName:='ReadJSPropertyUnicodeString';
|
||||||
|
'Variant': ReadFuncName:='ReadJSPropertyVariant';
|
||||||
'TJOB_JSValue': ReadFuncName:='ReadJSPropertyValue';
|
'TJOB_JSValue': ReadFuncName:='ReadJSPropertyValue';
|
||||||
else
|
else
|
||||||
if AttrType is TIDLSequenceTypeDefDefinition then
|
if AttrType is TIDLSequenceTypeDefDefinition then
|
||||||
@ -879,6 +883,7 @@ begin
|
|||||||
'Double': WriteFuncName:='WriteJSPropertyDouble';
|
'Double': WriteFuncName:='WriteJSPropertyDouble';
|
||||||
'UTF8String': WriteFuncName:='WriteJSPropertyUTF8String';
|
'UTF8String': WriteFuncName:='WriteJSPropertyUTF8String';
|
||||||
'UnicodeString': WriteFuncName:='WriteJSPropertyUnicodeString';
|
'UnicodeString': WriteFuncName:='WriteJSPropertyUnicodeString';
|
||||||
|
'Variant': WriteFuncName:='WriteJSPropertyVariant';
|
||||||
'TJOB_JSValue': WriteFuncName:='WriteJSPropertyValue';
|
'TJOB_JSValue': WriteFuncName:='WriteJSPropertyValue';
|
||||||
else
|
else
|
||||||
WriteFuncName:='WriteJSPropertyObject';
|
WriteFuncName:='WriteJSPropertyObject';
|
||||||
@ -991,9 +996,11 @@ begin
|
|||||||
inherited Create(ThOwner);
|
inherited Create(ThOwner);
|
||||||
// Switches.Add('modeswitch FunctionReferences');
|
// Switches.Add('modeswitch FunctionReferences');
|
||||||
PasDataClass:=TPasDataWasmJob;
|
PasDataClass:=TPasDataWasmJob;
|
||||||
FPasInterfacePrefix:='IJS';
|
ClassPrefix:='TJS';
|
||||||
|
PasInterfacePrefix:='IJS';
|
||||||
GetterPrefix:='_Get';
|
GetterPrefix:='_Get';
|
||||||
SetterPrefix:='_Set';
|
SetterPrefix:='_Set';
|
||||||
|
KeywordSuffix:='_';
|
||||||
BaseOptions:=BaseOptions+[coExpandUnionTypeArgs,coDictionaryAsClass];
|
BaseOptions:=BaseOptions+[coExpandUnionTypeArgs,coDictionaryAsClass];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user