The wiki is in the process of moving to Please make your edits there.

Blueprint for language specs system | Qt Wiki | Qt Project

Blueprint for language specs system

Current ModelManagerInterface::ProjectPart has following problems:

  • Pure C can be set only for whole ProjectPart. Objective C headers and objective C++ headers/sources cannot be set.
  • C++ language extensions not handled.
  • Project managers for autotools and cmake assume that any file is C++ source
  • ProjectManager can use only C++ flags and must ignore C/ObjC/ObjC++ flags.
  • QMake project manager doesn’t read OBJECTIVE_HEADERS variable

How clang can handle different languages:

  • Clang supports 4 languages: C, C++, ObjectiveC and ObjectiveC++. Each language has headers and implementation files. Like in such code:
    1. QStringList ClangCodeModel::Utils::clangLanguageOption(bool cxxEnabled,
    2.                                                       bool isHeader,
    3.                                                       bool isObjC)
    4. {
    5.     QStringList opts;
    6.     opts += QLatin1String("-x");
    8.     if (cxxEnabled && isHeader && isObjC)
    9.         opts += QLatin1String("objective-c++-header");
    10.     else if (!cxxEnabled && isHeader && isObjC)
    11.         opts += QLatin1String("objective-c-header");
    12.     else if (cxxEnabled && !isHeader && isObjC)
    13.         opts += QLatin1String("objective-c++");
    14.     else if (!cxxEnabled && !isHeader && isObjC)
    15.         opts += QLatin1String("objective-c");
    16.     else if (cxxEnabled && isHeader && !isObjC)
    17.         opts += QLatin1String("c++-header");
    18.     else if (!cxxEnabled && isHeader && !isObjC)
    19.         opts += QLatin1String("c-header");
    20.     else if (cxxEnabled && !isHeader && !isObjC)
    21.         opts += QLatin1String("c++");
    22.     else // !cxxEnabled && !isHeader && !isObjC
    23.         opts += QLatin1String("c");
    25.     return opts;
    26. }
  • If file directly included to project, than it language and isHeader flag can be determined by each project manager plugin. Otherwise, we can use dependency table and assume that <iostream> file is “c++-header”, because it included only by C++ files. (sergey shambir: I don’t know how to handle inclusion from both C++ and ObjectiveC++ files. Probably it should have type of file from which it was opened in editor).
  • Each language can have extensions: GNU, Microsoft and Borland. Only one extensions group used.
  • Each language can have own set of flags, at least in QMAKE
  • Each language can have several standards: c89, c99 and c11; c++98 and c++11