Generators can also extract data
by analyzing combinations of model elements, such as the relationships connecting
them, the submodels an element has, or other linkages between model elements.
Transforming Models to Output Code While navigating in models the data
accessed are combined for the purpose of code generation. Here the generator adds
additional information for the output as well as integrating with the framework code or
making calls to the underlying target environment and its libraries. Consider the
generated C++ code in Listing 4.1 below. The code is generated from the mobile
phone application design described in Fig. 1.6.
Listing 4.1 Sample code for the application described in Section 1.3.
01 // ---------------------------------------------------------
02 // void CAknConferenceRegistrationView::welcome()
03 // ---------------------------------------------------------
04
05 void CAknConferenceRegistrationView::welcome()
06 {
07 CAknInformationNote* aNote;
08 aNote = new (ELeave) CAknInformationNote(ETrue);
09 aNote->ExecuteLD(_L("Conference registration: Welcome"));
10 }
Typically a generator produces the syntax for the generated code: C++ here, but it
could equally well be some other target language, like Python, as discussed in depth in
Chapter 8. The generator also transforms model data, and sometimes also metamodel
data, to the output code.
Pages:
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176