MCPcopy Create free account
hub / github.com/KDE/kdevelop / defines

Method defines

plugins/custom-definesandincludes/compilerprovider/msvccompiler.cpp:20–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18using namespace KDevelop;
19
20Defines MsvcCompiler::defines(Utils::LanguageType, const QString&) const
21{
22 Defines ret;
23 //Get standard macros from kdevmsvcdefinehelpers
24 KProcess proc;
25 proc.setOutputChannelMode( KProcess::MergedChannels );
26 proc.setTextModeEnabled( true );
27
28 // we want to use kdevmsvcdefinehelper as a pseudo compiler backend which
29 // returns the defines used in msvc. there is no such thing as -dM with cl.exe
30 proc << path() << QStringLiteral("/nologo") << QStringLiteral("/Bxkdevmsvcdefinehelper") << QStringLiteral("empty.cpp");
31
32 // this will fail, so check on that as well
33 if ( proc.execute( 5000 ) == 2 ) {
34 QString line;
35 proc.readLine(); // read the filename
36
37 while ( proc.canReadLine() ) {
38 QByteArray buff = proc.readLine();
39 qCDebug(DEFINESANDINCLUDES) << "msvcstandardmacros:" << buff;
40 if ( !buff.isEmpty() ) {
41 line = QString::fromUtf8(buff);
42 if ( line.startsWith( QLatin1String("#define ") ) ) {
43 line = QStringView{line}.sliced(8).trimmed().toString();
44 int pos = line.indexOf(QLatin1Char(' '));
45
46 if ( pos != -1 ) {
47 ret[line.first(pos)] = line.sliced(pos + 1);
48 } else {
49 ret[line] = QLatin1String("");
50 }
51 }
52 }
53 }
54 } else {
55 qCDebug(DEFINESANDINCLUDES) << QLatin1String("Unable to read standard c++ macro definitions from ") + path();
56 while ( proc.canReadLine() ){
57 qCDebug(DEFINESANDINCLUDES) << proc.readLine();
58 }
59 qCDebug(DEFINESANDINCLUDES) << proc.exitCode();
60 }
61
62 // MSVC builtin attributes
63 {
64 ret[QStringLiteral("__cdecl")] = QLatin1String("");
65 ret[QStringLiteral("__fastcall")] = QLatin1String("");
66 ret[QStringLiteral("__stdcall")] = QLatin1String("");
67 ret[QStringLiteral("__thiscall")] = QLatin1String("");
68 }
69
70 // MSVC builtin types
71 // see http://msdn.microsoft.com/en-us/library/cc953fe1.aspx
72 {
73 ret[QStringLiteral("__int8")] = QStringLiteral("char");
74 ret[QStringLiteral("__int16")] = QStringLiteral("short");
75 ret[QStringLiteral("__int32")] = QStringLiteral("int");
76 ret[QStringLiteral("__int64")] = QStringLiteral("long long");
77 ret[QStringLiteral("__int16")] = QStringLiteral("short");

Callers 1

Calls 7

pathFunction · 0.85
readLineMethod · 0.80
executeMethod · 0.45
isEmptyMethod · 0.45
toStringMethod · 0.45
indexOfMethod · 0.45
firstMethod · 0.45

Tested by 1