Moved CPlusPlus::LookupItem.

This commit is contained in:
Roberto Raggi
2010-05-05 09:54:19 +02:00
parent 32a84df5c0
commit c8f03b46c1
5 changed files with 146 additions and 46 deletions

View File

@@ -41,13 +41,6 @@
#include <QtDebug>
uint CPlusPlus::qHash(const CPlusPlus::LookupItem &key)
{
const uint h1 = QT_PREPEND_NAMESPACE(qHash)(key.type().type());
const uint h2 = QT_PREPEND_NAMESPACE(qHash)(key.lastVisibleSymbol());
return ((h1 << 16) | (h1 >> 16)) ^ h2;
}
using namespace CPlusPlus;
/////////////////////////////////////////////////////////////////////

View File

@@ -31,41 +31,11 @@
#define CPLUSPLUS_DEPRECATEDLOOKUPCONTEXT_H
#include "CppDocument.h"
#include "LookupItem.h"
#include <FullySpecifiedType.h>
namespace CPlusPlus {
class CPLUSPLUS_EXPORT LookupItem
{
public:
LookupItem()
: _lastVisibleSymbol(0) {}
LookupItem(const FullySpecifiedType &type, Symbol *lastVisibleSymbol)
: _type(type), _lastVisibleSymbol(lastVisibleSymbol) {}
FullySpecifiedType type() const { return _type; }
void setType(const FullySpecifiedType &type) { _type = type; }
Symbol *lastVisibleSymbol() const { return _lastVisibleSymbol; }
void setLastVisibleSymbol(Symbol *symbol) { _lastVisibleSymbol = symbol; }
bool operator == (const LookupItem &other) const
{
if (_type == other._type)
return _lastVisibleSymbol == other._lastVisibleSymbol;
return false;
}
bool operator != (const LookupItem &result) const
{ return ! operator == (result); }
private:
FullySpecifiedType _type;
Symbol *_lastVisibleSymbol;
};
class CPLUSPLUS_EXPORT DeprecatedLookupContext
{
public:
@@ -228,14 +198,6 @@ private:
QList<Scope *> _visibleScopes;
};
uint qHash(const CPlusPlus::LookupItem &result);
} // end of namespace CPlusPlus
#if defined(Q_CC_MSVC) && _MSC_VER <= 1300
//this ensures that code outside QmlJS can use the hash function
//it also a workaround for some compilers
inline uint qHash(const CPlusPlus::LookupItem &item) { return CPlusPlus::qHash(item); }
#endif
#endif // CPLUSPLUS_DEPRECATEDLOOKUPCONTEXT_H

View File

@@ -0,0 +1,75 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#include "LookupItem.h"
#include <FullySpecifiedType.h>
#include <Symbol.h>
#include <Control.h>
#include <QtDebug>
using namespace CPlusPlus;
uint CPlusPlus::qHash(const CPlusPlus::LookupItem &key)
{
const uint h1 = QT_PREPEND_NAMESPACE(qHash)(key.type().type());
const uint h2 = QT_PREPEND_NAMESPACE(qHash)(key.lastVisibleSymbol());
return ((h1 << 16) | (h1 >> 16)) ^ h2;
}
LookupItem::LookupItem()
: _lastVisibleSymbol(0)
{ }
LookupItem::LookupItem(const FullySpecifiedType &type, Symbol *lastVisibleSymbol)
: _type(type), _lastVisibleSymbol(lastVisibleSymbol)
{ }
FullySpecifiedType LookupItem::type() const
{ return _type; }
void LookupItem::setType(const FullySpecifiedType &type)
{ _type = type; }
Symbol *LookupItem::lastVisibleSymbol() const
{ return _lastVisibleSymbol; }
void LookupItem::setLastVisibleSymbol(Symbol *symbol)
{ _lastVisibleSymbol = symbol; }
bool LookupItem::operator == (const LookupItem &other) const
{
if (_type == other._type)
return _lastVisibleSymbol == other._lastVisibleSymbol;
return false;
}
bool LookupItem::operator != (const LookupItem &result) const
{ return ! operator == (result); }

View File

@@ -0,0 +1,68 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef CPLUSPLUS_LOOKUPITEM_H
#define CPLUSPLUS_LOOKUPITEM_H
#include <FullySpecifiedType.h>
#include <QtCore/QHash>
namespace CPlusPlus {
class CPLUSPLUS_EXPORT LookupItem
{
public:
LookupItem();
LookupItem(const FullySpecifiedType &type, Symbol *lastVisibleSymbol);
FullySpecifiedType type() const;
void setType(const FullySpecifiedType &type);
Symbol *lastVisibleSymbol() const;
void setLastVisibleSymbol(Symbol *symbol);
bool operator == (const LookupItem &other) const;
bool operator != (const LookupItem &other) const;
private:
FullySpecifiedType _type;
Symbol *_lastVisibleSymbol;
};
uint qHash(const CPlusPlus::LookupItem &result);
} // end of namespace CPlusPlus
#if defined(Q_CC_MSVC) && _MSC_VER <= 1300
//this ensures that code outside QmlJS can use the hash function
//it also a workaround for some compilers
inline uint qHash(const CPlusPlus::LookupItem &item) { return CPlusPlus::qHash(item); }
#endif
#endif // CPLUSPLUS_LOOKUPITEM_H

View File

@@ -34,6 +34,7 @@ HEADERS += \
$$PWD/TypeOfExpression.h \
$$PWD/TypePrettyPrinter.h \
$$PWD/ResolveExpression.h \
$$PWD/LookupItem.h \
$$PWD/DeprecatedLookupContext.h \
$$PWD/CppBindings.h \
$$PWD/ASTParent.h \
@@ -59,6 +60,7 @@ SOURCES += \
$$PWD/TypeOfExpression.cpp \
$$PWD/TypePrettyPrinter.cpp \
$$PWD/ResolveExpression.cpp \
$$PWD/LookupItem.cpp \
$$PWD/DeprecatedLookupContext.cpp \
$$PWD/CppBindings.cpp \
$$PWD/ASTParent.cpp \