#1 2012-06-28 10:44:06

chapa
Member
Registered: 2012-04-30
Posts: 117

RTTI problem

Hi ab,

I use RTTI for my classes. I experience following case as explained here:

http://stackoverflow.com/questions/9499 … attributes

This is when I include mORMot SynCommons and SQLite3Commons in my uses before I try to access TRttiType's GetProperties method. Other RTTI information is also kind of broken.

If I use to build the whole project, run, AV raise at System.rtti ConstructAttributes, sub function FindCtor at line imp := PPPointer(p)^^; It seems p (CtorAddr) is not a valid pointer.
If I modify only my unit, recompile (not rebuild), already build dcus used (along with mORMot dcus).

In second case FindCtor() function exits on very begining:

    for Result in AttrType.GetMethods do
      if Result.CodeAddress = CtorAddr then
        Exit;

If seems now we have valid CtorAddr, no AV, result as expected.

I use Delphi XE2 Upd1. The author of the stackoverflow.com used Delphi XE. Do you have any clue why this happens? Googling does point me at any solutions. Can this problem be related to mORMot RTTI hacks?

Thanks.

Last edited by chapa (2012-06-28 10:48:59)

Offline

#2 2012-06-28 10:57:58

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,658
Website

Re: RTTI problem

SQLite3Commons RTTI functions does not hack the RTTI, just use the vmtAutoTable VMT slot.

You are probably mixing types of SQLite3Commons and TypeInfo units.
Some types have the same exact name in both units.
So be aware to name the exact needed unit last in your uses clause.

I do not know what to say else, without any code to reproduce.

Online

#3 2012-06-28 11:07:51

chapa
Member
Registered: 2012-04-30
Posts: 117

Re: RTTI problem

In Synopse.inc you have following:

{$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])}

But for my purposes I need following directive:

{$RTTI INHERIT METHODS([vcPublic]) PROPERTIES([vcPublic]) FIELDS([vcPublic])}

If I define it in my class declaration unit seems to work so far.

It may worth to know, that your code change the default behavior of compilator regarding RTTI generation and if anyone starts using mORMot units in existing project, default RTTI behavior may be broken. Like my case smile

Anyway, sorry for bothering you, hope it may help others too.

Last edited by chapa (2012-06-28 11:13:09)

Offline

#4 2012-06-28 14:07:22

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,658
Website

Re: RTTI problem

You are right!

Those settings have a local scope, so it would affect only class definitions within the units containing {$I Synopse.inc}, right?
Or perhaps it also affects sub-classes.

Worth putting some reference here, in all cases!
Thanks for the feedback.

Online

Board footer

Powered by FluxBB