You are not logged in.
Hi,
not sure, whether it is as-designed, or a bug.
I have a KDD object with published object arrays (all deriving from TSynAutoCreateFields. When creating a copy, using CopyObject from mormot.core.rtti, all properties get copied.
However, for dynarrays, it creates a copy of the array, but not the elements itself.
Internally, it flows from CopyObject -> cf.Props.CopyProperties(pointer(aTo), pointer(aFrom)) -> Value.ValueCopy(Dest + OffsetSet, Source + OffsetGet) -> fCopy(Dest, Source, fCache.Info) [aka mormot.core.rtti. _DynArrayCopy ] -> DynArrayCopy. There it calls Info^.DynArrayItemType(itemsize) to determine the array element type.
In mormot.core.rtti.delphi.inc, this is defined as
function TRttiInfo.DynArrayItemType(out aDataSize: PtrInt): PRttiInfo;
begin
with GetTypeData(@self)^ do
begin
aDataSize := elSize;
result := pointer(elType);
if result <> nil then
result := PPointer(result)^;
end;
end;
elType seems to be nil always. Defined in Delphi Rtti only for managed arrays, which those seem not to be. However, using
result := pointer(elType2);
will actually return the expected array element type.
So, my question would be, is CopyObject supposed to create copies of the array elements, or just the array itself. If later, the idea of TSynAutoCreateFields breaks, however.
Using Delphi 11 ;-)
Regards,
Daniel
Offline
Created a sample, explaining what I'd expect from copy object, and what I actually get...
Offline