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