Jump to content

Fr0sT.Brutal

Members
  • Content Count

    2268
  • Joined

  • Last visited

  • Days Won

    46

Everything posted by Fr0sT.Brutal

  1. You could take current mouse coordinates but this will fail if button is clicked by key. Not a problem if the button is unfocusable
  2. 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
  3. 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 🙂
  4. Good point - I wasn't aware these two differ. And Neslib's implementation has stream parsing as well.
  5. 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/
  6. Fr0sT.Brutal

    Using Attributes in class declarations

    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!
  7. Fr0sT.Brutal

    Delphi compatibility with Windows 11?

    That's good but doesn't software implementation makes whole idea of TPM useless?
  8. Fr0sT.Brutal

    Using Attributes in class declarations

    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
  9. Fr0sT.Brutal

    Delphi compatibility with Windows 11?

    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.
  10. Fr0sT.Brutal

    Delphi compatibility with Windows 11?

    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.
  11. Fr0sT.Brutal

    Calling a Delphi DLL from LabView

    According to https://m.eet.com/media/1089230/an087.pdf , function must be stdcall
  12. Fr0sT.Brutal

    Calling a Delphi DLL from LabView

    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.
  13. 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.
  14. Fr0sT.Brutal

    Few do-not in website

    Sure
  15. As for me, BUILTIN_TIMEOUT is MUCH more reasonable as default than USE_SSL xD
  16. And you either live without memory leak detection or get huge leak reports after every close.
  17. Fr0sT.Brutal

    Few do-not in website

    Shouldn't CAPTCHA fields have "autofill =no" (don't know exact naming) property set?
  18. 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)
  19. Fr0sT.Brutal

    Binary size, how-to make it smaller?

    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?
  20. Seems like it is. I misunderstood your point
  21. Fr0sT.Brutal

    Webhook example

    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
  22. Fr0sT.Brutal

    Out parameter is read before set

    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.
  23. 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)"
  24. Fr0sT.Brutal

    Binary size, how-to make it smaller?

    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).
×