You are not logged in.
Pages: 1
Hi,
in Delphi, there is the possibility to declare arrays using TArray<...> rather than array of ..., which has a few advantages.
However, TRttiCustom.SetPropsFromText only handles array of ..., when parsing a string of properties.
When using code such as
OrigRtti := Rtti.RegisterClass(aOrmClass);
for var Prop in OrigRtti.Props.List do
PropText := PropText + ';' + Prop.Name + ':' + Prop.Value.Name;
Prop.Value.Name will return TArray<...> when declared in that way.
Is there a fair chance of getting TRttiCustom.SetPropsFromText to work with TArray<...>, which from a mORMot pov would be the same, as array of ... ?
Regards,
Daniel
Offline
Here is a simple sample, breaking with TArray<...>, working with array of ...
Enable/Disable lines 14&17 to see difference.
Offline
Digging deeper, you call GetNextFieldProp, which in turn only selects alphanumeric and underscores
while tcIdentifier in tab[P^] do
inc(P); // go to end of ['_', '0'..'9', 'a'..'z', 'A'..'Z'] chars
Therefore, the <....> part never becomes part of the typename, therefore failing the test in lns 9000+
Regards,
Daniel
Offline
You are right.
Please try with https://github.com/synopse/mORMot2/commit/8c52628d
Offline
While this part works now, I have noticed another small, Delphi specific glitch around that. From the original sample code, I used
Prop.Value.Name
to get the type.
When using TArray it propagate as
TArray<Unitname.Typename.SubTypeName>
Due to including the unit name, FindType will not recognize the Type. Should prop value name be handled specific in that case?
I uploaded example it would generate
SomeStr: UTF8String;Fail:TArray<Decl.TPpCallSecurityRight>;
<-- note the Decl.
Regards,
Daniel
Offline
The problem is that in mormot.core.rtti the type name is expected to be unique globally.
We could remove the unit name, but if there are several TPpCallSecurityRight types defined, it would only find the first declared, which may not be in Decl...
See https://github.com/synopse/mORMot2/commit/3df95e4a
But it is likely not to work with Delphi specific Typename.SubTypeName type definitions.
Offline
Pages: 1