The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,854 other subscribers

Archive for the ‘Delphi’ Category

Reminder to self: be aware of implicit setup/tear down code in methods

Posted by jpluimers on 2020/02/13

If a part of a method requires implicit setup/tear-down code (for instance when using managed types like arrays, strings, etc), especially in rarely taken execution paths, then consider putting that code in a separate method.

I bumped into this recently, and found out it does not just hold for Delphi, it can happen in other languages too.

A Delphi example I found back is this one: [WayBackDelphi Corner Weblog: Speed problems caused by code that never ran.

The problem with Delphi is that the language does not have local scope (variables are at the start of the method) which means the penalty is for the full method.

I bumped into this in C# where a piece of legacy code had the variables declared away from the block where they finally were used.

This historically grew, because originally they were used in more placed of the code.

The refactoring limiting the scope just never put the declaration close to the usage hence violating the proximity principle.

Via: [WayBack] Ouch! Code that doesn’t get executed can still cause other code in the same procedure to become much slower. Of course, in retrospect, once you know the… – Thomas Mueller (dummzeuch) – Google+

–jeroen

Posted in .NET, Delphi, Development, Software Development | Leave a Comment »

Delphi desktop settings: .DST naming limitations and content similarity to .DSK files

Posted by jpluimers on 2020/02/12

Based on [WayBack] Bummer, cannot save a Delphi desktop named “Default Layout – right 3/4” – at load this one seems to be restored, but the list does not contain that entry. – Jeroen Wiert Pluimers – Google+:

–jeroen

Posted in Delphi, Development, Software Development | Leave a Comment »

Catch Me If You Can: LLVM back-end cannot catch all exceptions

Posted by jpluimers on 2020/02/11

[WayBack] Catch Me If You Can:

the LLVM backend cannot return from a hardware exception (like AV) if the hardware exception is raised directly within a try...except block. It can only safely return if there is a function (method) call within the try...except block.

Via and by [WayBack] Dalija Prasnikar – Google+

–jeroen

Posted in Delphi, Development, Software Development | 1 Comment »

Is there a keyboard shortcut to go to the next/previous compiler error in the current …

Posted by jpluimers on 2020/02/11

Via: [WayBack] Is there a keyboard shortcut to go to the next compiler error in the current source file? – Jeroen Wiert Pluimers – Google+:

Primož Gabrijelčič:
Alt-F7, Alt-F8 IIRC

And indeed, it is sort of documented as of Delphi 2007 for “Message View”, but appears to be a much older shortcut:

I also completely forgot the compiler output is indeed a “Message View”.

–jeroen

Posted in Delphi, Development, Software Development | Leave a Comment »

Delphi Berlin and up without disabled Castalia: Use Ctrl+W to select content in the IDE code editor. Place your curso…

Posted by jpluimers on 2020/02/06

If you have enough guts to keep Castalia enabled and have Delphi Berlin or higher, then you can use this shortcut:

[WayBack] Tip: Use Ctrl+W to select content in the IDE code editor. Place your cursor some random piece of code, preferably deep in code that have nested block… – Lars Fosdal – Google+

–jeroen

Posted in Castalia, Delphi, Development, Software Development | Leave a Comment »

The magic Delphi ReturnAddress intrinsic

Posted by jpluimers on 2020/02/05

I could not find any official place where ReturnAddress is documented even though it is used at quite a few places in the RTL, VCL, FMX and 3rd party libraries like DUnitX, Spring4D, JCL, ReportBuilder, TeeChart.

I tried searching it in the contexts of Delphi 2007, Delphi 2009, but there is only a [Archive.is] different System.ObjAuto.TParameters.ReturnAddress documented in XE2 and higher.

procedure Abort;
begin
  raise EAbort.CreateRes(@SOperationAborted) at ReturnAddress;
end;

There is a (usually broken*) ReturnAddr function used in various places of the RTL/VCL/FMX and (therefore wrongfully copied) in many other peoples code.

  function ReturnAddr: Pointer;
  // From classes.pas
  asm
    MOV     EAX,[EBP+4] // sysutils.pas says [EBP-4], but this works !
  end;
  • See the above link; I think this was fixed in Delphi XE, but the issue is still open.

Related to the above is the documented ExceptAddr.

I’ve used this in my ExceptionHelperUnit to build a GetStackTrace function in the example gist below.

I found these posts documenting the behaviour of the above intrinsic functions and more:

–jeroen

Read the rest of this entry »

Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | Leave a Comment »

Delphi: Bezier in FMX

Posted by jpluimers on 2020/02/04

In case I ever need to do some Bezier curve coding in Delphi: [WayBack] GitHub – zhaoyipeng/FMXComponents: Firemonkey Opensource Components

Via: [WayBack] Interesting set of components for FireMonkey – Christen Blom-Dahl – Google+

–jeroen

Read the rest of this entry »

Posted in Delphi, Development, FireMonkey, Software Development | Leave a Comment »

Some ideas on using DataSnap as a data-conversion layer between two systems

Posted by jpluimers on 2020/01/30

For my link archive as it contains some interesting ideas on how to use DataSnap as a conversion later between two systems: [WayBack] I need to write some DataSnap “middleware” between Google Glass and a SwissLog ERP system, and I am trying to figure out if there are significant differ… – Lars Fosdal – Google+

The ideas is basically a session based protocol converter.

–jeroen

Posted in Delphi, Development, Software Development | Leave a Comment »

OMF, COFF and the 32-bit/64-bit Delphi or C++ compilers

Posted by jpluimers on 2020/01/29

Via [WayBack] As far as I can tell (and documentation on that is reaaaaaaly hard to find), dcc64 can link in .obj files in OMF and COFF format. Bcc64 uses LLVM chain and therefore produces ELF .o files… – Primož Gabrijelčič – Google+:

David Heffernan:
dcc32 does coff and omf, dcc64 only coff

and later he commented:

One of the difficulties with linking objects is the handling of exceptions. The 64 bit exception model is table based, in contrast to the stack based 32 bit model.

I don’t think that the exception tables are written correctly for code linked in objects. If exceptions are raised then this can lead to abnormal process termination. Process just disappears. Poof!

One common way that this happens is floating point exceptions that are by default unmasked by the Delphi RTL. I have found it necessary to mask them when calling into any linked object code to avoid exceptions being raised.

And compiling with cl can be a bit of a game. It’s stack checking options need to be disabled. And there are a few other key switches that help. And then there’s the forward declaration trick to help the one pass compiler cope with C objects that are expected to be linked in a separate step.

Anyway, it can be quite a challenge at times, but I’ve yet to find a plain self contained C library that has defeated me!

–jeroen

Posted in C++, C++ Builder, Delphi, Delphi x64, Development, Software Development, Visual Studio C++ | 2 Comments »

DPI aware Vcl applications and use Vcl Styles

Posted by jpluimers on 2020/01/28

For my link archive: [WayBack] Do you want to produce DPI aware Vcl applications and use Vcl Styles?… – Kiriakos Vlahos – Google+

Source at [WayBack] pyscripter/VCL.Styles.DPIAware.pas at master · pyscripter/pyscripter · GitHub

–jeroen

Posted in Delphi, Development, Software Development | Leave a Comment »