From 96bb67a29d15d674cf4bfbb4fe87c6724a9a7c87 Mon Sep 17 00:00:00 2001 From: Daniele Teti Date: Thu, 31 Mar 2022 09:31:11 +0200 Subject: [PATCH] + Samples are compilable with Delphi 10.2 Tokyo or better --- README.md | 3 + samples/activerecord_showcase/MainFormU.pas | 57 ++++++++++++------- .../MainClientFormU.pas | 2 +- samples/master_details/BusinessObjects.pas | 8 ++- samples/master_details/Controllers.Orders.pas | 5 +- samples/swagger_primer/MyControllerU.pas | 8 ++- sources/MVCFramework.Server.Impl.pas | 7 ++- tasks.py | 9 --- 8 files changed, 63 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 0d4cf56f..c30e624c 100644 --- a/README.md +++ b/README.md @@ -715,6 +715,9 @@ The current beta release is named 3.2.2-nitrogen. If you want to stay on the-edg - Fixed an `IFDEF` compatibility problem on mobile platforms (Thanks to Marco Cotroneo) +- Samples are syntax compatible with Delphi 10.1 Berlin or better (Thanks to Mark Lobanov) + + ## Older Releases ### What's New in 3.2.0-boron diff --git a/samples/activerecord_showcase/MainFormU.pas b/samples/activerecord_showcase/MainFormU.pas index db617239..7fdc1711 100644 --- a/samples/activerecord_showcase/MainFormU.pas +++ b/samples/activerecord_showcase/MainFormU.pas @@ -771,12 +771,16 @@ begin end; procedure TMainForm.btnPartitioningClick(Sender: TObject); +var + lCust1: TCustomerWithRate1; + lCust2: TCustomerWithRate2; + lList: TObjectList; begin TMVCActiveRecord.DeleteAll(TCustomerWithRate1); Assert(TMVCActiveRecord.Count(TCustomerWithRate1) = 0); TMVCActiveRecord.DeleteAll(TCustomerWithRate2); Assert(TMVCActiveRecord.Count(TCustomerWithRate2) = 0); - var lCust1 := TCustomerWithRate1.Create; + lCust1 := TCustomerWithRate1.Create; try lCust1.City := 'Rome'; lCust1.Code := '123'; @@ -784,7 +788,7 @@ begin finally lCust1.Free; end; - var lCust2 := TCustomerWithRate2.Create; + lCust2 := TCustomerWithRate2.Create; try lCust2.City := 'Rome'; lCust2.Code := '456'; @@ -794,7 +798,7 @@ begin lCust2.Free; end; - var lList := TMVCActiveRecord.SelectRQL('eq(city,"Rome")',-1); + lList := TMVCActiveRecord.SelectRQL('eq(city,"Rome")',-1); try Assert(lList.Count = 1); Assert(lList[0].Code = '123'); @@ -1163,16 +1167,31 @@ begin end; procedure TMainForm.btnTableFilterClick(Sender: TObject); +var + i: Integer; + lIDOfABadCustomer: Int64; + lIDOfAGoodCustomer: Int64; + lHowMany: Int64; + lCust: TMVCActiveRecord; + Customer: TCustomer; + lCustomer: TCustomer; + lCustomer1: TCustomer; + lNotAGoodCustomer: TCustomer; + lThisShouldBeNil: TCustomer; + lAGoodCustomer: TCustomer; + lThisShouldNotBeNil: TCustomer; + lGoodCustomers: TObjectList; + lGoodCustomers2: TMVCActiveRecordList; begin Log('**Table Filtering'); Log('Deleting only best customers...'); - var lIDOfABadCustomer := -1; - var lIDOfAGoodCustomer := -1; + lIDOfABadCustomer := -1; + lIDOfAGoodCustomer := -1; TMVCActiveRecord.DeleteAll(TGoodCustomer); Log('Inserting some customers'); - for var I := 1 to 5 do + for i := 1 to 5 do begin - var Customer := TCustomer.Create(); + Customer := TCustomer.Create(); try Customer.Code := I.ToString; Customer.Rating := I; @@ -1191,10 +1210,10 @@ begin end; Log('Retrieving only best customers...'); - var lGoodCustomers := TMVCActiveRecord.SelectRQL('sort(+rating)',10); + lGoodCustomers := TMVCActiveRecord.SelectRQL('sort(+rating)',10); try Assert(lGoodCustomers.Count = 2); { only rating >= 4} - for var lCust in lGoodCustomers do + for lCust in lGoodCustomers do begin Log(lCust.ToString); end; @@ -1203,7 +1222,7 @@ begin end; Log('How many "best customers" we have?'); - var lHowMany := TMVCActiveRecord.Count; + lHowMany := TMVCActiveRecord.Count; Log(Format('We have %d best customers', [lHowMany])); Log('How many "best customers" with rating = 5 we have?'); @@ -1211,10 +1230,10 @@ begin Log(Format('We have %d best customers with rating = 5', [lHowMany])); Log('Retrieving only best customers...'); - var lGoodCustomers2 := TMVCActiveRecord.SelectRQL(TGoodCustomer, '', -1); + lGoodCustomers2 := TMVCActiveRecord.SelectRQL(TGoodCustomer, '', -1); try Assert(lGoodCustomers2.Count = 2); { only rating >= 4} - for var lCust in lGoodCustomers2 do + for lCust in lGoodCustomers2 do begin Log(lCust.ToString); end; @@ -1226,7 +1245,7 @@ begin lGoodCustomers := TMVCActiveRecord.SelectRQL('sort(+CompanyName)',10); try Assert(lGoodCustomers.Count = 2); { only rating >= 4} - for var lCust in lGoodCustomers do + for lCust in lGoodCustomers do begin Log(lCust.ToString); end; @@ -1237,17 +1256,17 @@ begin Log('Retrieving only best customers...'); - var lNotAGoodCustomer := TMVCActiveRecord.SelectOneByRQL('eq(rating,1)', True); + lNotAGoodCustomer := TMVCActiveRecord.SelectOneByRQL('eq(rating,1)', True); try - var lThisShouldBeNil := TMVCActiveRecord.GetByPK(lNotAGoodCustomer.ID, False); + lThisShouldBeNil := TMVCActiveRecord.GetByPK(lNotAGoodCustomer.ID, False); Assert(lThisShouldBeNil = nil); finally lNotAGoodCustomer.Free; end; - var lAGoodCustomer := TMVCActiveRecord.SelectOneByRQL('eq(rating,5)', True); + lAGoodCustomer := TMVCActiveRecord.SelectOneByRQL('eq(rating,5)', True); try - var lThisShouldNotBeNil := TMVCActiveRecord.GetByPK(lAGoodCustomer.ID, False); + lThisShouldNotBeNil := TMVCActiveRecord.GetByPK(lAGoodCustomer.ID, False); try Assert(lThisShouldNotBeNil <> nil); Log(lThisShouldNotBeNil.ToString); @@ -1259,7 +1278,7 @@ begin end; Log('Promoting a customer...'); - var lCustomer := TBadCustomer.Create; + lCustomer := TBadCustomer.Create; try lCustomer.LoadByPK(lIDOfABadCustomer); lCustomer.Rating := 5; @@ -1270,7 +1289,7 @@ begin end; Log('Demote a customer...'); - var lCustomer1 := TGoodCustomer.Create; + lCustomer1 := TGoodCustomer.Create; try lCustomer1.LoadByPK(lIDOfAGoodCustomer); lCustomer1.Rating := 1; diff --git a/samples/jsonrpc_with_published_objects/MainClientFormU.pas b/samples/jsonrpc_with_published_objects/MainClientFormU.pas index 37e234ea..a37b47b5 100644 --- a/samples/jsonrpc_with_published_objects/MainClientFormU.pas +++ b/samples/jsonrpc_with_published_objects/MainClientFormU.pas @@ -164,7 +164,7 @@ end; procedure TMainForm.btnExceptionClick(Sender: TObject); var lReq: IJSONRPCNotification; - lResp: IJSONRPCResponse; +// lResp: IJSONRPCResponse; begin ShowMessage('Now will be raised a custom exception on the server. This exception will be catched by the client'); lReq := TJSONRPCNotification.Create('RaiseCustomException'); diff --git a/samples/master_details/BusinessObjects.pas b/samples/master_details/BusinessObjects.pas index 44e1ae80..88048fc7 100644 --- a/samples/master_details/BusinessObjects.pas +++ b/samples/master_details/BusinessObjects.pas @@ -152,9 +152,11 @@ begin end; procedure TOrder.OnAfterInsert; +var + lOrderDetail: TOrderDetail; begin inherited; - for var lOrderDetail in fDetails do + for lOrderDetail in fDetails do begin lOrderDetail.IDOrder := ID; lOrderDetail.Insert; @@ -162,9 +164,11 @@ begin end; procedure TOrder.OnAfterUpdate; +var + lOrderItems: TObjectList; begin inherited; - var lOrderItems := TMVCActiveRecord.SelectRQL(Format('eq(idorder,%d)', [ID]), 100); + lOrderItems := TMVCActiveRecord.SelectRQL(Format('eq(idorder,%d)', [ID]), 100); try TMVCActiveRecord.Merge(lOrderItems, fDetails) .Apply( diff --git a/samples/master_details/Controllers.Orders.pas b/samples/master_details/Controllers.Orders.pas index a26c5e43..ed8b76dd 100644 --- a/samples/master_details/Controllers.Orders.pas +++ b/samples/master_details/Controllers.Orders.pas @@ -121,7 +121,6 @@ begin end; procedure TOrdersController.GetOrdersByDescription(const Search: String); -var lDict: IMVCObjectDictionary; begin // Render( @@ -149,9 +148,11 @@ begin end; procedure TOrdersController.UpdateOrderByID(const Order: TOrder; const id: Integer); +var + lCurrentOrder: TOrder; begin Order.id := id; - var lCurrentOrder := TMVCActiveRecord.GetByPK(id); + lCurrentOrder := TMVCActiveRecord.GetByPK(id); try Order.Update(); finally diff --git a/samples/swagger_primer/MyControllerU.pas b/samples/swagger_primer/MyControllerU.pas index db295924..e334a92f 100644 --- a/samples/swagger_primer/MyControllerU.pas +++ b/samples/swagger_primer/MyControllerU.pas @@ -67,8 +67,10 @@ begin end; procedure TMyController.CreateCustomer; +var + lCustomer: TCustomer; begin - var lCustomer := Self.Context.Request.BodyAs; + lCustomer := Self.Context.Request.BodyAs; try if not lCustomer.IsValid then begin @@ -82,8 +84,10 @@ begin end; procedure TMyController.UpdateCustomer(id: Integer); +var + lCustomer: TCustomer; begin - var lCustomer := Self.Context.Request.BodyAs; + lCustomer := Self.Context.Request.BodyAs; try lCustomer.ID := id; //dont be confident of the user! if not lCustomer.IsValid then diff --git a/sources/MVCFramework.Server.Impl.pas b/sources/MVCFramework.Server.Impl.pas index b1996a8a..3b9b4a8c 100644 --- a/sources/MVCFramework.Server.Impl.pas +++ b/sources/MVCFramework.Server.Impl.pas @@ -81,7 +81,9 @@ type AAuthData: String; var VUsername, VPassword: String; var VHandled: Boolean); procedure OnGetSSLPassword(var APassword: string); +{$IF Defined(RIOORBETTER)} procedure QuerySSLPort(APort: Word; var VUseSSL: boolean); +{$ENDIF} protected function GetActive: Boolean; @@ -265,7 +267,7 @@ begin FBridgeSSLHandler.SSLOptions.KeyFile := lSSLKeyFile; FBridgeSSLHandler.OnGetPassword := OnGetSSLPassword; FBridge.IOHandler := FBridgeSSLHandler; - {$IF CompilerVersion >= 33} + {$IF Defined(RIOORBETTER)} FBridge.OnQuerySSLPort := QuerySSLPort; {$ENDIF} end; @@ -288,10 +290,13 @@ begin vhandled := True; end; + +{$IF Defined(RIOORBETTER)} procedure TMVCListener.QuerySSLPort(APort: Word; var VUseSSL: boolean); begin VUseSSL := true; end; +{$ENDIF} function TMVCListener.GetActive: Boolean; begin diff --git a/tasks.py b/tasks.py index fc56d7f6..2de59c44 100644 --- a/tasks.py +++ b/tasks.py @@ -449,12 +449,3 @@ def generate_nullables(ctx): with open(src_folder.joinpath("implementation.out.txt"), "w") as f: f.writelines(impl_tmpl) - - -@task() -def pippo(ctx): - r = ctx.run("cmd.exe /c dsir", hide=True, warn=True) - if r.failed: - print(r.stderr) - else: - print(r.stdout)