When reverse engineering a language such as C++, you might find preprocessor directives scattered throughout the code. This can make code management easier, but can hamper parsing of the underlying C++ language.
To help remedy this, you can include any number of macro definitions, which are ignored during the parsing phase of the reverse engineering. It is still preferable, if you have the facility, to preprocess the code using the appropriate compiler first; this way, complex macro definitions and defines are expanded out and can be readily parsed. If you don't have this facility, then this option provides a convenient substitute.
You can transport these language macro (or preprocessor macro) definitions between models, using the Export Reference Data and Import Reference Data options on the Tools menu. The macros are exported as a Macro List.
Define a Macro
- Select the Settings | Preprocessor Macros menu option. The Language Macros dialog displays.
- Click on the Add New button.
- Enter details for your macro.
- Click on the OK button.
Macros Embedded Within Declarations
Macros are sometimes used within the declaration of Classes and operations, as in the following examples:
class __declspec Foo
int __declspec Bar(int p);
If declspec is defined as a C++ macro, as outlined above, the imported Class and operation contain a Tagged Value called DeclMacro1 with value __declspec. (Subsequent macros would be defined as DeclMacro2, DeclMacro3 and so on.) During forward engineering, these Tagged Values are used to regenerate the macros in code.
Define Complex Macros
It is sometimes useful to define rules for complex macros that can span multiple lines. Enterprise Architect ignores the entire code section defined by the rule. Such macros can be defined in Enterprise Architect as in the following two examples. Both types can be combined in one definition.
BEGIN_INTERFACE_PART ^ END_INTERFACE_PART
where the ^ symbol represents the body of the macro. This enables skipping from one macro to another.
The spaces surrounding the ^ symbol are required.
where Enterprise Architect skips over the token including everything inside the parentheses.