forked from qt-creator/qt-creator
FunctionDef(s) => ProFunctionDef(s), plus move to proitems.h
Change-Id: I7bdde81c1913237f11dbfbe7491e0fe750181cd5 Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
This commit is contained in:
@@ -152,7 +152,7 @@ public:
|
|||||||
bool evaluateFeatureFile(const QString &fileName);
|
bool evaluateFeatureFile(const QString &fileName);
|
||||||
enum EvalIntoMode { EvalProOnly, EvalWithDefaults, EvalWithSetup };
|
enum EvalIntoMode { EvalProOnly, EvalWithDefaults, EvalWithSetup };
|
||||||
bool evaluateFileInto(const QString &fileName, ProFileEvaluatorHandler::EvalFileType type,
|
bool evaluateFileInto(const QString &fileName, ProFileEvaluatorHandler::EvalFileType type,
|
||||||
QHash<ProString, ProStringList> *values, FunctionDefs *defs,
|
QHash<ProString, ProStringList> *values, ProFunctionDefs *defs,
|
||||||
EvalIntoMode mode); // values are output-only, defs are input-only
|
EvalIntoMode mode); // values are output-only, defs are input-only
|
||||||
|
|
||||||
static ALWAYS_INLINE VisitReturn returnBool(bool b)
|
static ALWAYS_INLINE VisitReturn returnBool(bool b)
|
||||||
@@ -160,8 +160,10 @@ public:
|
|||||||
|
|
||||||
QList<ProStringList> prepareFunctionArgs(const ushort *&tokPtr);
|
QList<ProStringList> prepareFunctionArgs(const ushort *&tokPtr);
|
||||||
QList<ProStringList> prepareFunctionArgs(const ProString &arguments);
|
QList<ProStringList> prepareFunctionArgs(const ProString &arguments);
|
||||||
ProStringList evaluateFunction(const FunctionDef &func, const QList<ProStringList> &argumentsList, bool *ok);
|
ProStringList evaluateFunction(const ProFunctionDef &func,
|
||||||
VisitReturn evaluateBoolFunction(const FunctionDef &func, const QList<ProStringList> &argumentsList,
|
const QList<ProStringList> &argumentsList, bool *ok);
|
||||||
|
VisitReturn evaluateBoolFunction(const ProFunctionDef &func,
|
||||||
|
const QList<ProStringList> &argumentsList,
|
||||||
const ProString &function);
|
const ProString &function);
|
||||||
|
|
||||||
bool modesForGenerator(const QString &gen,
|
bool modesForGenerator(const QString &gen,
|
||||||
@@ -206,7 +208,7 @@ public:
|
|||||||
QString m_outputDir;
|
QString m_outputDir;
|
||||||
|
|
||||||
int m_listCount;
|
int m_listCount;
|
||||||
FunctionDefs m_functionDefs;
|
ProFunctionDefs m_functionDefs;
|
||||||
ProStringList m_returnValue;
|
ProStringList m_returnValue;
|
||||||
QStack<QHash<ProString, ProStringList> > m_valuemapStack; // VariableName must be us-ascii, the content however can be non-us-ascii.
|
QStack<QHash<ProString, ProStringList> > m_valuemapStack; // VariableName must be us-ascii, the content however can be non-us-ascii.
|
||||||
QString m_tmp1, m_tmp2, m_tmp3, m_tmp[2]; // Temporaries for efficient toQString
|
QString m_tmp1, m_tmp2, m_tmp3, m_tmp[2]; // Temporaries for efficient toQString
|
||||||
@@ -905,11 +907,11 @@ ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::visitProBlock(
|
|||||||
void ProFileEvaluator::Private::visitProFunctionDef(
|
void ProFileEvaluator::Private::visitProFunctionDef(
|
||||||
ushort tok, const ProString &name, const ushort *tokPtr)
|
ushort tok, const ProString &name, const ushort *tokPtr)
|
||||||
{
|
{
|
||||||
QHash<ProString, FunctionDef> *hash =
|
QHash<ProString, ProFunctionDef> *hash =
|
||||||
(tok == TokTestDef
|
(tok == TokTestDef
|
||||||
? &m_functionDefs.testFunctions
|
? &m_functionDefs.testFunctions
|
||||||
: &m_functionDefs.replaceFunctions);
|
: &m_functionDefs.replaceFunctions);
|
||||||
hash->insert(name, FunctionDef(m_current.pro, tokPtr - m_current.pro->tokPtr()));
|
hash->insert(name, ProFunctionDef(m_current.pro, tokPtr - m_current.pro->tokPtr()));
|
||||||
}
|
}
|
||||||
|
|
||||||
ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::visitProLoop(
|
ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::visitProLoop(
|
||||||
@@ -1121,7 +1123,7 @@ ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::visitProFile(
|
|||||||
|
|
||||||
m_handler->aboutToEval(currentProFile(), pro, type);
|
m_handler->aboutToEval(currentProFile(), pro, type);
|
||||||
m_profileStack.push(pro);
|
m_profileStack.push(pro);
|
||||||
if (flags & LoadPreFiles) {
|
if (flags & ProFileEvaluator::LoadPreFiles) {
|
||||||
#ifdef PROEVALUATOR_THREAD_SAFE
|
#ifdef PROEVALUATOR_THREAD_SAFE
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&m_option->mutex);
|
QMutexLocker locker(&m_option->mutex);
|
||||||
@@ -1282,7 +1284,7 @@ ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::visitProFile(
|
|||||||
|
|
||||||
visitProBlock(pro, pro->tokPtr());
|
visitProBlock(pro, pro->tokPtr());
|
||||||
|
|
||||||
if (flags & LoadPostFiles) {
|
if (flags & ProFileEvaluator::LoadPostFiles) {
|
||||||
visitCmdLine(m_option->postcmds);
|
visitCmdLine(m_option->postcmds);
|
||||||
|
|
||||||
evaluateFeatureFile(QLatin1String("default_post.prf"));
|
evaluateFeatureFile(QLatin1String("default_post.prf"));
|
||||||
@@ -1962,7 +1964,7 @@ QList<ProStringList> ProFileEvaluator::Private::prepareFunctionArgs(const ProStr
|
|||||||
}
|
}
|
||||||
|
|
||||||
ProStringList ProFileEvaluator::Private::evaluateFunction(
|
ProStringList ProFileEvaluator::Private::evaluateFunction(
|
||||||
const FunctionDef &func, const QList<ProStringList> &argumentsList, bool *ok)
|
const ProFunctionDef &func, const QList<ProStringList> &argumentsList, bool *ok)
|
||||||
{
|
{
|
||||||
bool oki;
|
bool oki;
|
||||||
ProStringList ret;
|
ProStringList ret;
|
||||||
@@ -1998,7 +2000,7 @@ ProStringList ProFileEvaluator::Private::evaluateFunction(
|
|||||||
}
|
}
|
||||||
|
|
||||||
ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::evaluateBoolFunction(
|
ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::evaluateBoolFunction(
|
||||||
const FunctionDef &func, const QList<ProStringList> &argumentsList,
|
const ProFunctionDef &func, const QList<ProStringList> &argumentsList,
|
||||||
const ProString &function)
|
const ProString &function)
|
||||||
{
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
@@ -2026,7 +2028,7 @@ ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::evaluateBoolFu
|
|||||||
ProStringList ProFileEvaluator::Private::evaluateExpandFunction(
|
ProStringList ProFileEvaluator::Private::evaluateExpandFunction(
|
||||||
const ProString &func, const ushort *&tokPtr)
|
const ProString &func, const ushort *&tokPtr)
|
||||||
{
|
{
|
||||||
QHash<ProString, FunctionDef>::ConstIterator it =
|
QHash<ProString, ProFunctionDef>::ConstIterator it =
|
||||||
m_functionDefs.replaceFunctions.constFind(func);
|
m_functionDefs.replaceFunctions.constFind(func);
|
||||||
if (it != m_functionDefs.replaceFunctions.constEnd())
|
if (it != m_functionDefs.replaceFunctions.constEnd())
|
||||||
return evaluateFunction(*it, prepareFunctionArgs(tokPtr), 0);
|
return evaluateFunction(*it, prepareFunctionArgs(tokPtr), 0);
|
||||||
@@ -2038,7 +2040,7 @@ ProStringList ProFileEvaluator::Private::evaluateExpandFunction(
|
|||||||
ProStringList ProFileEvaluator::Private::evaluateExpandFunction(
|
ProStringList ProFileEvaluator::Private::evaluateExpandFunction(
|
||||||
const ProString &func, const ProString &arguments)
|
const ProString &func, const ProString &arguments)
|
||||||
{
|
{
|
||||||
QHash<ProString, FunctionDef>::ConstIterator it =
|
QHash<ProString, ProFunctionDef>::ConstIterator it =
|
||||||
m_functionDefs.replaceFunctions.constFind(func);
|
m_functionDefs.replaceFunctions.constFind(func);
|
||||||
if (it != m_functionDefs.replaceFunctions.constEnd())
|
if (it != m_functionDefs.replaceFunctions.constEnd())
|
||||||
return evaluateFunction(*it, prepareFunctionArgs(arguments), 0);
|
return evaluateFunction(*it, prepareFunctionArgs(arguments), 0);
|
||||||
@@ -2478,7 +2480,7 @@ ProStringList ProFileEvaluator::Private::evaluateExpandFunction(
|
|||||||
ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::evaluateConditionalFunction(
|
ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::evaluateConditionalFunction(
|
||||||
const ProString &function, const ProString &arguments)
|
const ProString &function, const ProString &arguments)
|
||||||
{
|
{
|
||||||
QHash<ProString, FunctionDef>::ConstIterator it =
|
QHash<ProString, ProFunctionDef>::ConstIterator it =
|
||||||
m_functionDefs.testFunctions.constFind(function);
|
m_functionDefs.testFunctions.constFind(function);
|
||||||
if (it != m_functionDefs.testFunctions.constEnd())
|
if (it != m_functionDefs.testFunctions.constEnd())
|
||||||
return evaluateBoolFunction(*it, prepareFunctionArgs(arguments), function);
|
return evaluateBoolFunction(*it, prepareFunctionArgs(arguments), function);
|
||||||
@@ -2491,7 +2493,7 @@ ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::evaluateCondit
|
|||||||
ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::evaluateConditionalFunction(
|
ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::evaluateConditionalFunction(
|
||||||
const ProString &function, const ushort *&tokPtr)
|
const ProString &function, const ushort *&tokPtr)
|
||||||
{
|
{
|
||||||
QHash<ProString, FunctionDef>::ConstIterator it =
|
QHash<ProString, ProFunctionDef>::ConstIterator it =
|
||||||
m_functionDefs.testFunctions.constFind(function);
|
m_functionDefs.testFunctions.constFind(function);
|
||||||
if (it != m_functionDefs.testFunctions.constEnd())
|
if (it != m_functionDefs.testFunctions.constEnd())
|
||||||
return evaluateBoolFunction(*it, prepareFunctionArgs(tokPtr), function);
|
return evaluateBoolFunction(*it, prepareFunctionArgs(tokPtr), function);
|
||||||
@@ -3232,7 +3234,7 @@ bool ProFileEvaluator::Private::evaluateFeatureFile(const QString &fileName)
|
|||||||
|
|
||||||
bool ProFileEvaluator::Private::evaluateFileInto(
|
bool ProFileEvaluator::Private::evaluateFileInto(
|
||||||
const QString &fileName, ProFileEvaluatorHandler::EvalFileType type,
|
const QString &fileName, ProFileEvaluatorHandler::EvalFileType type,
|
||||||
QHash<ProString, ProStringList> *values, FunctionDefs *funcs, EvalIntoMode mode)
|
QHash<ProString, ProStringList> *values, ProFunctionDefs *funcs, EvalIntoMode mode)
|
||||||
{
|
{
|
||||||
ProFileEvaluator visitor(m_option, m_parser, m_handler);
|
ProFileEvaluator visitor(m_option, m_parser, m_handler);
|
||||||
#ifdef PROEVALUATOR_CUMULATIVE
|
#ifdef PROEVALUATOR_CUMULATIVE
|
||||||
|
|||||||
@@ -65,33 +65,6 @@ class QMAKE_EXPORT ProFileEvaluator
|
|||||||
class Private;
|
class Private;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class FunctionDef {
|
|
||||||
public:
|
|
||||||
FunctionDef(ProFile *pro, int offset) : m_pro(pro), m_offset(offset) { m_pro->ref(); }
|
|
||||||
FunctionDef(const FunctionDef &o) : m_pro(o.m_pro), m_offset(o.m_offset) { m_pro->ref(); }
|
|
||||||
~FunctionDef() { m_pro->deref(); }
|
|
||||||
FunctionDef &operator=(const FunctionDef &o)
|
|
||||||
{
|
|
||||||
if (this != &o) {
|
|
||||||
m_pro->deref();
|
|
||||||
m_pro = o.m_pro;
|
|
||||||
m_pro->ref();
|
|
||||||
m_offset = o.m_offset;
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
ProFile *pro() const { return m_pro; }
|
|
||||||
const ushort *tokPtr() const { return m_pro->tokPtr() + m_offset; }
|
|
||||||
private:
|
|
||||||
ProFile *m_pro;
|
|
||||||
int m_offset;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct FunctionDefs {
|
|
||||||
QHash<ProString, FunctionDef> testFunctions;
|
|
||||||
QHash<ProString, FunctionDef> replaceFunctions;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum TemplateType {
|
enum TemplateType {
|
||||||
TT_Unknown = 0,
|
TT_Unknown = 0,
|
||||||
TT_Application,
|
TT_Application,
|
||||||
@@ -140,8 +113,6 @@ private:
|
|||||||
|
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(ProFileEvaluator::LoadFlags)
|
Q_DECLARE_OPERATORS_FOR_FLAGS(ProFileEvaluator::LoadFlags)
|
||||||
|
|
||||||
Q_DECLARE_TYPEINFO(ProFileEvaluator::FunctionDef, Q_MOVABLE_TYPE);
|
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
#endif // PROFILEEVALUATOR_H
|
#endif // PROFILEEVALUATOR_H
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
#include "qmake_global.h"
|
#include "qmake_global.h"
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
#include <QHash>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
@@ -217,6 +218,35 @@ private:
|
|||||||
bool m_ok;
|
bool m_ok;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ProFunctionDef {
|
||||||
|
public:
|
||||||
|
ProFunctionDef(ProFile *pro, int offset) : m_pro(pro), m_offset(offset) { m_pro->ref(); }
|
||||||
|
ProFunctionDef(const ProFunctionDef &o) : m_pro(o.m_pro), m_offset(o.m_offset) { m_pro->ref(); }
|
||||||
|
~ProFunctionDef() { m_pro->deref(); }
|
||||||
|
ProFunctionDef &operator=(const ProFunctionDef &o)
|
||||||
|
{
|
||||||
|
if (this != &o) {
|
||||||
|
m_pro->deref();
|
||||||
|
m_pro = o.m_pro;
|
||||||
|
m_pro->ref();
|
||||||
|
m_offset = o.m_offset;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
ProFile *pro() const { return m_pro; }
|
||||||
|
const ushort *tokPtr() const { return m_pro->tokPtr() + m_offset; }
|
||||||
|
private:
|
||||||
|
ProFile *m_pro;
|
||||||
|
int m_offset;
|
||||||
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_TYPEINFO(ProFunctionDef, Q_MOVABLE_TYPE);
|
||||||
|
|
||||||
|
struct ProFunctionDefs {
|
||||||
|
QHash<ProString, ProFunctionDef> testFunctions;
|
||||||
|
QHash<ProString, ProFunctionDef> replaceFunctions;
|
||||||
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
#endif // PROITEMS_H
|
#endif // PROITEMS_H
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ private:
|
|||||||
QString getEnv(const QString &) const;
|
QString getEnv(const QString &) const;
|
||||||
|
|
||||||
QHash<ProString, ProStringList> base_valuemap; // Cached results of qmake.conf, .qmake.cache & default_pre.prf
|
QHash<ProString, ProStringList> base_valuemap; // Cached results of qmake.conf, .qmake.cache & default_pre.prf
|
||||||
ProFileEvaluator::FunctionDefs base_functions;
|
ProFunctionDefs base_functions;
|
||||||
QStringList feature_roots;
|
QStringList feature_roots;
|
||||||
QString qmakespec_name;
|
QString qmakespec_name;
|
||||||
QString precmds, postcmds;
|
QString precmds, postcmds;
|
||||||
|
|||||||
Reference in New Issue
Block a user