Blueprint for Language Specs System: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
(Cleanup)
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
== 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.
Current ModelManagerInterface::ProjectPart has following problems:<br />* Pure C can be set only for whole ProjectPart. Objective C headers and objective C++ headers/sources cannot be set.<br />* C++ language extensions not handled.<br />* Project managers for autotools and cmake assume that any file is C++ source<br />* ProjectManager can use only C++ flags and must ignore C/ObjC/ObjC++ flags.<br />* QMake project manager doesn't read OBJECTIVE_HEADERS variable
* 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:
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:<br /><code><br />QStringList ClangCodeModel::Utils::clangLanguageOption(bool cxxEnabled,<br /> bool isHeader,<br /> bool isObjC)<br />{<br /> QStringList opts;<br /> opts''= QLatin1String(&quot;-x&amp;quot;);
* Clang supports 4 languages: C, C+'', ObjectiveC and ObjectiveC. Each language has headers and implementation files. Like in such code:
<code>
QStringList ClangCodeModel::Utils::clangLanguageOption(bool cxxEnabled,
bool isHeader,
bool isObjC)
{
QStringList opts;
opts''= QLatin1String("-x");


if (cxxEnabled &amp;&amp; isHeader &amp;&amp; isObjC)<br /> opts ''= QLatin1String(&quot;objective-c-header&amp;quot;);<br /> else if (!cxxEnabled &amp;&amp; isHeader &amp;&amp; isObjC)<br /> opts''= QLatin1String(&quot;objective-c-header&amp;quot;);<br /> else if (cxxEnabled &amp;&amp; !isHeader &amp;&amp; isObjC)<br /> opts ''= QLatin1String(&quot;objective-c&quot;);<br /> else if ([[Image:cxxEnabled &amp;&amp; |cxxEnabled &amp;&amp; ]]isHeader &amp;&amp; isObjC)<br /> opts''= QLatin1String(&quot;objective-c&amp;quot;);<br /> else if (cxxEnabled &amp;&amp; isHeader &amp;&amp; !isObjC)<br /> opts ''= QLatin1String(&quot;c-header&amp;quot;);<br /> else if ([[Image:cxxEnabled &amp;&amp; isHeader &amp;&amp; |cxxEnabled &amp;&amp; isHeader &amp;&amp; ]]isObjC)<br /> opts''= QLatin1String(&quot;c-header&amp;quot;);<br /> else if (cxxEnabled &amp;&amp; [[Image:isHeader &amp;&amp; |isHeader &amp;&amp; ]]isObjC)<br /> opts ''= QLatin1String(&quot;c&quot;);<br /> else // [[Image:cxxEnabled &amp;&amp; |cxxEnabled &amp;&amp; ]]isHeader &amp;&amp; !isObjC<br /> opts''= QLatin1String(&quot;c&amp;quot;);
if (cxxEnabled && isHeader && isObjC)
opts ''= QLatin1String("objective-c-header");
else if (!cxxEnabled && isHeader && isObjC)
opts''= QLatin1String("objective-c-header");
else if (cxxEnabled && !isHeader && isObjC)
opts ''= QLatin1String("objective-c");
else if ([[Image:cxxEnabled && |cxxEnabled && ]]isHeader && isObjC)
opts''= QLatin1String("objective-c");
else if (cxxEnabled && isHeader && !isObjC)
opts ''= QLatin1String("c-header");
else if ([[Image:cxxEnabled && isHeader && |cxxEnabled && isHeader && ]]isObjC)
opts''= QLatin1String("c-header");
else if (cxxEnabled && [[Image:isHeader && |isHeader && ]]isObjC)
opts ''= QLatin1String("c");
else // [[Image:cxxEnabled && |cxxEnabled && ]]isHeader && !isObjC
opts''= QLatin1String("c");


return opts;<br />}<br /></code><br />* 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 &lt;iostream&amp;gt; file is &quot;c+''-header&amp;quot;, 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).<br />* Each language can have extensions: GNU, Microsoft and Borland. Only one extensions group used.<br />* Each language can have own set of flags, at least in QMAKE
return opts;
}
</code>
* 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

Latest revision as of 11:47, 28 June 2015

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:
QStringList ClangCodeModel::Utils::clangLanguageOption(bool cxxEnabled,
 bool isHeader,
 bool isObjC)
{
 QStringList opts;
 opts''= QLatin1String("-x");

if (cxxEnabled && isHeader && isObjC)
 opts ''= QLatin1String("objective-c-header");
 else if (!cxxEnabled && isHeader && isObjC)
 opts''= QLatin1String("objective-c-header");
 else if (cxxEnabled && !isHeader && isObjC)
 opts ''= QLatin1String("objective-c");
 else if ([[Image:cxxEnabled && |cxxEnabled && ]]isHeader && isObjC)
 opts''= QLatin1String("objective-c");
 else if (cxxEnabled && isHeader && !isObjC)
 opts ''= QLatin1String("c-header");
 else if ([[Image:cxxEnabled && isHeader && |cxxEnabled && isHeader && ]]isObjC)
 opts''= QLatin1String("c-header");
 else if (cxxEnabled && [[Image:isHeader && |isHeader && ]]isObjC)
 opts ''= QLatin1String("c");
 else // [[Image:cxxEnabled && |cxxEnabled && ]]isHeader && !isObjC
 opts''= QLatin1String("c");

return opts;
}
  • 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