src/tools/moc/moc.cpp
changeset 33 3e2da88830cd
parent 30 5dc02b23752f
child 37 758a864f9613
equal deleted inserted replaced
30:5dc02b23752f 33:3e2da88830cd
  1206         case LPAREN: ++parenCount; break;
  1206         case LPAREN: ++parenCount; break;
  1207         case LANGLE: ++angleCount; break;
  1207         case LANGLE: ++angleCount; break;
  1208         default: break;
  1208         default: break;
  1209         }
  1209         }
  1210     }
  1210     }
       
  1211 
       
  1212     //when searching commas within the default argument, we should take care of template depth (anglecount)
       
  1213     // unfortunatelly, we do not have enough semantic information to know if '<' is the operator< or
       
  1214     // the begining of a template type. so we just use heuristics.
       
  1215     int possible = -1;
       
  1216 
  1211     while (index < symbols.size()) {
  1217     while (index < symbols.size()) {
  1212         Token t = symbols.at(index++).token;
  1218         Token t = symbols.at(index++).token;
  1213         switch (t) {
  1219         switch (t) {
  1214         case LBRACE: ++braceCount; break;
  1220         case LBRACE: ++braceCount; break;
  1215         case RBRACE: --braceCount; break;
  1221         case RBRACE: --braceCount; break;
  1224         }
  1230         }
  1225         if (t == target
  1231         if (t == target
  1226             && braceCount <= 0
  1232             && braceCount <= 0
  1227             && brackCount <= 0
  1233             && brackCount <= 0
  1228             && parenCount <= 0
  1234             && parenCount <= 0
  1229             && (target != RANGLE || angleCount <= 0))
  1235             && (target != RANGLE || angleCount <= 0)) {
       
  1236             if (target != COMMA || angleCount <= 0)
       
  1237                 return true;
       
  1238             possible = index;
       
  1239         }
       
  1240 
       
  1241         if (target == COMMA && t == EQ && possible != -1) {
       
  1242             index = possible;
  1230             return true;
  1243             return true;
       
  1244         }
  1231 
  1245 
  1232         if (braceCount < 0 || brackCount < 0 || parenCount < 0
  1246         if (braceCount < 0 || brackCount < 0 || parenCount < 0
  1233             || (target == RANGLE && angleCount < 0)) {
  1247             || (target == RANGLE && angleCount < 0)) {
  1234             --index;
  1248             --index;
  1235             break;
  1249             break;
  1236         }
  1250         }
  1237     }
  1251     }
       
  1252 
       
  1253     if(target == COMMA && angleCount != 0 && possible != -1) {
       
  1254         index = possible;
       
  1255         return true;
       
  1256     }
       
  1257 
  1238     return false;
  1258     return false;
  1239 }
  1259 }
  1240 
  1260 
  1241 void Moc::checkSuperClasses(ClassDef *def)
  1261 void Moc::checkSuperClasses(ClassDef *def)
  1242 {
  1262 {