Browse Source

* Some cleanup, fix warnings/hints

Michaël Van Canneyt 9 months ago
parent
commit
b8cc7fb175

+ 0 - 176
packages/fcl-jsonschema/src/fpjson.schema.schema.pp

@@ -415,165 +415,8 @@ Type
 
 
 implementation
 implementation
 
 
-uses FpJson.Schema.Consts;
-
-{ TSchemaValue }
-
-(*
-
-procedure TSchemaValue.SetSchema(AValue: TJSONSchema);
-begin
-  if FSchema=AValue then Exit;
-  FreeAndNil(Fschema);
-  FSchema:=AValue;
-  if Assigned(FSchema) then
-    begin
-    FreeAndNil(FValue);
-    FreeAndNil(FList);
-    end;
-  DoOnChanged;
-end;
-
-procedure TSchemaValue.SetList(AValue: TSchemaValueList);
-begin
-  if FList=AValue then Exit;
-  FreeAndNil(FList);
-  FList:=AValue;
-  if Assigned(FList) then
-    begin
-    FreeAndNil(FSchema);
-    FreeAndNil(FValue);
-    end;
-  DoOnChanged;
-end;
-
-procedure TSchemaValue.SetValue(AValue: TJSONData);
-begin
-  if FValue=AValue then Exit;
-  if aValue.JSONType in StructuredJSONTypes then
-    Raise EJSONSchema.Create(SErrOnlySimpleValues);
-  FreeAndNil(FValue);
-  FValue:=AValue;
-  if Assigned(FValue) then
-    begin
-    FreeAndNil(FSchema);
-    FreeAndNil(FList);
-    end;
-  DoOnChanged;
-end;
-
-procedure TSchemaValue.DoOnChanged;
-begin
-  If Assigned(FOnChange) then
-    FOnChange(Self);
-end;
-
-constructor TSchemaValue.Create;
-begin
-  // Assign nothing
-end;
-
-constructor TSchemaValue.Create(aValue: TJSONData);
-begin
-  FValue:=aValue;
-end;
-
-constructor TSchemaValue.Create(aSchema: TJSONSchema);
-begin
-  FSchema:=aSchema;
-end;
-
-constructor TSchemaValue.Create(aList: TSchemaValueList);
-begin
-  FList:=aList;
-end;
-
-destructor TSchemaValue.Destroy;
-begin
-  FreeAndNil(FValue);
-  FreeAndNil(FList);
-  FreeAndNil(FSchema);
-  inherited Destroy;
-end;
-
-procedure TSchemaValue.Clear;
-begin
-  SimpleValue:=Nil;
-  Schema:=Nil;
-  List:=Nil;
-end;
-
-function TSchemaValue.ValueType: TSchemaValueType;
-begin
-  Result:=svtEmpty;
-  if (FValue<>Nil) then
-    Result:=svtSimple
-  else if (FSchema<>Nil) then
-    Result:=svtSchema
-  else if (FList<>Nil) then
-    Result:=svtList;
-end;
-
-function TSchemaValue.IsEmpty: Boolean;
-begin
-  Result:=(FValue=Nil) and (FSchema=Nil) and (FList=Nil);
-end;
-
-function TSchemaValue.IsSimpleValue: Boolean;
-begin
-  Result:=(FValue<>Nil);
-end;
-
-function TSchemaValue.IsSchema: Boolean;
-begin
-  Result:=(FSchema<>Nil);
-end;
-
-function TSchemaValue.IsList: Boolean;
-begin
-  Result:=(FList<>Nil);
-end;
-
-{ TSchemaValueList }
-
-function TSchemaValueList.GetValue(aIndex : integer): TSchemaValue;
-begin
-  Result:=Items[aIndex] as TSchemaValue;
-end;
-
-procedure TSchemaValueList.SetValue(aIndex : integer; AValue: TSchemaValue);
-begin
-  Items[aIndex]:=aValue;
-end;
-
-procedure TSchemaValueList.DoOnAdd;
-begin
-  If assigned(FOnAdd) then FOnAdd(Self);
-end;
-
-constructor TSchemaValueList.create(aKeyword: TJSONSchemaKeyword);
-begin
-  Inherited Create(True);
-  FKeyword:=aKeyword;
-end;
-
-function TSchemaValueList.Add(aSchema: TJSONSchema): TSchemaValue;
-begin
-  Result:=TSchemaValue.Create(aSchema);
-  Inherited Add(Result);
-  DoOnAdd;
-end;
-
-function TSchemaValueList.Add(aValue: TJSONData): TSchemaValue;
-begin
-  Result:=TSchemaValue.Create(aValue);
-  Inherited Add(Result);
-  DoOnAdd;
-end;
-*)
 { TJSONSchemaMetadata }
 { TJSONSchemaMetadata }
 
 
