104

GetIt Package Manager

GetIt Package Manager Enhancements Coming in RAD Studio 10.4 RAD Studio has a light weight package manager, a mechanism for downloading additional product features, add-on libraries and components, demos, VCL and FMX styles and more. Some of the content is provided by Embarcadero, but a lot comes from our community of developers and third-party vendors. Now in the coming 10.4 release of Delphi and C++Builder, the GetIt Package manager is going to see significant changes in 10.4. The key addition is that now each entry has an associated release date, technically a timestamp. This is the foundation of different features: the ability of sorting the list of entries by date, seeing the most recent ones on top for each entry you have already installed, the indication that an updated version is available the ability to list all installed entries that have an update available Updated Filters In terms of UI change, the Filter section of the GetIt dialog UI will be modified: We are removing older, inactive filters (like Free and Paid) and keeping 2 options offering 2 new ones: All for all entries Installed for the packages installed on the current system Subscription only is a new filter for exclusive content published by Embarcadero and limited to customers with an active update subscription license Updates lists packages installed on the current system and for which a new release is available (that is a package with a newer timestamp than the installed version timestamp) This is the updates filter in action: Another change is in the Sort By section of the GetIt Dialog box, which is going to have a new option to sort packages by release date (or timestamp). GetIt Entries UI The UI of the individual entry in the GetIt dialog will also be modified to indicate the specific date the package was published and (eventually) the date you installed that package. Depending on the status, the entry UI includes new buttons for the action(s) — there are now more actions available, including Updating a package. Here you can see the standard UI for an entry and the same after the package has been installed and an update has been made available: Notice that the two dates indicated in the last image are the release date of the last update and the release date of the one currently installed (the timestamp of the installed item, not the date it was installed). RAD Studio Patches Another key feature we are enabling in 10.4 is the ability to use GetIt to distribute patches, with a specific way to alert customers that a patch is available. We’ve added a new section to the Welcome page to indicate when a patch is available and you have not installed it: Once installed, that indication will disappear. Combined to this Welcome page hint, we’ll have a new category in the GetIt package manager for patches. But this is not the only related change. We have technically introduced a deferred installation mode, so that a patch requiring to update files used by the RAD Studio IDE itself can be installed by a separate process once you close RAD Studio (or as you restart it). This will account for the installation of more complex patches, that require you to close RAD Studio first. Additional GetIt Features Beside the features […]

Read More

Nou în Delphi 10.4 – Custom Managed Records

What is a Custom Managed Record in Delphi? Records in Delphi can have fields of any data type. When a record has plain (non-managed) fields, like numeric or other enumerated values there isn’t much to do for the compiler. Creating and disposing the record consists of allocating memory or getting rid of the memory location. (Notice that by default Delphi does not zero-initialize records.) If a record has a field of a type managed by the compiler (like a string or an interface), the compiler needs to inject extra code to manage the initialization or finalization. A string, for example, is reference counted so when the record goes out of scope the string inside the record needs to have its reference count decreased, which might lead to de-allocating the memory for the string. Therefore, when you are using such a managed record in a section of the code, the compiler automatically adds a try-finally block around that code, and makes sure the data is cleared even in case of an exception. This has been the case for a long time. In other words, managed records have been part of the Delphi language. Records with Initialize and Finalize Operators  Now in Delphi 10.4 record type supports custom initialization and finalization, beyond the default operations the compiler does for managed records. You can declare a record with custom initialization and finalization code regardless of the data type of its fields, and you can write such custom initialization and finalization code. This is achieved by adding specific, new operators to the record type (you can have one without the other if you want).Below is a simple code snippet: type TMyRecord = record Value: Integer; class operator Initialize (out Dest: TMyRecord); class operator Finalize(var Dest: TMyRecord); end; You need to write the code for the two class methods, of course, for example logging their execution or initializing the record value — here we are also logging a reference to memory location, to see which record is performing each individual operation: class operator TMyRecord.Initialize (out Dest: TMyRecord); begin Dest.Value := 10; Log(‘created’ + IntToHex (Integer(Pointer(@Dest))))); end; class operator TMyRecord.Finalize(var Dest: TMyRecord); begin Log(‘destroyed’ + IntToHex (Integer(Pointer(@Dest))))); end; The huge difference between this construction mechanism and what was previously available for records is the automatic invocation. If you write something like the code below, you can invoke both the initializer and the finalizer, and end up with a try-finally block generated by the compiler for your managed record instance. procedure LocalVarTest; var my1: TMyRecord; begin Log (my1.Value.ToString); end; With this code you’ll get a log like: created 0019F2A8 10 destroyed 0019F2A8 Another scenario is the use of inline variables, like in: begin var t: TMyRecord; Log(t.Value.ToString); which gets you the same sequence in the log.  The Assign Operator The := assignment flatly copies all of the data of the record fields. While this is a reasonable default, when you have custom data fields and custom initialization you might want to change this behavior. This is why for Custom Managed Records you can also define an assignment operator. The new operator is invoked with the := syntax, but defined as Assign: class operator Assign (var Dest: TMyRecord; const [ref] Src: TMyRecord); The operator definition must follow very precise rules, including having the first parameter as a reference […]

Read More