Book a Demo

Author Topic: Complex C++ Macros : code import  problems  (Read 4196 times)

stevem

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Complex C++ Macros : code import  problems
« on: March 23, 2007, 10:20:30 am »
Hi,

I am a new EA user and I am trying to import a source code directory containing C++ code using complex framework macros typically like the following (a start sequence, some code and an end sequence):

 FRAMEWORK_DECLARE_INTERFACE_TYPE( MyLib, MyClass)

   virtual bool32 aMethod (const int aParam,
                           const int anotherParam) = 0;

   ... other pure virtual methods ...

 FRAMEWORK_END_INTERFACE_DECLARATION

where
FRAMEWORK_DECLARE_INTERFACE_TYPE macro corresponds to something like "class MyLib MyClass {"
and where
FRAMEWORK_END_DECLARATION corresponds to "};"

If I define those macros using Preprocessor macros option, it is pretty useless as my imported code will not be recognized as a class by EA.

Do I have another option than preprocessing my code in order to expand all macros before importing the code in EA?

I have a lot of those pairs of macros for various purposes and I would expect EA C++ code importer to be able to do this parsing and replacement for me; Is it a possibility?

Thanks a lot for your support

Steve

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Complex C++ Macros : code import  problems
« Reply #1 on: March 25, 2007, 01:46:38 pm »
No, EA's C++ parser only allows for definitions of macros to be completely skipped.

stevem

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Complex C++ Macros : code import  problem
« Reply #2 on: March 26, 2007, 03:54:23 am »
Hi,

Question 1: Are you aware of any tool that could give me a hand doing this pre-parsing (macro replacement) in order to have EA working with my code?

Question 2: Any chance that EA will eventually integrate such a tool?

Thanks again for your support,

Steve

sl@sh

  • EA User
  • **
  • Posts: 85
  • Karma: +0/-0
    • View Profile
Re: Complex C++ Macros : code import  problem
« Reply #3 on: March 26, 2007, 11:05:36 pm »
With respect to your second question I wouldn't hold my breath - EA can work with a lot of different languages, C++ is just one of many. Your only hope would be for the OMG to decide that C style preprocessor definitions should be UML objects and I cannot for the life of me imagine why they would ever do that ... :o

With respect to your first question, what OS and compiler are you working with? IIRC some compilers have an option to only do the preprocessor parsing step (however, this might also replace other stuff that again makes the code unusable by EA) In your case however a project-wide find/replace should go a long way to solving your problem. Better yet, some script languages such as AWK ( http://en.wikipedia.org/wiki/Awk ) are specialiced in tweaking text files. Never needed that myself but people I know used it for all kinds of stuff including code generation and even automatic translation of assembler code and data structures to C!
« Last Edit: March 26, 2007, 11:05:52 pm by sl@sh »

stevem

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Complex C++ Macros : code import  problem
« Reply #4 on: March 27, 2007, 04:17:59 am »
Hi,

Thanks for your reply; I am using Microsoft Visual C++ 2003 and soon 2005 on Windows XP Pro (I prefer Linux and GCC by far, but it was not my choice!). I will look into those compiler options you mentioned. I also tend to agree with the search and replace approach; Possibly Perl would be a viable option on Windows to perform such a task.

Steve

sl@sh

  • EA User
  • **
  • Posts: 85
  • Karma: +0/-0
    • View Profile
Re: Complex C++ Macros : code import  problem
« Reply #5 on: March 29, 2007, 02:52:11 am »
Well, I know a very good tool for Windows / Visual Studio, but unfortunately, the feature you are requesting is not quite implemented yet (it's on their ToDo list, though). I'm talking about Visual Assist, which already provides a couple of nice refactoring functions. You might want to check out their forums. The feature you are looking for has been suggested here: http://www.wholetomato.com/forum/topic.asp?TOPIC_ID=5915

stevem

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Complex C++ Macros : code import  problem
« Reply #6 on: March 29, 2007, 04:39:09 am »
Hi,

Thanks a lot for your suggestion; I have used previous versions of Visual Assist and I liked this product; I will certainly look into this.

This being said however, I have to admit that I might chose not to recommend to my company to migrate to EA since our current UML tool does support MACROS the way we need (to import code into UML diagrams). The reason why we looked at EA was its pricing and ease of use, but if it does not support MACROS, it becomes a real problem to us. Hopefully, other users will ask for this and EA will provide this service... fingers crossed!

Steve