Friday 18 May 2012

Delphi Language links/info

This week’s instalment of the UK Developer Direct webinar series is called Delphi Language Focus (Object development, RTTI, 64 Bit). The following is a set of links and general information picked up during the broadcast.


Miscellaneous info

  • XML documentation comments against types, methods, etc. are automatically turned into descriptive tooltips through IDE facility called Help Insight. To ease the process of creating correctly formed XML comments for this purpose, you can use Documentation Insight. This is a third part tool (it’s the Express version DevJet’s Documentation Insight product) bundled with the IDE that adds in a window to the IDE to help automate the process of adding in the correct comments, based on editor context. To access Documentation Insight, press Ctrl+Alt+D or choose Tools, Documentation Insight, Show Documentation Insight
  • Ctrl+Shift+G generates a GUID and inserts it in the code editor, including the appropriate braces, quotes and square brackets
  • Extended RTTI is only supported on Win32/Win64, not currently OS X. At least I think this is what I heard. If so, this is most likely due to assembly code in the RTTI support code that is pending translation to be suitable for OS X.
  • Delphi now supports scoped enumerations, as per C# and the Oxygene language. This reduces the need for prefix letters on enum values.
  • TOSVersion is a new record type in the SysUtils unit to analyse which platform architecture and version you are running on.
  • Multi-platform enabled TZipFile is available in the System.Zip unit. It supports, among other things, adding an existing file into an archive but such that it is stored in the archive with another name.

64-bit information:

  • 64-bit Windows application development has been introduced in RAD Studio XE2
  • On 64-bit Windows, Task Manager highlights 32-bit (x86) applications by suffixing the process name with *32; 64-bit (x64) applications have no suffix.
  • The Project Manager’s Target Platforms section allows a VCL app to target either Win32 or Win64, and FMX (FireMonkey) applications can target Win32, Win64 or OS X.
  • A primary benefit of targeting 64-bit Windows is the ability to range as much memory as your machine can address. In the case of a 32-bit app running in a 32-bit OS, a max of 4GB of memory, but that includes memory reserved by the graphics card and various system devices and all the memory space Windows reserves for itself. Generally a 32-bit Windows OS can access between 2.75GB and 3.5GB max and user processes have a maximum accessible memory space of 2GB (or 3GB if Windows is started with a special switch). See this MS article for more details.
  • The size of pointer types (e.g. object references) change between 32-bit and 64-bit.
  • NativeInt is 32-bit or 64-bit based on target platform. The TComponent Tag property is defined to be NativeInt to cater for the common habit of developers storing pointers (such as object references) in Tag (with a suitable typecast).
  • Integer remains 32-bit when targeting 64-bit apps.
  • To build a 64-bit app all dependent libraries must also be 64-bit. 32-bit DLLs and libraries are not usable in 64-bit apps.
  • 64-bit has but one calling convention, very much unlike 32-bit. However the 64-bit compiler just ignores the Delphi calling-convention keywords register, pascal, cdecl & stdcall, so you can leave them in. No need for conditional compilation.
  • Assembler code: rewrite it in Pascal so it works on any target. Inline assembly code is platform-dependant and so will need rewriting for 64-bit and will require a _lot_ of learning – there are many differences. Additionally, if targeting OS X there will be a host of additional requirements thanks to the way the OS architectures differ.
  • 32-bit values (e.g. Integer) will shl & shr in 32-bit space.
  • 64-bit does not support the Extended type (well, ok it does, but it’s mapped onto the 10-byte type Double) but Delphi offers the TExtended80Rec record type to process extended values from binary data files.
  • 1 comment: