-
Content Count
2268 -
Joined
-
Last visited
-
Days Won
46
Everything posted by Fr0sT.Brutal
-
Get rectangle of the button that was pushed on another form...
Fr0sT.Brutal replied to RTollison's topic in General Help
You could take current mouse coordinates but this will fail if button is clicked by key. Not a problem if the button is unfocusable -
Can I force compiler to report on enum change that related code needs changing?
Fr0sT.Brutal replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
Yep and they're with us since D2009 or so. Even in D7 there were $message (without modificator). Though, it could be just a plain text or anything else: {$IF ...} BADABOOM! {$IFEND} but this makes source parsing harder (like generating docs) so $message is preferred. I also add such kind of checks to places where I rely on some assumptions. F.ex., I send short 4-char string code via PostMessage directly in WPARAM so I add compiler directive to check whether the code truly fits in SizeOf(WPARAM). If sometimes the code grows, these checks won't let me forget where I should modify the algo -
Can I force compiler to report on enum change that related code needs changing?
Fr0sT.Brutal replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
Compiler directives come to help. This is to ensure TEnum is starting from 1 (needed to loop through a string that contains chars for every item in enum) const EnumLiterals: array[TEnum] of Char = ('Q', 'W', 'E', 'R', 'T'); function SetToFixedStr(aSet: TSomeSet): string; var elem: TEnum; begin // check {$IF Ord(Low(TEnum)) <> 1} {$MESSAGE FATAL 'Must start from 1 (using as string index)'} {$IFEND} ... end Or, in every case that handles ALL values in enum: case item of enumItem1: ...; enumItemN: ...; {$IF Ord(High(TEnum)) <> 5} {$MESSAGE FATAL 'Implement it'} {$IFEND} end; // case This will catch addition to every place of enum. In case of enums starting from custom number, use Ord(High(TStatsType))-Ord(Low(TStatsType)) to get number of items. Btw, FPC catches switches that don't handle every item in an enum. Sometimes it helps, sometimes annoys 🙂 -
Fastest Way to Read / Parse a large JSON File?
Fr0sT.Brutal replied to Steve Maughan's topic in Algorithms, Data Structures and Class Design
Good point - I wasn't aware these two differ. And Neslib's implementation has stream parsing as well. -
Fastest Way to Read / Parse a large JSON File?
Fr0sT.Brutal replied to Steve Maughan's topic in Algorithms, Data Structures and Class Design
If the file is large enough to exceed available memory, probably you'll want to use stream-like parser, like SAX from XML. Grijjy has something alike https://blog.grijjy.com/2017/01/30/efficient-and-easy-to-use-json-and-bson-library/ -
Using Attributes in class declarations
Fr0sT.Brutal replied to Lars Fosdal's topic in RTL and Delphi Object Pascal
But you can load them from config. In your sample, there are repeating 70, 40 etc. Unclear what these numbers mean You define structure in declaration but mix it with representation properties I'm not against attributes, I just don't see their real benefit. Any other examples are gladly welcome! -
Delphi compatibility with Windows 11?
Fr0sT.Brutal replied to PeterPanettone's topic in General Help
That's good but doesn't software implementation makes whole idea of TPM useless? -
Using Attributes in class declarations
Fr0sT.Brutal replied to Lars Fosdal's topic in RTL and Delphi Object Pascal
Honestly, this example rather shows how awkward attributes are. All options you provided seem to be better defined in form props/code than in class declaration. Drawbacks of attributes IMHO: - hard-coded values - constants are scattered and repeating - violation of abstraction of structure from style (like visual styles defined right in HTML) I could be wrong but so far I see only one really useful application - defining structures for (de)serialization but even here attributes are not required for simple cases. 2nd application, handy but not necessary (the only one I use myself) is marking DUnitX's test methods -
Delphi compatibility with Windows 11?
Fr0sT.Brutal replied to PeterPanettone's topic in General Help
My guess: M$ either looses TPM requirements or loses significant piece of virtualized systems market. Anyway W11 is not so much killer-featured to run and buy it. Some will reject upgrading, some will switch to Linux. -
Delphi compatibility with Windows 11?
Fr0sT.Brutal replied to PeterPanettone's topic in General Help
TPM sucks. Requirement of TPM sucks twice! AFAIU it could be used for DRM stuff so the soft, games and media you bought would be tied to the chip. Once it breaks, you lose all you've paid for. Moreover, it provides a unique identifier of a PC which destroys privacy. -
According to https://m.eet.com/media/1089230/an087.pdf , function must be stdcall
-
BTW, you can debug DLLs by defining host process in Run options dialog. Then you can set breakpoints and see what's going on in fact.
-
How to deal with running async / await during application close
Fr0sT.Brutal replied to merijnb's topic in OmniThreadLibrary
Unit tests check just a part of the whole app. The main adventures frequently start when these tested units are combined into an app. That's where leaks could appear not detected by even the most severe test. -
any way to limit time for SSL authentication
Fr0sT.Brutal replied to merijnb's topic in ICS - Internet Component Suite
As for me, BUILTIN_TIMEOUT is MUCH more reasonable as default than USE_SSL xD -
How to handle delphi exception elegantly with logging feature.
Fr0sT.Brutal replied to HalfBlindCoder's topic in Algorithms, Data Structures and Class Design
Change "true" to "not true" ))) -
How to deal with running async / await during application close
Fr0sT.Brutal replied to merijnb's topic in OmniThreadLibrary
And you either live without memory leak detection or get huge leak reports after every close. -
Shouldn't CAPTCHA fields have "autofill =no" (don't know exact naming) property set?
-
any way to limit time for SSL authentication
Fr0sT.Brutal replied to merijnb's topic in ICS - Internet Component Suite
Don't server's sockets inherit from TCustomTimeoutWSocket which has IdleTimeout that seem to do what OP needs? (never tried ICS-powered TLS server so just supposing theoretically) -
Binary size, how-to make it smaller?
Fr0sT.Brutal replied to Wil van Antwerpen's topic in General Help
Nice note. How did you produce custom RTL build? Just putting Classes and all its used units near the project or recompiled all units somehow? -
How to handle delphi exception elegantly with logging feature.
Fr0sT.Brutal replied to HalfBlindCoder's topic in Algorithms, Data Structures and Class Design
Seems like it is. I misunderstood your point -
Server-side: listening HTTP server processing subscriptions Client-side: HTTP client for subscribing to server and listening HTTP server for receiving events All could be implemented with ICS
-
Out parameter is read before set
Fr0sT.Brutal replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
Currently "out" is more just a usage hint than real compiler-controlled restriction. But even this state is better than "var". Hoping sometimes in Delphi v.25 Tegucigalpa they will add "use uninit'ed" compiler warning. -
How to handle delphi exception elegantly with logging feature.
Fr0sT.Brutal replied to HalfBlindCoder's topic in Algorithms, Data Structures and Class Design
How would "if smth = Boolean(0)" help in this compared to "if not smth"? The only code I've seen where this could benefit is turning "if Condition then i := i + 1" to "i := i + Ord(Condition)" -
Binary size, how-to make it smaller?
Fr0sT.Brutal replied to Wil van Antwerpen's topic in General Help
I have x64 DLL that uses SysUtils and DateUtils weighting 590 Kb compiled with XE2. Unfortunately, RTL is not designed having little binary size in mind (bloated Classes unit that you have to include just when you need TStream).