Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   RttiRecordType und RTttiArrayType (https://www.delphipraxis.net/211091-rttirecordtype-und-rtttiarraytype.html)

charly52 26. Jul 2022 18:23

Delphi-Version: 10.4 Sydney

RttiRecordType und RTttiArrayType
 
Hi

2 Fragen zur Delphi Hilfe

in https://docwiki.embarcadero.com/Libr...RttiRecordType

steht

Zitat:

TRttiRecordType is the RTTI object that reflects a record type.
TRttiRecordType is the RTTI class that reflects record types. TRttiRecordType allows querying the reflected record type for field information or for managed field information.
1. Frage: Ist TRttiRecordType jetzt eine Klasse oder ein Object?

und 2.: Wieso wird "System.Rtti.TRttiArrayType" direkt von "System.Rtti.TRttiType" abgeleitet und nicht auch von "System.Rtti.TRttiStructuredType"
obwohl laut der Doku von "System.Rtti.TRttiStructuredType"

Zitat:

TRttiStructuredType is the base class for all the RTTI objects that reflect structured types.
TRttiStructuredType is the class used as base for all the RTTI classes that reflect structured types. A structured type, in Delphi, is usually made up of several components. For example, a record or an array are structured types.

Vieleicht hat ja jemand ne gute Erklärung.
Charly

himitsu 26. Jul 2022 22:27

AW: RttiRecordType und RTttiArrayType
 
1: Es ist sozusagen das Gleiche?

Klasse ist die Definition
Objekt ist die Instanz der Klasse (das was aus dem create raus kommt)


2: War jemals alles im Delphi logisch?

Nja, TRttiStructuredType sind Typen, welche unterschiedliche (strukturiert) und sogar keine untergeordneten Typen enthalten kann
und TRttiArrayType enthält nur einen untergeordneten Typ und das mehrmals.

charly52 27. Jul 2022 09:29

AW: RttiRecordType und RTttiArrayType
 
Danke,
aber schon das nächste was ich nicht verstehe. Es geht um Delphi 10.4

Delphi-Quellcode:
 TValueData = record            <---------------------------  steht in System.Rtti.pas bei Zeile 48 
    FTypeInfo: PTypeInfo;
    // FValueData vs old FHeapData:
    // FHeapData doubled as storage for interfaces. However, that was ambiguous
    // in the case of nil interface values: FTypeInfo couldn't be trusted
    // because it looked like the structure was uninitialized. Then, DataSize
    // would be 0.
    // FValueData is different: interfaces are always stored like strings etc.,
    // as a reference stored in a blob on the heap.
    FValueData: IValueData;
    case Integer of
      0: (FAsUByte: Byte);
      1: (FAsUWord: Word);
      2: (FAsULong: Cardinal);
      3: (FAsObject: Pointer);
      4: (FAsClass: TClass);
      5: (FAsSByte: ShortInt);
      6: (FAsSWord: SmallInt);
      7: (FAsSLong: Integer);
      8: (FAsSingle: Single);
      9: (FAsDouble: Double);
      10: (FAsExtended: Extended);
      11: (FAsComp: Comp);
      12: (FAsCurr: Currency);
      13: (FAsUInt64: UInt64);
      14: (FAsSInt64: Int64);
      15: (FAsMethod: TMethod);
      16: (FAsPointer: Pointer);
  end;

  [HPPGEN(HPPGenAttribute.mkNonPackage)]
  TValue = record
Wo ist das "end;" zu "TValueData = record" ?

Charly

charly52 27. Jul 2022 09:50

AW: RttiRecordType und RTttiArrayType
 
Hat sich geklärt,


"case integer of" hat KEIN eigenes end.
Mein Editor hat gelogen und das "end" vom record als "end" vom case angezeigt.

charly

himitsu 27. Jul 2022 10:28

AW: RttiRecordType und RTttiArrayType
 
Das hat aber nichts mit der RTTI zu zu tun.
Er lügt nicht. Das END gehört zum RECORD und CASE hat hier kein END.
Und es ist/war leider schon immer so, seit vielen Jahrzehnten. :wall:

Der variante Record-Part hat kein Ende.
https://docwiki.embarcadero.com/RADS...Types_(Delphi)

Blöd, denn so kann man Ihn nicht in der Mitte haben (nachfolgend noch invariante Felder ... die muß man also mit in den varianten Teil reinschieben)
und mehrere variante Teile sind auch nicht möglich, so wie z.B. in C++, wenn man verzweifelt versucht Header zu übersetzen.

Und ja, es sieht blöd aus, macht garkeinen Spaß, ist absolut unverständlich und lässt sich beschissen in der Codeformatierung unterbringen. (zwei mal nach rechts und nur einmal doppelt nach links)

peterbelow 27. Jul 2022 11:12

AW: RttiRecordType und RTttiArrayType
 
Zitat:

Zitat von himitsu (Beitrag 1509365)
Blöd, denn so kann man Ihn nicht in der Mitte haben (nachfolgend noch invariante Felder ... die muß man also mit in den varianten Teil reinschieben)
und mehrere variante Teile sind auch nicht möglich, so wie z.B. in C++, wenn man verzweifelt versucht Header zu übersetzen.

Doch, das geht. Man muss nur für jede Gruppe von Feldern mit einem variablen Teil einen eigenen Record-Typ deklarieren und den "master" Record aus Feldern dieser "Subtypen" zusammensetzen.


Alle Zeitangaben in WEZ +1. Es ist jetzt 09:05 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz