Book a Demo

Author Topic: Is there anyway to process macro of C++ file ?  (Read 4188 times)

freekiller

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Is there anyway to process macro of C++ file ?
« on: November 18, 2010, 03:38:37 pm »
EA process c++ macro by record them but without parse them.
For example , when I import a c++ file "strmif.h" in platform sdk include files , the definition of the interface is a macro MIDL_INTERFACE , which is defined as
#define MIDL_INTERFACE(x)   struct DECLSPEC_UUID(x) DECLSPEC_NOVTABLE

In EA help file for language macros , there is a paragraph :
Function Macros
RTTI_EMULATION()
where Enterprise Architect skips over the token including everything inside the parentheses.

So EA skip the implement of  MIDL_INTERFACE , and not found it is in fact a "struct" definition , then EA import none of interface in strmif.h .


How to solve it ?

DanG83616

  • EA User
  • **
  • Posts: 180
  • Karma: +0/-0
    • View Profile
Re: Is there anyway to process macro of C++ file ?
« Reply #1 on: November 19, 2010, 02:55:20 am »
You can run the C++ preprocessor on the files and then import the preprocessed code. It is inconvenient but not too bad for code that doesn't change.

You could try importing the MIDL files instead of the C++ files. I use CORBA idl and there is a free add-in for that. I don't know if it would work for MIDL but you could try it. This option will enable you to reference the interfaces and use the methods in sequence diagrams.

You might consider neglecting those interfaces altogether. It may be sufficient to model only the package dependency and not worry about the details of how your code uses the interface. For me, most of the modeling benefit is to clarify and verify the interfaces I'm designing. I get less benefit from modeling the interfaces I do not control. YMMV.

HTH, Dan

freekiller

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Is there anyway to process macro of C++ file ?
« Reply #2 on: November 19, 2010, 05:08:13 pm »
Thx to dear Dan,

I downloaded the MDG for CORBA and installed it . But I not found where to import IDL into EA , there is no guide in help file for import IDL.

Can you tell me how to import a existed IDL file ?

I'm a beginner for use EA, I'm try to build a small project to show my program with more clarity .
I had several class which realized the interfaces in strmif.h , if I cannot import the definition of interfaces from the header file , I had to type it manuallly.


DanG83616

  • EA User
  • **
  • Posts: 180
  • Karma: +0/-0
    • View Profile
Re: Is there anyway to process macro of C++ file ?
« Reply #3 on: November 20, 2010, 02:28:26 am »
[Deleted misleading comments about IDL code gen/import]
If you installed the MDG technology for Corba then IDL will appear in the language options for source code import. Make sure you used Add-ins->Corba to install the MDG technology. If you don't see Corba in the list then you also need to enable the add-in using Add-ins->Manage Add-ins. Even at this point, you will be faced with possible incompatibilities between MIDL and CORBA IDL.

Yet another idea for your primary goal is to just do a quick macro expansion using search-and-replace on a copy of strmif.h. The import source code feature is most valuable when you change the code before changing the design. Since strmif.h (and any other 3rd party lib interfaces you use) won't change very frequently the value of automatic import becomes much less significant.
« Last Edit: November 20, 2010, 10:42:06 am by dgeorge83616 »