update etc/fscl-json to 33310

This commit is contained in:
Basile Burg 2016-03-28 21:56:44 +02:00
parent cece2ad6d8
commit e03fd44777
5 changed files with 27 additions and 6 deletions

View File

@ -668,6 +668,7 @@ function StringToJSONString(const S: TJSONStringType): TJSONStringType;
Var Var
I,J,L : Integer; I,J,L : Integer;
P : PJSONCharType; P : PJSONCharType;
C : AnsiChar;
begin begin
I:=1; I:=1;
@ -677,10 +678,11 @@ begin
P:=PJSONCharType(S); P:=PJSONCharType(S);
While I<=L do While I<=L do
begin begin
if (AnsiChar(P^) in ['"','/','\',#8,#9,#10,#12,#13]) then C:=AnsiChar(P^);
if (C in ['"','/','\',#0..#31]) then
begin begin
Result:=Result+Copy(S,J,I-J); Result:=Result+Copy(S,J,I-J);
Case P^ of Case C of
'\' : Result:=Result+'\\'; '\' : Result:=Result+'\\';
'/' : Result:=Result+'\/'; '/' : Result:=Result+'\/';
'"' : Result:=Result+'\"'; '"' : Result:=Result+'\"';
@ -689,6 +691,8 @@ begin
#10 : Result:=Result+'\n'; #10 : Result:=Result+'\n';
#12 : Result:=Result+'\f'; #12 : Result:=Result+'\f';
#13 : Result:=Result+'\r'; #13 : Result:=Result+'\r';
else
Result:=Result+'\u'+HexStr(Ord(C),4);
end; end;
J:=I+1; J:=I+1;
end; end;

View File

@ -1,4 +1,4 @@
unit fpjsonrtti; unit xfpjsonrtti;
{$mode objfpc} {$mode objfpc}

View File

@ -23,13 +23,15 @@
{$H+} {$H+}
{$ENDIF} {$ENDIF}
unit jsonConf; unit xjsonConf;
interface interface
uses uses
SysUtils, Classes, xfpjson, xjsonscanner, xjsonparser; SysUtils, Classes, xfpjson, xjsonscanner, xjsonparser;
Const
DefaultJSONOptions = [joUTF8,joComments];
type type
EJSONConfigError = class(Exception); EJSONConfigError = class(Exception);
@ -57,9 +59,11 @@ type
FFormatIndentSize: Integer; FFormatIndentSize: Integer;
FFormatoptions: TFormatOptions; FFormatoptions: TFormatOptions;
FFormatted: Boolean; FFormatted: Boolean;
FJSONOptions: TJSONOptions;
FKey: TJSONObject; FKey: TJSONObject;
procedure DoSetFilename(const AFilename: String; ForceReload: Boolean); procedure DoSetFilename(const AFilename: String; ForceReload: Boolean);
procedure SetFilename(const AFilename: String); procedure SetFilename(const AFilename: String);
procedure SetJSONOptions(AValue: TJSONOptions);
Function StripSlash(Const P : UnicodeString) : UnicodeString; Function StripSlash(Const P : UnicodeString) : UnicodeString;
protected protected
FJSON: TJSONObject; FJSON: TJSONObject;
@ -109,6 +113,7 @@ type
Property Formatted : Boolean Read FFormatted Write FFormatted; Property Formatted : Boolean Read FFormatted Write FFormatted;
Property FormatOptions : TFormatOptions Read FFormatoptions Write FFormatOptions Default DefaultFormat; Property FormatOptions : TFormatOptions Read FFormatoptions Write FFormatOptions Default DefaultFormat;
Property FormatIndentsize : Integer Read FFormatIndentSize Write FFormatIndentSize Default DefaultIndentSize; Property FormatIndentsize : Integer Read FFormatIndentSize Write FFormatIndentSize Default DefaultIndentSize;
Property JSONOptions : TJSONOptions Read FJSONOptions Write SetJSONOptions Default DefaultJSONOptions;
end; end;
@ -127,6 +132,7 @@ begin
FKey:=FJSON; FKey:=FJSON;
FFormatOptions:=DefaultFormat; FFormatOptions:=DefaultFormat;
FFormatIndentsize:=DefaultIndentSize; FFormatIndentsize:=DefaultIndentSize;
FJSONOptions:=DefaultJSONOptions;
end; end;
destructor TJSONConfig.Destroy; destructor TJSONConfig.Destroy;
@ -687,7 +693,7 @@ begin
begin begin
F:=TFileStream.Create(AFileName,fmopenRead); F:=TFileStream.Create(AFileName,fmopenRead);
try try
P:=TJSONParser.Create(F,[joUTF8,joComments]); P:=TJSONParser.Create(F,FJSONOptions);
try try
J:=P.Parse; J:=P.Parse;
If (J is TJSONObject) then If (J is TJSONObject) then
@ -712,6 +718,16 @@ begin
DoSetFilename(AFilename, False); DoSetFilename(AFilename, False);
end; end;
procedure TJSONConfig.SetJSONOptions(AValue: TJSONOptions);
begin
if FJSONOptions=AValue then Exit;
FJSONOptions:=AValue;
if csLoading in ComponentState then
exit;
if (FFileName<>'') then
Reload;
end;
function TJSONConfig.StripSlash(const P: UnicodeString): UnicodeString; function TJSONConfig.StripSlash(const P: UnicodeString): UnicodeString;
Var Var

View File

@ -212,6 +212,7 @@ begin
parser := TJSONParser.Create(loader, [joIgnoreTrailingComma, joUTF8]); parser := TJSONParser.Create(loader, [joIgnoreTrailingComma, joUTF8]);
//TODO-cfcl-json: remove etc/fcl-json the day they'll merge and rlz the version with 'Options' //TODO-cfcl-json: remove etc/fcl-json the day they'll merge and rlz the version with 'Options'
//TODO-cfcl-json: track possible changes and fixes at http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/packages/fcl-json/ //TODO-cfcl-json: track possible changes and fixes at http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/packages/fcl-json/
//latest in in etc = rev 33310.
try try
try try
fJSON := parser.Parse as TJSONObject; fJSON := parser.Parse as TJSONObject;

View File

@ -251,7 +251,7 @@ begin
begin begin
nme := aEditor.GetPropInfo^.Name; nme := aEditor.GetPropInfo^.Name;
len := nme.length; len := nme.length;
// TODO-cbugfix: filtering does not work on sub componenets 'e.g D2HL options) // TODO-cbugfix: filtering does not work on sub components (see editor options, highlighterDlang)
if (len > 2) and (nme[len - 2 .. len] = 'Tag') then if (len > 2) and (nme[len - 2 .. len] = 'Tag') then
aShow := false aShow := false
else if (len > 3) and (nme[len - 3 .. len] = 'Name') then else if (len > 3) and (nme[len - 3 .. len] = 'Name') then