Still need to research this: [WayBack] I search for way to automatically generate class body from interface definition… – Jacek Laskowski – Google+
–jeroen
Posted by jpluimers on 2019/01/23
Still need to research this: [WayBack] I search for way to automatically generate class body from interface definition… – Jacek Laskowski – Google+
–jeroen
Posted in Conference Topics, Conferences, Delphi, Development, Event, ModelMaker Code Explorer, Software Development | 2 Comments »
Posted by jpluimers on 2019/01/22
Interesting code generator from 3D models into Xamarin, Delphi or Oxygene code:
[WayBack] Petra Sketch Plugin | Melbourne | Applying Code
Convert Sketch drawings to iOS, macOS, Android and Windows native drawing code.
[WayBack] Documentation of Petra Sketch Plugin | Melbourne | Applying Code
Via:
–jeroen
Posted in .NET, C#, Delphi, Development, Software Development, Xamarin Studio | Leave a Comment »
Posted by jpluimers on 2019/01/21
Historically, [WayBack] W1036: Variable '%s' might not have been initialized (Delphi) has had a lot of gotchas.
The most important still is that it never show for managed types (strings, interfaces, etc).
Usually W1036 shows for non-managed types, but Dan Hacker has found a new case where it does not in [WayBack] Why don’t I get the warning W1036 Variable “‘MyStrings’ might not have been initialized’ if the StringsToDo parameter in DoSomething is defined as a var… – Dan Hacker – Google+
He noticed it in Delphi XE and 10.2 Tokyo.
I tested it with the Win32 compiler in XE8.
This warns:
program W1036;
{$APPTYPE CONSOLE}
uses
System.SysUtils,
System.Classes;
procedure DoSomething(var StringsToDo: TStringList); // <-------- this line makes the difference
begin
//do nothing
end;
procedure Test;
var
MyStrings : TStringList;
begin
MyStrings.Free; {W1036 warning if StringsToDo param is NOT var}
DoSomething(MyStrings);
end;
begin
end.
This does not warn:
program W1036;
{$APPTYPE CONSOLE}
uses
System.SysUtils,
System.Classes;
procedure DoSomething(StringsToDo: TStringList); // <-------- this line makes the difference
begin
//do nothing
end;
procedure Test;
var
MyStrings : TStringList;
begin
MyStrings.Free; {W1036 warning if StringsToDo param is NOT var}
DoSomething(MyStrings);
end;
begin
end.
initially, I misread his report and reacted wrongly on the cause (but rightly on the suggested use case of var and of TStringList):
Because a var parameter means that the caller should pass in an initialised parameter. Otherwise it should be an
outparameter, not avarparameter.
varparameter for reference types likeTStrings(only pass asTStringListif it deliberately is not compatible withTStrings) is a risky thing anyway, because the called method can overwrite it and then the caller has to notice the change, then decide what to do with the previous value (likely free it).
I later correct myself:
Looking better, I think it is a compiler issue.
The only difference between nothing and var is the loading of the parameter as a pointer:
with
var//W1036.dpr.16: MyStrings.Free; {W1036 warning if StringsToDo param is NOT var}
//004CD924 8B45FC mov eax,[ebp-$04]
//004CD927 E8B8A6F3FF call TObject.Free
//Project1.dpr.17: DoSomething(MyStrings);
//004CD92C 8D45FC lea eax,[ebp-$04]
//004CD92F E8E0FFFFFF call DoSomethingwithout
var//W1036.dpr.16: MyStrings.Free; {W1036 warning if StringsToDo param is NOT var}
//004CD924 8B45FC mov eax,[ebp-$04]
//004CD927 E8B8A6F3FF call TObject.Free
//Project1.dpr.17: DoSomething(MyStrings);
//004CD92C 8B45FC mov eax,[ebp-$04]
//004CD92F E8E0FFFFFF call DoSomething
So:
var, a pointer to the instance of MyStrings (obtained by a lea instruction) gets pushed on the stackvar, the instance of MyStrings (obtained by a mov instruction) gets pushed on the stack.For the difference metween mov and lea, and the use of [] brackets, see:
Given the following
code:L1 db "word", 0
mov al, [L1]
mov eax, L1What do the brackets ([L1]) represent?
–jeroen
Source: Why don’t I get the warning W1036 Variable “‘MyStrings’ might not have been i…
Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | 3 Comments »
Posted by jpluimers on 2019/01/17
Interesting: [WayBack] GitHub – pyscripter/python4delphi: Free components that wrap up Python into Delphi and Lazarus (FPC)
Via [WayBack] 【Develope a rabbitmq application with python4delphi】 You can download the vcl from https://github.com/pyscripter/python4delphi The VCL can support pyth… – dorje sona – Google+
–jeroen
Posted in Delphi, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2019/01/17
Every time he finds a new compiler use, I’m all like “wow!”. This time [WayBack] Stefan Glienke – Google+: One of these rare moments when the compiler positively impresses me found a new way to make single responsibility principle easier to attain by using a class helper to resolve interface delegation.
In the comments are a few nice tidbits on what the compiler emits in order to implement interface delegation and reference counting.
–jeroen
Posted in Delphi, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2019/01/17
If you dare using Delphi 10.3 Rio instead of waiting for Update 1 to stabalise (and hopefully speed up things), you might want to try the development snapshot of [WayBack] IDE Fix pack for Rio – Page 2 – Delphi Third-Party – Delphi-PRAXiS [en] that got released last week (thanks Andy!):
A new development snapshot of IDE Fix Pack for 10.3 Rio is available.
The Win64 (DCC64) and Android (DCCAARM) compiler patches should now work as excepted.
Changes:
- Added: Support for Delphi 10.3 Rio
- Added: Fix for TStringList.IndexOfName bug (RSP-21633)
- Added: Fix for access violoation in the Welcomepage JScript9.dll binding
- Added: TCustomListBox.ResetContent is skipped if the handle isn’t created yet
- Added: DFM Streaming optimizations
- Added: FillChar uses Enhanced REP MOVSB/STOSB cpu feature if available for large sizes.
- Added: Enabled CPU LOCK string assignment optimization for local variables
- Added: -Oe (experimental optimizations) and -x-cgo compiler option extension (Remove of some unneccessary push/pop operations)
- Added: Expression Evaluator allows array access to pointers even if the type wasn’t declared with {$POINTERMATH ON}
- Added: New compiler option extensions: -x–compileonly, -x–reslist, -x–depfile, -x–unitstats
- Added: More performance optimization for the DCC64 compiler
- Added: TStringBuilder.SetLength optimization [RSP-19178]
- Added: TStrings.GetDelimitedText optimization
- Fixed: Packages with duplicate units may not have caused a fatal compiler error.
Related:
–jeroen
Posted in Delphi, Delphi 10.3 Rio (Carnival), Development, Software Development | 4 Comments »
Posted by jpluimers on 2019/01/09
Basically I learned that I should not only look for ClassType, but also for MetaclassType: [WayBack] Not a major problem, but given that xProp is a TRttiProperty instance is there a better way to get the ClassType of a property that is tkClass? – Chad Hower – Google+:
Chris Rolliston
The
System.Rttiway is this –
x := xProp.PropertyType.AsInstance.MetaclassType;Been in since
TRttiContextwas first added, IIRC.
It indeed has been documented since Delphi 2010: [Archive.is] Rtti.TRttiClassRefType.MetaclassType – RAD Studio VCL Reference
–jeroen
Posted in Delphi, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2019/01/08
[WayBack] Delphi sorcery: Loop wars – measuring performance – already showing some nice optimisations that should have been in the RTL into the first place, – sprouted into a nice discussion at [WayBack] Since there was this offtopic argument going on about performance of for-in versus for-to. – Stefan Glienke – Google+ with some relatively straightforward forand for ... in loop compiler optimizations that could be done, but we have dreamt of for like the last decade or two.
–jeroen
Posted in Delphi, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2019/01/03
Reminder to self: [WayBack] …The IOTAComponent method SetPropByName, when used for an integer property, always sets that property to 0 instead of the desired value…. – Thomas Mueller (dummzeuch) – Google+
Fix in GExperts for the Rename Component functionality in [WayBack] GExperts / Code / Commit [r2318]: Workaround for an apparent OTA-bug: IOTAComponent.SetPropByName for integers always sets the property to 0 instead of the given value. Now we compare the values and if they don’t match use RTTY on the NativeObject to set it. This seems to work. (The bug exists on Delphi 2007 and 10.2, I haven’t tested other versions. The bugfix also works on these versions.):
VInteger := StrToInt(Value);
Result := AComponent.SetPropByName(PropertyName, VInteger);
+ if AComponent.GetPropValueByName(PropertyName, TempInt) then begin
+ // Setting an integer property often (always?) fails, so we check the value here and if
+ // it is different, we use the native object to set the value. This works.
+ // (Example: Try to set the Interval property of a TTimer. It always gets set to 0.)
+ // This happens in Delphi 2007 and 10.2, I haven't tested other versions.)
+ // -- 2018-07-16 twm
+ if TempInt <> VInteger then
+ SetPropValue(NativeObject, PropertyName, VInteger);
+ end;
Only the IOTAComponent interface is mentioned (only once!) in the documentation at [Archive.is] Using Editor Interfaces – RAD Studio, so I have ambivalent feelings on how important this is for Embarcadero to fix IOTAComponent.SetPropByName.
It has been broken since at least Delphi 2007 as per GExperts fix and XE3 as per [RSP-20895] IOTAComponent.SetPropByName always sets an integer to zero – Embarcadero Technologies.
–jeroen
Posted in Delphi, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2019/01/02
For my archive as [Archive.is] TFmxObject.Release is deprecated since Delphi 10.2 Tokyo, and – worse – broken on some platforms: [WayBack] android – How to release a Firemonkey control properly, in this case a child form with a parent? – Stack Overflow
TFmxObject.ReleaseusesTThread.ForceQueueinternally, and that’s currently broken under Android (see discussion above).As a workaround, a working cross-platform version for releasing an object from its event handler would be
procedure TForm.CloseBtnClick(Sender: TObject); begin Parent := nil; TThread.CreateAnonymousThread( procedure begin TThread.Synchronize(nil, procedure begin Self.DisposeOf; end); end).Start; end;Instead of
Synchronizeyou can also useQueuein above method.What is important to keep in mind is that you should not keep any other references to the control you are releasing or you may hit the trouble down the road.
Via:
[WayBack] What are the solutions for a wizard like application (a single form with content changed depending on some action) in Firemonkey?
–jeroen
Posted in Delphi, Development, Software Development | Leave a Comment »