Code Generation Basic Concepts |
| Technical Article |
AbstractThis article presents the basic concepts of the code generation infrastructure. It explains the goal of the product, its global architecture, and its integration into Visual Studio. |
In order to increase the productivity of developers, it's possible to automate the development of some portions applications. Native C++ code is not always the more natural way to represent or develop some application parts. The goal is to provide graphical tools or high level languages to accelerate the creation process and to improve the code reliability. The final native code is then automatically generated after this process.
The automation of code production represents a major development speedup in the complete project lifecycle. In the specification phase, an application prototype can be quickly designed, and then tested in a simulation process, to check that is has the desired behavior. Once the design validated, it's automatically transformed into native source code. Finally, since this code is generated, it's reliable, and doesn't require maintenance.
CAA programming is based on C++ programming, and contains some parts that can't be automated, like data models and algorithms. This infrastructure must support both graphical and native code edition. More over those two representations are highly linked, and must be authored in a tool that will integrate this process properly. For this reason, we integrated our application in Visual Studio, to control what we can automate, and to let VS handle the native code edition.
The whole development process is integrated in an IDE (Visual Studio). The design editor of the IDE is the core of the code generation infrastructure. This editor is used to design the application domains handle by the code generation infrastructure. The code editor supports native language code authoring, required to complement the graphical design of the developed component.
Both views are a partial representation of the same model. This model contains the full representation of the designed application, and the editors are always synchronized with it. This model is directly saved on the disk, and this file represents the only persistent data of the application being developed with the infrastructure.

Although the design editor uses a representation of the model close to the real look of the application, some differences can exist with the program that will be generated. In particular, this difference might be useful to design the application easier. Moreover, the view in the design editor can't always reflect the dynamic behavior of the produced application.
The code generation file can be simulated to allow the developer to quickly check the real application appearance, and its dynamic behavior. This process avoids long compile/run sequences to check that the application is behaving properly.
The code generation process is not inserted in Visual Studio, but directly in mkmk. Before compiling C++ code, mkmk has a grammar step. In this step, if mkmk encounters a code generation file (with extension .DSGen), it calls our specific compiler that will create the final native code. Those files are then compiled and linked with the application.
The created header(s) and implement(s) files are generated in the LocalGenerated directory. Thus, they are not meant to be used or edited directly.

The code generation infrastructure is inserted in a VS Package. This type of VS extension offers the best integration in Visual Studio, with more functionalities and flexibility than an Add-in. This package provides specialized interfaces to control Visual Studio and controls every code automation domains like dialog, dialog engine, etc.
This diagram illustrates the integration of the code generation package in Visual Studio:

More precisely, the package consists in:
Here is a global view of the package elements in a development context in Visual Studio:
| Version: 1 [July 2007] | Document creation |