~ubuntu-branches/ubuntu/utopic/aspectc++/utopic

« back to all changes in this revision

Viewing changes to AspectC++/AspectIncludes.cc

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2006-04-07 11:56:35 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060407115635-e8wfgmetasrf2p27
Tags: 0.99+1.0pre3-1
* new upstream release
* Apply patch from Martin Michlmayr for g++-4.1 (Closes: #357901)
* further (simple) patches in Puma/ and AspectC++ for g++-4.1
* note that Puma needs to be rewoven so that it can be compiled
  with g++-4.1. This will be done we switch the default compiler
  version.
* Patch JoinPointRepo.cc so that it doesn't loop endlessly anymore.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
  AspectRef::Kind kind) {
37
37
  assert (iu);
38
38
 
39
 
  // ignore the dependency if a file should include itself
40
 
  Unit *au = aspect_unit (acai);
41
 
  if ((kind == AspectRef::AR_DEF) && (iu == au))
42
 
    return;
43
 
  
44
39
  // check if there is already an entry for this unit
45
40
  iterator entry = find (iu);
46
41
  if (entry == end ()) {
61
56
    else {
62
57
      // a definition request dominates a declaration request...
63
58
      AspectRef &ref = (AspectRef&)(*ref_entry);
64
 
      if (kind > ref._kind) {
 
59
      if (kind > ref._kind)
65
60
        ref._kind = kind;
66
 
        ref._mark = false; // the defintion shall be generated!
67
 
      }
68
61
    }
69
62
  }
70
63
}
89
82
string AspectIncludes::generate (CProject &prj, const_iterator entry) const {
90
83
  string includes;
91
84
  const AspectRefSet &set = (*entry).second;
92
 
  std::set<Unit*> units;
93
85
  for (AspectRefSet::const_iterator iter = set.begin ();
94
86
    iter != set.end (); ++iter) {
95
87
 
96
 
    // add the #include directive for the current unit
97
 
    if (!(*iter)._mark) {
98
 
 
99
 
      switch ((*iter)._kind) {
100
 
        case AspectRef::AR_DECL: 
101
 
          includes += "class ";
102
 
          includes += (*iter)._concrete_aspect->name ();
103
 
          includes += ";\n";
104
 
          break;
105
 
        case AspectRef::AR_DEF:
106
 
          {
107
 
            Unit *unit = aspect_unit (*iter);
108
 
            // generate the include, but suppress duplicates
109
 
            if (units.find (unit) == units.end ()) {
110
 
              includes += generate (prj, *iter);
111
 
              includes += "\n";
112
 
              units.insert (unit);
113
 
            }
114
 
          }
115
 
          break;
116
 
        case AspectRef::AR_ADVICE:
117
 
          {
118
 
            includes += (*iter)._concrete_aspect->ifct_decls ();
119
 
            Unit *unit = aspect_unit (*iter);
120
 
            assert (unit && unit->isFile ());
121
 
            stringstream define;
122
 
            define << "#ifndef __ac_need_";
123
 
            Naming::mangle_file (define, (FileUnit*)unit);
124
 
            define << endl << "#define __ac_need_";
125
 
            Naming::mangle_file (define, (FileUnit*)unit);
126
 
            define << endl << "#endif" << endl;
127
 
            includes += define.str ();          
128
 
          }
129
 
          break;
130
 
        default:
131
 
          cout << "aspect ref type not yet implemented" << endl;
132
 
      }
133
 
    
134
 
      (*iter)._mark = true;
 
88
    switch ((*iter)._kind) {
 
89
      case AspectRef::AR_DECL: 
 
90
        includes += "class ";
 
91
        includes += (*iter)._concrete_aspect->name ();
 
92
        includes += ";\n";
 
93
        break;
 
94
      case AspectRef::AR_ADVICE:
 
95
        {
 
96
          includes += (*iter)._concrete_aspect->ifct_decls ();
 
97
          Unit *unit = aspect_unit (*iter);
 
98
          assert (unit && unit->isFile ());
 
99
          stringstream define;
 
100
          define << "#ifndef __ac_need_";
 
101
          Naming::mangle_file (define, (FileUnit*)unit);
 
102
          define << endl << "#define __ac_need_";
 
103
          Naming::mangle_file (define, (FileUnit*)unit);
 
104
          define << endl << "#endif" << endl;
 
105
          includes += define.str ();          
 
106
        }
 
107
        break;
 
108
      default:
 
109
        cout << "aspect ref type not yet implemented" << endl;
135
110
    }
136
111
  }
137
 
  // mark that the code for this unit has been generated now
138
 
  (*entry).first._mark = true;
139
112
  return includes;
140
113
}