~ubuntu-branches/ubuntu/maverick/aspectc++/maverick

« back to all changes in this revision

Viewing changes to AspectC++/ACWeaver.cc

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2008-04-10 17:40:52 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20080410174052-xdnsm7oi8hauyyf1
Tags: 1.0pre4~svn.20080409+dfsg-3
Fix another missing include, this time in Ag++/StdSystem.cc

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
#include "Repository.h"
40
40
#include "Naming.h"
41
41
#include "NamespaceAC.h"
 
42
#include "JoinPointModel.h"
42
43
 
43
44
// PUMA includes
44
45
#include "Puma/CProject.h"
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;
104
108
   _pointcut_defs << "  void proceed();" << endl;
105
109
   _pointcut_defs << "} *thisJoinPoint, *tjp;" << endl;
106
110
   _pointcut_defs << "#endif" << endl;
107
 
 
108
 
   _pointcut_defs << ends;
109
111
 }
110
112
 
111
113
 
168
170
   // set of manipulated (and saved) units
169
171
   set<Unit*> h_units;
170
172
   set<Unit*> cc_units;
171
 
     
 
173
   string aspect_includes;
 
174
        
172
175
   if (!_conf.iterate () && !_conf.ifiles () && _conf.file_in ()) {
173
176
 
174
177
     Transformer transformer (vm, err (), _project, repo, _conf, _line_mgr);
178
181
 
179
182
     // remember this unit
180
183
     cc_units.insert (unit);
181
 
     
 
184
 
 
185
     // remember the aspect includes
 
186
     aspect_includes = transformer.aspect_includes ();
 
187
           
182
188
     // break in case of errors
183
189
     if (err ().severity () >= sev_error)
184
190
       return;
187
193
 
188
194
     // Transform all translation units in the project directory tree
189
195
     stringstream extpat;
190
 
     extpat << ".*\\." << _conf.extension () << "$" << ends;
 
196
     extpat << ".*\\." << _conf.extension () << "$";
191
197
     
 
198
     bool first = true;
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);
205
212
 
 
213
       // remember the aspect units for inclusion
 
214
       if (first) {
 
215
         aspect_includes = transformer.aspect_includes ();
 
216
         first = false;
 
217
       }
 
218
 
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;
239
252
     }
240
253
     str << "/*** end of includes ***/" << endl;
241
 
     str << ends;
242
254
     
243
255
     CScanner scanner (err ());
244
256
     scanner.fill_unit (str.str ().data (), *unit); 
247
259
 
248
260
     translate (vm, _conf.file_in (), transformer);
249
261
 
 
262
     // remember the aspect units for inclusion
 
263
     aspect_includes = transformer.aspect_includes ();
 
264
 
250
265
     // discard the generated translation unit
251
266
     _project.close (_conf.file_in (), true, true);
252
267
 
268
283
      return;
269
284
 
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);
272
287
   
273
288
   vm << "Updating #line directives of generated code fragments" << endvm;
274
289
   update_line_directives (cc_units, h_units);
329
344
       iter != cc_units.end (); ++iter) {
330
345
    ostringstream out;
331
346
    if (_project.getDestinationPath ((*iter)->name (), out)) {
332
 
      out << ends;
333
347
      update_line_directives (*iter, out.str ().c_str ());
334
348
    }
335
349
  }
337
351
       iter != h_units.end (); ++iter) {
338
352
    ostringstream out;
339
353
    if (_project.getDestinationPath ((*iter)->name (), out)) {
340
 
      out << ends;
341
354
      update_line_directives (*iter, out.str ().c_str ());
342
355
    }
343
356
  }
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) {
350
363
  vm++;
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);
355
368
  }
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);
360
373
  }
361
374
  vm--;
362
375
}
363
376
       
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) {
365
379
 
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);
459
473
 
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) {
463
477
 
464
478
  includes << "/*** begin of aspect includes ***/" << endl;
465
479
 
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 ());
472
486
  }
473
487
  else {
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));
477
491
  }
478
492
  includes << "/*** end of aspect includes ***/" << endl;
479
493
}
480
494
 
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,
484
 
                               bool conditional) {
485
 
 
 
497
void ACWeaver::aspect_include (ostream &includes, const char *name) {
486
498
  Filename incname = _project.getInclString (name);
487
 
  if (conditional) {
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);
497
 
    includes << endl;
498
 
  }
499
499
  includes << "#include \"" << incname << "\"" << endl;
500
 
  if (conditional)
501
 
    includes << "#endif" << endl;
502
500
}
503
501
 
504
502
Unit *ACWeaver::translate (VerboseMgr &vm, const char *file, 
528
526
   assert (file_last);
529
527
   
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 ();