Jump to content

Kryvich

Members
  • Content Count

    279
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by Kryvich

  1. Kryvich

    Recompile Delphi RIO RTL/VCL?

    Perhaps this will help:
  2. https://stackoverflow.com/questions/2113182/fillchar-but-for-integer-cardinal
  3. Kryvich

    Block windows access

    Using the Group Policy Editor it is possible to prevent users from accessing to Ctrl-Alt-Del options. https://ccm.net/faq/41738-how-to-prevent-users-from-accessing-the-task-manager
  4. You're right. We can compare the squares of distances: checkDistance2 := Sqr(checkDistance); ... dist2 := Sqr(X1-X2) + Sqr(Y1-Y2); if dist2 < checkDistance2 then .....
  5. @Lars Fosdal Sorry I cannot help you with it. I tried the attribute [JsonReflectAttribute(ctObject???,rtObject???,TArrayElementInterceptor)] but there is no a converter/reverter type that accepts values of any type: strings, numbers, and objects. Perhaps you may need to create a descendant of TJSONUnMarshal to handle all the options. It would be great if Embarcadero improves JSON support and allow to convert other types to a custom record if this record can take values of other types: type TSwitch = class private FSwitch: Boolean; public property Switch: Boolean read FSwitch write FSwitch; end; TArrayElement = record private FValue: Variant; public class operator Implicit(const Value: Integer): TArrayElement; class operator Implicit(const Value: string): TArrayElement; class operator Implicit(const Value: TSwitch): TArrayElement; end;
  6. @Schokohase In fact RTTI is generated for types declared in a DPR file. But it is not findable by TRttiContext.FindType(AQualifiedName: string). In the Delphi help for the function FindType it is written: But there is no information what types have qualified names. And only in System.Rtti.pas I found this comment: @Lars Fosdal Unfortunately, this will not work for the Variant type without additional processing. You can try to declare a custom reverter for an element of the inner array.
  7. @Schokohase It worked, thanks! Can you explain why?
  8. May be TMessageArray = array of array of Variant; ? program TestJson; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils, REST.Json; const JsonData = '{' + ' "message": [' + ' [ 0, "a text" ],' + ' [ 1 ],' + ' [ 1, { "switch": true } ],' + ' [ 2, "text one", "text line two" ]' + ' ]' + '}'; type TMessageArray = array of array of Variant; TJsonMessage = class private Fmessage: TMessageArray; public property message: TMessageArray read FMessage write FMessage; end; var Message: TJsonMessage; begin try if TypeInfo(TJsonMessage) = nil then Writeln('No RTTI for ', TJsonMessage.ClassName); Message := TJson.JsonToObject<TJsonMessage>(JsonData); Writeln('Length = ', Length(Message.message)); Message.Free; except on E: Exception do begin Writeln(E.ClassName, ': ', E.Message); Readln; end; end; end. I tried this option, but my test application gives the exception: "Exception class EConversionError with message 'Internal: Cannot instantiate type TestJson.TJsonMessage'.". I still do not understand why.
  9. Having access to source files of the project perhaps it would be easier to extract all the necessary information from the source code using DelphiAST or similar parser.
  10. I've checked this function in 10.2.3 and 10.3, and it works identically in both cases. When I set a text size = 125%, the app shows 1.25. Windows 7 64 bit. Demo app is attached. TestGetScreenScale.zip
  11. Kryvich

    IDE Fix pack for Rio

    Delphi 10.3 with IDE Fix Pack dev 2018-12-11-2343, Compiler Speed Pack x86 / x64 dev 2018-12-11-2343 -- 05 min 53 sec. :) IDE Fix Pack is an IDE package that I always installed the very first when switching to a new version of Delphi.
  12. Kryvich

    What does TDataSet.CopyFields do?

    @Uwe Raabe Of course, https://quality.embarcadero.com/browse/RSP-22946
  13. Kryvich

    What does TDataSet.CopyFields do?

    @Dany Marmur No, it does not work. You can see for yourself: I have prepared a test application with 2 in-memory datasets and 2 nested datasets (see TestCopyFields.zip in the attachment). Values of fields of the nested dataset are not copied: But if you copy the Data.DB.pas to the application's folder and make the modification I suggested, it works: I think Embarcadero never tested this feature. Honestly, I myself learned about nested data sets only today. TestCopyFields.zip
  14. Kryvich

    What does TDataSet.CopyFields do?

    @Dany Marmur I would say the else section is for fields that are not inherited from TDataSetField.
  15. Kryvich

    Pointers are dangerous

    @dummzeuch There could be a warning: "The pointer ptr1 to an element of the array arr is invalid after its reallocation by the function SetLength". There is a plenty of static code analyzer for Delphi - https://stackoverflow.com/questions/532986/are-there-any-static-code-analysis-tools-for-delphi-pascal. But I do not know one that catches this error. It would be great to have a utility for Delphi similar to PVS Studio.
  16. Kryvich

    Pointers are dangerous

    I would prefer it like this: with const Ptr = @SomeArray[SomeStructure.SomeIndex] do begin // Inline constant declaration with type inference Ptr.bla := 5; Ptr.blub := 10; end; @Rollo62 Not only. Using a temporary variable can optimize the binary code.
  17. Kryvich

    Pointers are dangerous

    A good case for a static code analyzer.
  18. Kryvich

    What does TDataSet.CopyFields do?

    Looking at the function code, I would say that it copies the field values of the current record from the source data set to another data set. It also copies records of all nested data sets. But I think there is a bug in their code: instead of CopyFields(TDataSetField(DestField).NestedDataSet); should be TDataSetField(DestField).NestedDataSet.CopyFields(TDataSetField(SourceField).NestedDataSet); Not tested yet.
  19. Kryvich

    Units design

    I would go with Example A. But exclude not used utility units from uses clauses of your units. Error Insight does not like conditionally compiled blocks, especially in the definitions of types and classes.
  20. According to the Delphi roadmap: High DPI IDE support is planned for 10.3.x.
  21. Kryvich

    RttiMethod Invoke (invalid class typecast)

    procedure Run is a method of object, not a class method. So you need an object instance to call the method.
  22. Kryvich

    IDE Fix pack for Rio

    Well, I'm sure Andreas Hausladen could improve the result for 10.3 anyway.
  23. Kryvich

    Delphi 10.3

    Delphi 10.3 Rio is out so please add Delphi 10.3 to the profile.
  24. Kryvich

    IDE Fix pack for Rio

    I measured a time to build the camera_shake.dpr project from TERRA-Engine framework in Delphi 10.2.3 and Delphi 10.3. TERRA Engine is a complex cross-platform engine, known for its cyclic unit references, and freezes in IDE. Camera_shake.dpr project build time, Windows 32-bit platform: Delphi 10.2.3 with IDE Fix Pack 6.3.1, Compiler Speed Pack x86 / x64 6.3.1 -- 06 min 59 sec. Delphi 10.3 -- 06 min 33 sec. I measured the time on my phone manually, so there may be some error.
  25. As you know, modern Delphi versions add the RTTI information to the executable file. RTTI gives you the opportunity to do incredible things in your application. But it is not always necessary. You can disable RTTI in your application by adding the following lines to each unit: {$WEAKLINKRTTI ON} {$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])} But to completely disable RTTI, you need to add these lines to used RTL units too, and rebuild the project. How much will the size of the executable file decrease? Well, I checked it on small utilities from the Delphi Localizer project, and here is the result: kdlscan.exe was 742400 bytes, now 360448 bytes, -51% lngupdate.exe was 727040 bytes, now 282112 bytes, -61% (!!!) The smaller size of an executable file means that the file is read twice as fast from disk. In addition, the processor is more likely to be able to fully fit your utility into its cache. You can give other reasons why this makes sense.
×