[fpc-devel] restbase.pp LoadFromJSON calling StopRecordPropertyChanges;
Wayne Sherman
wsherman at gmail.com
Tue Jan 17 04:52:01 CET 2023
On Mon, Jan 16, 2023 at 12:16 PM Wayne Sherman wrote:
> I need clarification about the auto generated class index
> specifiers. Do they always start at 0 in each descendant
> class, or are they unique across all descendant classes?
>
> TBaseObject --> TChild --> TGrandChild
>
> TChild = class(TBaseObject)
> ...
> published
> property Field1: string index 0...
> property Field2: string index 8...
> end;
>
> TGrandChild = class(TChild)
> ...
> published
> property Field3: string index 16... // does this continue at 16
> or start at 0 again?
> property Field4: string index 24...
> end;
It appears the index specifiers restart at 0 in each descendant class.
Which is why this code works:
procedure TBaseObject.MarkPropertyChanged(AIndex: Integer);
begin
If Assigned(FBits) then
FBits.SetOn(GetParentPropCount+(AIndex shr IndexShift));
end;
function TBaseObject.IsPropertyModified(Info: PPropInfo): Boolean;
begin
Result:=Not Assigned(FBits) or FBits.Bits[Info^.NameIndex]
end;
The name list (from which NameIndex gets its value) includes the
published property names of all the parents plus the names in the
current class, so for a REST property in a descendant class with Index
specifiers starting at 0:
GetParentPropCount+(IndexSpecifier shr IndexShift) = NameIndex
More information about the fpc-devel
mailing list