Sfoglia il codice sorgente

[global] fixed more warnings & hints

Exilon 3 anni fa
parent
commit
a42fdae899

+ 6 - 2
Quick.Commons.pas

@@ -1,13 +1,13 @@
 { ***************************************************************************
 { ***************************************************************************
 
 
-  Copyright (c) 2016-2021 Kike P�rez
+  Copyright (c) 2016-2022 Kike P�rez
 
 
   Unit        : Quick.Commons
   Unit        : Quick.Commons
   Description : Common functions
   Description : Common functions
   Author      : Kike P�rez
   Author      : Kike P�rez
   Version     : 2.0
   Version     : 2.0
   Created     : 14/07/2017
   Created     : 14/07/2017
-  Modified    : 03/10/2021
+  Modified    : 19/01/2022
 
 
   This file is part of QuickLib: https://github.com/exilon/QuickLib
   This file is part of QuickLib: https://github.com/exilon/QuickLib
 
 
@@ -1042,7 +1042,11 @@ function GetLoggedUserName : string;
     {$IFDEF POSIX}
     {$IFDEF POSIX}
     try
     try
       plogin := getlogin;
       plogin := getlogin;
+      {$IFDEF NEXTGEN}
+      Result := string(plogin);
+      {$ELSE}
       Result := Copy(plogin,1,Length(Trim(plogin)));
       Result := Copy(plogin,1,Length(Trim(plogin)));
+      {$ENDIF}
     except
     except
       Result := 'N/A';
       Result := 'N/A';
     end;
     end;

+ 2 - 2
Quick.Config.Base.pas

@@ -59,7 +59,7 @@ type
     procedure Load(cConfig : TAppConfig); virtual; abstract;
     procedure Load(cConfig : TAppConfig); virtual; abstract;
     procedure Save(cConfig : TAppConfig); virtual; abstract;
     procedure Save(cConfig : TAppConfig); virtual; abstract;
   public
   public
-    constructor Create; virtual;
+    constructor Create;
     property CreateIfNotExists : Boolean read fCreateIfNotExists write fCreateIfNotExists;
     property CreateIfNotExists : Boolean read fCreateIfNotExists write fCreateIfNotExists;
     property SerializeLevel : TSerializeProperty read fSerializeLevel write fSerializeLevel;
     property SerializeLevel : TSerializeProperty read fSerializeLevel write fSerializeLevel;
     property UseEnumNames : Boolean read fUseEnumNames write fUseEnumNames;
     property UseEnumNames : Boolean read fUseEnumNames write fUseEnumNames;
@@ -75,7 +75,7 @@ type
   protected
   protected
     fProvider : TAppConfigProvider;
     fProvider : TAppConfigProvider;
   public
   public
-    constructor Create(aConfigProvider : TAppConfigProvider); virtual;
+    constructor Create(aConfigProvider : TAppConfigProvider);
     destructor Destroy; override;
     destructor Destroy; override;
     {$IFNDEF FPC}[TNotSerializableProperty]{$ENDIF}
     {$IFNDEF FPC}[TNotSerializableProperty]{$ENDIF}
     property OnApplyConfig : TApplyConfigEvent read fOnApplyConfig write fOnApplyConfig;
     property OnApplyConfig : TApplyConfigEvent read fOnApplyConfig write fOnApplyConfig;

+ 2 - 2
Quick.Config.YAML.pas

@@ -77,7 +77,7 @@ type
     procedure Load(cConfig : TAppConfig); override;
     procedure Load(cConfig : TAppConfig); override;
     procedure Save(cConfig : TAppConfig); override;
     procedure Save(cConfig : TAppConfig); override;
   public
   public
-    constructor Create(const aFilename : string; aReloadIfFileChanged : Boolean = False); virtual;
+    constructor Create(const aFilename : string; aReloadIfFileChanged : Boolean = False); overload;
     destructor Destroy; override;
     destructor Destroy; override;
     property Filename : string read fFilename write SetFileName;
     property Filename : string read fFilename write SetFileName;
     property ReloadIfFileChanged : Boolean read fReloadIfFileChanged write SetReloadIfFileChanged;
     property ReloadIfFileChanged : Boolean read fReloadIfFileChanged write SetReloadIfFileChanged;
@@ -92,7 +92,7 @@ type
     function GetProvider : TAppConfigYMALProvider;
     function GetProvider : TAppConfigYMALProvider;
     procedure ReloadNotify;
     procedure ReloadNotify;
   public
   public
-    constructor Create(const aFilename : string; aReloadIfFileChanged : Boolean = False); virtual;
+    constructor Create(const aFilename : string; aReloadIfFileChanged : Boolean = False);
     destructor Destroy; override;
     destructor Destroy; override;
     property Provider : TAppConfigYMALProvider read GetProvider;
     property Provider : TAppConfigYMALProvider read GetProvider;
     function ToYAML : string;
     function ToYAML : string;

+ 5 - 5
Quick.Data.Redis.pas

@@ -110,7 +110,7 @@ type
     function Command(const aCommand, aArgumentsFormat : string; aValues : array of const) : IRedisResponse; overload;
     function Command(const aCommand, aArgumentsFormat : string; aValues : array of const) : IRedisResponse; overload;
     function Command(const aCommand : string) : IRedisResponse; overload;
     function Command(const aCommand : string) : IRedisResponse; overload;
     function EscapeString(const json: string) : string;
     function EscapeString(const json: string) : string;
-    function BulkString(const aValue : string) : string;
+    //function BulkString(const aValue : string) : string;
   public
   public
     constructor Create;
     constructor Create;
     destructor Destroy; override;
     destructor Destroy; override;
@@ -275,10 +275,10 @@ begin
   //Result := StringReplace(Result,'/','\/"',[rfReplaceAll]);
   //Result := StringReplace(Result,'/','\/"',[rfReplaceAll]);
 end;
 end;
 
 
-function TRedisClient.BulkString(const aValue : string) : string;
-begin
-  Result := Format('$%d%s%s%s',[aValue.Length,CRLF,aValue,CRLF]);
-end;
+//function TRedisClient.BulkString(const aValue : string) : string;
+//begin
+//  Result := Format('$%d%s%s%s',[aValue.Length,CRLF,aValue,CRLF]);
+//end;
 
 
 procedure TRedisClient.SetConnectionTimeout(const Value: Integer);
 procedure TRedisClient.SetConnectionTimeout(const Value: Integer);
 begin
 begin

+ 2 - 0
Quick.HttpServer.Response.pas

@@ -62,6 +62,7 @@ type
     property ContentType : string read GetContentType write SetContentType;
     property ContentType : string read GetContentType write SetContentType;
   end;
   end;
 
 
+  {$M+}
   THttpResponse = class(TInterfacedObject,IHttpResponse)
   THttpResponse = class(TInterfacedObject,IHttpResponse)
   private
   private
     fHeaders : TPairList;
     fHeaders : TPairList;
@@ -94,6 +95,7 @@ type
     property ContentText : string read GetContentText write SetContentText;
     property ContentText : string read GetContentText write SetContentText;
     property ContentType : string read GetContentType write SetContentType;
     property ContentType : string read GetContentType write SetContentType;
   end;
   end;
+  {$M-}
 
 
 implementation
 implementation
 
 

+ 2 - 20
Quick.IOC.pas

@@ -1,13 +1,13 @@
 { ***************************************************************************
 { ***************************************************************************
 
 
-  Copyright (c) 2016-2021 Kike Pérez
+  Copyright (c) 2016-2022 Kike Pérez
 
 
   Unit        : Quick.IoC
   Unit        : Quick.IoC
   Description : IoC Dependency Injector
   Description : IoC Dependency Injector
   Author      : Kike Pérez
   Author      : Kike Pérez
   Version     : 1.0
   Version     : 1.0
   Created     : 19/10/2019
   Created     : 19/10/2019
-  Modified    : 07/02/2021
+  Modified    : 19/01/2022
 
 
   This file is part of QuickLib: https://github.com/exilon/QuickLib
   This file is part of QuickLib: https://github.com/exilon/QuickLib
 
 
@@ -185,7 +185,6 @@ type
     fResolver : TIocResolver;
     fResolver : TIocResolver;
     fInjector : TIocInjector;
     fInjector : TIocInjector;
     fLogger : ILogger;
     fLogger : ILogger;
-    function InterfaceTypeInfo(const AGUID : TGUID) : PTypeInfo;
   class var
   class var
     GlobalInstance: TIocContainer;
     GlobalInstance: TIocContainer;
   protected
   protected
@@ -334,23 +333,6 @@ begin
   inherited;
   inherited;
 end;
 end;
 
 
-function TIocContainer.InterfaceTypeInfo(const AGUID : TGUID) : PTypeInfo;
-var
-  ctx : TRttiContext;
-  rtype : TRttiType;
-  rtypei : TRttiInterfaceType;
-begin
-  for rtype in ctx.GetTypes do
-  begin
-    if rtype.TypeKind = TTypeKind.tkInterface then
-    begin
-      rtypei := (rtype as TRttiInterfaceType);
-      if IsEqualGUID(rtypei.GUID,AGUID) then Exit(rtypei.Handle);
-    end;
-  end;
-  Result := nil;
-end;
-
 function TIocContainer.IsRegistered<TInterface, TImplementation>(const aName: string): Boolean;
 function TIocContainer.IsRegistered<TInterface, TImplementation>(const aName: string): Boolean;
 begin
 begin
   Result := fRegistrator.IsRegistered<TInterface,TImplementation>(aName);
   Result := fRegistrator.IsRegistered<TInterface,TImplementation>(aName);

+ 4 - 4
Quick.Linq.pas

@@ -1,13 +1,13 @@
 { ***************************************************************************
 { ***************************************************************************
 
 
-  Copyright (c) 2016-2019 Kike Pérez
+  Copyright (c) 2016-2022 Kike Pérez
 
 
   Unit        : Quick.Linq
   Unit        : Quick.Linq
   Description : Arrays and Generic Lists Linq functions
   Description : Arrays and Generic Lists Linq functions
   Author      : Kike Pérez
   Author      : Kike Pérez
   Version     : 1.0
   Version     : 1.0
   Created     : 04/04/2019
   Created     : 04/04/2019
-  Modified    : 22/03/20120
+  Modified    : 19/01/2022
 
 
   This file is part of QuickLib: https://github.com/exilon/QuickLib
   This file is part of QuickLib: https://github.com/exilon/QuickLib
 
 
@@ -499,9 +499,9 @@ begin
       vtAnsiString : Result := StringReplace(Result,'?',string(aWhereParams[i].VAnsiString),[]);
       vtAnsiString : Result := StringReplace(Result,'?',string(aWhereParams[i].VAnsiString),[]);
       vtWideString : Result := StringReplace(Result,'?',string(aWhereParams[i].VWideString^),[]);
       vtWideString : Result := StringReplace(Result,'?',string(aWhereParams[i].VWideString^),[]);
       {$IFNDEF NEXTGEN}
       {$IFNDEF NEXTGEN}
-      vtString : Result := StringReplace(Result,'?',aWhereParams[i].VString^,[]);
+      vtString : Result := StringReplace(Result,'?',string(aWhereParams[i].VString^),[]);
       {$ENDIF}
       {$ENDIF}
-      vtChar : Result := StringReplace(Result,'?',aWhereParams[i].VChar,[]);
+      vtChar : Result := StringReplace(Result,'?',string(aWhereParams[i].VChar),[]);
       vtPChar : Result := StringReplace(Result,'?',string(aWhereParams[i].VPChar),[]);
       vtPChar : Result := StringReplace(Result,'?',string(aWhereParams[i].VPChar),[]);
     else Result := StringReplace(Result,'?', DbQuotedStr(string(aWhereParams[i].VUnicodeString)),[]);
     else Result := StringReplace(Result,'?', DbQuotedStr(string(aWhereParams[i].VUnicodeString)),[]);
     end;
     end;

+ 1 - 0
Quick.Log.pas

@@ -49,6 +49,7 @@ uses
   {$ENDIF}
   {$ENDIF}
   {$IF Defined(NEXTGEN) OR Defined(LINUX) or Defined(MACOS)}
   {$IF Defined(NEXTGEN) OR Defined(LINUX) or Defined(MACOS)}
   syncObjs,
   syncObjs,
+  Posix.Unistd,
   {$ENDIF}
   {$ENDIF}
   SysUtils;
   SysUtils;
 
 

+ 6 - 0
Quick.Logger.Intf.pas

@@ -84,6 +84,7 @@ type
     procedure &Except(const aMsg : string; aValues : array of const); overload;
     procedure &Except(const aMsg : string; aValues : array of const); overload;
     procedure &Except(const aMsg, aException, aStackTrace : string); overload;
     procedure &Except(const aMsg, aException, aStackTrace : string); overload;
     procedure &Except(const aMsg : string; aValues: array of const; const aException, aStackTrace: string); overload;
     procedure &Except(const aMsg : string; aValues: array of const; const aException, aStackTrace: string); overload;
+    procedure &Except(MsgObject : TObject); overload;
   end;
   end;
 
 
 implementation
 implementation
@@ -151,6 +152,11 @@ begin
 
 
 end;
 end;
 
 
+procedure TNullLogger.&Except(MsgObject: TObject);
+begin
+
+end;
+
 procedure TNullLogger.Critical(const aMsg: string; aParams: array of const);
 procedure TNullLogger.Critical(const aMsg: string; aParams: array of const);
 begin
 begin
 
 

+ 1 - 1
Quick.Options.Serializer.Json.pas

@@ -7,7 +7,7 @@
   Author      : Kike Pérez
   Author      : Kike Pérez
   Version     : 1.0
   Version     : 1.0
   Created     : 18/10/2019
   Created     : 18/10/2019
-  Modified    : 30/08/2021
+  Modified    : 15/12/2021
 
 
   This file is part of QuickLib: https://github.com/exilon/QuickLib
   This file is part of QuickLib: https://github.com/exilon/QuickLib
 
 

+ 1 - 1
Quick.Options.Serializer.Yaml.pas

@@ -7,7 +7,7 @@
   Author      : Kike Pérez
   Author      : Kike Pérez
   Version     : 1.0
   Version     : 1.0
   Created     : 18/10/2019
   Created     : 18/10/2019
-  Modified    : 05/04/2020
+  Modified    : 15/12/2021
 
 
   This file is part of QuickLib: https://github.com/exilon/QuickLib
   This file is part of QuickLib: https://github.com/exilon/QuickLib
 
 

+ 2 - 0
Quick.Parameters.pas

@@ -123,6 +123,7 @@ type
   end;
   end;
   {$ENDIF}
   {$ENDIF}
 
 
+  {$M+}
   TParameters = class
   TParameters = class
   type
   type
     TValueType = (vtString, vtInteger, vtFloat, vtBoolean, vtEnumeration);
     TValueType = (vtString, vtInteger, vtFloat, vtBoolean, vtEnumeration);
@@ -188,6 +189,7 @@ type
     property Help : Boolean read fHelp write fHelp;
     property Help : Boolean read fHelp write fHelp;
     function ExistsParam(const aParam : string): Boolean; overload;
     function ExistsParam(const aParam : string): Boolean; overload;
   end;
   end;
+  {$M-}
 
 
   TServiceParameters = class(TParameters)
   TServiceParameters = class(TParameters)
   private
   private

+ 153 - 9
Quick.Threads.pas

@@ -7,7 +7,7 @@
   Author      : Kike Pérez
   Author      : Kike Pérez
   Version     : 1.5
   Version     : 1.5
   Created     : 09/03/2018
   Created     : 09/03/2018
-  Modified    : 08/03/2021
+  Modified    : 08/09/2021
 
 
   This file is part of QuickLib: https://github.com/exilon/QuickLib
   This file is part of QuickLib: https://github.com/exilon/QuickLib
 
 
@@ -149,6 +149,17 @@ type
 
 
   TThreadWorkStatus = (wsRunning, wsDone, wsException);
   TThreadWorkStatus = (wsRunning, wsDone, wsException);
 
 
+  TSimpleThread = class(TThread)
+  private
+    fExecuteProc : TProc;
+    fTimeoutFlag : TLightweightEvent;
+  public
+    constructor Create(aProc: TProc; aCreateSuspended, aFreeOnTerminate : Boolean);
+    destructor Destroy; override;
+    procedure Execute; override;
+    function WaitFor(const aTimeout : Cardinal) : TWaitResult; overload;
+  end;
+
   TAdvThread = class(TThread)
   TAdvThread = class(TThread)
   private
   private
     fExecuteProc : TProc;
     fExecuteProc : TProc;
@@ -521,6 +532,42 @@ type
     class function Execute_Sync(aParamArray: array of const; aOwnedParams: Boolean; aTaskProc: TTaskProc): IWorkTask; overload;
     class function Execute_Sync(aParamArray: array of const; aOwnedParams: Boolean; aTaskProc: TTaskProc): IWorkTask; overload;
   end;
   end;
 
 
+  IAsyncTask = interface
+  ['{90A27D06-6FCD-493C-8AA0-C52C5105ED8B}']
+    procedure Wait; overload;
+    procedure Wait(const aTimeout : Cardinal); overload;
+  end;
+
+  TAsyncTask = class(TInterfacedObject,IAsyncTask)
+  private
+    fProcess : TSimpleThread;
+    constructor Create(aAction : TProc);
+  public
+    class function Run(const aAction : TProc) : IAsyncTask; virtual;
+    procedure Wait; overload;
+    procedure Wait(const aTimeout : Cardinal); overload;
+    destructor Destroy; override;
+  end;
+
+  IAsyncTask<T> = interface
+  ['{8529BBD4-B5AD-4674-8E42-3C74F5156A97}']
+    function Result : T; overload;
+    function Result(const aTimeout : Cardinal) : T; overload;
+  end;
+
+  TAsyncTask<T> = class(TInterfacedObject,IAsyncTask<T>)
+  private
+    fProcess : TSimpleThread;
+    fTaskResult : T;
+    fWaitForResult : Boolean;
+    function Result : T; overload;
+    function Result(const aTimeout : Cardinal) : T; overload;
+    constructor Create(aAction : TFunc<T>);
+  public
+    class function Run(const aAction : TFunc<T>) : IAsyncTask<T>; virtual;
+    destructor Destroy; override;
+  end;
+
   TBackgroundTasks = class
   TBackgroundTasks = class
   private
   private
     fMaxQueue : Integer;
     fMaxQueue : Integer;
@@ -600,7 +647,6 @@ type
     fWorkerRetryProc : TTaskRetryProc;
     fWorkerRetryProc : TTaskRetryProc;
     fWorkerExceptionProc : TTaskExceptionProc;
     fWorkerExceptionProc : TTaskExceptionProc;
     fWorkerTerminateProc : TTaskProc;
     fWorkerTerminateProc : TTaskProc;
-    fMaxRetries : Integer;
     fFaultPolicy : TFaultPolicy;
     fFaultPolicy : TFaultPolicy;
     procedure SetRetryPolicy(aMaxRetries, aWaitTimeBetweenRetriesMS : Integer; aWaitTimeMultiplierFactor: Double);
     procedure SetRetryPolicy(aMaxRetries, aWaitTimeBetweenRetriesMS : Integer; aWaitTimeMultiplierFactor: Double);
   public
   public
@@ -614,7 +660,6 @@ type
     function Retry(aMaxRetries : Integer) : TBackgroundWorkers;
     function Retry(aMaxRetries : Integer) : TBackgroundWorkers;
     function RetryForever : TBackgroundWorkers;
     function RetryForever : TBackgroundWorkers;
     function WaitAndRetry(aMaxRetries, aWaitTimeBetweenRetriesMS : Integer) : TBackgroundWorkers; overload;
     function WaitAndRetry(aMaxRetries, aWaitTimeBetweenRetriesMS : Integer) : TBackgroundWorkers; overload;
-    function WaitAndRetry(aWaitTimeArray : TArray<Integer>) : TBackgroundWorkers; overload;
     function WaitAndRetry(aMaxRetries, aWaitTimeBetweenRetriesMS : Integer; aWaitTimeMultiplierFactor : Double) : TBackgroundWorkers; overload;
     function WaitAndRetry(aMaxRetries, aWaitTimeBetweenRetriesMS : Integer; aWaitTimeMultiplierFactor : Double) : TBackgroundWorkers; overload;
     function WaitAndRetryForever(aWaitTimeBetweenRetriesMS : Integer) : TBackgroundWorkers; overload;
     function WaitAndRetryForever(aWaitTimeBetweenRetriesMS : Integer) : TBackgroundWorkers; overload;
     function WaitAndRetryForever(aWaitTimeBetweenRetriesMS : Integer; aWaitTimeMultiplierFactor : Double) : TBackgroundWorkers; overload;
     function WaitAndRetryForever(aWaitTimeBetweenRetriesMS : Integer; aWaitTimeMultiplierFactor : Double) : TBackgroundWorkers; overload;
@@ -2314,6 +2359,72 @@ begin
   worker.Start;
   worker.Start;
 end;
 end;
 
 
+{ TAsyncTask }
+
+constructor TAsyncTask.Create(aAction : TProc);
+begin
+  fProcess := TSimpleThread.Create(aAction,False,True);
+end;
+
+destructor TAsyncTask.Destroy;
+begin
+  inherited;
+end;
+
+class function TAsyncTask.Run(const aAction : TProc) : IAsyncTask;
+begin
+  Result := TAsyncTask.Create(aAction);
+end;
+
+procedure TAsyncTask.Wait(const aTimeout: Cardinal);
+begin
+  if aTimeout = 0 then fProcess.WaitFor
+    else fProcess.WaitFor(aTimeout);
+end;
+
+procedure TAsyncTask.Wait;
+begin
+  fProcess.WaitFor;
+end;
+
+{ TAsyncTask<T> }
+
+constructor TAsyncTask<T>.Create(aAction: TFunc<T>);
+begin
+  fWaitForResult := False;
+  fProcess := TSimpleThread.Create(procedure
+                                begin
+                                  fTaskResult := aAction();
+                                end,False,False);
+end;
+
+destructor TAsyncTask<T>.Destroy;
+begin
+  if not fWaitForResult then fProcess.FreeOnTerminate := True;
+  inherited;
+end;
+
+class function TAsyncTask<T>.Run(const aAction: TFunc<T>): IAsyncTask<T>;
+begin
+  Result := TAsyncTask<T>.Create(aAction);
+end;
+
+function TAsyncTask<T>.Result: T;
+begin
+  fWaitForResult := True;
+  fProcess.WaitFor;
+  Result := fTaskResult;
+  fProcess.Free;
+end;
+
+function TAsyncTask<T>.Result(const aTimeout: Cardinal): T;
+begin
+  fWaitForResult := True;
+  fProcess.WaitFor(aTimeout);
+  Result := fTaskResult;
+  fProcess.Free;
+end;
+
 { TParamValue }
 { TParamValue }
 
 
 constructor TParamValue.Create(const aName: string; aValue: TFlexValue; aOwnedValue: Boolean);
 constructor TParamValue.Create(const aName: string; aValue: TFlexValue; aOwnedValue: Boolean);
@@ -2440,27 +2551,60 @@ end;
 
 
 function TBackgroundWorkers.WaitAndRetry(aMaxRetries, aWaitTimeBetweenRetriesMS: Integer; aWaitTimeMultiplierFactor: Double): TBackgroundWorkers;
 function TBackgroundWorkers.WaitAndRetry(aMaxRetries, aWaitTimeBetweenRetriesMS: Integer; aWaitTimeMultiplierFactor: Double): TBackgroundWorkers;
 begin
 begin
-
+  Result := Self;
+  SetRetryPolicy(aMaxRetries,aWaitTimeBetweenRetriesMS,aWaitTimeMultiplierFactor);
 end;
 end;
 
 
-function TBackgroundWorkers.WaitAndRetry(aWaitTimeArray: TArray<Integer>): TBackgroundWorkers;
+function TBackgroundWorkers.WaitAndRetry(aMaxRetries, aWaitTimeBetweenRetriesMS: Integer): TBackgroundWorkers;
 begin
 begin
-
+  Result := Self;
+  SetRetryPolicy(aMaxRetries,aWaitTimeBetweenRetriesMS,1);
 end;
 end;
 
 
-function TBackgroundWorkers.WaitAndRetry(aMaxRetries, aWaitTimeBetweenRetriesMS: Integer): TBackgroundWorkers;
+function TBackgroundWorkers.WaitAndRetryForever(aWaitTimeBetweenRetriesMS: Integer): TBackgroundWorkers;
 begin
 begin
+  Result := Self;
+  SetRetryPolicy(-1,aWaitTimeBetweenRetriesMS,1);
+end;
 
 
+function TBackgroundWorkers.WaitAndRetryForever(aWaitTimeBetweenRetriesMS: Integer; aWaitTimeMultiplierFactor: Double): TBackgroundWorkers;
+begin
+  Result := Self;
+  SetRetryPolicy(-1,aWaitTimeBetweenRetriesMS,aWaitTimeMultiplierFactor);
 end;
 end;
 
 
-function TBackgroundWorkers.WaitAndRetryForever(aWaitTimeBetweenRetriesMS: Integer): TBackgroundWorkers;
+{ TSimpleThread }
+
+constructor TSimpleThread.Create(aProc: TProc; aCreateSuspended, aFreeOnTerminate : Boolean);
 begin
 begin
+  if not Assigned(aProc) then raise EArgumentNilException.Create('param cannot be nil!');
+  fTimeoutFlag := TLightweightEvent.Create;
+  fTimeoutFlag.ResetEvent;
+  fExecuteProc := aProc;
+  inherited Create(aCreateSuspended);
+  Self.FreeOnTerminate := aFreeOnTerminate;
+end;
 
 
+destructor TSimpleThread.Destroy;
+begin
+  if Assigned(fTimeoutFlag) then
+  begin
+    fTimeoutFlag.Release;
+    fTimeoutFlag.Free;
+  end;
+  inherited;
 end;
 end;
 
 
-function TBackgroundWorkers.WaitAndRetryForever(aWaitTimeBetweenRetriesMS: Integer; aWaitTimeMultiplierFactor: Double): TBackgroundWorkers;
+procedure TSimpleThread.Execute;
 begin
 begin
+  fExecuteProc;
+  fTimeoutFlag.SetEvent;
+end;
 
 
+function TSimpleThread.WaitFor(const aTimeout: Cardinal) : TWaitResult;
+begin
+  Result := fTimeoutFlag.WaitFor(aTimeout);
+  if Result = TWaitResult.wrTimeout then raise Exception.Create('Timeout');
 end;
 end;
 
 
 end.
 end.

+ 1 - 1
Quick.Value.RTTI.pas

@@ -106,7 +106,7 @@ begin
       dtBoolean : Result := AsBoolean;
       dtBoolean : Result := AsBoolean;
       dtString : Result := AsString;
       dtString : Result := AsString;
       {$IFDEF MSWINDOWS}
       {$IFDEF MSWINDOWS}
-      dtAnsiString : Result := AsAnsiString;
+      dtAnsiString : Result := string(AsAnsiString);
       dtWideString : Result := AsWideString;
       dtWideString : Result := AsWideString;
       {$ENDIF}
       {$ENDIF}
       dtInteger,
       dtInteger,

+ 54 - 58
Quick.YAML.Serializer.pas

@@ -1,4 +1,4 @@
-{ ***************************************************************************
+{ ***************************************************************************
   Copyright (c) 2015-2021 Kike P�rez
   Copyright (c) 2015-2021 Kike P�rez
   Unit        : Quick.YAML.Serializer
   Unit        : Quick.YAML.Serializer
   Description : YAML Serializer
   Description : YAML Serializer
@@ -86,20 +86,20 @@ type
     fUseEnumNames : Boolean;
     fUseEnumNames : Boolean;
     fUseYamlCaseSense : Boolean;
     fUseYamlCaseSense : Boolean;
     function GetValue(aAddr: Pointer; aType: TRTTIType): TValue; overload;
     function GetValue(aAddr: Pointer; aType: TRTTIType): TValue; overload;
-    function GetValue(aAddr: Pointer; aTypeInfo: PTypeInfo): TValue; overload;
+    //function GetValue(aAddr: Pointer; aTypeInfo: PTypeInfo): TValue; overload;
     function IsAllowedProperty(aObject : TObject; const aPropertyName : string) : Boolean;
     function IsAllowedProperty(aObject : TObject; const aPropertyName : string) : Boolean;
     function IsGenericList(aObject : TObject) : Boolean;
     function IsGenericList(aObject : TObject) : Boolean;
     function IsGenericXArray(const aClassName : string) : Boolean;
     function IsGenericXArray(const aClassName : string) : Boolean;
-    function GetPropertyValue(Instance : TObject; const PropertyName : string) : TValue;
+    //function GetPropertyValue(Instance : TObject; const PropertyName : string) : TValue;
     function GetPropertyValueFromObject(Instance : TObject; const PropertyName : string) : TValue;
     function GetPropertyValueFromObject(Instance : TObject; const PropertyName : string) : TValue;
     {$IFNDEF FPC}
     {$IFNDEF FPC}
     function GetFieldValueFromRecord(aValue : TValue; const FieldName : string) : TValue;
     function GetFieldValueFromRecord(aValue : TValue; const FieldName : string) : TValue;
     function CreateInstance(aClass: TClass): TValue; overload;
     function CreateInstance(aClass: TClass): TValue; overload;
     function CreateInstance(aType: TRttiType): TValue; overload;
     function CreateInstance(aType: TRttiType): TValue; overload;
     {$ENDIF}
     {$ENDIF}
+    {$IFDEF FPC}
     procedure SetPropertyValue(Instance : TObject; aPropInfo : PPropInfo; aValue : TValue); overload;
     procedure SetPropertyValue(Instance : TObject; aPropInfo : PPropInfo; aValue : TValue); overload;
     procedure SetPropertyValue(Instance : TObject; const PropertyName : string; aValue : TValue); overload;
     procedure SetPropertyValue(Instance : TObject; const PropertyName : string; aValue : TValue); overload;
-    {$IFDEF FPC}
     function FloatProperty(aObject : TObject; aPropInfo: PPropInfo): string;
     function FloatProperty(aObject : TObject; aPropInfo: PPropInfo): string;
     function GetPropType(aPropInfo: PPropInfo): PTypeInfo;
     function GetPropType(aPropInfo: PPropInfo): PTypeInfo;
     procedure LoadSetProperty(aInstance : TObject; aPropInfo: PPropInfo; const aValue: string);
     procedure LoadSetProperty(aInstance : TObject; aPropInfo: PPropInfo; const aValue: string);
@@ -397,11 +397,6 @@ begin
 end;
 end;
 
 
 function TRTTIYaml.DeserializeClass(aType: TClass; const aYaml: TYamlObject): TObject;
 function TRTTIYaml.DeserializeClass(aType: TClass; const aYaml: TYamlObject): TObject;
-var
-  Ctx: TRttiContext;
-  rType: TRttiType;
-  mType: TRTTIMethod;
-  metaClass: TClass;
 begin
 begin
   Result := nil;
   Result := nil;
   if (aYaml = nil) or ((aYaml as TYamlValue) is TYamlNull) or (aYaml.Count = 0) then Exit;
   if (aYaml = nil) or ((aYaml as TYamlValue) is TYamlNull) or (aYaml.Count = 0) then Exit;
@@ -459,7 +454,7 @@ begin
             begin
             begin
               DeserializeList(rProp.GetValue(aObject).AsObject,'List',TYamlObject(aYaml.GetValue(propertyname)));
               DeserializeList(rProp.GetValue(aObject).AsObject,'List',TYamlObject(aYaml.GetValue(propertyname)));
             end
             end
-            else if (not rProp.GetValue(aObject).IsObject) and (IsGenericXArray(rProp.GetValue(aObject){$IFNDEF NEXTGEN}.TypeInfo.Name{$ELSE}.TypeInfo.NameFld.ToString{$ENDIF})) then
+            else if (not rProp.GetValue(aObject).IsObject) and (IsGenericXArray(string(rProp.GetValue(aObject){$IFNDEF NEXTGEN}.TypeInfo.Name{$ELSE}.TypeInfo.NameFld.ToString{$ENDIF}))) then
             begin
             begin
               DeserializeXArray(Result,rProp.GetValue(aObject),rProp,propertyname,aYaml);
               DeserializeXArray(Result,rProp.GetValue(aObject),rProp,propertyname,aYaml);
             end
             end
@@ -864,6 +859,7 @@ var
   yvalue : TYamlValue;
   yvalue : TYamlValue;
   i : Integer;
   i : Integer;
 begin
 begin
+  Result := nil;
   if fUseYamlCaseSense then
   if fUseYamlCaseSense then
   begin
   begin
     yvalue := aYaml.GetValue(aName);
     yvalue := aYaml.GetValue(aName);
@@ -884,48 +880,48 @@ begin
   Result := nil;
   Result := nil;
 end;
 end;
 
 
-function TRTTIYaml.GetPropertyValue(Instance : TObject; const PropertyName : string) : TValue;
-var
-  pinfo : PPropInfo;
-begin
-  Result := nil;
-  pinfo := GetPropInfo(Instance,PropertyName);
-  case pinfo.PropType^.Kind of
-    tkInteger : Result := GetOrdProp(Instance,pinfo);
-    tkInt64 : Result := GetInt64Prop(Instance,PropertyName);
-    tkFloat : Result := GetFloatProp(Instance,PropertyName);
-    tkChar : Result := Char(GetOrdProp(Instance,PropertyName));
-    {$IFDEF FPC}
-    tkWString : Result := GetWideStrProp(Instance,PropertyName);
-    tkSString,
-    tkAString,
-    {$ELSE}
-    tkWString,
-    {$ENDIF}
-    tkLString : Result := GetStrProp(Instance,pinfo);
-    {$IFDEF FPC}
-    tkEnumeration :
-      begin
-        if fUseEnumNames then Result := GetEnumName(pinfo.PropType,GetOrdProp(Instance,PropertyName))
-          else Result := GetOrdProp(Instance,PropertyName);
-      end;
-    {$ELSE}
-    tkEnumeration :
-      begin
-        if fUseEnumNames then Result := GetEnumName(@pinfo.PropType,GetOrdProp(Instance,PropertyName))
-          else Result := GetOrdProp(Instance,PropertyName);
-      end;
-    {$ENDIF}
-    tkSet : Result := GetSetProp(Instance,pinfo,True);
-    {$IFNDEF FPC}
-    tkClass :
-    {$ELSE}
-    tkBool : Result := Boolean(GetOrdProp(Instance,pinfo));
-    tkObject :
-    {$ENDIF} Result := GetObjectProp(Instance,pinfo);
-    tkDynArray : Result := GetDynArrayProp(Instance,pinfo);
-  end;
-end;
+//function TRTTIYaml.GetPropertyValue(Instance : TObject; const PropertyName : string) : TValue;
+//var
+//  pinfo : PPropInfo;
+//begin
+//  Result := nil;
+//  pinfo := GetPropInfo(Instance,PropertyName);
+//  case pinfo.PropType^.Kind of
+//    tkInteger : Result := GetOrdProp(Instance,pinfo);
+//    tkInt64 : Result := GetInt64Prop(Instance,PropertyName);
+//    tkFloat : Result := GetFloatProp(Instance,PropertyName);
+//    tkChar : Result := Char(GetOrdProp(Instance,PropertyName));
+//    {$IFDEF FPC}
+//    tkWString : Result := GetWideStrProp(Instance,PropertyName);
+//    tkSString,
+//    tkAString,
+//    {$ELSE}
+//    tkWString,
+//    {$ENDIF}
+//    tkLString : Result := GetStrProp(Instance,pinfo);
+//    {$IFDEF FPC}
+//    tkEnumeration :
+//      begin
+//        if fUseEnumNames then Result := GetEnumName(pinfo.PropType,GetOrdProp(Instance,PropertyName))
+//          else Result := GetOrdProp(Instance,PropertyName);
+//      end;
+//    {$ELSE}
+//    tkEnumeration :
+//      begin
+//        if fUseEnumNames then Result := GetEnumName(@pinfo.PropType,GetOrdProp(Instance,PropertyName))
+//          else Result := GetOrdProp(Instance,PropertyName);
+//      end;
+//    {$ENDIF}
+//    tkSet : Result := GetSetProp(Instance,pinfo,True);
+//    {$IFNDEF FPC}
+//    tkClass :
+//    {$ELSE}
+//    tkBool : Result := Boolean(GetOrdProp(Instance,pinfo));
+//    tkObject :
+//    {$ENDIF} Result := GetObjectProp(Instance,pinfo);
+//    tkDynArray : Result := GetDynArrayProp(Instance,pinfo);
+//  end;
+//end;
 
 
 function TRTTIYaml.GetPropertyValueFromObject(Instance : TObject; const PropertyName : string) : TValue;
 function TRTTIYaml.GetPropertyValueFromObject(Instance : TObject; const PropertyName : string) : TValue;
 var
 var
@@ -984,6 +980,7 @@ begin
 end;
 end;
 {$ENDIF}
 {$ENDIF}
 
 
+{$IFDEF FPC}
 procedure TRTTIYaml.SetPropertyValue(Instance : TObject; const PropertyName : string; aValue : TValue);
 procedure TRTTIYaml.SetPropertyValue(Instance : TObject; const PropertyName : string; aValue : TValue);
 var
 var
   pinfo : PPropInfo;
   pinfo : PPropInfo;
@@ -1020,7 +1017,6 @@ begin
   end;
   end;
 end;
 end;
 
 
-{$IFDEF FPC}
 procedure TRTTIYaml.LoadSetProperty(aInstance : TObject; aPropInfo: PPropInfo; const aValue: string);
 procedure TRTTIYaml.LoadSetProperty(aInstance : TObject; aPropInfo: PPropInfo; const aValue: string);
 type
 type
   TCardinalSet = set of 0..SizeOf(Cardinal) * 8 - 1;
   TCardinalSet = set of 0..SizeOf(Cardinal) * 8 - 1;
@@ -1101,7 +1097,7 @@ begin
                 ypair := Serialize(propertyname,GetPropertyValueFromObject(rProp.GetValue(aObject).AsObject,'List'));
                 ypair := Serialize(propertyname,GetPropertyValueFromObject(rProp.GetValue(aObject).AsObject,'List'));
               end
               end
               {$IFNDEF FPC}
               {$IFNDEF FPC}
-              else if (not rProp.GetValue(aObject).IsObject) and (IsGenericXArray(rProp.GetValue(aObject){$IFNDEF NEXTGEN}.TypeInfo.Name{$ELSE}.TypeInfo.NameFld.ToString{$ENDIF})) then
+              else if (not rProp.GetValue(aObject).IsObject) and (IsGenericXArray(string(rProp.GetValue(aObject){$IFNDEF NEXTGEN}.TypeInfo.Name{$ELSE}.TypeInfo.NameFld.ToString{$ENDIF}))) then
               begin
               begin
                 ypair := Serialize(propertyname,GetFieldValueFromRecord(rProp.GetValue(aObject),'fArray'));
                 ypair := Serialize(propertyname,GetFieldValueFromRecord(rProp.GetValue(aObject),'fArray'));
               end
               end
@@ -1143,10 +1139,10 @@ begin
   TValue.Make(aAddr,aType.Handle,Result);
   TValue.Make(aAddr,aType.Handle,Result);
 end;
 end;
 
 
-function TRTTIYaml.GetValue(aAddr: Pointer; aTypeInfo: PTypeInfo): TValue;
-begin
-  TValue.Make(aAddr,aTypeInfo,Result);
-end;
+//function TRTTIYaml.GetValue(aAddr: Pointer; aTypeInfo: PTypeInfo): TValue;
+//begin
+//  TValue.Make(aAddr,aTypeInfo,Result);
+//end;
 
 
 {$IFNDEF FPC}
 {$IFNDEF FPC}
 function TRTTIYaml.Serialize(const aName : string; aValue : TValue) : TYamlPair;
 function TRTTIYaml.Serialize(const aName : string; aValue : TValue) : TYamlPair;

+ 27 - 8
Quick.YAML.pas

@@ -186,7 +186,6 @@ type
     class function ParsePairValue(const aPair : string) : string;
     class function ParsePairValue(const aPair : string) : string;
     class function ParseArrayValue(const aValue : string) : TYamlValue;
     class function ParseArrayValue(const aValue : string) : TYamlValue;
     class function GetItemLevel(const aValue : string) : Integer;
     class function GetItemLevel(const aValue : string) : Integer;
-    function InSameLevel(const aValue1, aValue2 : string) : Boolean;
     function ParseToYaml(aIndent : Integer) : string;
     function ParseToYaml(aIndent : Integer) : string;
   protected
   protected
     procedure AddDescendant(const aDescendent: TYamlAncestor); override;
     procedure AddDescendant(const aDescendent: TYamlAncestor); override;
@@ -208,6 +207,7 @@ type
     function GetEnumerator: TEnumerator; inline;
     function GetEnumerator: TEnumerator; inline;
     property Pairs[const aIndex: Integer]: TYamlPair read GetPair;
     property Pairs[const aIndex: Integer]: TYamlPair read GetPair;
     function ToYaml : string;
     function ToYaml : string;
+    function AsString : string; override;
   end;
   end;
 
 
   { TYamlArray }
   { TYamlArray }
@@ -239,6 +239,7 @@ type
     property Items[const aIndex: Integer]: TYamlValue read GetValue;
     property Items[const aIndex: Integer]: TYamlValue read GetValue;
     procedure AddElement(const aElement: TYamlValue);
     procedure AddElement(const aElement: TYamlValue);
     function GetEnumerator: TEnumerator; inline;
     function GetEnumerator: TEnumerator; inline;
+    function AsString : string; override;
   end;
   end;
 
 
   EYAMLException = class(Exception);
   EYAMLException = class(Exception);
@@ -298,6 +299,11 @@ begin
   Result := Self;
   Result := Self;
 end;
 end;
 
 
+function TYamlObject.AsString: string;
+begin
+  Result := ToYaml;
+end;
+
 constructor TYamlObject.Create(const aData: string);
 constructor TYamlObject.Create(const aData: string);
 begin
 begin
   inherited Create;
   inherited Create;
@@ -393,11 +399,6 @@ begin
   Result := nil;
   Result := nil;
 end;
 end;
 
 
-function TYamlObject.InSameLevel(const aValue1, aValue2: string): Boolean;
-begin
-  Result := GetItemLevel(aValue1) = GetItemLevel(aValue2);
-end;
-
 class function TYamlObject.ParseArrayValue(const aValue: string): TYamlValue;
 class function TYamlObject.ParseArrayValue(const aValue: string): TYamlValue;
 var
 var
   nint : Int64;
   nint : Int64;
@@ -430,6 +431,8 @@ var
   aitem : string;
   aitem : string;
   yamlType : TYamlType;
   yamlType : TYamlType;
 begin
 begin
+  Result := nil;
+  level := 0;
   while yaml.Count > vIndex do
   while yaml.Count > vIndex do
   begin
   begin
     value := yaml[vIndex].Trim;
     value := yaml[vIndex].Trim;
@@ -453,7 +456,8 @@ begin
       value := ParsePairValue(value);
       value := ParsePairValue(value);
       if (value.StartsWith('[')) and (value.EndsWith(']')) then yamlType := ytScalarArray
       if (value.StartsWith('[')) and (value.EndsWith(']')) then yamlType := ytScalarArray
         else yamlType := ytScalar;
         else yamlType := ytScalar;
-    end;
+    end
+    else yamlType := TYamlType.ytScalar;
 
 
     case yamlType of
     case yamlType of
       ytArray : //is array
       ytArray : //is array
@@ -881,6 +885,20 @@ begin
   if aElement <> nil then AddDescendant(aElement);
   if aElement <> nil then AddDescendant(aElement);
 end;
 end;
 
 
+function TYamlArray.AsString: string;
+var
+  first : Boolean;
+  element : TYamlValue;
+begin
+  first := True;
+  for element in fElements do
+  begin
+    if first then Result := Result + element.AsString
+      else  Result := Result + ',' + element.AsString;
+  end;
+  Result := Format('[%s]',[Result]);
+end;
+
 destructor TYamlArray.Destroy;
 destructor TYamlArray.Destroy;
 var
 var
   element: TYamlAncestor;
   element: TYamlAncestor;
@@ -920,6 +938,7 @@ var
   isscalar : Boolean;
   isscalar : Boolean;
 begin
 begin
   Result := '';
   Result := '';
+  yvalue := nil;
   yaml := TYamlWriter.Create;
   yaml := TYamlWriter.Create;
   try
   try
     indent := StringOfChar(' ',aIndent);
     indent := StringOfChar(' ',aIndent);
@@ -953,7 +972,7 @@ begin
       end;
       end;
       yaml.Writeln('');
       yaml.Writeln('');
     end;
     end;
-    if yvalue.IsScalar then
+    if (yvalue <> nil) and (yvalue.IsScalar) then
     begin
     begin
       Result := '[' + Result + ']';
       Result := '[' + Result + ']';
       vIsScalar := True;
       vIsScalar := True;

+ 20 - 20
QuickLib.inc

@@ -70,78 +70,78 @@
     {$endif LINUX}
     {$endif LINUX}
     {$if CompilerVersion >= 17}
     {$if CompilerVersion >= 17}
       {$define DELPHI2005_UP} //Delphi 2005 or newer
       {$define DELPHI2005_UP} //Delphi 2005 or newer
-    {$ifend}
+    {$endif}
     {$if CompilerVersion >= 18}
     {$if CompilerVersion >= 18}
       {$define DELPHI2006_UP} //Delphi 2006 or newer
       {$define DELPHI2006_UP} //Delphi 2006 or newer
       {$define HASINLINE}
       {$define HASINLINE}
-    {$ifend}
+    {$endif}
     {$if CompilerVersion > 18}
     {$if CompilerVersion > 18}
       {$define DELPHI2007_UP} //Delphi 2007 or newer
       {$define DELPHI2007_UP} //Delphi 2007 or newer
-    {$ifend}
+    {$endif}
     {$if CompilerVersion = 20}
     {$if CompilerVersion = 20}
       {$define DELPHI2009_UP} //Delphi 2009
       {$define DELPHI2009_UP} //Delphi 2009
-    {$ifend}
+    {$endif}
     {$if CompilerVersion >= 21.0} //Delphi 2010
     {$if CompilerVersion >= 21.0} //Delphi 2010
       {$define DELPHI2010_UP}
       {$define DELPHI2010_UP}
       {$define FPC_OR_UNICODE}
       {$define FPC_OR_UNICODE}
-    {$ifend}
+    {$endif}
     {$if CompilerVersion >= 22.0} //Delphi XE
     {$if CompilerVersion >= 22.0} //Delphi XE
       {$define DELPHIXE_UP}
       {$define DELPHIXE_UP}
-    {$ifend}
+    {$endif}
     {$if CompilerVersion >= 23.0} //Delphi XE2
     {$if CompilerVersion >= 23.0} //Delphi XE2
       {$define DELPHIXE2_UP}
       {$define DELPHIXE2_UP}
-    {$ifend}
+    {$endif}
     {$if CompilerVersion >= 24.0} //Delphi XE3
     {$if CompilerVersion >= 24.0} //Delphi XE3
       {$define DELPHIXE3_UP}
       {$define DELPHIXE3_UP}
-    {$ifend}
+    {$endif}
     {$if CompilerVersion >= 25.0} //Delphi XE4
     {$if CompilerVersion >= 25.0} //Delphi XE4
       {$define DELPHIXE4_UP}
       {$define DELPHIXE4_UP}
-    {$ifend}
+    {$endif}
     {$if CompilerVersion >= 26.0} //Delphi XE5
     {$if CompilerVersion >= 26.0} //Delphi XE5
       {$define DELPHIXE5_UP}
       {$define DELPHIXE5_UP}
-    {$ifend}
+    {$endif}
     {$if CompilerVersion >= 27.0} //Delphi XE6
     {$if CompilerVersion >= 27.0} //Delphi XE6
       {$define DELPHIXE6_UP}
       {$define DELPHIXE6_UP}
-    {$ifend}
+    {$endif}
     {$if CompilerVersion >= 28.0} //Delphi XE7
     {$if CompilerVersion >= 28.0} //Delphi XE7
       {$define DELPHIXE7_UP}
       {$define DELPHIXE7_UP}
-    {$ifend}
+    {$endif}
     {$if CompilerVersion >= 29.0} //Delphi XE8
     {$if CompilerVersion >= 29.0} //Delphi XE8
       {$define DELPHIXE8_UP}
       {$define DELPHIXE8_UP}
-    {$ifend}
+    {$endif}
     {$if CompilerVersion >= 30.0} //Delphi XE10 Seattle
     {$if CompilerVersion >= 30.0} //Delphi XE10 Seattle
       {$define DELPHIRX10_UP}
       {$define DELPHIRX10_UP}
 	  {$define DELPHISEATTLE_UP}
 	  {$define DELPHISEATTLE_UP}
-    {$ifend}
+    {$endif}
     {$if CompilerVersion >= 31.0} //Delphi RX10.1 Berlin
     {$if CompilerVersion >= 31.0} //Delphi RX10.1 Berlin
       {$define DELPHIRX101_UP}
       {$define DELPHIRX101_UP}
 	    {$define DELPHIBERLIN_UP}
 	    {$define DELPHIBERLIN_UP}
-    {$ifend}
+    {$endif}
     {$if CompilerVersion >= 32.0} //Delphi RX10.2 Tokyo
     {$if CompilerVersion >= 32.0} //Delphi RX10.2 Tokyo
       {$define DELPHIRX102_UP}
       {$define DELPHIRX102_UP}
 	    {$define DELPHITOKYO_UP}
 	    {$define DELPHITOKYO_UP}
       {$ifdef LINUX}
       {$ifdef LINUX}
         {$define DELPHILINUX}
         {$define DELPHILINUX}
-      {$ifend}
-    {$ifend}
+      {$endif}
+    {$endif}
     {$if CompilerVersion >= 33.0} //Delphi RX10.3 Rio
     {$if CompilerVersion >= 33.0} //Delphi RX10.3 Rio
       {$define DELPHIRX103_UP}
       {$define DELPHIRX103_UP}
 	    {$define DELPHIRIO_UP}
 	    {$define DELPHIRIO_UP}
-    {$ifend}
+    {$endif}
     {$if CompilerVersion >= 34.0} //Delphi RX10.4 Sydney
     {$if CompilerVersion >= 34.0} //Delphi RX10.4 Sydney
       {$define DELPHIRX104_UP}
       {$define DELPHIRX104_UP}
 	    {$define DELPHISYDNEY_UP}
 	    {$define DELPHISYDNEY_UP}
       {$if defined(ANDROID) OR defined(IOS)}
       {$if defined(ANDROID) OR defined(IOS)}
         {$define NEXTGEN} //compatibility with older delphis
         {$define NEXTGEN} //compatibility with older delphis
       {$endif}
       {$endif}
-    {$ifend}
+    {$endif}
     {$if CompilerVersion >= 35.0} //Delphi RX11 Alexandria
     {$if CompilerVersion >= 35.0} //Delphi RX11 Alexandria
       {$define DELPHIRX11_UP}
       {$define DELPHIRX11_UP}
 	    {$define DELPHIALEXANDRIA_UP}
 	    {$define DELPHIALEXANDRIA_UP}
       {$if defined(ANDROID) OR defined(IOS)}
       {$if defined(ANDROID) OR defined(IOS)}
         {$define NEXTGEN} //compatibility with older delphis
         {$define NEXTGEN} //compatibility with older delphis
       {$endif}
       {$endif}
-    {$ifend}
+    {$endif}
   {$else}
   {$else}
     //Delphi 5 or older
     //Delphi 5 or older
     {$define DELPHI6OROLDER}
     {$define DELPHI6OROLDER}