mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 05:29:21 +02:00
fcl-js: changed some ifdefs to be more specific
git-svn-id: trunk@40029 -
This commit is contained in:
parent
d26fb3b663
commit
37e98d3726
@ -49,7 +49,7 @@ Type
|
|||||||
FOnWriting: TTextWriterWriting;
|
FOnWriting: TTextWriterWriting;
|
||||||
protected
|
protected
|
||||||
Function DoWrite(Const S : TJSWriterString) : Integer; virtual; abstract;
|
Function DoWrite(Const S : TJSWriterString) : Integer; virtual; abstract;
|
||||||
{$ifdef fpc}
|
{$ifdef FPC_HAS_CPSTRING}
|
||||||
Function DoWrite(Const S : UnicodeString) : Integer; virtual; abstract;
|
Function DoWrite(Const S : UnicodeString) : Integer; virtual; abstract;
|
||||||
{$endif}
|
{$endif}
|
||||||
procedure SetCurElement(const AValue: TJSElement); virtual;
|
procedure SetCurElement(const AValue: TJSElement); virtual;
|
||||||
@ -57,7 +57,7 @@ Type
|
|||||||
Public
|
Public
|
||||||
// All functions return the number of bytes copied to output stream.
|
// All functions return the number of bytes copied to output stream.
|
||||||
constructor Create;
|
constructor Create;
|
||||||
{$ifdef fpc}
|
{$ifdef FPC_HAS_CPSTRING}
|
||||||
Function Write(Const S : UnicodeString) : Integer;
|
Function Write(Const S : UnicodeString) : Integer;
|
||||||
{$endif}
|
{$endif}
|
||||||
Function Write(Const S : TJSWriterString) : Integer;
|
Function Write(Const S : TJSWriterString) : Integer;
|
||||||
@ -105,13 +105,13 @@ Type
|
|||||||
{$endif}
|
{$endif}
|
||||||
function GetBufferLength: Integer;
|
function GetBufferLength: Integer;
|
||||||
function GetCapacity: Cardinal;
|
function GetCapacity: Cardinal;
|
||||||
{$ifdef fpc}
|
{$ifdef FPC_HAS_CPSTRING}
|
||||||
function GetUnicodeString: UnicodeString;
|
function GetUnicodeString: UnicodeString;
|
||||||
{$endif}
|
{$endif}
|
||||||
procedure SetCapacity(AValue: Cardinal);
|
procedure SetCapacity(AValue: Cardinal);
|
||||||
Protected
|
Protected
|
||||||
Function DoWrite(Const S : TJSWriterString) : integer; override;
|
Function DoWrite(Const S : TJSWriterString) : integer; override;
|
||||||
{$ifdef fpc}
|
{$ifdef FPC_HAS_CPSTRING}
|
||||||
Function DoWrite(Const S : UnicodeString) : integer; override;
|
Function DoWrite(Const S : UnicodeString) : integer; override;
|
||||||
{$endif}
|
{$endif}
|
||||||
Public
|
Public
|
||||||
@ -123,7 +123,7 @@ Type
|
|||||||
Property BufferLength : Integer Read GetBufferLength;
|
Property BufferLength : Integer Read GetBufferLength;
|
||||||
Property Capacity : Cardinal Read GetCapacity Write SetCapacity;
|
Property Capacity : Cardinal Read GetCapacity Write SetCapacity;
|
||||||
Property AsString : TJSWriterString Read GetAsString;
|
Property AsString : TJSWriterString Read GetAsString;
|
||||||
{$ifdef fpc}
|
{$ifdef FPC_HAS_CPSTRING}
|
||||||
Property AsAnsiString : AnsiString Read GetAsString; deprecated 'use AsString instead, fpc 3.3.1';
|
Property AsAnsiString : AnsiString Read GetAsString; deprecated 'use AsString instead, fpc 3.3.1';
|
||||||
Property AsUnicodeString : UnicodeString Read GetUnicodeString;
|
Property AsUnicodeString : UnicodeString Read GetUnicodeString;
|
||||||
{$endif}
|
{$endif}
|
||||||
@ -138,7 +138,7 @@ Type
|
|||||||
{ TJSWriter }
|
{ TJSWriter }
|
||||||
|
|
||||||
TWriteOption = (woCompact,
|
TWriteOption = (woCompact,
|
||||||
{$ifdef fpc}
|
{$ifdef FPC_HAS_CPSTRING}
|
||||||
woUseUTF8,
|
woUseUTF8,
|
||||||
{$endif}
|
{$endif}
|
||||||
woTabIndent,
|
woTabIndent,
|
||||||
@ -168,12 +168,12 @@ Type
|
|||||||
Procedure Error(Const Msg : TJSWriterString);
|
Procedure Error(Const Msg : TJSWriterString);
|
||||||
Procedure Error(Const Fmt : TJSWriterString; Args : Array of {$ifdef pas2js}jsvalue{$else}const{$endif});
|
Procedure Error(Const Fmt : TJSWriterString; Args : Array of {$ifdef pas2js}jsvalue{$else}const{$endif});
|
||||||
Procedure WriteIndent; // inline;
|
Procedure WriteIndent; // inline;
|
||||||
{$ifdef fpc}
|
{$ifdef FPC_HAS_CPSTRING}
|
||||||
Procedure Write(Const U : UnicodeString);
|
Procedure Write(Const U : UnicodeString);
|
||||||
{$endif}
|
{$endif}
|
||||||
Procedure Write(Const S : TJSWriterString);
|
Procedure Write(Const S : TJSWriterString);
|
||||||
Procedure WriteLn(Const S : TJSWriterString);
|
Procedure WriteLn(Const S : TJSWriterString);
|
||||||
{$ifdef fpc}
|
{$ifdef FPC_HAS_CPSTRING}
|
||||||
Procedure WriteLn(Const U : UnicodeString);
|
Procedure WriteLn(Const U : UnicodeString);
|
||||||
{$endif}
|
{$endif}
|
||||||
// one per type of statement
|
// one per type of statement
|
||||||
@ -229,7 +229,7 @@ Type
|
|||||||
end;
|
end;
|
||||||
EJSWriter = Class(Exception);
|
EJSWriter = Class(Exception);
|
||||||
|
|
||||||
{$ifdef fpc}
|
{$ifdef FPC_HAS_CPSTRING}
|
||||||
Function UTF16ToUTF8(const S: UnicodeString): string;
|
Function UTF16ToUTF8(const S: UnicodeString): string;
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
@ -239,7 +239,7 @@ Resourcestring
|
|||||||
SErrUnknownJSClass = 'Unknown javascript element class : %s';
|
SErrUnknownJSClass = 'Unknown javascript element class : %s';
|
||||||
SErrNilNode = 'Nil node in Javascript';
|
SErrNilNode = 'Nil node in Javascript';
|
||||||
|
|
||||||
{$ifdef fpc}
|
{$ifdef FPC_HAS_CPSTRING}
|
||||||
function HexDump(p: PChar; Count: integer): string;
|
function HexDump(p: PChar; Count: integer): string;
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
@ -291,7 +291,7 @@ begin
|
|||||||
Result:=Length(FBuffer);
|
Result:=Length(FBuffer);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$ifdef fpc}
|
{$ifdef FPC_HAS_CPSTRING}
|
||||||
function TBufferWriter.GetUnicodeString: UnicodeString;
|
function TBufferWriter.GetUnicodeString: UnicodeString;
|
||||||
|
|
||||||
Var
|
Var
|
||||||
@ -343,7 +343,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
{$ifdef fpc}
|
{$ifdef FPC_HAS_CPSTRING}
|
||||||
Function TBufferWriter.DoWrite(Const S: UnicodeString): integer;
|
Function TBufferWriter.DoWrite(Const S: UnicodeString): integer;
|
||||||
|
|
||||||
Var
|
Var
|
||||||
@ -401,7 +401,7 @@ end;
|
|||||||
|
|
||||||
function TJSWriter.GetUseUTF8: Boolean;
|
function TJSWriter.GetUseUTF8: Boolean;
|
||||||
begin
|
begin
|
||||||
Result:={$ifdef pas2js}false{$else}(woUseUTF8 in Options){$endif};
|
Result:={$ifdef FPC_HAS_CPSTRING}(woUseUTF8 in Options){$else}false{$endif};
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TJSWriter.Error(const Msg: TJSWriterString);
|
procedure TJSWriter.Error(const Msg: TJSWriterString);
|
||||||
@ -409,7 +409,8 @@ begin
|
|||||||
Raise EJSWriter.Create(Msg);
|
Raise EJSWriter.Create(Msg);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TJSWriter.Error(const Fmt: TJSWriterString; Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif});
|
procedure TJSWriter.Error(const Fmt: TJSWriterString;
|
||||||
|
Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif});
|
||||||
begin
|
begin
|
||||||
Raise EJSWriter.CreateFmt(Fmt,Args);
|
Raise EJSWriter.CreateFmt(Fmt,Args);
|
||||||
end;
|
end;
|
||||||
@ -437,7 +438,7 @@ begin
|
|||||||
FCurIndent:=0;
|
FCurIndent:=0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$ifdef fpc}
|
{$ifdef FPC_HAS_CPSTRING}
|
||||||
procedure TJSWriter.Write(const U: UnicodeString);
|
procedure TJSWriter.Write(const U: UnicodeString);
|
||||||
|
|
||||||
Var
|
Var
|
||||||
@ -462,7 +463,7 @@ end;
|
|||||||
|
|
||||||
procedure TJSWriter.Write(const S: TJSWriterString);
|
procedure TJSWriter.Write(const S: TJSWriterString);
|
||||||
begin
|
begin
|
||||||
{$ifdef fpc}
|
{$ifdef FPC_HAS_CPSTRING}
|
||||||
if Not (woUseUTF8 in Options) then
|
if Not (woUseUTF8 in Options) then
|
||||||
Write(UnicodeString(S))
|
Write(UnicodeString(S))
|
||||||
else
|
else
|
||||||
@ -477,7 +478,7 @@ end;
|
|||||||
|
|
||||||
procedure TJSWriter.WriteLn(const S: TJSWriterString);
|
procedure TJSWriter.WriteLn(const S: TJSWriterString);
|
||||||
begin
|
begin
|
||||||
{$ifdef fpc}
|
{$ifdef FPC_HAS_CPSTRING}
|
||||||
if Not (woUseUTF8 in Options) then
|
if Not (woUseUTF8 in Options) then
|
||||||
Writeln(UnicodeString(S))
|
Writeln(UnicodeString(S))
|
||||||
else
|
else
|
||||||
@ -490,7 +491,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$ifdef fpc}
|
{$ifdef FPC_HAS_CPSTRING}
|
||||||
procedure TJSWriter.WriteLn(const U: UnicodeString);
|
procedure TJSWriter.WriteLn(const U: UnicodeString);
|
||||||
Var
|
Var
|
||||||
S : String;
|
S : String;
|
||||||
@ -799,7 +800,7 @@ constructor TJSWriter.Create(AWriter: TTextWriter);
|
|||||||
begin
|
begin
|
||||||
FWriter:=AWriter;
|
FWriter:=AWriter;
|
||||||
FIndentChar:=' ';
|
FIndentChar:=' ';
|
||||||
FOptions:=[{$ifdef fpc}woUseUTF8{$endif}];
|
FOptions:=[{$ifdef FPC_HAS_CPSTRING}woUseUTF8{$endif}];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$ifdef fpc}
|
{$ifdef fpc}
|
||||||
@ -1832,7 +1833,7 @@ begin
|
|||||||
FCurColumn:=1;
|
FCurColumn:=1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$ifdef fpc}
|
{$ifdef FPC_HAS_CPSTRING}
|
||||||
function TTextWriter.Write(const S: UnicodeString): Integer;
|
function TTextWriter.Write(const S: UnicodeString): Integer;
|
||||||
var
|
var
|
||||||
p: PWideChar;
|
p: PWideChar;
|
||||||
@ -1974,7 +1975,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TTextWriter.WriteLn(const Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}): Integer;
|
function TTextWriter.WriteLn(
|
||||||
|
const Args: array of {$ifdef pas2js}jsvalue{$else}const{$endif}): Integer;
|
||||||
begin
|
begin
|
||||||
Result:=Write(Args)+Writeln('');
|
Result:=Write(Args)+Writeln('');
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user