diff --git a/.gitattributes b/.gitattributes index 7861285056..1ab3a6a824 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4447,7 +4447,6 @@ components/sparta/dockedformeditor/source/sparta_fakecustom.pas svneol=native#te components/sparta/dockedformeditor/source/sparta_fakeform.pas svneol=native#text/pascal components/sparta/dockedformeditor/source/sparta_fakeframe.pas svneol=native#text/pascal components/sparta/dockedformeditor/source/sparta_fakenoncontrol.pas svneol=native#text/pascal -components/sparta/dockedformeditor/source/sparta_hashutils.pas svneol=native#text/pascal components/sparta/dockedformeditor/source/sparta_mainide.pas svneol=native#text/pascal components/sparta/dockedformeditor/source/sparta_reg_dockedformeditor.pas svneol=native#text/pascal components/sparta/dockedformeditor/source/sparta_resizer.pas svneol=native#text/pascal @@ -4457,14 +4456,14 @@ components/sparta/dockedformeditor/source/spartaapi.pas svneol=native#text/pasca components/sparta/dockedformeditor/sparta_dockedformeditor.lpk svneol=native#text/plain components/sparta/dockedformeditor/sparta_dockedformeditor.pas svneol=native#text/pascal components/sparta/dockedformeditor/sparta_strconsts.pas svneol=native#text/pascal -components/sparta/generics/source/generics.collections.pas svneol=native#text/pascal -components/sparta/generics/source/generics.defaults.pas svneol=native#text/pascal -components/sparta/generics/source/generics.hashes.pas svneol=native#text/pascal -components/sparta/generics/source/generics.helpers.pas svneol=native#text/pascal -components/sparta/generics/source/generics.memoryexpanders.pas svneol=native#text/pascal -components/sparta/generics/source/generics.strings.pas svneol=native#text/pascal components/sparta/generics/source/inc/generics.dictionaries.inc svneol=native#text/plain components/sparta/generics/source/inc/generics.dictionariesh.inc svneol=native#text/plain +components/sparta/generics/source/sparta_generics.collections.pas svneol=native#text/pascal +components/sparta/generics/source/sparta_generics.defaults.pas svneol=native#text/pascal +components/sparta/generics/source/sparta_generics.hashes.pas svneol=native#text/pascal +components/sparta/generics/source/sparta_generics.helpers.pas svneol=native#text/pascal +components/sparta/generics/source/sparta_generics.memoryexpanders.pas svneol=native#text/pascal +components/sparta/generics/source/sparta_generics.strings.pas svneol=native#text/pascal components/sparta/generics/sparta_generics.lpk svneol=native#text/plain components/sparta/generics/sparta_generics.pas svneol=native#text/pascal components/sparta/mdi/source/sparta_abstractresizer.pas svneol=native#text/pascal diff --git a/components/sparta/dockedformeditor/source/sparta_fakecustom.pas b/components/sparta/dockedformeditor/source/sparta_fakecustom.pas index 718e226801..313e38cb0f 100644 --- a/components/sparta/dockedformeditor/source/sparta_fakecustom.pas +++ b/components/sparta/dockedformeditor/source/sparta_fakecustom.pas @@ -18,9 +18,6 @@ interface uses Classes, SysUtils, - {$IFDEF USE_GENERICS_COLLECTIONS} - Generics.Defaults, - {$ENDIF} // LCL Forms, Controls, // IdeIntf @@ -178,8 +175,7 @@ type { TDesignedNonControlFormImpl } -function TDesignedNonControlFormImpl.GetPublishedBounds(AIndex: Integer - ): Integer; +function TDesignedNonControlFormImpl.GetPublishedBounds(AIndex: Integer): Integer; var LBounds, LClientRect: TRect; LMediator: TDesignerMediator; @@ -487,8 +483,7 @@ begin Result := True; end; -procedure TFakeCustomNonControl.SetBounds(ALeft, ATop, AWidth, AHeight: integer - ); +procedure TFakeCustomNonControl.SetBounds(ALeft, ATop, AWidth, AHeight: integer); begin SetDesignerFormBounds(ALeft, ATop, AWidth, AHeight); end; diff --git a/components/sparta/dockedformeditor/source/sparta_hashutils.pas b/components/sparta/dockedformeditor/source/sparta_hashutils.pas deleted file mode 100644 index d6d8f228ed..0000000000 --- a/components/sparta/dockedformeditor/source/sparta_hashutils.pas +++ /dev/null @@ -1,30 +0,0 @@ -unit sparta_HashUtils; - -{$mode delphi}{$H+} - -interface - -uses - Classes, SysUtils; - -{$IFNDEF USE_GENERICS_COLLECTIONS} -type - THash_TObject = record - class function Hash(A: TObject; B: SizeUInt): SizeUInt; static; - end; -{$ENDIF} - -implementation - -{$IFNDEF USE_GENERICS_COLLECTIONS} -class function THash_TObject.Hash(A: TObject; B: SizeUInt): SizeUInt; -begin - if A = nil then - Exit($2A and (b - 1)); - - Result := A.GetHashCode() and (b - 1); -end; -{$ENDIF} - -end. - diff --git a/components/sparta/dockedformeditor/source/sparta_mainide.pas b/components/sparta/dockedformeditor/source/sparta_mainide.pas index 7ef101250b..7927cb8ff9 100644 --- a/components/sparta/dockedformeditor/source/sparta_mainide.pas +++ b/components/sparta/dockedformeditor/source/sparta_mainide.pas @@ -18,11 +18,11 @@ interface uses Classes, SysUtils, - {$IFDEF USE_GENERICS_COLLECTIONS} - Generics.Collections, Generics.Defaults, - {$ELSE} - ghashmap, sparta_HashUtils, gvector, - {$ENDIF} +{$IF FPC_FULLVERSION>=30200} + Generics.Collections, Generics.Defaults, +{$ELSE} + sparta_Generics.Collections, sparta_Generics.Defaults, +{$ENDIF} contnrs, // LCL LCLIntf, LCLType, LMessages, ComCtrls, Controls, Forms, ExtCtrls, Graphics, @@ -46,25 +46,15 @@ type FLastScreenshot: TBitmap; FPopupParent: TSourceEditorWindowInterface; FHiding: boolean; -{$IFDEF USE_GENERICS_COLLECTIONS} FFormImages: TList; -{$ELSE} - FFormImages: TList; -{$ENDIF} procedure WndMethod(var Msg: TLMessage); procedure SetPopupParent(AVal: TSourceEditorWindowInterface); procedure DoAddForm; procedure FormChangeBounds(Sender: TObject); public -{$IFDEF USE_GENERICS_COLLECTIONS} class var AddFormEvents: TList; -{$ELSE} - class var AddFormEvents: TVector; -{$ENDIF} - class constructor Init; class destructor Finit; - procedure AddFormImage(AImage: TImage); procedure RemoveFormImage(AImage: TImage); procedure RepaintFormImages; @@ -101,11 +91,7 @@ type private FActiveDesignFormData: TDesignFormData; FForm: TSourceEditorWindowInterface; -{$IFDEF USE_GENERICS_COLLECTIONS} FPageCtrlList: TDictionary; -{$ELSE} - FPageCtrlList: THashmap; -{$ENDIF} FLastTopParent: TControl; procedure SetActiveDesignFormData(const AValue: TDesignFormData); @@ -188,15 +174,9 @@ type var normForms: Classes.TList; // normal forms dsgnForms: Classes.TList; // design forms -{$IFDEF USE_GENERICS_COLLECTIONS} SourceEditorWindows: TObjectDictionary; -{$ELSE} - SourceEditorWindows: THashmap; -{$ENDIF} - LastActiveSourceEditorWindow: TSourceEditorWindowInterface = nil; LastActiveSourceEditor: TSourceEditorInterface = nil; - BoundInitialized: Boolean; function FindModulePageControl(AForm: TSourceEditorWindowInterface): TModulePageControl; overload; @@ -262,29 +242,11 @@ end; function AbsoluteFindModulePageControl(ASrcEditor: TSourceEditorInterface): TModulePageControl; var LSEWD: TSourceEditorWindowData; -{$IFnDEF USE_GENERICS_COLLECTIONS} - LIterator: THashmap.TIterator; -{$ENDIF} begin Result := nil; -{$IFDEF USE_GENERICS_COLLECTIONS} for LSEWD in SourceEditorWindows.Values do if LSEWD.FPageCtrlList.ContainsKey(ASrcEditor) then Exit(LSEWD.FPageCtrlList[ASrcEditor]); -{$ELSE} - LIterator := SourceEditorWindows.Iterator; - if LIterator <> nil then - try - repeat - LSEWD := LIterator.Value; - if LSEWD.FPageCtrlList.contains(ASrcEditor) then - Exit(LSEWD.FPageCtrlList[ASrcEditor]); - until not LIterator.next; - finally - LIterator.Free; - end; -{$ENDIF} - end; function FindSourceEditorForDesigner(ADesigner: TIDesigner): TSourceEditorInterface; @@ -325,11 +287,7 @@ procedure RefreshAllSourceWindowsModulePageControl; var LWindow: TSourceEditorWindowInterface; LPageCtrl: TModulePageControl; -{$IFnDEF USE_GENERICS_COLLECTIONS} - LIterator: THashmap.TIterator; -{$ENDIF} begin -{$IFDEF USE_GENERICS_COLLECTIONS} for LWindow in SourceEditorWindows.Keys do begin LPageCtrl := FindModulePageControl(LWindow); @@ -347,32 +305,6 @@ begin else LPageCtrl.HideDesignPage; end; -{$ELSE} - LIterator := SourceEditorWindows.Iterator; - if LIterator <> nil then - try - repeat - LWindow := LIterator.Key; - - LPageCtrl := FindModulePageControl(LWindow); - - // for example LPageCtrl is nil when we clone module to new window - if (LPageCtrl = nil) or (csDestroying in LWindow.ComponentState) then - Continue; - - if LWindow.ActiveEditor = nil then - LPageCtrl.HideDesignPage - else - if LWindow.ActiveEditor.GetDesigner(True) <> nil then - // TODO some check function: is displayed right form? - LPageCtrl.ShowDesignPage - else - LPageCtrl.HideDesignPage; - until not LIterator.next; - finally - LIterator.Free; - end; -{$ENDIF} end; // sometimes at some level of initialization form can not contain TIDesigner @@ -396,16 +328,10 @@ function FindDesignFormData(AModulePageCtrl: TModulePageControl): TDesignFormDat var LSourceWindow: TSourceEditorWindowInterface; LSourceEditor: TSourceEditorInterface; -{$IFnDEF USE_GENERICS_COLLECTIONS} - LIterator: THashmap.TIterator; -{$ENDIF} begin Result := nil; - if AModulePageCtrl = nil then Exit; - -{$IFDEF USE_GENERICS_COLLECTIONS} for LSourceWindow in SourceEditorWindows.Keys do begin if AModulePageCtrl.Owner = LSourceWindow then @@ -419,28 +345,6 @@ begin Exit; end; end; -{$ELSE} - LIterator := SourceEditorWindows.Iterator; - if LIterator <> nil then - try - repeat - LSourceWindow := LIterator.Key; - - if AModulePageCtrl.Owner = LSourceWindow then - begin - LSourceEditor := LSourceWindow.ActiveEditor; - if LSourceEditor = nil then - Exit; - - Result := FindDesignFormData(LSourceEditor.GetDesigner(True)); - - Exit; - end; - until not LIterator.next; - finally - LIterator.Free; - end; -{$ENDIF} end; { TDesignFormData } @@ -515,11 +419,7 @@ end; class constructor TDesignFormData.Init; begin -{$IFDEF USE_GENERICS_COLLECTIONS} AddFormEvents := TList.Create; -{$ELSE} - AddFormEvents := TVector.Create; -{$ENDIF} end; class destructor TDesignFormData.Finit; @@ -552,21 +452,10 @@ end; procedure TDesignFormData.DoAddForm; var -{$IFDEF USE_GENERICS_COLLECTIONS} ne: TNotifyEvent; -{$ELSE} - i: Integer; -{$ENDIF} begin -{$IFDEF USE_GENERICS_COLLECTIONS} for ne in AddFormEvents do ne(Self); -{$ELSE} - if AddFormEvents.Size > 0 then // Arithmetic overflow without a test. Size = unsigned. - for i := 0 to AddFormEvents.Size-1 do - AddFormEvents[i](Self); -{$ENDIF} - end; procedure TDesignFormData.FormChangeBounds(Sender: TObject); @@ -587,11 +476,7 @@ begin if FForm.Form is TFakeForm then begin -{$IFDEF USE_GENERICS_COLLECTIONS} FFormImages := TList.Create; -{$ELSE} - FFormImages := TList.Create; -{$ENDIF} DoAddForm; end; end; @@ -717,11 +602,7 @@ end; constructor TSourceEditorWindowData.Create(AForm: TSourceEditorWindowInterface); begin FForm := AForm; -{$IFDEF USE_GENERICS_COLLECTIONS} FPageCtrlList := TDictionary.Create; -{$ELSE} - FPageCtrlList := THashmap.Create; -{$ENDIF} end; destructor TSourceEditorWindowData.Destroy; @@ -750,21 +631,13 @@ end; procedure TSourceEditorWindowData.AddPageCtrl(ASrcEditor: TSourceEditorInterface; APage: TModulePageControl); begin -{$IFDEF USE_GENERICS_COLLECTIONS} FPageCtrlList.Add(ASrcEditor, APage); -{$ELSE} - FPageCtrlList.insert(ASrcEditor, APage); -{$ENDIF} APage.Pages[1].OnChangeBounds:=OnChangeBounds; end; procedure TSourceEditorWindowData.RemovePageCtrl(ASrcEditor: TSourceEditorInterface); begin -{$IFDEF USE_GENERICS_COLLECTIONS} FPageCtrlList.Remove(ASrcEditor); -{$ELSE} - FPageCtrlList.Delete(ASrcEditor); -{$ENDIF} end; { TDTXTabMaster } @@ -981,10 +854,6 @@ var LSEWD: TSourceEditorWindowData; mpc: TModulePageControl; LFormData: TDesignFormData; -{$IFnDEF USE_GENERICS_COLLECTIONS} - LIterator: THashmap.TIterator; - LIterator2: THashmap.TIterator; -{$ENDIF} begin Form.Parent := nil; Application.ProcessMessages; // For TFrame - System Error. Code: 1400. Invalid window handle. @@ -992,7 +861,6 @@ begin LFormData := FindDesignFormData(Form); dsgnForms.Remove(LFormData); -{$IFDEF USE_GENERICS_COLLECTIONS} for LSEWD in SourceEditorWindows.Values do begin if LSEWD.ActiveDesignFormData <> nil then @@ -1004,34 +872,6 @@ begin if mpc.DesignFormData.Form.Form = Form then mpc.DesignFormData := nil; end; -{$ELSE} - LIterator := SourceEditorWindows.Iterator; - if LIterator <> nil then - try - repeat - LSEWD := LIterator.Value; - if LSEWD.ActiveDesignFormData <> nil then - if LSEWD.ActiveDesignFormData.Form.Form = Form then - LSEWD.FActiveDesignFormData := nil; // important - we can't call OnChange tab, because tab don't exist anymore - - LIterator2 := LSEWD.FPageCtrlList.Iterator; - if LIterator2 <> nil then - try - repeat - mpc := LIterator2.Value; - if mpc.DesignFormData <> nil then - if mpc.DesignFormData.Form.Form = Form then - mpc.DesignFormData := nil; - until not LIterator2.next; - finally - LIterator2.Free; - end; - until not LIterator.next; - finally - LIterator.Free; - end; -{$ENDIF} - LFormData.Free; end; @@ -1055,11 +895,7 @@ begin if Sender.ClassNameIs('TSourceNotebook') then begin LSourceEditorWindow := Sender as TSourceEditorWindowInterface; -{$IFDEF USE_GENERICS_COLLECTIONS} SourceEditorWindows.Add(LSourceEditorWindow, TSourceEditorWindowData.Create(LSourceEditorWindow)); -{$ELSE} - SourceEditorWindows.insert(LSourceEditorWindow, TSourceEditorWindowData.Create(LSourceEditorWindow)); -{$ENDIF} end; end; @@ -1071,12 +907,7 @@ begin for p in dsgnForms do if f.FForm.LastActiveSourceWindow = Sender then f.FForm.LastActiveSourceWindow := nil; -{$IFDEF USE_GENERICS_COLLECTIONS} SourceEditorWindows.Remove(Sender as TSourceEditorWindowInterface); -{$ELSE} - SourceEditorWindows[Sender as TSourceEditorWindowInterface].Free; - SourceEditorWindows.Delete(Sender as TSourceEditorWindowInterface); -{$ENDIF} if LastActiveSourceEditorWindow = Sender then LastActiveSourceEditorWindow := nil; end; @@ -1088,20 +919,10 @@ var LDesignedForm: IDesignedForm; begin LWindow := Sender as TSourceEditorWindowInterface; - -{$IFDEF USE_GENERICS_COLLECTIONS} if not SourceEditorWindows.TryGetValue(LWindow, LWindowData) or (LWindowData.ActiveDesignFormData = nil) then Exit; -{$ELSE} - if not SourceEditorWindows.contains(LWindow) then - Exit; - LWindowData := SourceEditorWindows[LWindow]; - if LWindowData.ActiveDesignFormData = nil then - Exit; -{$ENDIF} - LDesignedForm := LWindowData.ActiveDesignFormData as IDesignedForm; LDesignedForm.ShowWindow; end; @@ -1113,20 +934,10 @@ var LDesignedForm: IDesignedForm; begin LWindow := Sender as TSourceEditorWindowInterface; - -{$IFDEF USE_GENERICS_COLLECTIONS} if not SourceEditorWindows.TryGetValue(LWindow, LWindowData) or (LWindowData.ActiveDesignFormData = nil) then Exit; -{$ELSE} - if not SourceEditorWindows.contains(LWindow) then - Exit; - LWindowData := SourceEditorWindows[LWindow]; - if LWindowData.ActiveDesignFormData = nil then - Exit; -{$ENDIF} - LDesignedForm := LWindowData.ActiveDesignFormData as IDesignedForm; LDesignedForm.HideWindow; end; @@ -1144,9 +955,6 @@ class procedure TSpartaMainIDE.EditorActivated(Sender: TObject); var LDesigner: TIDesigner; LSourceEditor: TSourceEditorInterface; -{$IFnDEF USE_GENERICS_COLLECTIONS} - LIterator: THashmap.TIterator; -{$ENDIF} function LastSourceEditorNotFound: boolean; var @@ -1155,8 +963,6 @@ var begin if (LastActiveSourceEditorWindow = nil) or (LastActiveSourceEditor = nil) then Exit(False); - -{$IFDEF USE_GENERICS_COLLECTIONS} for se in SourceEditorWindows[LastActiveSourceEditorWindow].FPageCtrlList.Keys do begin Result := True; @@ -1173,30 +979,6 @@ var Exit; end; end; -{$ELSE} - LIterator := SourceEditorWindows[LastActiveSourceEditorWindow].FPageCtrlList.Iterator; - if LIterator <> nil then - try - repeat - se := LIterator.Key; - Result := True; - for i := 0 to LastActiveSourceEditorWindow.Count - 1 do - if se = LastActiveSourceEditorWindow.Items[i] then - begin - Result := False; - Break; - end; - if Result then - begin - LastActiveSourceEditor := se; // after moving code editor into other window, sometimes IDE switch to other tab :\ damn... this line prevent this. - Exit; - end; - until not LIterator.next; - finally - LIterator.Free; - end; -{$ENDIF} - Result := False; end; @@ -1401,13 +1183,7 @@ class procedure TSpartaMainIDE.TabChange(Sender: TObject); var LActiveSourceWindow: TSourceEditorWindowInterface; w: TSourceEditorWindowInterface; -{$IFDEF USE_GENERICS_COLLECTIONS} p: TPair; -{$ELSE} - p: THashmap.TPair; - LIterator: THashmap.TIterator; - LIterator2: THashmap.TIterator; -{$ENDIF} LDesigner: TIDesigner; LFormData: TDesignFormData; LPageCtrl: TModulePageControl; @@ -1425,18 +1201,12 @@ begin begin LDesigner := LActiveSourceWindow.ActiveEditor.GetDesigner(True); LFormData := FindDesignFormData(LDesigner); - -{$IFDEF USE_GENERICS_COLLECTIONS} - if (LFormData <> nil) and SourceEditorWindows.TryGetValue(LActiveSourceWindow, LSourceWndData) then + if (LFormData <> nil) + and SourceEditorWindows.TryGetValue(LActiveSourceWindow, LSourceWndData) then begin case LPageCtrl.ActivePageIndex of - 0: - begin - LSourceWndData.ActiveDesignFormData := nil; - end; - 1: - begin - // deactivate design tab in other page control :) + 0: LSourceWndData.ActiveDesignFormData := nil; + 1: begin // deactivate design tab in other page control :) for w in SourceEditorWindows.Keys do if w = LActiveSourceWindow then Continue @@ -1446,87 +1216,23 @@ begin begin IDETabMaster.ShowCode(p.Key); end; - LSourceWndData.ActiveDesignFormData := LFormData; - // to handle windows with different size - LPageCtrl.BoundToDesignTabSheet; - end; - end; - end; -{$ELSE} - if (LFormData <> nil) and SourceEditorWindows.contains(LActiveSourceWindow) then - begin - LSourceWndData := SourceEditorWindows[LActiveSourceWindow]; - case LPageCtrl.ActivePageIndex of - 0: - begin - LSourceWndData.ActiveDesignFormData := nil; - end; - 1: - begin - // deactivate design tab in other page control :) - LIterator := SourceEditorWindows.Iterator; - if LIterator <> nil then - try - repeat - w := LIterator.Key; - if w = LActiveSourceWindow then - Continue - else - begin - LIterator2 := SourceEditorWindows[w].FPageCtrlList.Iterator; - if LIterator2 <> nil then - try - repeat - p := LIterator2.Data; - if (p.Value.DesignFormData = LFormData) and (p.Value <> Sender) then - IDETabMaster.ShowCode(p.Key); - until not LIterator2.next; - finally - LIterator2.Free; - end; - end; - until not LIterator.next; - finally - LIterator.Free; - end; - - LSourceWndData.ActiveDesignFormData := LFormData; - // enable autosizing after creating a new form, see issue #32207 + // enable autosizing after creating a new form TDTXTabMaster(IDETabMaster).EnableAutoSizing(LFormData.Form.Form); // to handle windows with different size LPageCtrl.BoundToDesignTabSheet; end; end; end; -{$ENDIF} end; end; class procedure TSpartaMainIDE.GlobalOnChangeBounds(Sender: TObject); var sewd: TSourceEditorWindowData; -{$IFnDEF USE_GENERICS_COLLECTIONS} - LIterator: THashmap.TIterator; -{$ENDIF} begin -{$IFDEF USE_GENERICS_COLLECTIONS} for sewd in SourceEditorWindows.Values do - begin sewd.OnChangeBounds(Sender); - end; -{$ELSE} - LIterator := SourceEditorWindows.Iterator; - if LIterator <> nil then - try - repeat - sewd := LIterator.Value; - sewd.OnChangeBounds(Sender) - until not LIterator.next; - finally - LIterator.Free; - end; -{$ENDIF} end; class procedure TSpartaMainIDE.GlobalSNOnChangeBounds(Sender: TObject); @@ -1539,14 +1245,8 @@ begin LWindow := Sender as TSourceEditorWindowInterface; // dock/undock event :) -{$IFDEF USE_GENERICS_COLLECTIONS} if not SourceEditorWindows.TryGetValue(LWindow, LWindowData) then Exit; -{$ELSE} - if not SourceEditorWindows.contains(LWindow) then - Exit; - LWindowData := SourceEditorWindows[LWindow]; -{$ENDIF} if LWindowData.FLastTopParent <> LWindow.GetTopParent then begin LWindowData.FLastTopParent := LWindow.GetTopParent; @@ -1597,26 +1297,17 @@ var LPageCtrl, p: TModulePageControl; w: TSourceEditorWindowInterface; e: TSourceEditorInterface; -{$IFnDEF USE_GENERICS_COLLECTIONS} - LIterator: THashmap.TIterator; -{$ENDIF} begin LForm := FindDesignFormData(TCustomForm(Sender).Designer); - if LForm = nil then + if (LForm = nil) or LForm.FHiding then Exit; - - if LForm.FHiding then - Exit; - LPageCtrl := FindModulePageControl(SourceEditorManagerIntf.ActiveEditor); - if LPageCtrl = nil then Exit; // it should not happen but who knows :P Lazarus IDE is sometimes mischievous if AComponentPaletteClassSelected then begin // if form is already opened do nothing, if not then show form for active module. -{$IFDEF USE_GENERICS_COLLECTIONS} for w in SourceEditorWindows.Keys do begin e := w.ActiveEditor; @@ -1627,26 +1318,7 @@ begin if p.PageIndex = 1 then Exit; end; -{$ELSE} - LIterator := SourceEditorWindows.Iterator; - if LIterator <> nil then - try - repeat - w := LIterator.Key; - e := w.ActiveEditor; - if (e = nil) or (e.GetDesigner(True) <> LForm.Form.Form.Designer) then - Continue; - - p := FindModulePageControl(e); - if p.PageIndex = 1 then - Exit; - until not LIterator.next; - finally - LIterator.Free; - end; -{$ENDIF} end; - IDETabMaster.ShowDesigner(SourceEditorManagerIntf.ActiveEditor); end; @@ -1749,37 +1421,13 @@ begin end; end; -{$IFnDEF USE_GENERICS_COLLECTIONS} -class procedure FreeSourceEditorWindowsValues; -var - LIterator: THashmap.TIterator; -begin - LIterator := SourceEditorWindows.Iterator; - if LIterator <> nil then - try - repeat - LIterator.Value.Free; - until not LIterator.next; - finally - LIterator.Free; - end; -end; -{$ENDIF} - initialization dsgnForms := Classes.TList.Create; -{$IFDEF USE_GENERICS_COLLECTIONS} SourceEditorWindows := TObjectDictionary.Create([doOwnsValues]); -{$ELSE} - SourceEditorWindows := THashmap.Create(); -{$ENDIF} normForms := Classes.TList.Create; finalization normForms.Free; -{$IFnDEF USE_GENERICS_COLLECTIONS} - FreeSourceEditorWindowsValues; -{$ENDIF} SourceEditorWindows.Free; FreeAndNil(dsgnForms); end. diff --git a/components/sparta/dockedformeditor/sparta_dockedformeditor.lpk b/components/sparta/dockedformeditor/sparta_dockedformeditor.lpk index 28f0a612c9..6b80c2dc3b 100644 --- a/components/sparta/dockedformeditor/sparta_dockedformeditor.lpk +++ b/components/sparta/dockedformeditor/sparta_dockedformeditor.lpk @@ -22,7 +22,7 @@ - + @@ -65,13 +65,9 @@ - - - - - + diff --git a/components/sparta/dockedformeditor/sparta_dockedformeditor.pas b/components/sparta/dockedformeditor/sparta_dockedformeditor.pas index 845ebb8056..bb3e006989 100644 --- a/components/sparta/dockedformeditor/sparta_dockedformeditor.pas +++ b/components/sparta/dockedformeditor/sparta_dockedformeditor.pas @@ -10,8 +10,8 @@ interface uses sparta_reg_DockedFormEditor, sparta_DesignedForm, sparta_Resizer, sparta_ResizerFrame, SpartaAPI, sparta_FakeCustom, sparta_FakeForm, - sparta_FakeFrame, sparta_FakeNonControl, sparta_MainIDE, sparta_HashUtils, - sparta_strconsts, LazarusPackageIntf; + sparta_FakeFrame, sparta_FakeNonControl, sparta_MainIDE, sparta_strconsts, + LazarusPackageIntf; implementation diff --git a/components/sparta/generics/source/generics.collections.pas b/components/sparta/generics/source/sparta_generics.collections.pas similarity index 97% rename from components/sparta/generics/source/generics.collections.pas rename to components/sparta/generics/source/sparta_generics.collections.pas index 907f6acfe7..8f6215409e 100644 --- a/components/sparta/generics/source/generics.collections.pas +++ b/components/sparta/generics/source/sparta_generics.collections.pas @@ -1,11 +1,11 @@ { - This file is part of the Free Pascal run time library. + This file is part of the Free Pascal/NewPascal run time library. Copyright (c) 2014 by Maciej Izak (hnb) - member of the Free Sparta development team (http://freesparta.com) + member of the NewPascal development team (http://newpascal.org) - Copyright(c) 2004-2014 DaThoX + Copyright(c) 2004-2018 DaThoX - It contains the Free Pascal generics library + It contains the generics collections library See the file COPYING.FPC, included in this distribution, for details about the copyright. @@ -24,7 +24,7 @@ **********************************************************************} -unit Generics.Collections; +unit sparta_Generics.Collections; {$MODE DELPHI}{$H+} {$MACRO ON} @@ -41,27 +41,9 @@ unit Generics.Collections; interface uses - RtlConsts, Classes, SysUtils, Generics.MemoryExpanders, Generics.Defaults, - Generics.Helpers, Generics.Strings; - -{ FPC BUGS related to Generics.* (54 bugs, 19 fixed) - REGRESSION: 26483, 26481 - FIXED REGRESSION: 26480, 26482 - - CRITICAL: 24848(!!!), 24872(!), 25607(!), 26030, 25917, 25918, 25620, 24283, 24254, 24287 (Related to? 24872) - IMPORTANT: 23862(!), 24097, 24285, 24286 (Similar to? 24285), 24098, 24609 (RTL inconsistency), 24534, - 25606, 25614, 26177, 26195 - OTHER: 26484, 24073, 24463, 25593, 25596, 25597, 25602, 26181 (or MYBAD?) - CLOSED BUT IMO STILL TO FIX: 25601(!), 25594 - FIXED: 25610(!), 24064, 24071, 24282, 24458, 24867, 24871, 25604, 25600, 25605, 25598, 25603, 25929, 26176, 26180, - 26193, 24072 - MYBAD: 24963, 25599 -} - -{ LAZARUS BUGS related to Generics.* (7 bugs, 0 fixed) - CRITICAL: 25613 - OTHER: 25595, 25612, 25615, 25617, 25618, 25619 -} + RtlConsts, Classes, SysUtils, + sparta_Generics.MemoryExpanders, sparta_Generics.Defaults, + sparta_Generics.Helpers, sparta_Generics.Strings; {.$define EXTRA_WARNINGS} {.$define ENABLE_METHODS_WITH_TEnumerableWithPointers} @@ -698,7 +680,10 @@ type procedure ValueNotify(constref AValue: TValue; ACollectionNotification: TCollectionNotification); inline; procedure NodeNotify(ANode: PNode; ACollectionNotification: TCollectionNotification; ADispose: boolean); inline; procedure SetValue(var AValue: TValue; constref ANewValue: TValue); + function GetItem(const AKey: TKey): TValue; + procedure SetItem(const AKey: TKey; const AValue: TValue); + property Items[Index: TKey]: TValue read GetItem write SetItem; // for reporting procedure WriteStr(AStream: TStream; const AText: string); public type @@ -761,14 +746,17 @@ type destructor Destroy; override; function AddNode(ANode: PNode): boolean; overload; inline; + function AddNodeArray(const AArray: TArray): boolean; overload; inline; function Add(constref APair: TTreePair): PNode; overload; inline; function Add(constref AKey: TKey; constref AValue: TValue): PNode; overload; inline; function Remove(constref AKey: TKey; ADisposeNode: boolean = true): boolean; function ExtractPair(constref AKey: TKey; ADisposeNode: boolean = true): TTreePair; overload; function ExtractPair(constref ANode: PNode; ADispose: boolean = true): TTreePair; overload; - function ExtractNode(constref AKey: TKey; ADisposeNode: boolean): PNode; overload; - function ExtractNode(ANode: PNode; ADispose: boolean): PNode; overload; + function Extract(constref AKey: TKey; ADisposeNode: boolean): PNode; + function ExtractNode(ANode: PNode; ADispose: boolean): PNode; + function ExtractNodeArray(const AArray: TArray; ADispose: boolean): TArray; overload; procedure Delete(ANode: PNode; ADispose: boolean = true); inline; + procedure DeleteArray(const AArray: TArray; ADispose: boolean = true); inline; function GetEnumerator: TPairEnumerator; property Nodes: TNodeCollection read GetNodeCollection; @@ -801,6 +789,8 @@ type end; TAVLTreeMap = class(TCustomAVLTreeMap) + public + property Items; default; end; TIndexedAVLTreeMap = class(TCustomAVLTreeMap) @@ -827,6 +817,7 @@ type protected property OnKeyNotify; property OnValueNotify; + property Items; public type TItemEnumerator = TKeyEnumerator; public @@ -947,6 +938,7 @@ type function Add(constref AValue: T): Boolean; override; function Remove(constref AValue: T): Boolean; override; function Extract(constref AValue: T): T; override; + function PeekPtr(constref AValue: T): PT; procedure Clear; override; function Contains(constref AValue: T): Boolean; override; @@ -2359,7 +2351,7 @@ end; { TCustomSet } -function TCustomSet.DoGetEnumerator: Generics.Collections.TEnumerator; +function TCustomSet.DoGetEnumerator: TEnumerator; begin Result := GetEnumerator; end; @@ -3338,6 +3330,21 @@ begin Result := TValueCollection(FValues); end; +function TCustomAVLTreeMap.GetItem(const AKey: TKey): TValue; +var + LNode: PNode; +begin + LNode := Find(AKey); + if not Assigned(LNode) then + raise EAVLTree.CreateRes(@SDictionaryKeyDoesNotExist); + result := LNode.Value; +end; + +procedure TCustomAVLTreeMap.SetItem(const AKey: TKey; const AValue: TValue); +begin + Find(AKey).Value := AValue; +end; + constructor TCustomAVLTreeMap.Create; begin FComparer := TComparer.Default; @@ -3402,6 +3409,15 @@ begin Result := ANode=InternalAdd(ANode, false); end; +function TCustomAVLTreeMap.AddNodeArray(const AArray: TArray): boolean; +var + LNode: PNode; +begin + result := true; + for LNode in AArray do + result := result and AddNode(LNode); +end; + function TCustomAVLTreeMap.Add(constref APair: TTreePair): PNode; begin Result := NewNode; @@ -3449,7 +3465,7 @@ begin Result.Value := DoRemove(ANode, cnExtracted, ADispose); end; -function TCustomAVLTreeMap.ExtractNode(constref AKey: TKey; ADisposeNode: boolean): PNode; +function TCustomAVLTreeMap.Extract(constref AKey: TKey; ADisposeNode: boolean): PNode; begin Result:=Find(AKey); if Result<>nil then @@ -3469,11 +3485,31 @@ begin Result := ANode; end; +function TCustomAVLTreeMap.ExtractNodeArray(const AArray: TArray; ADispose: boolean): TArray; +var + LNode: PNode; +begin + for LNode in AArray do + ExtractNode(LNode, ADispose); + if ADispose then + Result := nil + else + Result := AArray; +end; + procedure TCustomAVLTreeMap.Delete(ANode: PNode; ADispose: boolean); begin DoRemove(ANode, cnRemoved, ADispose); end; +procedure TCustomAVLTreeMap.DeleteArray(const AArray: TArray; ADispose: boolean); +var + LNode: PNode; +begin + for LNode in AArray do + Delete(LNode, ADispose); +end; + procedure TCustomAVLTreeMap.Clear(ADisposeNodes: Boolean); begin if (FRoot<>nil) and ADisposeNodes then @@ -4109,6 +4145,17 @@ begin Result := Default(T); end; +function TSortedHashSet.PeekPtr(constref AValue: T): PT; +var + LIndex: SizeInt; +begin + LIndex := FInternalDictionary.FindBucketIndex(@AValue); + if LIndex >= 0 then + result := FInternalDictionary.FItems[LIndex].Pair.Key + else + result := nil; +end; + procedure TSortedHashSet.Clear; begin FInternalDictionary.Clear; diff --git a/components/sparta/generics/source/generics.defaults.pas b/components/sparta/generics/source/sparta_generics.defaults.pas similarity index 98% rename from components/sparta/generics/source/generics.defaults.pas rename to components/sparta/generics/source/sparta_generics.defaults.pas index 3259d654ee..054fe76b79 100644 --- a/components/sparta/generics/source/generics.defaults.pas +++ b/components/sparta/generics/source/sparta_generics.defaults.pas @@ -1,11 +1,11 @@ { - This file is part of the Free Pascal run time library. + This file is part of the Free Pascal/NewPascal run time library. Copyright (c) 2014 by Maciej Izak (hnb) - member of the Free Sparta development team (http://freesparta.com) + member of the NewPascal development team (http://newpascal.org) - Copyright(c) 2004-2014 DaThoX + Copyright(c) 2004-2018 DaThoX - It contains the Free Pascal generics library + It contains the generics collections library See the file COPYING.FPC, included in this distribution, for details about the copyright. @@ -24,7 +24,7 @@ **********************************************************************} -unit Generics.Defaults; +unit sparta_Generics.Defaults; {$MODE DELPHI}{$H+} {$POINTERMATH ON} @@ -39,7 +39,8 @@ unit Generics.Defaults; interface uses - Classes, SysUtils, Generics.Hashes, TypInfo, Variants, Math, Generics.Strings, Generics.Helpers; + Classes, SysUtils, TypInfo, Variants, Math, + sparta_Generics.Hashes, sparta_Generics.Strings, sparta_Generics.Helpers; type IComparer = interface @@ -229,8 +230,8 @@ type _Release: CodePointer; Equals: CodePointer; GetHashCode: CodePointer; - __Reserved: Pointer; // initially or TExtendedEqualityComparerVMT compatibility - // (important when ExtendedEqualityComparer is calling Binary method) + __Reserved: CodePointer; // initially or TExtendedEqualityComparerVMT compatibility + // (important when ExtendedEqualityComparer is calling Binary method) __ClassRef: THashFactoryClass; // hidden field in VMT. For class ref THashFactoryClass end; @@ -512,6 +513,7 @@ type TExtendedHashService = class(THashService) public + class function LookupEqualityComparer(ATypeInfo: PTypeInfo; ASize: SizeInt): Pointer; override; class function LookupExtendedEqualityComparer(ATypeInfo: PTypeInfo; ASize: SizeInt): Pointer; virtual; abstract; end; @@ -865,7 +867,25 @@ type class function GetHashCode(AKey: Pointer; ASize: SizeInt; AInitVal: UInt32 = 0): UInt32; override; end; - TmORMotHashFactory = class(THashFactory) + { TGenericsHashFactory } + + TGenericsHashFactory = class(THashFactory) + public + class function GetHashService: THashServiceClass; override; + class function GetHashCode(AKey: Pointer; ASize: SizeInt; AInitVal: UInt32 = 0): UInt32; override; + end; + + { TxxHash32HashFactory } + + TxxHash32HashFactory = class(THashFactory) + public + class function GetHashService: THashServiceClass; override; + class function GetHashCode(AKey: Pointer; ASize: SizeInt; AInitVal: UInt32 = 0): UInt32; override; + end; + + { TxxHash32PascalHashFactory } + + TxxHash32PascalHashFactory = class(THashFactory) public class function GetHashService: THashServiceClass; override; class function GetHashCode(AKey: Pointer; ASize: SizeInt; AInitVal: UInt32 = 0): UInt32; override; @@ -936,7 +956,7 @@ type class procedure GetHashList(AKey: Pointer; ASize: SizeInt; AHashList: PUInt32; AOptions: TGetHashListOptions = []); override; end; - TDefaultHashFactory = TmORMotHashFactory; + TDefaultHashFactory = TGenericsHashFactory; TDefaultGenericInterface = (giComparer, giEqualityComparer, giExtendedEqualityComparer); @@ -2168,6 +2188,13 @@ begin Result.SelectorInstance := ASelectorInstance; end; +{ TExtendedHashService } + +class function TExtendedHashService.LookupEqualityComparer(ATypeInfo: PTypeInfo; ASize: SizeInt): Pointer; +begin + Result := LookupExtendedEqualityComparer(ATypeInfo, ASize); +end; + { THashService } class function THashService.SelectIntegerEqualityComparer(ATypeData: PTypeData; ASize: SizeInt): Pointer; @@ -2796,18 +2823,44 @@ begin Result := DelphiHashLittle(AKey, ASize, AInitVal); end; -{ TmORMotHashFactory } +{ TGenericsHashFactory } -class function TmORMotHashFactory.GetHashService: THashServiceClass; +class function TGenericsHashFactory.GetHashService: THashServiceClass; begin - Result := THashService; + Result := THashService; end; -class function TmORMotHashFactory.GetHashCode(AKey: Pointer; ASize: SizeInt; AInitVal: UInt32): UInt32; +class function TGenericsHashFactory.GetHashCode(AKey: Pointer; ASize: SizeInt; AInitVal: UInt32): UInt32; begin Result := mORMotHasher(AInitVal, AKey, ASize); end; +{ TxxHash32HashFactory } + +class function TxxHash32HashFactory.GetHashService: THashServiceClass; +begin + Result := THashService; +end; + +class function TxxHash32HashFactory.GetHashCode(AKey: Pointer; ASize: SizeInt; + AInitVal: UInt32): UInt32; +begin + Result := xxHash32(AInitVal, AKey, ASize); +end; + +{ TxxHash32PascalHashFactory } + +class function TxxHash32PascalHashFactory.GetHashService: THashServiceClass; +begin + Result := THashService; +end; + +class function TxxHash32PascalHashFactory.GetHashCode(AKey: Pointer; ASize: SizeInt; + AInitVal: UInt32): UInt32; +begin + Result := xxHash32Pascal(AInitVal, AKey, ASize); +end; + { TAdler32HashFactory } class function TAdler32HashFactory.GetHashService: THashServiceClass; diff --git a/components/sparta/generics/source/generics.hashes.pas b/components/sparta/generics/source/sparta_generics.hashes.pas similarity index 96% rename from components/sparta/generics/source/generics.hashes.pas rename to components/sparta/generics/source/sparta_generics.hashes.pas index 6dba729c95..e1c186790f 100644 --- a/components/sparta/generics/source/generics.hashes.pas +++ b/components/sparta/generics/source/sparta_generics.hashes.pas @@ -1,11 +1,11 @@ { - This file is part of the Free Pascal run time library. + This file is part of the Free Pascal/NewPascal run time library. Copyright (c) 2014 by Maciej Izak (hnb) - member of the Free Sparta development team (http://freesparta.com) + member of the NewPascal development team (http://newpascal.org) - Copyright(c) 2004-2014 DaThoX + Copyright(c) 2004-2018 DaThoX - It contains the Free Pascal generics library + It contains the generics collections library See the file COPYING.FPC, included in this distribution, for details about the copyright. @@ -24,7 +24,7 @@ **********************************************************************} -unit Generics.Hashes; +unit sparta_Generics.Hashes; {$MODE DELPHI}{$H+} {$POINTERMATH ON} @@ -38,6 +38,44 @@ interface uses Classes, SysUtils; +{ Warning: the following set of macro code + that decides to use assembler or normal code + needs to stay after the _INTERFACE keyword + because FPC_PIC macro is only set after this keyword, + as it can be modified before by the global $PIC preprocessor directive. + Pierre Muller 2018/07/04 } + +{$ifdef FPC_PIC} + {$define DISABLE_X86_CPUINTEL} +{$endif FPC_PIC} + +{$if defined(OPENBSD) or defined(EMX) or defined(OS2)} + { These targets have old GNU assemblers that } + { do not support all instructions used in assembler code below } + {$define DISABLE_X86_CPUINTEL} +{$endif} + +{$ifdef CPU64} + {$define PUREPASCAL} + {$ifdef CPUX64} + {$define CPUINTEL} + {$ASMMODE INTEL} + {$endif CPUX64} +{$else} + {$ifdef CPUX86} + {$ifndef DISABLE_X86_CPUINTEL} + {$define CPUINTEL} + {$ASMMODE INTEL} + {$else} + { Assembler code uses references to static + variables with are not PIC ready } + {$define PUREPASCAL} + {$endif} + {$else CPUX86} + {$define PUREPASCAL} + {$endif} +{$endif CPU64} + // Original version of Bob Jenkins Hash // http://burtleburtle.net/bob/c/lookup3.c function HashWord( @@ -72,7 +110,9 @@ function SimpleChecksumHash(AKey: Pointer; ALength: SizeInt): UInt32; // https://code.google.com/p/hedgewars/source/browse/hedgewars/adler32.pas function Adler32(AKey: Pointer; ALength: SizeInt): UInt32; function sdbm(AKey: Pointer; ALength: SizeInt): UInt32; -function xxHash32(crc: cardinal; P: Pointer; len: integer): cardinal; +function xxHash32(crc: cardinal; P: Pointer; len: integer): cardinal;{$IFNDEF CPUINTEL}inline;{$ENDIF} +// pure pascal implementation of xxHash32 +function xxHash32Pascal(crc: cardinal; P: Pointer; len: integer): cardinal; type THasher = function(crc: cardinal; buf: Pointer; len: cardinal): cardinal; @@ -927,27 +967,6 @@ begin Result := Int32(c); end; -{$ifdef CPU64} - {$define PUREPASCAL} - {$ifdef CPUX64} - {$define CPUINTEL} - {$ASMMODE INTEL} - {$endif CPUX64} -{$else} - {$ifdef CPUX86} - {$ifndef FPC_PIC} - {$define CPUINTEL} - {$ASMMODE INTEL} - {$else} - { Assembler code uses references to static - variables with are not PIC ready } - {$define PUREPASCAL} - {$endif} - {$else CPUX86} - {$define PUREPASCAL} - {$endif} -{$endif CPU64} - {$ifdef CPUARM} // circumvent FPC issue on ARM function ToByte(value: cardinal): cardinal; inline; begin @@ -1156,8 +1175,13 @@ asm {$endif} end; {$endif CPUX64} - {$else not CPUINTEL} +function xxHash32(crc: cardinal; P: Pointer; len: integer): cardinal; +begin + result := xxHash32Pascal(crc, P, len); +end; +{$endif CPUINTEL} + const PRIME32_1 = 2654435761; PRIME32_2 = 2246822519; @@ -1171,7 +1195,7 @@ begin result := RolDWord(value, 13); end; -function xxHash32(crc: cardinal; P: Pointer; len: integer): cardinal; +function xxHash32Pascal(crc: cardinal; P: Pointer; len: integer): cardinal; var c1, c2, c3, c4: cardinal; PLimit, PEnd: PAnsiChar; begin @@ -1193,7 +1217,12 @@ begin end else result := crc + PRIME32_5; inc(result, len); - while P <= PEnd - 4 do begin + { Use "P + 4 <= PEnd" instead of "P <= PEnd - 4" to avoid crashes in case P = nil. + When P = nil, + then "PtrUInt(PEnd - 4)" is 4294967292, + so the condition "P <= PEnd - 4" would be satisfied, + and the code would try to access PCardinal(nil)^ causing a SEGFAULT. } + while P + 4 <= PEnd do begin inc(result, PCardinal(P)^ * PRIME32_3); result := RolDWord(result, 17) * PRIME32_4; inc(P, 4); @@ -1209,7 +1238,6 @@ begin result := result * PRIME32_3; result := result xor (result shr 16); end; -{$endif CPUINTEL} {$ifdef CPUINTEL} @@ -1583,7 +1611,7 @@ begin begin InitializeCrc32ctab; crc32c := @crc32cfast; - mORMotHasher := @xxHash32; + mORMotHasher := @{$IFDEF CPUINTEL}xxHash32{$ELSE}xxHash32Pascal{$ENDIF}; end; end. diff --git a/components/sparta/generics/source/generics.helpers.pas b/components/sparta/generics/source/sparta_generics.helpers.pas similarity index 92% rename from components/sparta/generics/source/generics.helpers.pas rename to components/sparta/generics/source/sparta_generics.helpers.pas index a03cf8887a..0a24a89172 100644 --- a/components/sparta/generics/source/generics.helpers.pas +++ b/components/sparta/generics/source/sparta_generics.helpers.pas @@ -1,11 +1,11 @@ { - This file is part of the Free Pascal run time library. + This file is part of the Free Pascal/NewPascal run time library. Copyright (c) 2014 by Maciej Izak (hnb) - member of the Free Sparta development team (http://freesparta.com) + member of the NewPascal development team (http://newpascal.org) - Copyright(c) 2004-2014 DaThoX + Copyright(c) 2004-2018 DaThoX - It contains the Free Pascal generics library + It contains the generics collections library See the file COPYING.FPC, included in this distribution, for details about the copyright. @@ -16,7 +16,7 @@ **********************************************************************} -unit Generics.Helpers; +unit sparta_Generics.Helpers; {$MODE DELPHI}{$H+} {$MODESWITCH TYPEHELPERS} diff --git a/components/sparta/generics/source/generics.memoryexpanders.pas b/components/sparta/generics/source/sparta_generics.memoryexpanders.pas similarity index 95% rename from components/sparta/generics/source/generics.memoryexpanders.pas rename to components/sparta/generics/source/sparta_generics.memoryexpanders.pas index 77acbf4448..9c69109d82 100644 --- a/components/sparta/generics/source/generics.memoryexpanders.pas +++ b/components/sparta/generics/source/sparta_generics.memoryexpanders.pas @@ -1,11 +1,11 @@ { - This file is part of the Free Pascal run time library. + This file is part of the Free Pascal/NewPascal run time library. Copyright (c) 2014 by Maciej Izak (hnb) - member of the Free Sparta development team (http://freesparta.com) + member of the NewPascal development team (http://newpascal.org) - Copyright(c) 2004-2014 DaThoX + Copyright(c) 2004-2018 DaThoX - It contains the Free Pascal generics library + It contains the generics collections library See the file COPYING.FPC, included in this distribution, for details about the copyright. @@ -16,7 +16,7 @@ **********************************************************************} -unit Generics.MemoryExpanders; +unit sparta_Generics.MemoryExpanders; // Memory expanders {$mode delphi} diff --git a/components/sparta/generics/source/generics.strings.pas b/components/sparta/generics/source/sparta_generics.strings.pas similarity index 77% rename from components/sparta/generics/source/generics.strings.pas rename to components/sparta/generics/source/sparta_generics.strings.pas index da80e01499..88568dcbe2 100644 --- a/components/sparta/generics/source/generics.strings.pas +++ b/components/sparta/generics/source/sparta_generics.strings.pas @@ -1,11 +1,11 @@ { - This file is part of the Free Pascal run time library. + This file is part of the Free Pascal/NewPascal run time library. Copyright (c) 2014 by Maciej Izak (hnb) - member of the Free Sparta development team (http://freesparta.com) + member of the NewPascal development team (http://newpascal.org) - Copyright(c) 2004-2014 DaThoX + Copyright(c) 2004-2018 DaThoX - It contains the Free Pascal generics library + It contains the generics collections library See the file COPYING.FPC, included in this distribution, for details about the copyright. @@ -16,7 +16,7 @@ **********************************************************************} -unit Generics.Strings; +unit sparta_Generics.Strings; {$mode objfpc}{$H+} diff --git a/components/sparta/generics/sparta_generics.lpk b/components/sparta/generics/sparta_generics.lpk index 8b1a34da56..d33e338502 100644 --- a/components/sparta/generics/sparta_generics.lpk +++ b/components/sparta/generics/sparta_generics.lpk @@ -14,27 +14,27 @@ - + - + - + - + - + - + diff --git a/components/sparta/generics/sparta_generics.pas b/components/sparta/generics/sparta_generics.pas index 993cfe3ffa..e6d158e3d8 100644 --- a/components/sparta/generics/sparta_generics.pas +++ b/components/sparta/generics/sparta_generics.pas @@ -4,11 +4,13 @@ unit sparta_Generics; +{$warn 5023 off : no warning about unused units} interface uses - Generics.Collections, Generics.Defaults, Generics.Hashes, Generics.Helpers, - Generics.MemoryExpanders, Generics.Strings; + sparta_Generics.Collections, sparta_Generics.Defaults, + sparta_Generics.Hashes, sparta_Generics.Helpers, + sparta_Generics.MemoryExpanders, sparta_Generics.Strings; implementation diff --git a/components/sparta/mdi/source/sparta_abstractresizer.pas b/components/sparta/mdi/source/sparta_abstractresizer.pas index f29d07f939..149ff94b0b 100644 --- a/components/sparta/mdi/source/sparta_abstractresizer.pas +++ b/components/sparta/mdi/source/sparta_abstractresizer.pas @@ -5,8 +5,8 @@ unit sparta_AbstractResizer; interface uses - Classes, SysUtils, Controls, ExtCtrls, Forms, Math, StdCtrls, Buttons, Dialogs, - LCLType, + Classes, SysUtils, Math, + LCLType, Controls, ExtCtrls, Forms, StdCtrls, Buttons, Dialogs, sparta_InterfacesMDI, sparta_BasicResizeFrame, sparta_MDI_StrConsts; type diff --git a/components/sparta/mdi/source/sparta_basicfakecustom.pas b/components/sparta/mdi/source/sparta_basicfakecustom.pas index a4e0f8f3e5..abd1d0bd07 100644 --- a/components/sparta/mdi/source/sparta_basicfakecustom.pas +++ b/components/sparta/mdi/source/sparta_basicfakecustom.pas @@ -5,8 +5,9 @@ unit sparta_BasicFakeCustom; interface uses - Classes, SysUtils, Controls, Forms, sparta_InterfacesMDI, LCLIntf, - LCLType, sparta_FormBackgroundForMDI; + Classes, SysUtils, + LCLType, LCLIntf, Controls, Forms, + sparta_InterfacesMDI, sparta_FormBackgroundForMDI; type diff --git a/components/sparta/mdi/source/sparta_basicresizeframe.pas b/components/sparta/mdi/source/sparta_basicresizeframe.pas index 4c7291e256..69e6656d7e 100644 --- a/components/sparta/mdi/source/sparta_basicresizeframe.pas +++ b/components/sparta/mdi/source/sparta_basicresizeframe.pas @@ -5,8 +5,10 @@ unit sparta_BasicResizeFrame; interface uses - Classes, contnrs, SysUtils, FileUtil, Forms, Controls, ExtCtrls, StdCtrls, - Graphics, LCLType, lclintf, Menus, LMessages, Math, Types, sparta_InterfacesMDI; + Classes, Types, contnrs, SysUtils, Math, + FileUtil, + LCLType, LCLIntf, LMessages, Forms, Controls, ExtCtrls, StdCtrls, Graphics, Menus, + sparta_InterfacesMDI; type TPositioningCode = (pcPositioning, pcPositioningEnd); diff --git a/components/sparta/mdi/source/sparta_basicresizer.pas b/components/sparta/mdi/source/sparta_basicresizer.pas index 0c36a4947a..4697ad3a9a 100644 --- a/components/sparta/mdi/source/sparta_basicresizer.pas +++ b/components/sparta/mdi/source/sparta_basicresizer.pas @@ -5,9 +5,9 @@ unit sparta_BasicResizer; interface uses - Classes, SysUtils, Controls, ExtCtrls, sparta_BasicResizeFrame, Forms, StdCtrls, - LCLType, Buttons, Dialogs, - sparta_InterfacesMDI, sparta_AbstractResizer; + Classes, SysUtils, + LCLType, Controls, ExtCtrls, Forms, StdCtrls, Buttons, Dialogs, + sparta_BasicResizeFrame, sparta_InterfacesMDI, sparta_AbstractResizer; type diff --git a/components/sparta/mdi/source/sparta_multiplyresizer.pas b/components/sparta/mdi/source/sparta_multiplyresizer.pas index 4cf88e39b0..0412101727 100644 --- a/components/sparta/mdi/source/sparta_multiplyresizer.pas +++ b/components/sparta/mdi/source/sparta_multiplyresizer.pas @@ -5,8 +5,13 @@ unit sparta_MultiplyResizer; interface uses - Forms, Classes, SysUtils, Controls, Generics.Collections, LMessages, - + Classes, SysUtils, + Forms, Controls, LMessages, +{$IF FPC_FULLVERSION>=30200} + Generics.Collections, +{$ELSE} + sparta_Generics.Collections, +{$ENDIF} sparta_AbstractResizer, sparta_InterfacesMDI, sparta_BasicResizeFrame; type diff --git a/components/sparta/smartformeditor/source/sparta_componentpalette.pas b/components/sparta/smartformeditor/source/sparta_componentpalette.pas index 34c6d331b5..5cdb08c0c4 100644 --- a/components/sparta/smartformeditor/source/sparta_componentpalette.pas +++ b/components/sparta/smartformeditor/source/sparta_componentpalette.pas @@ -19,10 +19,10 @@ interface uses Forms, Classes, SysUtils, Controls, ComCtrls, ComponentReg, ExtCtrls, Buttons, Math, LazIDEIntf, PropEdits, LResources, LCLType, Graphics, -{$IFDEF USE_GENERICS_COLLECTIONS} +{$IF FPC_FULLVERSION>=30200} Generics.Collections, {$ELSE} - ghashmap, sparta_HashUtils, + sparta_Generics.Collections, {$ENDIF} FormEditingIntf, IDEImagesIntf; @@ -43,14 +43,9 @@ type TComponentsPalette = class(TComponent) private pcComponents: TPageControl; - FFilter: string; FRoot: TPersistent; -{$IFDEF USE_GENERICS_COLLECTIONS} FPages: TDictionary; -{$ELSE} - FPages: THashmap; -{$ENDIF} FLastForm: TCustomForm; FIgnoreRoot: Boolean; @@ -228,11 +223,7 @@ var i, j: Integer; LCtrl: TControl; LPComponents: TPanel; -{$IFDEF USE_GENERICS_COLLECTIONS} LButtons: TList; -{$ELSE} - LButtons: TList; -{$ENDIF} LVisibleButtons: Integer; LCompName: string; LSearchResult: TTabSheet; @@ -280,11 +271,7 @@ begin // use filter ! else begin -{$IFDEF USE_GENERICS_COLLECTIONS} LButtons := TList.Create; -{$ELSE} - LButtons := TList.Create; -{$ENDIF} for i := 1 to pcComponents.PageCount - 1 do begin LPComponents := FPages[pcComponents.Pages[i]].FComponents; @@ -341,11 +328,7 @@ var LUpDown: TUpDown; LLines: Integer; begin -{$IFDEF USE_GENERICS_COLLECTIONS} if (pcComponents.ActivePage = nil) or (not FPages.ContainsKey(pcComponents.ActivePage)) then -{$ELSE} - if (pcComponents.ActivePage = nil) or (not FPages.contains(pcComponents.ActivePage)) then -{$ENDIF} Exit; LPComponents := FPages[pcComponents.ActivePage].FComponents; @@ -417,11 +400,7 @@ begin IDEComponentPalette.AddHandlerComponentAdded(ComponentAdded); GlobalDesignHook.AddHandlerSetSelection(OnDesignSetSelection); -{$IFDEF USE_GENERICS_COLLECTIONS} FPages := TDictionary.Create; -{$ELSE} - FPages := THashmap.Create; -{$ENDIF} pcComponents := TPageControl.Create(AOwner); pcComponents.Parent := AParent; @@ -566,19 +545,10 @@ procedure TComponentsPalette.UpdateComponentsList; LPComponents.Top := 0; LPComponents.AnchorSideBottom.Control := LPage; LPComponents.AnchorSideBottom.Side := asrBottom; - - LPComponents.ChildSizing.Layout := cclLeftToRightThenTopToBottom; - LPComponents.BevelOuter := bvNone; - LUpDown.Visible := False; - -{$IFDEF USE_GENERICS_COLLECTIONS} FPages.Add(LPage, TPageData.Create(LUpDown, LPComponents, LButton)); -{$ELSE} - FPages.insert(LPage, TPageData.Create(LUpDown, LPComponents, LButton)); -{$ENDIF} // not each page has components - for example: searching result if (APage = nil) or (not APage.Visible) then @@ -598,7 +568,6 @@ procedure TComponentsPalette.UpdateComponentsList; LIcon.Free; Hint := Format('%s' + sLineBreak + '(%s)', [LClass.ClassName, LClass.UnitName]); - ShowHint := True; Flat := True; GroupIndex := 1; @@ -622,42 +591,29 @@ var begin if FRoot = nil then Exit; - -{$IFDEF USE_GENERICS_COLLECTIONS} FPages.Clear; -{$ELSE} - FPages.Free; - FPages := THashmap.Create; -{$ENDIF} - if Assigned(IDEComponentPalette) then begin for i := pcComponents.PageCount - 1 downto 0 do pcComponents.Pages[i].Free; - CreatePage('Search result', nil); - for i := 0 to IDEComponentPalette.Pages.Count-1 do begin LPage := IDEComponentPalette.Pages[i]; if not LPage.Visible then Continue; - CreatePage(LPage.PageName, LPage); end; end; - pcComponentsResize(nil); RefreshSearchResult; end; -procedure TComponentsPalette.OnDesignSetSelection( - const ASelection: TPersistentSelectionList); +procedure TComponentsPalette.OnDesignSetSelection(const ASelection: TPersistentSelectionList); begin // to replace original components palette if not FIgnoreRoot or (csDestroying in ComponentState) then Exit; - Root := GlobalDesignHook.LookupRoot; end; diff --git a/components/sparta/toolsapi/source/designeditors.pas b/components/sparta/toolsapi/source/designeditors.pas index 27ca202bb2..bf781196d7 100644 --- a/components/sparta/toolsapi/source/designeditors.pas +++ b/components/sparta/toolsapi/source/designeditors.pas @@ -5,8 +5,15 @@ unit DesignEditors; interface uses - Classes, SysUtils, ComponentEditors, PropEdits, DesignIntf, DesignMenus, Generics.Defaults, - TypInfo, IniFiles, Menus; + Classes, SysUtils, TypInfo, IniFiles, + Menus, + ComponentEditors, PropEdits, +{$IF FPC_FULLVERSION>=30200} + Generics.Defaults, +{$ELSE} + sparta_Generics.Defaults, +{$ENDIF} + DesignIntf, DesignMenus; type