Commit 14e36bcd authored by mae's avatar mae
Browse files

Merge branch 'master' of git@scm.dev.nokia.troll.no:creator/mainline

parents 0d507a18 7d63307b
......@@ -216,7 +216,7 @@ QT_END_NAMESPACE
// comma-separated integer list
static char qDumpInBuffer[10000];
static char qDumpOutBuffer[100000];
static char qDumpSize[20];
//static char qDumpSize[20];
namespace {
......@@ -309,10 +309,16 @@ static bool isSimpleType(const char *type)
return false;
}
static bool isShortKey(const char *type)
#if 0
static bool isStringType(const char *type)
{
return isSimpleType(type) || isEqual(type, NS"QString");
return isEqual(type, NS"QString")
|| isEqual(type, NS"QByteArray")
|| isEqual(type, "std::string")
|| isEqual(type, "std::wstring")
|| isEqual(type, "wstring");
}
#endif
static bool isMovableType(const char *type)
{
......@@ -555,7 +561,7 @@ void QDumper::addCommaIfNeeded()
put(',');
}
void QDumper::putBase64Encoded(const char *buf, int n, char delim)
void QDumper::putBase64Encoded(const char *buf, int n)
{
const char alphabet[] = "ABCDEFGH" "IJKLMNOP" "QRSTUVWX" "YZabcdef"
"ghijklmn" "opqrstuv" "wxyz0123" "456789+/";
......@@ -740,6 +746,7 @@ static void qDumpInnerValueHelper(QDumper &d, const char *type, const void *addr
return;
case 'B':
if (isEqual(type, "QByteArray")) {
d.addCommaIfNeeded();
d << field << "encoded=\"1\",";
P(d, field, *(QByteArray*)addr);
}
......@@ -769,6 +776,7 @@ static void qDumpInnerValueHelper(QDumper &d, const char *type, const void *addr
return;
case 'S':
if (isEqual(type, "QString")) {
d.addCommaIfNeeded();
d << field << "encoded=\"1\",";
P(d, field, *(QString*)addr);
}
......@@ -1086,13 +1094,15 @@ static void qDumpQHash(QDumper &d)
if (d.dumpChildren) {
if (n > 1000)
n = 1000;
bool simpleKey = isShortKey(keyType);
bool simpleValue = isShortKey(valueType);
bool isSimpleKey = isSimpleType(keyType);
bool isSimpleValue = isSimpleType(valueType);
bool opt = isOptimizedIntKey(keyType);
int keyOffset = hashOffset(opt, true, keySize, valueSize);
int valueOffset = hashOffset(opt, false, keySize, valueSize);
P(d, "extra", "simplekey: " << simpleKey << " simpleValue: " << simpleValue
P(d, "extra", "isSimpleKey: " << isSimpleKey
<< " isSimpleValue: " << isSimpleValue
<< " valueType: '" << isSimpleValue
<< " keySize: " << keyOffset << " valueOffset: " << valueOffset
<< " opt: " << opt);
......@@ -1103,18 +1113,17 @@ static void qDumpQHash(QDumper &d)
d << ",children=[";
while (node != end) {
d.beginHash();
if (simpleKey) {
P(d, "name", i);
qDumpInnerValueHelper(d, keyType, addOffset(node, keyOffset), "key");
if (simpleValue)
qDumpInnerValueHelper(d, valueType, addOffset(node, valueOffset));
P(d, "name", i);
qDumpInnerValueHelper(d, keyType, addOffset(node, keyOffset), "key");
qDumpInnerValueHelper(d, valueType, addOffset(node, valueOffset));
if (isSimpleKey && isSimpleValue) {
P(d, "type", valueType);
P(d, "addr", addOffset(node, valueOffset));
} else {
P(d, "name", i);
//P(d, "exp", "*(char*)" << node);
P(d, "exp", "*('"NS"QHashNode<" << keyType << "," << valueType << " >'*)" << node);
P(d, "type", "'"NS"QHashNode<" << keyType << "," << valueType << " >'");
P(d, "exp", "*('"NS"QHashNode<" << keyType << ","
<< valueType << " >'*)" << node);
P(d, "type", "'"NS"QHashNode<" << keyType << ","
<< valueType << " >'");
}
d.endHash();
++i;
......@@ -1131,15 +1140,18 @@ static void qDumpQHashNode(QDumper &d)
const char *keyType = d.templateParameters[0];
const char *valueType = d.templateParameters[1];
P(d, "value", "");
unsigned keySize = d.extraInt[0];
unsigned valueSize = d.extraInt[1];
bool opt = isOptimizedIntKey(keyType);
int keyOffset = hashOffset(opt, true, keySize, valueSize);
int valueOffset = hashOffset(opt, false, keySize, valueSize);
if (isSimpleType(valueType))
qDumpInnerValueHelper(d, valueType, addOffset(h, valueOffset));
else
P(d, "value", "");
P(d, "numchild", 2);
if (d.dumpChildren) {
unsigned keySize = d.extraInt[0];
unsigned valueSize = d.extraInt[1];
bool opt = isOptimizedIntKey(keyType);
int keyOffset = hashOffset(opt, true, keySize, valueSize);
int valueOffset = hashOffset(opt, false, keySize, valueSize);
// there is a hash specialization in cast the key are integers or shorts
d << ",children=[";
d.beginHash();
......@@ -1262,8 +1274,8 @@ static void qDumpQLinkedList(QDumper &d)
P(d, "numchild", n);
P(d, "childtype", d.innertype);
if (d.dumpChildren) {
unsigned innerSize = d.extraInt[0];
bool innerTypeIsPointer = isPointerType(d.innertype);
//unsigned innerSize = d.extraInt[0];
//bool innerTypeIsPointer = isPointerType(d.innertype);
QByteArray strippedInnerType = stripPointerType(d.innertype);
const char *stripped =
isPointerType(d.innertype) ? strippedInnerType.data() : 0;
......@@ -1397,13 +1409,13 @@ static void qDumpQMap(QDumper &d)
unsigned mapnodesize = d.extraInt[2];
unsigned valueOff = d.extraInt[3];
bool simpleKey = isShortKey(keyType);
bool simpleValue = isShortKey(valueType);
bool isSimpleKey = isSimpleType(keyType);
bool isSimpleValue = isSimpleType(valueType);
// both negative:
int keyOffset = 2 * sizeof(void*) - int(mapnodesize);
int valueOffset = 2 * sizeof(void*) - int(mapnodesize) + valueOff;
P(d, "extra", "simplekey: " << simpleKey << " simpleValue: " << simpleValue
P(d, "extra", "simplekey: " << isSimpleKey << " isSimpleValue: " << isSimpleValue
<< " keyOffset: " << keyOffset << " valueOffset: " << valueOffset
<< " mapnodesize: " << mapnodesize);
d << ",children=[";
......@@ -1415,12 +1427,9 @@ static void qDumpQMap(QDumper &d)
while (node != end) {
d.beginHash();
P(d, "name", i);
if (simpleKey) {
P(d, "type", valueType);
qDumpInnerValueHelper(d, keyType, addOffset(node, keyOffset), "key");
if (simpleValue)
qDumpInnerValueHelper(d, valueType, addOffset(node, valueOffset));
qDumpInnerValueHelper(d, keyType, addOffset(node, keyOffset), "key");
qDumpInnerValueHelper(d, valueType, addOffset(node, valueOffset));
if (isSimpleKey && isSimpleValue) {
P(d, "type", valueType);
P(d, "addr", addOffset(node, valueOffset));
} else {
......@@ -2194,35 +2203,38 @@ static void qDumpStdMap(QDumper &d)
// (#4, "std::allocator<std::pair<key, value> >")
// as it is there, and, equally importantly, in an order that
// gdb accepts when fed with it.
char *pairType = (char *)(d.templateParameters[3]) + 16;
char *pairType = (char *)(d.templateParameters[3]) + 15;
pairType[strlen(pairType) - 2] = 0;
P(d, "pairtype", pairType);
if (d.dumpChildren) {
bool simpleKey = isSimpleType(keyType);
bool simpleValue = isShortKey(valueType);
bool isSimpleKey = isSimpleType(keyType);
bool isSimpleValue = isSimpleType(valueType);
int valueOffset = d.extraInt[2];
P(d, "extra", "isSimpleKey: " << isSimpleKey
<< " isSimpleValue: " << isSimpleValue
<< " valueType: '" << valueType
<< " valueOffset: " << valueOffset);
d << ",children=[";
it = map.begin();
for (int i = 0; i < 1000 && it != map.end(); ++i, ++it) {
const void *node = it.operator->();
if (simpleKey) {
d.beginHash();
P(d, "type", valueType);
qDumpInnerValueHelper(d, keyType, node, "name");
P(d, "nameisindex", "1");
if (simpleValue)
qDumpInnerValueHelper(d, valueType, addOffset(node, valueOffset));
P(d, "addr", addOffset(node, valueOffset));
d.endHash();
} else {
d.beginHash();
d.beginHash();
const void *node = it.operator->();
P(d, "name", i);
P(d, "addr", it.operator->());
P(d, "type", pairType);
d.endHash();
}
qDumpInnerValueHelper(d, keyType, node, "key");
qDumpInnerValueHelper(d, valueType, addOffset(node, valueOffset));
if (isSimpleKey && isSimpleValue) {
P(d, "type", valueType);
P(d, "addr", addOffset(node, valueOffset));
P(d, "numchild", 0);
} else {
P(d, "addr", node);
P(d, "type", pairType);
P(d, "numchild", 2);
}
d.endHash();
}
if (it != map.end())
d.putEllipsis();
......
......@@ -110,7 +110,7 @@ PathChooser::PathChooser(QWidget *parent) :
connect(m_d->m_lineEdit, SIGNAL(textChanged(QString)), this, SIGNAL(changed()));
connect(m_d->m_lineEdit, SIGNAL(validChanged()), this, SIGNAL(validChanged()));
m_d->m_lineEdit->setMinimumWidth(260);
m_d->m_lineEdit->setMinimumWidth(200);
hLayout->addWidget(m_d->m_lineEdit);
hLayout->setSizeConstraint(QLayout::SetMinimumSize);
......
......@@ -291,7 +291,7 @@ void BookmarkView::gotoBookmark(const QModelIndex &index)
////
BookmarkContext::BookmarkContext(BookmarkView *widget)
: m_bookmarkView(widget)
: Core::IContext(widget), m_bookmarkView(widget)
{
m_context << UniqueIDManager::instance()->uniqueIdentifier(Constants::BOOKMARKS_CONTEXT);
}
......
......@@ -116,6 +116,8 @@ QWidget *ShortcutSettings::createPage(QWidget *parent)
commandChanged(0);
delete m_page;
return w;
}
......
......@@ -1249,6 +1249,8 @@ void EditorManager::addCurrentPositionToNavigationHistory(bool compress)
if ((previousLocation->editor && editor == previousLocation->editor)
|| (!fileName.isEmpty() && previousLocation->fileName == fileName)) {
firstIndexToRemove = m_d->currentNavigationHistoryPosition;
} else {
firstIndexToRemove = m_d->currentNavigationHistoryPosition+1;
}
} else {
firstIndexToRemove = m_d->currentNavigationHistoryPosition+1;
......
......@@ -69,6 +69,7 @@ OpenEditorsWidget::OpenEditorsWidget()
m_ui.editorList->setTextElideMode(Qt::ElideMiddle);
m_ui.editorList->installEventFilter(this);
m_ui.editorList->setFrameStyle(QFrame::NoFrame);
m_ui.editorList->setAttribute(Qt::WA_MacShowFocusRect, false);
EditorManager *em = EditorManager::instance();
m_ui.editorList->setModel(em->openedEditorsModel());
connect(em, SIGNAL(currentEditorChanged(Core::IEditor*)),
......
......@@ -74,7 +74,7 @@ QIcon FileIconProvider::icon(const QFileInfo &fileInfo)
// Disabled since for now we'll make sure that all icons fit with our
// own custom icons by returning an empty one if we don't know it.
#if 0
#ifdef Q_OS_WIN
// This is incorrect if the OS does not always return the same icon for the
// same suffix (Mac OS X), but should speed up the retrieval a lot ...
icon = m_systemIconProvider.icon(fileInfo);
......@@ -127,7 +127,7 @@ void FileIconProvider::registerIconOverlayForSuffix(const QIcon &icon, const QSt
QIcon FileIconProvider::iconForSuffix(const QString &suffix) const
{
QIcon icon;
#ifndef Q_OS_WIN // On windows we use the file system icons
if (suffix.isEmpty())
return icon;
......@@ -138,7 +138,7 @@ QIcon FileIconProvider::iconForSuffix(const QString &suffix) const
break;
}
}
#endif
return icon;
}
......
......@@ -64,7 +64,7 @@ QString GeneralSettings::trCategory() const
QWidget *GeneralSettings::createPage(QWidget *parent)
{
m_page = new Ui_GeneralSettings;
m_page = new Ui_GeneralSettings();
QWidget *w = new QWidget(parent);
m_page->setupUi(w);
......@@ -77,7 +77,7 @@ QWidget *GeneralSettings::createPage(QWidget *parent)
this, SLOT(resetExternalEditor()));
connect(m_page->helpExternalEditorButton, SIGNAL(clicked()),
this, SLOT(showHelpForExternalEditor()));
delete m_page;
return w;
}
......
......@@ -1054,3 +1054,11 @@ void ManhattanStyle::drawComplexControl(ComplexControl control, const QStyleOpti
break;
}
}
// Mac style reimplements this to control the
// focus widget among other things
bool ManhattanStyle::event(QEvent *e)
{
Q_ASSERT(d->style);
return d->style->event(e);
}
......@@ -78,6 +78,9 @@ public:
void unpolish(QWidget *widget);
void unpolish(QApplication *app);
protected:
bool event(QEvent *e);
protected Q_SLOTS:
QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const;
int layoutSpacingImplementation(QSizePolicy::ControlType control1,
......
......@@ -45,6 +45,7 @@
#include <CoreTypes.h>
#include <Literals.h>
#include <Semantic.h>
#include <SymbolVisitor.h>
#include <cplusplus/ExpressionUnderCursor.h>
#include <cplusplus/LookupContext.h>
#include <cplusplus/Overview.h>
......@@ -100,6 +101,44 @@ public:
}
};
class FindFunctionDefinitions: protected SymbolVisitor
{
Name *_declarationName;
QList<Function *> *_functions;
public:
FindFunctionDefinitions()
: _declarationName(0),
_functions(0)
{ }
void operator()(Name *declarationName, Scope *globals,
QList<Function *> *functions)
{
_declarationName = declarationName;
_functions = functions;
for (unsigned i = 0; i < globals->symbolCount(); ++i) {
accept(globals->symbolAt(i));
}
}
protected:
using SymbolVisitor::visit;
virtual bool visit(Function *function)
{
Name *name = function->name();
if (QualifiedNameId *q = name->asQualifiedNameId())
name = q->unqualifiedNameId();
if (_declarationName->isEqualTo(name))
_functions->append(function);
return false;
}
};
} // end of anonymous namespace
QualifiedNameId *qualifiedNameIdForSymbol(Symbol *s, const LookupContext &context)
......@@ -550,58 +589,60 @@ void CPPEditor::jumpToDefinition()
}
}
Symbol *CPPEditor::findDefinition(Symbol *lastSymbol)
Symbol *CPPEditor::findDefinition(Symbol *symbol)
{
// Currently only functions are supported
if (!lastSymbol->type()->isFunction())
return 0;
if (symbol->isFunction())
return 0; // symbol is a function definition.
QVector<Name *> qualifiedName;
Scope *scope = lastSymbol->scope();
for (; scope; scope = scope->enclosingScope()) {
if (scope->isClassScope() || scope->isNamespaceScope()) {
if (scope->owner() && scope->owner()->name()) {
Name *scopeOwnerName = scope->owner()->name();
if (QualifiedNameId *q = scopeOwnerName->asQualifiedNameId()) {
for (unsigned i = 0; i < q->nameCount(); ++i) {
qualifiedName.prepend(q->nameAt(i));
}
} else {
qualifiedName.prepend(scopeOwnerName);
}
}
Function *funTy = symbol->type()->asFunction();
if (! funTy)
return 0; // symbol does not have function type.
Name *name = symbol->name();
if (! name)
return 0; // skip anonymous functions!
if (QualifiedNameId *q = name->asQualifiedNameId())
name = q->unqualifiedNameId();
// map from file names to function definitions.
QMap<QString, QList<Function *> > functionDefinitions;
// find function definitions.
FindFunctionDefinitions findFunctionDefinitions;
// save the current snapshot
const Snapshot snapshot = m_modelManager->snapshot();
foreach (Document::Ptr doc, snapshot) {
if (Scope *globals = doc->globalSymbols()) {
QList<Function *> *localFunctionDefinitions =
&functionDefinitions[doc->fileName()];
findFunctionDefinitions(name, globals,
localFunctionDefinitions);
}
}
qualifiedName.append(lastSymbol->name());
Control control;
QualifiedNameId *q = control.qualifiedNameId(&qualifiedName[0], qualifiedName.size());
LookupContext context(&control);
const Snapshot documents = m_modelManager->snapshot();
foreach (Document::Ptr doc, documents) {
QList<Scope *> visibleScopes;
visibleScopes.append(doc->globalSymbols());
visibleScopes = context.expand(visibleScopes);
//qDebug() << "** doc:" << doc->fileName() << "visible scopes:" << visibleScopes.count();
foreach (Scope *visibleScope, visibleScopes) {
Symbol *symbol = 0;
if (NameId *nameId = q->unqualifiedNameId()->asNameId())
symbol = visibleScope->lookat(nameId->identifier());
else if (DestructorNameId *dtorId = q->unqualifiedNameId()->asDestructorNameId())
symbol = visibleScope->lookat(dtorId->identifier());
else if (TemplateNameId *templNameId = q->unqualifiedNameId()->asTemplateNameId())
symbol = visibleScope->lookat(templNameId->identifier());
else if (OperatorNameId *opId = q->unqualifiedNameId()->asOperatorNameId())
symbol = visibleScope->lookat(opId->kind());
// ### cast operators
for (; symbol; symbol = symbol->next()) {
if (! symbol->isFunction())
continue;
else if (! isCompatible(symbol->asFunction(), lastSymbol, q))
continue;
return symbol;
// a dummy document.
Document::Ptr expressionDocument = Document::create("<empty>");
QMapIterator<QString, QList<Function *> > it(functionDefinitions);
while (it.hasNext()) {
it.next();
// get the instance of the document.
Document::Ptr thisDocument = snapshot.value(it.key());
foreach (Function *f, it.value()) {
// create a lookup context
const LookupContext context(f, expressionDocument,
thisDocument, snapshot);
// search the matching definition for the function declaration `symbol'.
foreach (Symbol *s, context.resolve(f->name())) {
if (s == symbol)
return f;
}
}
}
......
......@@ -94,7 +94,6 @@ DebuggerSettings::DebuggerSettings()
m_skipKnownFrames = false;
m_debugDumpers = false;
m_useToolTips = false;
m_useTerminal = false;
m_useCustomDumpers = true;
}
......
......@@ -198,7 +198,6 @@ public:
bool m_debugDumpers;
bool m_useFastStart;
bool m_useToolTips;
bool m_useTerminal;
QString m_scriptFile;
};
......
......@@ -282,7 +282,6 @@ QWidget *GdbOptionPage::createPage(QWidget *parent)
m_ui.checkBoxUseCustomDumpers->setChecked(m_settings.m_useCustomDumpers);
m_ui.checkBoxFastStart->setChecked(m_settings.m_useFastStart);
m_ui.checkBoxUseToolTips->setChecked(m_settings.m_useToolTips);
m_ui.checkBoxUseTerminal->setChecked(m_settings.m_useTerminal);
#ifndef QT_DEBUG
#if 0
......@@ -325,7 +324,6 @@ void GdbOptionPage::apply()
m_settings.m_useCustomDumpers = m_ui.checkBoxUseCustomDumpers->isChecked();
m_settings.m_useFastStart = m_ui.checkBoxFastStart->isChecked();
m_settings.m_useToolTips = m_ui.checkBoxUseToolTips->isChecked();
m_settings.m_useTerminal = m_ui.checkBoxUseTerminal->isChecked();
*m_plugin->m_manager->settings() = m_settings;
m_plugin->writeSettings();
......@@ -892,7 +890,6 @@ void DebuggerPlugin::writeSettings() const
s->setValue("UseFastStart", m->m_useFastStart);
s->setValue("UseToolTips", m->m_useToolTips);
s->setValue("UseTerminal", m->m_useTerminal);
s->setValue("UseCustomDumpers", m->m_useCustomDumpers);
s->setValue("SkipKnowFrames", m->m_skipKnownFrames);
s->setValue("DebugDumpers", m->m_debugDumpers);
......@@ -926,7 +923,6 @@ void DebuggerPlugin::readSettings()
m->m_useCustomDumpers = s->value("UseCustomDumpers", true).toBool();
m->m_useFastStart = s->value("UseFastStart", false).toBool();
m->m_useToolTips = s->value("UseToolTips", false).toBool();
m->m_useTerminal = s->value("UseTerminal", false).toBool();
s->endGroup();
m_manager->mainWindow()->restoreState(ba);
......
......@@ -2833,9 +2833,12 @@ static bool extractTemplate(const QString &type, QString *tmplate, QString *inne
// 'tmplate' and "Inner1@Inner2@..." etc in 'inner'. Result indicates
// whether parsing was successful
int level = 0;
bool skipSpace = false;
for (int i = 0; i != type.size(); ++i) {
QChar c = type[i];
if (c == '<') {
if (c == ' ' && skipSpace) {
skipSpace = false;
} else if (c == '<') {
*(level == 0 ? tmplate : inner) += c;
++level;
} else if (c == '>') {
......@@ -2843,6 +2846,7 @@ static bool extractTemplate(const QString &type, QString *tmplate, QString *inne
*(level == 0 ? tmplate : inner) += c;
} else if (c == ',') {
*inner += (level == 1) ? '@' : ',';
skipSpace = true;
} else {
*(level == 0 ? tmplate : inner) += c;
}
......@@ -2850,7 +2854,7 @@ static bool extractTemplate(const QString &type, QString *tmplate, QString *inne
*tmplate = tmplate->trimmed();
*tmplate = tmplate->remove("<>");
*inner = inner->trimmed();
//qDebug() << "EXTRACT TEMPLATE: " << *tmplate << *inner;
//qDebug() << "EXTRACT TEMPLATE: " << *tmplate << *inner << " FROM " << type;
return !inner->isEmpty();
}
......@@ -3555,9 +3559,15 @@ void GdbEngine::handleDumpCustomValue2(const GdbResultRecord &record,
data1.name = '[' + data1.name + ']';
QString key = item.findChild("key").data();
if (!key.isEmpty()) {
if (item.findChild("keyencoded").data()[0] == '1')
if (item.findChild("keyencoded").data()[0] == '1') {
key = '"' + QByteArray::fromBase64(key.toUtf8()) + '"';
data1.name += " (" + key + ")";
if (key.size() > 13) {