[Dwarf-discuss] Proposal: Add support for "property" with getter/setter (based on Pascal properties)

Martin lists@mfriebe.de
Mon Oct 7 09:23:27 GMT 2024


On 04/10/2024 21:56, Augusto Noronha via Dwarf-discuss wrote:
> Hi Martin,
> 
> Could you explain what a Pascal-style stored accessor is or link to a reference to it? I tried looking it up but couldn’t find anything relevant.
> 

https://www.freepascal.org/docs-html/ref/refsu38.html

FreePascal and Delphi have RTTI, which allows accessing data. One use 
case is streaming of a class (well the published part of it).

This is for example used for GUI apps where the properties of a designed 
GUI (form, buttons, ..) are streamed so the runtime can load them. But 
also ORM libs make use of it, or REST.

For classes there is a "published" section (public + RTTI).
It can contain fields and properties.
And any code, without knowledge of the class, can read those fields.

In some scenarios it is not needed to stream properties if they have 
there default value. So the streaming code needs to access that.

property Foo: integer read GetFoo write SetFoo stored ShouldStoreFoo 
default 123;

default takes a value (and exists only for certain data types like 
integer properties. It is stored in the RTTI.

Stored can be a function or field (or constant) of boolean type. The 
RTTI also has a link to it, so the streaming code can call it.

Stored = true => the property should be stored in the stream
Stored = false -> the property should not be stored



More information about the Dwarf-discuss mailing list