Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
0422bcbb
Commit
0422bcbb
authored
Dec 22, 2008
by
Roberto Raggi
Browse files
Some more clean up in the preprocessor.
parent
e325aa38
Changes
11
Hide whitespace changes
Inline
Side-by-side
src/libs/cplusplus/CppDocument.h
View file @
0422bcbb
...
...
@@ -35,8 +35,7 @@
#define CPPDOCUMENT_H
#include <CPlusPlusForwardDeclarations.h>
#include "pp-macro.h"
#include "Macro.h"
#include <QByteArray>
#include <QList>
...
...
src/libs/cplusplus/Macro.cpp
0 → 100644
View file @
0422bcbb
/***************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
**
** Non-Open Source Usage
**
** Licensees may use this file in accordance with the Qt Beta Version
** License Agreement, Agreement version 2.2 provided with the Software or,
** alternatively, in accordance with the terms contained in a written
** agreement between you and Nokia.
**
** GNU General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the packaging
** of this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
**
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt GPL Exception
** version 1.3, included in the file GPL_EXCEPTION.txt in this package.
**
***************************************************************************/
/*
Copyright 2005 Roberto Raggi <roberto@kdevelop.org>
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
KDEVELOP TEAM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "Macro.h"
using
namespace
CPlusPlus
;
Macro
::
Macro
()
:
_next
(
0
),
_hashcode
(
0
),
_line
(
0
),
_state
(
0
)
{
}
QString
Macro
::
toString
()
const
{
QString
text
;
if
(
_hidden
)
text
+=
QLatin1String
(
"#undef "
);
else
text
+=
QLatin1String
(
"#define "
);
text
+=
QString
::
fromUtf8
(
_name
.
constData
(),
_name
.
size
());
if
(
_functionLike
)
{
text
+=
QLatin1Char
(
'('
);
bool
first
=
true
;
foreach
(
const
QByteArray
formal
,
_formals
)
{
if
(
!
first
)
text
+=
QLatin1String
(
", "
);
else
first
=
false
;
text
+=
QString
::
fromUtf8
(
formal
.
constData
(),
formal
.
size
());
}
if
(
_variadic
)
text
+=
QLatin1String
(
"..."
);
text
+=
QLatin1Char
(
')'
);
}
text
+=
QLatin1Char
(
' '
);
text
+=
QString
::
fromUtf8
(
_definition
.
constData
(),
_definition
.
size
());
return
text
;
}
src/libs/cplusplus/
pp-m
acro.h
→
src/libs/cplusplus/
M
acro.h
View file @
0422bcbb
...
...
@@ -64,12 +64,7 @@ namespace CPlusPlus {
class
CPLUSPLUS_EXPORT
Macro
{
public:
Macro
()
:
_next
(
0
),
_hashcode
(
0
),
_line
(
0
),
_state
(
0
)
{
}
Macro
();
QByteArray
name
()
const
{
return
_name
;
}
...
...
@@ -119,32 +114,7 @@ public:
void
setVariadic
(
bool
isVariadic
)
{
_variadic
=
isVariadic
;
}
QString
toString
()
const
{
QString
text
;
if
(
_hidden
)
text
+=
QLatin1String
(
"#undef "
);
else
text
+=
QLatin1String
(
"#define "
);
text
+=
QString
::
fromUtf8
(
_name
.
constData
(),
_name
.
size
());
if
(
_functionLike
)
{
text
+=
QLatin1Char
(
'('
);
bool
first
=
true
;
foreach
(
const
QByteArray
formal
,
_formals
)
{
if
(
!
first
)
text
+=
QLatin1String
(
", "
);
else
first
=
false
;
text
+=
QString
::
fromUtf8
(
formal
.
constData
(),
formal
.
size
());
}
if
(
_variadic
)
text
+=
QLatin1String
(
"..."
);
text
+=
QLatin1Char
(
')'
);
}
text
+=
QLatin1Char
(
' '
);
text
+=
QString
::
fromUtf8
(
_definition
.
constData
(),
_definition
.
size
());
return
text
;
}
QString
toString
()
const
;
// ### private
Macro
*
_next
;
...
...
src/libs/cplusplus/PreprocessorClient.cpp
0 → 100644
View file @
0422bcbb
/***************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
**
** Non-Open Source Usage
**
** Licensees may use this file in accordance with the Qt Beta Version
** License Agreement, Agreement version 2.2 provided with the Software or,
** alternatively, in accordance with the terms contained in a written
** agreement between you and Nokia.
**
** GNU General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the packaging
** of this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
**
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt GPL Exception
** version 1.3, included in the file GPL_EXCEPTION.txt in this package.
**
***************************************************************************/
#include "PreprocessorClient.h"
using
namespace
CPlusPlus
;
Client
::
Client
()
{
}
Client
::~
Client
()
{
}
src/libs/cplusplus/
pp-c
lient.h
→
src/libs/cplusplus/
PreprocessorC
lient.h
View file @
0422bcbb
...
...
@@ -35,10 +35,12 @@
#define CPLUSPLUS_PP_CLIENT_H
#include <CPlusPlusForwardDeclarations.h>
#include <QtGlobal>
#include <QByteArray>
#include <QString>
#include <QFile>
QT_BEGIN_NAMESPACE
class
QByteArray
;
class
QString
;
QT_END_NAMESPACE
namespace
CPlusPlus
{
...
...
@@ -56,11 +58,8 @@ public:
};
public:
Client
()
{
}
virtual
~
Client
()
{
}
Client
();
virtual
~
Client
();
virtual
void
macroAdded
(
const
Macro
&
macro
)
=
0
;
virtual
void
sourceNeeded
(
QString
&
fileName
,
IncludeType
mode
,
...
...
src/libs/cplusplus/
pp-e
nvironment.cpp
→
src/libs/cplusplus/
PreprocessorE
nvironment.cpp
View file @
0422bcbb
...
...
@@ -50,16 +50,15 @@
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "pp-environment.h"
#include "pp.h"
#include "PreprocessorEnvironment.h"
#include "Macro.h"
#include <cstring>
using
namespace
CPlusPlus
;
Environment
::
Environment
()
:
currentLine
(
0
),
hide
_n
ext
(
false
),
hide
N
ext
(
false
),
_macros
(
0
),
_allocated_macros
(
0
),
_macro_count
(
-
1
),
...
...
@@ -94,7 +93,7 @@ Macro *Environment::bind(const Macro &__macro)
Q_ASSERT
(
!
__macro
.
name
().
isEmpty
());
Macro
*
m
=
new
Macro
(
__macro
);
m
->
_hashcode
=
hash
_c
ode
(
m
->
name
());
m
->
_hashcode
=
hash
C
ode
(
m
->
name
());
if
(
++
_macro_count
==
_allocated_macros
)
{
if
(
!
_allocated_macros
)
...
...
@@ -192,12 +191,12 @@ bool Environment::isBuiltinMacro(const QByteArray &s) const
return
false
;
}
Macro
*
Environment
::
resolve
(
const
QByteArray
&
name
)
const
Macro
*
Environment
::
resolve
(
const
QByteArray
&
name
)
const
{
if
(
!
_macros
)
return
0
;
Macro
*
it
=
_hash
[
hash
_c
ode
(
name
)
%
_hash_count
];
Macro
*
it
=
_hash
[
hash
C
ode
(
name
)
%
_hash_count
];
for
(;
it
;
it
=
it
->
_next
)
{
if
(
it
->
name
()
!=
name
)
continue
;
...
...
@@ -208,7 +207,7 @@ Macro *Environment::resolve (const QByteArray &name) const
return
it
;
}
unsigned
Environment
::
hash
_c
ode
(
const
QByteArray
&
s
)
unsigned
Environment
::
hash
C
ode
(
const
QByteArray
&
s
)
{
unsigned
hash_value
=
0
;
...
...
src/libs/cplusplus/
pp-e
nvironment.h
→
src/libs/cplusplus/
PreprocessorE
nvironment.h
View file @
0422bcbb
...
...
@@ -90,13 +90,13 @@ public:
{
return
_macros
+
_macro_count
+
1
;
}
private:
static
unsigned
hash
_c
ode
(
const
QByteArray
&
s
);
static
unsigned
hash
C
ode
(
const
QByteArray
&
s
);
void
rehash
();
public:
QByteArray
currentFile
;
unsigned
currentLine
;
bool
hide
_n
ext
;
bool
hide
N
ext
;
private:
Macro
**
_macros
;
...
...
src/libs/cplusplus/cplusplus.pro
View file @
0422bcbb
...
...
@@ -22,14 +22,14 @@ HEADERS += \
TypePrettyPrinter
.
h
\
ResolveExpression
.
h
\
LookupContext
.
h
\
PreprocessorClient
.
h
\
PreprocessorEnvironment
.
h
\
Macro
.
h
\
pp
.
h
\
pp
-
cctype
.
h
\
pp
-
engine
.
h
\
pp
-
macro
-
expander
.
h
\
pp
-
scanner
.
h
\
pp
-
client
.
h
\
pp
-
environment
.
h
\
pp
-
macro
.
h
pp
-
scanner
.
h
SOURCES
+=
\
SimpleLexer
.
cpp
\
...
...
@@ -44,8 +44,10 @@ SOURCES += \
TypePrettyPrinter
.
cpp
\
ResolveExpression
.
cpp
\
LookupContext
.
cpp
\
PreprocessorClient
.
cpp
\
PreprocessorEnvironment
.
cpp
\
Macro
.
cpp
\
pp
-
engine
.
cpp
\
pp
-
environment
.
cpp
\
pp
-
macro
-
expander
.
cpp
\
pp
-
scanner
.
cpp
...
...
src/libs/cplusplus/pp-engine.h
View file @
0422bcbb
...
...
@@ -53,7 +53,7 @@
#ifndef CPLUSPLUS_PP_ENGINE_H
#define CPLUSPLUS_PP_ENGINE_H
#include "
pp-c
lient.h"
#include "
PreprocessorC
lient.h"
#include <Token.h>
#include <QVector>
...
...
src/libs/cplusplus/pp-macro-expander.cpp
View file @
0422bcbb
...
...
@@ -213,12 +213,12 @@ const char *MacroExpander::operator () (const char *__first, const char *__last,
}
Macro
*
macro
=
env
.
resolve
(
fast_name
);
if
(
!
macro
||
macro
->
isHidden
()
||
env
.
hide
_n
ext
)
if
(
!
macro
||
macro
->
isHidden
()
||
env
.
hide
N
ext
)
{
if
(
fast_name
.
size
()
==
7
&&
fast_name
[
0
]
==
'd'
&&
fast_name
==
"defined"
)
env
.
hide
_n
ext
=
true
;
env
.
hide
N
ext
=
true
;
else
env
.
hide
_n
ext
=
false
;
env
.
hide
N
ext
=
false
;
if
(
fast_name
.
size
()
==
8
&&
fast_name
[
0
]
==
'_'
&&
fast_name
[
1
]
==
'_'
)
{
...
...
src/libs/cplusplus/pp.h
View file @
0422bcbb
...
...
@@ -53,11 +53,11 @@
#ifndef CPLUSPLUS_PREPROCESSOR_H
#define CPLUSPLUS_PREPROCESSOR_H
#include "pp-macro.h"
#include "pp-environment.h"
#include "Macro.h"
#include "PreprocessorClient.h"
#include "PreprocessorEnvironment.h"
#include "pp-scanner.h"
#include "pp-macro-expander.h"
#include "pp-engine.h"
#include "pp-client.h"
#endif // CPLUSPLUS_PREPROCESSOR_H
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment