Jump to content

Lars Fosdal

Administrators
  • Content Count

    3345
  • Joined

  • Last visited

  • Days Won

    111

Posts posted by Lars Fosdal


  1. 13 hours ago, hsvandrew said:

    I'm going to pause this rant for now, perhaps these issues have been resolved and its just the tickets in quality control haven't been closed. 

    We spend a lot of time on this in January and it failed miserably (especially for Linux) so we gave up.

    It appears it might be ok now on 10.2.3/10.3 I will do some more testing and advise

    Please amend the title. The title should IMO reflect the contents of the post, which "-------" does not.

    • Like 3

  2. https://quality.embarcadero.com/browse/RSP-23024

    Quote

    If a record helper has a class constructor, the compiler will output the following error

    [dcc32 Warning] W1035 Return value of function 'THelperType.ClassConstructorName' might be undefined

    This doesn't make sense, since a class constructor doesn't have an assignable result value.

    Note that the class constructor actually works as expected - it is only the bogus warning that is a problem.

    Our build server is configured to not accept warning W1035, to ensure that we actually never release code which may have undefined return values, so this false warning is a problem.

    MCVE attatched to report.


  3. 1 hour ago, Kryvich said:

    @Schokohase

    @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.

    @Kryvich Do you know of any good examples of custom reverters?

    I am only going to consume these structures, not produce them - so that simplifies it a bit.  Basically, I'd love to be able to transform the inner array elements to a single object, as there is only a limited number of permutations.


  4. Consider the following Json data:

    The array elements are lists of integers, strings and objects.

    {
           "message": [
                  [ 0, "a text" ],
                  [ 1  ],
                  [ 1, { "switch": true } ],
                  [ 2,  "text one",  "text line two" ]
           ]
    }
    


    Assume the JsonData const below is filled with the Json above. Using the Json tools from unit REST.Json, I would typically do like this.

     

    const
      JsonData = // see Json data above
    var
      Message: TJsonMessage;
    begin
      Message := TJson.JsonToObject<TJsonMessage>(JsonData);

     

    But - how should TMessageArray be declared to accept the above structure? Is it actually possible? 

     

    TJsonMessage = class
    private
      Fmessage: TMessageArray;
    public 
      property message: TMessageArray read FMessage write FMessage;
    end;

     

    • Like 1

  5. Consider

    type
      TSomeType = (One, Two Three);
      TSomeTypeHelper = record helper for TSomeType
        class function Values: TArray<string>;
      end;

     

    Can I use RTTI to find the record helper type for TSomeType and the Values function?

     

    Reason: I'd like to call Values  - which would be a naming convention (since record helpers can't be inherited or generic) - for any type that has a record helper with a class function named Values.


  6. Is there a way to use RTTI for records to allow walking public consts and types to extract names and values?

    Asking for a friend 😛 - kidding ... I'm try to produce documentation of certain structures at run time, and would like to do something like TDocBuilder.WalkRecordType<html>.

     

    type
      html = record
      type
        TRow = TArray<string>;
      public const
        LineBreak  = '<BR />';
        nbsp   = ' ';
        lt     = '<';
        gt     = '>';
        DivEnd = '</div>';
    
      public type
        divStyleDefault = record
          public const
            info     = 'info';
            book     = 'book';
            chapter  = 'chapter';
            section  = 'section';
            detail   = 'detail';
            example  = 'example';
            jsoncode = 'jsoncode';
        end;
        
        divStyleDebug = record
          public const
            info     = 'debuginfo';
            book     = 'debugbook';
            chapter  = 'debugchapter';
            section  = 'debugsection';
            detail   = 'debugdetail';
            example  = 'debugexample';
            jsoncode = 'debugjsoncode';
        end;
      {$ifdef debug}
        divStyle = divStyleDebug;
      {$else}
        divStyle = divStyleDefault;
      {$endif}
      end;

     

×