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

2024-10-07 Thread Martin via Dwarf-discuss

On 07/10/2024 22:40, Augusto Noronha wrote:



Streaming as a language construct (and controlling whether a property should be 
streamable or not) seems like a pretty Pascal specific feature, maybe this 
could be a Pascal extension?


Or probably be moved to RTTI, of which I have not yet evaluated if it 
needs special DWARF support.


RTTI seems to exist in C++, but I haven't used it there myself. Also 
RTTI is in the end a structure of its own, and the most that DWARF may 
need if at all would be a pointer to it, but even that could be an 
artificial field.


"stored" only has a language constructs for defining it. Calling it is 
done via the fields in RTTI.


So, yes. "stored" can be dropped.






On Oct 7, 2024, at 2:23 AM, Martin via Dwarf-discuss 
 wrote:

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.




I may just have done above.

There is a hidden field in the class that points to RTTI. And in RTTI 
there is a field "pointer to function".


So you would actually not find any code that directly calls that 
function (via any language construct).


I initially went only through how the property is defined, not how it is 
used.


--
Dwarf-discuss mailing list
Dwarf-discuss@lists.dwarfstd.org
https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss


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

2024-10-07 Thread Martin via Dwarf-discuss

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

--
Dwarf-discuss mailing list
Dwarf-discuss@lists.dwarfstd.org
https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss


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

2024-10-07 Thread Augusto Noronha via Dwarf-discuss
> 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

Thanks for the clarification Martin. 

Streaming as a language construct (and controlling whether a property should be 
streamable or not) seems like a pretty Pascal specific feature, maybe this 
could be a Pascal extension?


> On Oct 7, 2024, at 2:23 AM, Martin via Dwarf-discuss 
>  wrote:
> 
> 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
> 
> -- 
> Dwarf-discuss mailing list
> Dwarf-discuss@lists.dwarfstd.org
> https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss

-- 
Dwarf-discuss mailing list
Dwarf-discuss@lists.dwarfstd.org
https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss