Trying to reverse Qt 4.4.3

General discussions about code engineering

Moderator: Moderators

Trying to reverse Qt 4.4.3

Postby Angel Catala » Fri Sep 24, 2010 1:00 pm

Hello,

I am newbie with MagicDraw and I am using Qt 4.4.3 for my software projects. I would like to get a reversed model from #include headers, but the only thing that I get is "Parser error".

I am following the procedure in the "MagicDraw Code & Database Engineering User Guide". I am not able to figure out where I am making a mistake.

The scenario is this:
Debian 5.0.6
Qt 4.4.3
MagicDraw 16.9 Professional C++ Edition
Execution from non-root user

CASE A:
Reverse C++ ANSI (Use set to import code only)
Working directory /usr/include/qt4
Working package Qt 4.4.3 Reverse
Add Recursively
Reverse options (Using default options)

Output from CASE A:
I get plenty of messages like the two next (one for each filename in the qt4 subtree):
Failed to create temporary file: /usr/include/qt4/filename.h.tmp. File is in use or read only.
Parsing failed (/usr/include/qt4/filename.h) null

Finish parsing: 0 error(s).
0 file(s) passed, 0 file(s) failed, 0 file(s) skipped

There is a privileges problem. That's the expeted.


CASE B:
Reverse C++ ANSI (Use set to import code only)
Working directory /home/zuul/tmp/qt4
Working package Qt 4.4.3 Reverse
Add Recursively
Reverse options (Using default options)

Output from Case B:

Parser error: /home/zuul/tmp/qt4/Qt/q3accel.h:50:1: unexpected token: class
Parser error: /home/zuul/tmp/qt4/Qt/q3accel.h:102:1: unexpected token: QT_END_NAMESPACE
Parser error: /home/zuul/tmp/qt4/Qt/q3action.h:54:1: unexpected token: class
Stop parsing after 3 error(s).
0 file(s) passed, 2 file(s) failed, 1.177 file(s) skipped
Unable to find parent of 'QObject' create in 'default' package.
Unable to find parent of 'QWidget' create in 'default' package.
Unable to find parent of 'uint' create in 'default' package.
Unable to find parent of 'QKeySequence' create in 'default' package.
Unable to find parent of 'QString' create in 'default' package.
Unable to find parent of 'Q3AccelPrivate' create in 'default' package.

Thanks in advance.

Angel.
Angel Catala
Forum Newbie
Forum Newbie
 
Posts: 10
Posts Rating:2
Joined: Tue Aug 10, 2010 1:50 am

Re: Trying to reverse Qt 4.4.3

Postby bhoomchai » Sun Oct 03, 2010 10:38 pm

Hello,

MagicDraw C++ parser does not natively know macro and some other construct from Qt. So, to successfully reverse Qt code, you have to let MagicDraw parser know about Qt macro declaration or just put an empty macro definition for MagicDraw. Please try the following steps
- From MagicDraw main menu, select Options->Project to open Project Options dialog
- Select C++ Language Options. You'll see an option, Use explicit macros. Click at "..." button.
- You'll see C++ Macros dialog. Here you can add Qt macro definition.
For example, you can add

#define QT_BEGIN_NAMESPACE namespace QT_NAMESPACE {
#define QT_END_NAMESPACE }

So MagicDraw will now know QT_BEGIN_NAMESPACE and see it as "namespace QT_NAMESPACE{".

However, if you don't care about QT macro, you can put empty definition instead like

#define QT_BEGIN_NAMESPACE
#define QT_END_NAMESPACE

Hope this could help you solve the problem.
bhoomchai
Customer Support
Customer Support
 
Posts: 36
Posts Rating:5
Joined: Thu Jan 21, 2010 12:38 am

Re: Trying to reverse Qt 4.4.3

Postby Angel Catala » Mon Oct 04, 2010 10:45 am

Thanks bhoomchai, it seems it works. Now I have to discover and/or define all macros that are not predefined in MagicDraw.

I also would like apologize because this morning I have discovered a section in "MagicDraw Code & Database Engineering User Guide", in page 187, related with this issue. I did not realize it until this very morning. I have not had time to read all documentation. In either case, this could be useful for other people.

Thanks and best regards.

Angel Catala.
Angel Catala
Forum Newbie
Forum Newbie
 
Posts: 10
Posts Rating:2
Joined: Tue Aug 10, 2010 1:50 am


Return to Code engineering

Who is online

Users browsing this forum: No registered users and 0 guests