Show in Frame No Frame
Up Previous Next Title Page Index Contents Search

5.2.3 Code generation

Code generation works similarly to other generators described in the previous section. The code generators are modeling language and target language dependent. This means that code generators available for one modeling language are not necessarily available for others (e.g. there is a C++ generator for UML Class Diagrams but not for the Digital Watch example).

The set of predefined code generators shipped with MetaEdit+ include:
*UML: C++, Java, Smalltalk, Delphi and CORBA IDL, plus JavaScript for WebApps.
*Digital Watch: Java, including variants for MIDP and Android; C#, including a variant for Windows Phone; and C.
*Entity-Relationship Diagram: SQL
*Turtle Graphics: Python
*Mobile UI: Python, C++
*Heating System: PLC
Descriptions of each generator can be found from the comments at the start of that generator’s definition.

Code generation is available from the Graph | Generate... menu or the Generate toolbar command that are available in all editors, as well as through the Generate... menu or Generate Launcher toolbar button in Graph and Type Browsers when a graph is selected. For example, to generate and compile C# code for the Watch example:
1)Choose the ‘WatchModels’ WatchFamily graph in the Graph Browser.
2)Press the Generate button in the Launcher toolbar. Alternatively, open the pop-up menu with the right mouse button and select Generate....
3)Select ‘Autobuild’ from the dialog that appears.

As a result of the selection C# class definitions are written into files, compiled and executed.

In line with the other customizable metamodeling features of MetaEdit+, code generation can be extended to cover other modeling and programming languages. For more information about how to define generators, see ‘MetaEdit+ Workbench User’s Guide’.

Show in Frame No Frame
Up Previous Next Title Page Index Contents Search