[WayBack] The Delphi Open Tools API Book 1.1 – Dave’s Development Blog
- Where is available open tools api book for download?
A:David Hoyle has a great website and book. https://www.davidghoyle.co.uk/WordPress/?page_id=1110
–jeroen
Posted by jpluimers on 2021/10/07
[WayBack] The Delphi Open Tools API Book 1.1 – Dave’s Development Blog
–jeroen
Posted in Delphi, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2021/09/23
From a long time ago, but got a request for it a while ago is [WayBack/Archive.is] Howto create C-Header for Delphi/Free Pascal/Lazarus DLL – data types – Stack Overflow:
I have used the below construct to generate header files compatible with the C-mode compiler of Visual C++ 6 from Delphi 5 code when Delphi had the -JPH switch (see notes below).Note that I have not used this since Delphi 5, but the switch has since then been expanded:Somewhere along the line, the [WayBack] JPHNE switch has been added to thedcc32command-line compiler:-JPHNE = Generate C++ .obj file, .hpp file, in namespace, export allRudy Velthuis has a [WayBack] nice article using the JPHNE switch.It certainly does not handle all types, and you will need quite a bit of [Archive.is] HPPEMIT and [Archive.is] EXTERNALSYM directives.I uploaded my [Archive.is] Delphi 5 to Visual C++ 6 HPP conversion from back then to BitBucket.It generates the .hpp files to import the DLL that was written in Delphi.Notes from the Delphi 5 era:{ Visual C++ 6 does not like nested structs/unions the way that BC++ can handle them. Visual C++ 6 requires the "typedef" to be present AND the typename AFTER the struct definition. You will see this when defining TConversationId, TReturnKey and other types that depend on nested structs/unions The trick is to perform these steps each and every time this unit changes: - Generate this unit once with all the EXTERNALSYM disabled. - Then the DCC32 -JPH will generate the basic structs for them. - Copy all the nested struct and union definitions to this file - Embed the definitions with (*$HPPEMIT '' *) - Append the typename at the end of the struct definition - Enable all the EXTERNALSYM again - Regenerate the HPP files by using DCC32 -JPH To make this process easier, we have introduced two new conditional defines: - BCB - disable EXTERNALSYM, disable HPPEMIT - VC6 - enable EXTERNALSYM, enable HPPEMIT A similar thing is with these constructions that VC6 does not like those either: - short strings (BCB defines them as "SmallString<##>" which VC6 does not like). - short integers (BCB defines them as "Shortint" so we have included an HPPEMIT for that) } {$ifdef win32} { important! Makes sure that the all enumerated types fit in exactly one byte each! } {$Z1} { force the C/C++ HPP header files to have the C/C++ compiler pack structure elements on byte boundaries } {$ifdef BCB} {$HPPEMIT '#pragma option push -a1' } {$endif BCB} {$endif win32}
And the download (hopefully I have converted it to git by then):
The link to the converter is now [Archive.is] bitbucket.org/jeroenp/wiert.me/src/default/Native/… – Delphi Coder
–jeroen
Posted in Delphi, Delphi 5, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2021/08/31
For my link archive:
I am requesting Delphi (Object Pascal) support as it’s still a widely used language. At minimum, a generic Pascal language support is requested so it could be used for Delphi and FreePascal (FPC) A somewhat workable plugin is available for use as a base: https://github.com/fabriciocolombo/sonar-delphi
--jeroen
Posted in Delphi, Development, Software Development, SonarQube, Static Code Analysis | 2 Comments »
Posted by jpluimers on 2021/08/24
The Flux architecture is often used in ReactJS, but there are also implementations outside that realm.
So here are some links for my archive:
Flux is the application architecture that Facebook uses for building client-side web applications. It complements React’s composable view components by utilizing a unidirectional data flow. It’s more of a pattern rather than a formal framework, and you can start using Flux immediately without a lot of new code.
–jeroen
Posted in .NET, C#, Delphi, Development, JavaScript/ECMAScript, ReactJS, Scripting, Software Development | Leave a Comment »
Posted by jpluimers on 2021/08/17
I hardly use the [WayBack] TClientDataSet Class any more, so every once in a while I bump into a legacy project that does.
Often that forgets provide a deployment list, so usually with deployment of the underlying DLL is forgotten.
Those moments, it slips my mind that the original name for the underlying DataSnap technology is called MIDAS, and the DLL is MIDAS.DLL. Sometimes even a wrong version of that DLL is distributed (unicode versus non-unicode still can still be a thing).
You can avoid loading it (often at a premium of reduced speed) my adding MidasLib to the uses list of any unit in your project:
you add
MidasLibto your project’s USES clause. This embeds the basic functionality into your program without having to rely on a separate DLL for it.
When you use BPLs instead of full units, then missing this can lead to a nasty access violation like this one where the ClientDataSet cannot be created because the wrong Midas.dll (non-unicode) was loaded, see the screenshot and stack overflow below.
Lessons re-learned:
OS EAccessViolation at adress 5110E007: Access violation at address 5110E007 in module 'dsnap250.bpl'. Read of address 00000000 {occured in main thread} Stack: [50060B13]{rtl250.bpl } System.@HandleAnyException [00404815]{GVS.exe } FastMM4.CalculateHeaderCheckSum$qqrp29Fastmm4.TFullDebugBlockHeader (Line 9098, "FastMM4.pas" + 1) [50060039]{rtl250.bpl } System.@AfterConstruction [00404815]{GVS.exe } FastMM4.CalculateHeaderCheckSum$qqrp29Fastmm4.TFullDebugBlockHeader (Line 9098, "FastMM4.pas" + 1) [00404824]{GVS.exe } FastMM4.UpdateHeaderAndFooterCheckSums$qqrp29Fastmm4.TFullDebugBlockHeader (Line 9108, "FastMM4.pas" + 1) [004057C6]{GVS.exe } FastMM4.DebugGetMem$qqri (Line 9649, "FastMM4.pas" + 42) [00405817]{GVS.exe } FastMM4.DebugGetMem$qqri (Line 9686, "FastMM4.pas" + 79) [5005A247]{rtl250.bpl } System.@ReallocMem [50065674]{rtl250.bpl } System.DynArraySetLength [50065715]{rtl250.bpl } System.@DynArraySetLength [5110D001]{dsnap250.bpl} Datasnap.Dbclient.TCustomClientDataSet.CreateDSBase [51111571]{dsnap250.bpl} Datasnap.Dbclient.TCustomClientDataSet.CreateDataSet [500E920D]{rtl250.bpl } System.Rtti.TValue._op_Implicit [00559D29]{CDSDemo.exe } MainDataModuleUnit.TMainDataModule.DataModuleCreate (Line 50, "MainDataModuleUnit.pas" + 1) [5016E7EF]{rtl250.bpl } System.Classes.TDataModule.DoCreate [5016E69C]{rtl250.bpl } System.Classes.TDataModule.AfterConstruction [50060039]{rtl250.bpl } System.@AfterConstruction [5016E67A]{rtl250.bpl } System.Classes.TDataModule [00544941]{CDSDemo.exe } MainFormUnit.TMainForm.PageControlChange (Line 30, "MainFormUnit.pas" + 19) [0054598B]{CDSDemo.exe } MainFormUnit.TMainForm.FormShow (Line 40, "MainFormUnit.pas" + 47) [50C075DD]{vcl250.bpl } Vcl.Forms.TCustomForm.DoShow [50C0BF7D]{vcl250.bpl } Vcl.Forms.TCustomForm.CMShowingChanged [5005FD9F]{rtl250.bpl } System.TObject.Dispatch [50AC4C16]{vcl250.bpl } Vcl.Controls.TControl.WndProc [50AC97FB]{vcl250.bpl } Vcl.Controls.TWinControl.WndProc [50C080B5]{vcl250.bpl } Vcl.Forms.TCustomForm.WndProc [50AC4850]{vcl250.bpl } Vcl.Controls.TControl.Perform [50AC8B71]{vcl250.bpl } Vcl.Controls.TWinControl.UpdateShowing [50AC8C80]{vcl250.bpl } Vcl.Controls.TWinControl.UpdateControlState [50ACB9D6]{vcl250.bpl } Vcl.Controls.TWinControl.CMVisibleChanged [50AC4C16]{vcl250.bpl } Vcl.Controls.TControl.WndProc [50AC97FB]{vcl250.bpl } Vcl.Controls.TWinControl.WndProc [50C080B5]{vcl250.bpl } Vcl.Forms.TCustomForm.WndProc [50C0E597]{vcl250.bpl } Vcl.Forms.TScreen.GetMonitor [50C094C5]{vcl250.bpl } Vcl.Forms.TCustomForm.SetWindowToMonitor [50AC4850]{vcl250.bpl } Vcl.Controls.TControl.Perform [50AC31E6]{vcl250.bpl } Vcl.Controls.TControl.SetVisible [50C078C1]{vcl250.bpl } Vcl.Forms.TCustomForm.SetVisible [50C11DCF]{vcl250.bpl } Vcl.Forms.TApplication.Run [004B3B28]{CDSDemo.exe } VclApplication.TApplication.Run (Line 113, "VclApplication.pas" + 1) (00161097){CDSDemo.exe } [00562097]
–jeroen
Posted in Delphi, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2021/08/12
Some links, because I had a hard time finding good documentation on VolatileAttribute (which is the name of the type; you use it as [Volatile] on variables, parameters and fields.
Volatile
The
volatileattribute is used to mark fields that are subject to change by different threads, so that code generation does not optimize copying the value in a register or another temporary memory location.You can use the
volatileattribute to mark the following declarations:
- Variables (global and local)
- Parameters
- Fields of a record or a class.
You cannot use the
volatileattribute to mark the following declarations:type TMyClass = class private [volatile] FMyVariable: TMyType; end;
VolatileAttriute is only used as [Volatile]).Posted in Delphi, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2021/08/11
This seems to have been introduced into Delphi Berlin: [WayBack] System.TypInfo.SizeOfSet – RAD Studio API Documentation. Maybe slightly earlier, but at least it was not documented in XE8 [WayBack] (via [WayBack] Delphi “SizeOfSet”.).
This is a useful function, for instance to get the Cardinality of a set in [WayBack] delphi – How can I get the number of elements of any variable of type set? – Stack Overflow.
From what I can see, the undocumented
TLargestSettype also got introduced in Delphi Berlin.Few hits by Google on [WayBack] Delphi “TLargestSet”, including [WayBack] Free Automated Malware Analysis Service – powered by Falcon Sandbox – Viewing online file analysis results for ‘Coperativa.exe’.
Not much more is documented than this in Tokyo [WayBack]:
System.TypInfo.SizeOfSet
Delphi
function SizeOfSet(TypeInfo: PTypeInfo): Integer;C++
extern DELPHI_PACKAGE int __fastcall SizeOfSet(PTypeInfo TypeInfo);Properties
Type Visibility Source Unit Parent function public System.TypInfo.pasSystem.TypInfo.hppSystem.TypInfo System.TypInfo Description
Embarcadero Technologies does not currently have any additional information. Please help us document this topic by using the Discussion page!
–jeroen
Posted in Delphi, Delphi 10.1 Berlin (BigBen), Delphi 10.2 Tokyo (Godzilla), Delphi 10.3 Rio (Carnival), Delphi XE8, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2021/08/10
There is a very tricky compiler and IDE issue in Delphi 10.2 and up that on the compiler site behaves differently from Delphi 1.10.1 Berlin, and on the IDE side stays the same from Delphi 2005 on.
The issue baffled me, as lot’s features were not added in the Delphi compiler because of backward compatibility reasons.
The problem is that the compiler now favours the unit search path over the paths specified in the .dpr. This breaks compatibility with earlier versions and the IDE: the IDE still thinks pathnames in the .dpr files are the ones to follow.
There are some permutations on this problem, of which a few ones below.
This results in Delphi 1..10.1 Berlin to error on compiling the project (because the unit is not found), but 10.2 and up succeeding (because the unit is found).
Another permutation is this one:
Yet another permutation:
This works the same in all versions of Delphi: the unit file referenced in the .dpr is compiled.
Via: [WayBack] Jeroen Pluimers on Twitter: “Delphi 10.2 Tokyo and 10.3 Rio compilers break Delphi 1…10.1 Berlin behaviour. Still reproducing and researching the consequences. It for instance means stuff suddenly compiles when it should not, or breaks when it should not. Preliminary reproduction at “
[WayBack] wiert.me / public / delphi / DelphiConsoleProjectWithMissingProjectUnitThatIsOnTheSearchPath · GitLab
–jeroen
Posted in Delphi, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2021/08/05
Steps:
FASTMM to your project$(BDS)\source\DUnit\src in your search path in your project (as otherwise Delphi will pick the pre-built TestFramework.dcu file which was compiled without the FASTMM conditional define)SetUp method of a class, set FailsOnMemoryLeak to TrueSetUp method of the class allocates memory, ensure the TearDown de-allocates it. Otherwise you will have leaks:
SetUp until the end of the TearDowndestructor or by automatic finalization after the destructor!TestFramework unit will not take into account the FASTMM conditional define)Depending in your test framework, FailsOnMemoryLeak might be by default be False or True:
FailsIfMemoryLeaked set to True for the root test suite (which is then applied to FailsOnMemoryLeak of any test method).procedure RunRegisteredTests(const baseUrl: string); var suite: ITestSuite; result: TTestResult; listener: ITestListener; begin suite := RegisteredTests; if not Assigned(suite) then Exit; result := TTestResult.Create; result.FailsIfNoChecksExecuted := True; result.FailsIfMemoryLeaked := True; listener := TTestInsightListener.Create(baseUrl, suite.CountEnabledTestCases); result.AddListener(listener); try suite.Run(result); finally result.Free; end; end;
FailsIfMemoryLeaked set to False.FailsIfMemoryLeaked depending on the options:Note that recent Delphi versions (I think XE and up) ship with almost the same sources as https://sourceforge.net/code-snapshots/svn/d/du/dunit/svn/dunit-svn-r44-trunk.zip, with these Embarcadero changes:
$Date: 2008-04-24 07:59:47 -0400 (Thu, 24 Apr 2008) $ $Date: 2008-04-24 11:59:47 +0000 (Thu, 24 Apr 2008) $TODO in them.dof, .cfg, and.wmzNGUITestRunner.nfm and NGUITestRunner.pas/etc/usermap/private and /projects/src/versioninfo.res from 9.3.0 to 9.2.1 (which is odd, as all files are from 9.3.0)TextTestRunner to support:
FailureCountErrorCountIndentLevelPrefixCharsADDITIONAL_INFO, BASIC_INFOUnitNameTestExtensions to support:
ANDROID_FIXME and LINUXLEGACYIFENDGUITestRunner.dfm to have ResultsView: TListView property Height value 45 instead of 39ReturnAddress in stead of CallerAddr:
TGUITestCase.FindControlTGUITestCase.ClickTGUITestCase.EnterKeyIntoTGUITestCase.EnterTextIntoTGUITestCase.ShowTGUITestCase.CheckTabTo overloadsTGUITestCase.CheckFocused overloadsTGUITestCase.CheckEnabled overloadsTGUITestCase.SetFocus overloadsTGUITestCase.CheckVisible overloadsTGUITestRunner.RunTest
class procedure TGUITestRunner.RunTest(test: ITest); begin with TGUITestRunner.Create(nil) do begin try suite := test; ShowModal; finally Free; end; end; end;
class procedure TGUITestRunner.RunTest(test: ITest); var GUI :TGUITestRunner; begin Application.CreateForm(TGUITestRunner, GUI); with GUI do begin try suite := test; ShowModal; finally Free; end; end; end;
GUITestRunner:
procedure RunTest(test: ITest); begin with TGUITestRunner.Create(nil) do begin try Suite := test; ShowModal; finally Free; end; end; end;
procedure RunTest(test: ITest); var GUI :TGUITestRunner; begin Application.CreateForm(TGUITestRunner, GUI); with GUI do begin try Suite := test; if Suite <> nil then ShowModal; finally Free; end; end; end;
TGUITestRunner.SetUp not to set SubItems[0] := ''; when there is no test suite.TGUITestRunner.FormCreate to use FormatSettings.TimeSeparator instead of TimeSeparator.HPPEMITLEGACYIFENDCLR and _USE_SYSDEBUG_AUTOREFCOUNTNEXTGENANDROIDRunCountAttribute and RunCount supportCheckEquals overload for uint64CheckNotEquals overload for TCharArrayCheckCircularRefCompareFloatRelativeNotSameErrorMessage with WideString arguments instead of stringTestDataDir functionReturnAddress for older compilersDUnitTestRunnerMakefile file–jeroen
Posted in Conference Topics, Conferences, Delphi, Development, DUnit, Event, FastMM, Software Development, TestInsight | 1 Comment »
Posted by jpluimers on 2021/08/04
You’d think the math does not add up:
But it does: both “Success” and “Warnings” are counted as “passed”.
–jeroen
Posted in Delphi, Development, Software Development, TestInsight | Leave a Comment »