You are not logged in.
Pages: 1
Hi,
Unit mORMot.pas has a defined type PTypeInfo. It is incompatible with the Delphi native type PTypeInfo. For this reason I have often errors when compiling my own code where I use both mORMot.pas and TypInfo.pas units.
Is it possible to change the name of this type in mORMot, for example to PMTypeInfo?
kind regards
Last edited by jaclas (2016-01-25 17:50:54)
Offline
Why not ust use SynCommons.PTypeInfo ? With some database constants you will have this problem too and other cases surely.
Esteban
Offline
SynCommons.PTypeInfo is in implementation section of unit, private.
Last edited by jaclas (2016-01-25 18:40:52)
Offline
This unfortunately does not solve the problem, because mORMot.pas does not have the PTypeData type (and additional functions like GetTypeData()), which forces me to use TypInfo - so the problem returns
Offline
You have a better alternative to PTypeData with mORMot's TTypeInfo wrappers, using e.g. ClassType method for class properties, OrdType method for ordinal types, RecordType for record types, and so on...
Instead of a bulky PTypeData, you have dedicated types with some convenient wrapper methods.
Which method is missing for you?
Offline
For example, how to replace this code?
g := GetTypeData(TypeInfo(IMyInterface)).Guid;
Offline
Use http://synopse.info/files/html/api-1.18 … ERFACEGUID
Note that the IMyInterface is a TGuid....
So you can write g := IMyInterface
Offline
Ok, that was a bad example, I think about something like this:
var p : PTypeInfo;
...
g := GetTypeData(p).Guid;
But using mORMot RTTI creates a new problems. In other place of my code I use a System.Rtti.pas. Using it forces me to use native type PTypeInfo.
I must unfortunately abandon the use of incompatible PTypeInfo from mORMot and do some workaround
Last edited by jaclas (2016-01-26 13:12:30)
Offline
PTypeInfo is defined in System.TypInfo.pas - and we return to the starting point :-)
Offline
So, add System.TypInfo.pas AFTER mORMot.pas in your uses clause.
I do not see why it is difficult.
Type names collisions do often occur in Delphi.
You fix it either:
- By putting the expected order in your "uses" clause;
- Or by prefixing the type name (e.g. TypeInfo.PTypeInfo or mORMot.PTypeInfo).
Offline
I know, but these solutions are ... unsightly, dangerous, introduce depending on the source code order - this is not good.
I did alias on type PTypeInfo and I use that alias. Tough luck, let it be :-)
Offline
Since both types would point to the same RTTI information, there is no big issue at runtime to be encountered.
Everything should be identified at compile time, and therefore could be easily fixed by the proper order of units in the "uses" clause.
Offline
Pages: 1