You've already forked lazarus-ccr
Fix Compilation with fpc-trunck
Take advantage of fcl-json "Clone" method git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1257 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -70,7 +70,7 @@ type
|
|||||||
function CreateInt64Buffer(
|
function CreateInt64Buffer(
|
||||||
Const AName : string;
|
Const AName : string;
|
||||||
const AValue : Int64
|
const AValue : Int64
|
||||||
) : TJSONData;virtual;
|
) : TJSONData;virtual; abstract;
|
||||||
{$IFDEF HAS_QWORD}
|
{$IFDEF HAS_QWORD}
|
||||||
function CreateUInt64Buffer(
|
function CreateUInt64Buffer(
|
||||||
Const AName : string;
|
Const AName : string;
|
||||||
@ -110,6 +110,10 @@ type
|
|||||||
Const AName : string;
|
Const AName : string;
|
||||||
const AValue : TJsonInteger
|
const AValue : TJsonInteger
|
||||||
) : TJSONData;override;
|
) : TJSONData;override;
|
||||||
|
function CreateInt64Buffer(
|
||||||
|
Const AName : string;
|
||||||
|
const AValue : Int64
|
||||||
|
) : TJSONData; override;
|
||||||
function CreateFloatBuffer(
|
function CreateFloatBuffer(
|
||||||
Const AName : string;
|
Const AName : string;
|
||||||
const AValue : TJSONFloat
|
const AValue : TJSONFloat
|
||||||
@ -141,7 +145,11 @@ type
|
|||||||
function CreateIntBuffer(
|
function CreateIntBuffer(
|
||||||
Const AName : string;
|
Const AName : string;
|
||||||
const AValue : TJsonInteger
|
const AValue : TJsonInteger
|
||||||
) : TJSONData;override;
|
) : TJSONData;override;
|
||||||
|
function CreateInt64Buffer(
|
||||||
|
Const AName : string;
|
||||||
|
const AValue : Int64
|
||||||
|
) : TJSONData; override;
|
||||||
function CreateFloatBuffer(
|
function CreateFloatBuffer(
|
||||||
Const AName : string;
|
Const AName : string;
|
||||||
const AValue : TJSONFloat
|
const AValue : TJSONFloat
|
||||||
@ -171,7 +179,11 @@ type
|
|||||||
function CreateIntBuffer(
|
function CreateIntBuffer(
|
||||||
Const AName : string;
|
Const AName : string;
|
||||||
const AValue : TJsonInteger
|
const AValue : TJsonInteger
|
||||||
) : TJSONData;override;
|
) : TJSONData;override;
|
||||||
|
function CreateInt64Buffer(
|
||||||
|
Const AName : string;
|
||||||
|
const AValue : Int64
|
||||||
|
) : TJSONData; override;
|
||||||
function CreateFloatBuffer(
|
function CreateFloatBuffer(
|
||||||
Const AName : string;
|
Const AName : string;
|
||||||
const AValue : TJSONFloat
|
const AValue : TJSONFloat
|
||||||
@ -432,6 +444,16 @@ implementation
|
|||||||
uses
|
uses
|
||||||
jsonparser, imp_utils, wst_consts;
|
jsonparser, imp_utils, wst_consts;
|
||||||
|
|
||||||
|
function FindObject(AObject : TJSONObject; const AName : TJSONStringType) : TJSONData;
|
||||||
|
var
|
||||||
|
i : Integer;
|
||||||
|
begin
|
||||||
|
i := AObject.IndexOfName(AName);
|
||||||
|
if ( i >= 0 ) then
|
||||||
|
Result := AObject.Items[i]
|
||||||
|
else
|
||||||
|
Result := nil;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TJsonRpcBaseFormatter }
|
{ TJsonRpcBaseFormatter }
|
||||||
|
|
||||||
@ -1613,14 +1635,6 @@ begin
|
|||||||
FScopeType := AScopeType;
|
FScopeType := AScopeType;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TStackItem.CreateInt64Buffer(
|
|
||||||
const AName : string;
|
|
||||||
const AValue : Int64
|
|
||||||
) : TJSONData;
|
|
||||||
begin
|
|
||||||
Result := CreateFloatBuffer(AName,AValue);
|
|
||||||
end;
|
|
||||||
|
|
||||||
{$IFDEF HAS_QWORD}
|
{$IFDEF HAS_QWORD}
|
||||||
function TStackItem.CreateUInt64Buffer(
|
function TStackItem.CreateUInt64Buffer(
|
||||||
const AName : string;
|
const AName : string;
|
||||||
@ -1645,7 +1659,7 @@ end;
|
|||||||
|
|
||||||
function TObjectStackItem.FindNode(var ANodeName : string) : TJSONData;
|
function TObjectStackItem.FindNode(var ANodeName : string) : TJSONData;
|
||||||
begin
|
begin
|
||||||
Result := GetDataObject().Elements[ANodeName];
|
Result := FindObject(GetDataObject(),ANodeName);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TObjectStackItem.CreateStringBuffer(
|
function TObjectStackItem.CreateStringBuffer(
|
||||||
@ -1657,7 +1671,7 @@ var
|
|||||||
i : PtrInt;
|
i : PtrInt;
|
||||||
begin
|
begin
|
||||||
locObj := GetDataObject();
|
locObj := GetDataObject();
|
||||||
Result := locObj.Elements[AName];
|
Result := FindObject(locObj,AName);
|
||||||
if ( Result = nil ) then begin
|
if ( Result = nil ) then begin
|
||||||
i := locObj.Add(AName,AValue);
|
i := locObj.Add(AName,AValue);
|
||||||
Result := locObj.Items[i];
|
Result := locObj.Items[i];
|
||||||
@ -1675,7 +1689,7 @@ var
|
|||||||
i : PtrInt;
|
i : PtrInt;
|
||||||
begin
|
begin
|
||||||
locObj := GetDataObject();
|
locObj := GetDataObject();
|
||||||
Result := locObj.Elements[AName];
|
Result := FindObject(locObj,AName);
|
||||||
if ( Result = nil ) then begin
|
if ( Result = nil ) then begin
|
||||||
i := locObj.Add(AName,AValue);
|
i := locObj.Add(AName,AValue);
|
||||||
Result := locObj.Items[i];
|
Result := locObj.Items[i];
|
||||||
@ -1684,6 +1698,30 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TObjectStackItem.CreateInt64Buffer(
|
||||||
|
const AName : string;
|
||||||
|
const AValue : Int64
|
||||||
|
) : TJSONData;
|
||||||
|
{$IFDEF WST_HAS_JSON_INT64}
|
||||||
|
var
|
||||||
|
locObj : TJSONObject;
|
||||||
|
i : PtrInt;
|
||||||
|
begin
|
||||||
|
locObj := GetDataObject();
|
||||||
|
Result := FindObject(locObj,AName);
|
||||||
|
if ( Result = nil ) then begin
|
||||||
|
i := locObj.Add(AName,AValue);
|
||||||
|
Result := locObj.Items[i];
|
||||||
|
end else begin
|
||||||
|
Result.AsInt64 := AValue;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
{$ELSE WST_HAS_JSON_INT64}
|
||||||
|
begin
|
||||||
|
Result := CreateFloatBuffer(AName,AValue);
|
||||||
|
end;
|
||||||
|
{$ENDIF WST_HAS_JSON_INT64}
|
||||||
|
|
||||||
function TObjectStackItem.CreateFloatBuffer(
|
function TObjectStackItem.CreateFloatBuffer(
|
||||||
const AName : string;
|
const AName : string;
|
||||||
const AValue : TJSONFloat
|
const AValue : TJSONFloat
|
||||||
@ -1693,7 +1731,7 @@ var
|
|||||||
i : PtrInt;
|
i : PtrInt;
|
||||||
begin
|
begin
|
||||||
locObj := GetDataObject();
|
locObj := GetDataObject();
|
||||||
Result := locObj.Elements[AName];
|
Result := FindObject(locObj,AName);
|
||||||
if ( Result = nil ) then begin
|
if ( Result = nil ) then begin
|
||||||
i := locObj.Add(AName,AValue);
|
i := locObj.Add(AName,AValue);
|
||||||
Result := locObj.Items[i];
|
Result := locObj.Items[i];
|
||||||
@ -1711,7 +1749,7 @@ var
|
|||||||
i : PtrInt;
|
i : PtrInt;
|
||||||
begin
|
begin
|
||||||
locObj := GetDataObject();
|
locObj := GetDataObject();
|
||||||
Result := locObj.Elements[AName];
|
Result := FindObject(locObj,AName);
|
||||||
if ( Result = nil ) then begin
|
if ( Result = nil ) then begin
|
||||||
i := locObj.Add(AName,AValue);
|
i := locObj.Add(AName,AValue);
|
||||||
Result := locObj.Items[i];
|
Result := locObj.Items[i];
|
||||||
@ -1723,12 +1761,15 @@ end;
|
|||||||
function TObjectStackItem.CreateObjectBuffer(const AName : string) : TJSONObject;
|
function TObjectStackItem.CreateObjectBuffer(const AName : string) : TJSONObject;
|
||||||
var
|
var
|
||||||
locObj : TJSONObject;
|
locObj : TJSONObject;
|
||||||
|
locIndex : Integer;
|
||||||
begin
|
begin
|
||||||
locObj := GetDataObject();
|
locObj := GetDataObject();
|
||||||
Result := locObj.Elements[AName] as TJSONObject;
|
locIndex := locObj.IndexOfName(AName);
|
||||||
if ( Result = nil ) then begin
|
if ( locIndex = -1 ) then begin
|
||||||
Result := TJSONObject.Create();
|
Result := TJSONObject.Create();
|
||||||
locObj.Add(AName,Result);
|
locObj.Add(AName,Result);
|
||||||
|
end else begin
|
||||||
|
Result := locObj.Items[locIndex] as TJSONObject;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1737,7 +1778,7 @@ var
|
|||||||
locObj : TJSONObject;
|
locObj : TJSONObject;
|
||||||
begin
|
begin
|
||||||
locObj := GetDataObject();
|
locObj := GetDataObject();
|
||||||
Result := locObj.Elements[AName] as TJSONArray;
|
Result := FindObject(locObj,AName) as TJSONArray;
|
||||||
if ( Result = nil ) then begin
|
if ( Result = nil ) then begin
|
||||||
Result := TJSONArray.Create();
|
Result := TJSONArray.Create();
|
||||||
locObj.Add(AName,Result);
|
locObj.Add(AName,Result);
|
||||||
@ -1804,6 +1845,18 @@ begin
|
|||||||
Result := GetDataObject().Items[GetDataObject().Add(AValue)];
|
Result := GetDataObject().Items[GetDataObject().Add(AValue)];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TArrayStackItem.CreateInt64Buffer(
|
||||||
|
const AName : string;
|
||||||
|
const AValue : Int64
|
||||||
|
) : TJSONData;
|
||||||
|
begin
|
||||||
|
{$IFDEF WST_HAS_JSON_INT64}
|
||||||
|
Result := GetDataObject().Items[GetDataObject().Add(AValue)];
|
||||||
|
{$ELSE WST_HAS_JSON_INT64}
|
||||||
|
Result := CreateFloatBuffer(AName,AValue);
|
||||||
|
{$ENDIF WST_HAS_JSON_INT64}
|
||||||
|
end;
|
||||||
|
|
||||||
function TArrayStackItem.CreateFloatBuffer(const AName : string; const AValue : TJSONFloat) : TJSONData;
|
function TArrayStackItem.CreateFloatBuffer(const AName : string; const AValue : TJSONFloat) : TJSONData;
|
||||||
begin
|
begin
|
||||||
Result := GetDataObject().Items[GetDataObject().Add(AValue)];
|
Result := GetDataObject().Items[GetDataObject().Add(AValue)];
|
||||||
@ -1890,6 +1943,11 @@ begin
|
|||||||
RaiseNotApplicable();
|
RaiseNotApplicable();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TNullStackItem.CreateInt64Buffer(const AName : string; const AValue : Int64) : TJSONData;
|
||||||
|
begin
|
||||||
|
RaiseNotApplicable();
|
||||||
|
end;
|
||||||
|
|
||||||
function TNullStackItem.CreateFloatBuffer(const AName : string; const AValue : TJSONFloat) : TJSONData;
|
function TNullStackItem.CreateFloatBuffer(const AName : string; const AValue : TJSONFloat) : TJSONData;
|
||||||
begin
|
begin
|
||||||
RaiseNotApplicable();
|
RaiseNotApplicable();
|
||||||
|
@ -15,6 +15,16 @@
|
|||||||
{$DEFINE HAS_TKBOOL}
|
{$DEFINE HAS_TKBOOL}
|
||||||
{$UNDEF WST_INTF_DOM}
|
{$UNDEF WST_INTF_DOM}
|
||||||
//{$DEFINE USE_INLINE}
|
//{$DEFINE USE_INLINE}
|
||||||
|
{$IF Defined(FPC_VERSION) and
|
||||||
|
( (FPC_VERSION > 2) or
|
||||||
|
( (FPC_VERSION = 2) and
|
||||||
|
(FPC_RELEASE > 4)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
{ $DEFINE HAS_JSON_CLONE}
|
||||||
|
{$IFEND}
|
||||||
|
|
||||||
{$IF Defined(FPC_VERSION) and (FPC_VERSION = 2) }
|
{$IF Defined(FPC_VERSION) and (FPC_VERSION = 2) }
|
||||||
{$IF Defined(FPC_RELEASE) }
|
{$IF Defined(FPC_RELEASE) }
|
||||||
{$IF Defined(FPC_VERSION) and (FPC_RELEASE > 0) }
|
{$IF Defined(FPC_VERSION) and (FPC_RELEASE > 0) }
|
||||||
@ -22,6 +32,7 @@
|
|||||||
{$IF Defined(FPC_RELEASE) and (FPC_RELEASE > 2) }
|
{$IF Defined(FPC_RELEASE) and (FPC_RELEASE > 2) }
|
||||||
{$DEFINE WST_TKPROCVAR}
|
{$DEFINE WST_TKPROCVAR}
|
||||||
{$DEFINE WST_UNICODESTRING}
|
{$DEFINE WST_UNICODESTRING}
|
||||||
|
{$DEFINE WST_HAS_JSON_INT64}
|
||||||
{$IFEND}
|
{$IFEND}
|
||||||
{$IF Defined(FPC_RELEASE) and (FPC_RELEASE > 2) }
|
{$IF Defined(FPC_RELEASE) and (FPC_RELEASE > 2) }
|
||||||
{$DEFINE TDOMNodeList_RELEASE_NOT_FREE}
|
{$DEFINE TDOMNodeList_RELEASE_NOT_FREE}
|
||||||
|
Reference in New Issue
Block a user