-
 procedure TJSONSchemaMetadata.SetConstrained;
 procedure TJSONSchemaMetadata.SetConstrained;
 
 
 begin
 begin
@@ -581,17 +424,6 @@ begin
     Schema.MatchType:=smConstrained;
     Schema.MatchType:=smConstrained;
 end;
 end;
 
 
-(*
-function TJSONSchemaMetadata.GetDefaultValue: TSchemaValue;
-begin
-  if FDefaultValue=Nil then
-    begin
-    FDefaultValue:=TSchemaValue.Create(TJSONData(Nil));
-    SetConstrained;
-    end;
-  Result:=FDefaultValue;
-end;
-*)
 procedure TJSONSchemaMetadata.DoAddExample(Sender: TObject);
 procedure TJSONSchemaMetadata.DoAddExample(Sender: TObject);
 begin
 begin
   SetConstrained;
   SetConstrained;
@@ -606,14 +438,6 @@ begin
     SetKeywordData(jskDefault);
     SetKeywordData(jskDefault);
 end;
 end;
 
 
-(*
-procedure TJSONSchemaMetadata.DoValueChanged(Sender: TObject);
-begin
-  if not TSchemaValue(Sender).IsEmpty then
-    SetConstrained;
-end;
-*)
-
 procedure TJSONSchemaMetadata.SetDeprecated(AValue: Boolean);
 procedure TJSONSchemaMetadata.SetDeprecated(AValue: Boolean);
 begin
 begin
   SetKeywordData(jskDeprecated);
   SetKeywordData(jskDeprecated);

+ 1 - 0
packages/fcl-jsonschema/src/fpjson.schema.types.pp

@@ -434,6 +434,7 @@ var
   Kw : TJSONSchemaKeyword;
   Kw : TJSONSchemaKeyword;
   T : TJSONSubschema;
   T : TJSONSubschema;
 begin
 begin
+  kw:=Default(TJSONSchemaKeyword);
   Kw.AsString:=aValue;
   Kw.AsString:=aValue;
   For T in TJSONSubSchema do
   For T in TJSONSubSchema do
     if JSONSubschemaKeys[T]=kw then
     if JSONSubschemaKeys[T]=kw then

+ 1 - 0
packages/fcl-jsonschema/src/fpjson.schema.validator.pp

@@ -432,6 +432,7 @@ var
   OK : Boolean;
   OK : Boolean;
 
 
 begin
 begin
+  OK:=True;
   Result:=OK;
   Result:=OK;
 end;
 end;
 
 

+ 0 - 2
packages/fcl-jsonschema/src/fpjson.schema.writer.pp

@@ -64,8 +64,6 @@ Type
 
 
 implementation
 implementation
 
 
-uses FpJson.Schema.Consts;
-
 { TJSONSchemaWriter }
 { TJSONSchemaWriter }
 
 
 procedure TJSONSchemaWriter.WriteProperty(const aName: TJSONStringType; aValue: TJSONSchema);
 procedure TJSONSchemaWriter.WriteProperty(const aName: TJSONStringType; aValue: TJSONSchema);