Record marked as "external"

Issue #95 resolved
Former user created an issue

When we convert typescript to dwscript compatible code, it would be handy if record type were marked as "external", such as:

type
    TShopItem = record external
      Name : string;
      Price : float;
    end;

I would like to initializate the record as:

var
    Items : array[1..3] of TShopItem =
    (
      (Name : 'Clock';  Price : 20.99),
      (Name : 'Pencil'; Price : 15.75),
      (Name : 'Board';  Price : 42.96)
    );

When we compile with SMS, the fields are obfuscated.

ofuscating disabled: Items$23 = [{Name$3:"Clock",Price:20.99}, {Name$3:"Pencil",Price:15.75}, {Name$3:"Board",Price:42.96}];

ofuscating enabled: A8 = [{USI:"Clock",IM:20.99}, {USI:"Pencil",IM:15.75}, {USI:"Board",IM:42.96}];

When I use 'property Name : Type;' part of the problem is resolved...

    TShopItem = record
      property Name : string;
      property Price : float;
    end;

...but we can not initializate the records using property like was previously used:

    Items : array[1..3] of TShopItem =
    (
      (Name : 'Clock';  Price : 20.99),
      (Name : 'Pencil'; Price : 15.75),
      (Name : 'Board';  Price : 42.96)
    );

Comments (3)

  1. Eric Grange repo owner

    Note that with previous version, this should have worked as well

    type
        TShopItem = record
          Name : string; external 'Name';
          Price : float; external 'Price';
        end;
    

    the "record external" declaration adds an implicit external name for the fields equal to the Pascal-side name, but it can still be overwritten, f.i.

    type
        TShopItem = record external
          MyName : string; external 'Name';
          Price : float;
        end;
    

    Will declare MyName/Price internally, and use Name/Price externally.

  2. Log in to comment