82
83
_pointcut_defs << " typedef __unknown_t That;" << endl;
83
84
_pointcut_defs << " typedef __unknown_t Target;" << endl;
84
85
_pointcut_defs << " typedef __unknown_t Result;" << endl;
85
_pointcut_defs << " enum { ARGS, JPID, JPTYPE };" << endl;
86
_pointcut_defs << " enum { ARGS, JPID };" << endl;
87
_pointcut_defs << " static const AC::JPType JPTYPE = (AC::JPType)0;" << endl;
86
88
_pointcut_defs << " template <int> struct Arg {" << endl;
87
89
_pointcut_defs << " typedef __unknown_t Type;" << endl;
88
90
_pointcut_defs << " typedef __unknown_t ReferredType;" << endl;
89
91
_pointcut_defs << " };" << endl;
90
92
_pointcut_defs << " typedef char* Type;" << endl;
91
93
_pointcut_defs << " static const char *signature ();" << endl;
94
_pointcut_defs << " static const char *filename ();" << endl;
95
_pointcut_defs << " static int line ();" << endl;
92
96
_pointcut_defs << " static int args ();" << endl;
93
97
_pointcut_defs << " void *arg (int);" << endl;
94
98
_pointcut_defs << " template <int> __unknown_t *arg ();" << endl;
168
170
// set of manipulated (and saved) units
169
171
set<Unit*> h_units;
170
172
set<Unit*> cc_units;
173
string aspect_includes;
172
175
if (!_conf.iterate () && !_conf.ifiles () && _conf.file_in ()) {
174
177
Transformer transformer (vm, err (), _project, repo, _conf, _line_mgr);
188
194
// Transform all translation units in the project directory tree
189
195
stringstream extpat;
190
extpat << ".*\\." << _conf.extension () << "$" << ends;
196
extpat << ".*\\." << _conf.extension () << "$";
192
199
PathIterator iter (extpat.str ().data ());
193
200
while (_project.iterate (iter)) {
194
201
if (!(_project.isNewer (iter.file ()) || header_changed)) {
203
210
// remember that we need this file
204
211
cc_units.insert (unit);
213
// remember the aspect units for inclusion
215
aspect_includes = transformer.aspect_includes ();
206
219
// discard changes in header files
207
220
UnitManager::UMap &umap = _project.unitManager ().getTable ();
208
221
for (UnitManager::UMapIter iter = umap.begin ();
238
251
str << "#include \"" << incname << "\"" << endl;
240
253
str << "/*** end of includes ***/" << endl;
243
255
CScanner scanner (err ());
244
256
scanner.fill_unit (str.str ().data (), *unit);
248
260
translate (vm, _conf.file_in (), transformer);
262
// remember the aspect units for inclusion
263
aspect_includes = transformer.aspect_includes ();
250
265
// discard the generated translation unit
251
266
_project.close (_conf.file_in (), true, true);
270
285
vm << "Inserting unit pro- and epilogues" << endvm;
271
insert_aspect_includes (vm, cc_units, h_units);
286
insert_aspect_includes (vm, cc_units, h_units, aspect_includes);
273
288
vm << "Updating #line directives of generated code fragments" << endvm;
274
289
update_line_directives (cc_units, h_units);
346
359
// insert a pro- and epilogue into all saved units to make sure that in
347
360
// any case the relevant aspect headers will be defined
348
361
void ACWeaver::insert_aspect_includes (VerboseMgr &vm, set<Unit*> &cc_units,
349
set<Unit*> &h_units) {
362
set<Unit*> &h_units, const string &aspect_includes) {
351
364
for (set<Unit*>::iterator iter = cc_units.begin ();
352
365
iter != cc_units.end (); ++iter) {
353
366
vm << "Manipulating translation unit file " << (*iter)->name () << endvm;
354
insert_aspect_includes (vm, *iter, false);
367
insert_aspect_includes (vm, *iter, false, aspect_includes);
356
369
for (set<Unit*>::iterator iter = h_units.begin ();
357
370
iter != h_units.end (); ++iter) {
358
371
vm << "Manipulating header file " << (*iter)->name () << endvm;
359
insert_aspect_includes (vm, *iter, true);
372
insert_aspect_includes (vm, *iter, true, aspect_includes);
364
void ACWeaver::insert_aspect_includes (VerboseMgr &vm, Unit* u, bool header) {
377
void ACWeaver::insert_aspect_includes (VerboseMgr &vm, Unit* u,
378
bool header, const string &aspect_includes) {
366
380
assert (u->isFile ());
367
381
FileUnit *unit = (FileUnit*)u;
402
416
epilogue << endl << "#ifdef __ac_FIRST_FILE_";
403
417
Naming::mangle_file (epilogue, unit);
404
418
epilogue << endl;
405
aspect_includes (epilogue, true); // generate the aspect includes
419
epilogue << aspect_includes;
406
420
epilogue << "#undef " << first_macro.c_str () << endl;
407
421
epilogue << "#undef __ac_FIRST_FILE_";
408
422
Naming::mangle_file (epilogue, unit);
460
474
// Create includes for the aspect header files that should be regarded
461
475
// in this translation unit
462
void ACWeaver::aspect_includes (ostream &includes, bool conditional) {
476
void ACWeaver::aspect_includes (ostream &includes) {
464
478
includes << "/*** begin of aspect includes ***/" << endl;
468
482
// generate a unit with include statements for these files,
469
483
PathIterator ah_iter (".*\\.ah$");
470
484
while (_project.iterate (ah_iter))
471
aspect_include (includes, ah_iter.file (), conditional);
485
aspect_include (includes, ah_iter.file ());
474
488
// Get the names from the configuration object (-a options)
475
489
for (int i = 0; i < _conf.aspect_headers (); i++)
476
aspect_include (includes, _conf.aspect_header (i), conditional);
490
aspect_include (includes, _conf.aspect_header (i));
478
492
includes << "/*** end of aspect includes ***/" << endl;
481
495
// Create an include directive for one aspect header file that should be
482
496
// considered in this translation unit
483
void ACWeaver::aspect_include (ostream &includes, const char *name,
497
void ACWeaver::aspect_include (ostream &includes, const char *name) {
486
498
Filename incname = _project.getInclString (name);
488
Unit *unit = _project.unitManager ().getUnit (name, true);
489
assert (unit && unit->isFile ());
490
includes << "#if !defined(__ac_have_";
491
Naming::mangle_file (includes, (FileUnit*)unit);
492
includes << ") && defined(__ac_need_";
493
Naming::mangle_file (includes, (FileUnit*)unit);
494
includes << ")" << endl;
495
includes << "#define __ac_have_";
496
Naming::mangle_file (includes, (FileUnit*)unit);
499
499
includes << "#include \"" << incname << "\"" << endl;
501
includes << "#endif" << endl;
504
502
Unit *ACWeaver::translate (VerboseMgr &vm, const char *file,
528
526
assert (file_last);
530
528
ACUnit global_includes (err ());
531
aspect_includes (global_includes, false);
529
aspect_includes (global_includes);
532
530
global_includes << endu;
533
531
ListElement *inc_first = (ListElement*)global_includes.first ();
534
532
ListElement *inc_last = (ListElement*)global_includes.last ();