Commit e6f7cb68 authored by hjk's avatar hjk

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

parents 947b6807 281c462d
......@@ -117,6 +117,9 @@ CatchClauseAST *AST::asCatchClause()
ClassSpecifierAST *AST::asClassSpecifier()
{ return dynamic_cast<ClassSpecifierAST *>(this); }
CompoundLiteralAST *AST::asCompoundLiteral()
{ return dynamic_cast<CompoundLiteralAST *>(this); }
CompoundStatementAST *AST::asCompoundStatement()
{ return dynamic_cast<CompoundStatementAST *>(this); }
......@@ -774,6 +777,42 @@ unsigned BoolLiteralAST::lastToken() const
return token + 1;
}
CompoundLiteralAST *CompoundLiteralAST::clone(MemoryPool *pool) const
{
CompoundLiteralAST *ast = new (pool) CompoundLiteralAST;
ast->lparen_token = lparen_token;
if (type_id)
ast->type_id = type_id->clone(pool);
ast->rparen_token = rparen_token;
if (initializer)
ast->initializer = initializer->clone(pool);
return ast;
}
void CompoundLiteralAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
accept(type_id, visitor);
accept(initializer, visitor);
}
}
unsigned CompoundLiteralAST::firstToken() const
{
return lparen_token;
}
unsigned CompoundLiteralAST::lastToken() const
{
if (initializer)
return initializer->lastToken();
else if (rparen_token)
return rparen_token + 1;
else if (type_id)
return type_id->lastToken();
return lparen_token + 1;
}
BreakStatementAST *BreakStatementAST::clone(MemoryPool *pool) const
{
BreakStatementAST *ast = new (pool) BreakStatementAST;
......
......@@ -94,6 +94,7 @@ public:
CastExpressionAST *asCastExpression();
CatchClauseAST *asCatchClause();
ClassSpecifierAST *asClassSpecifier();
CompoundLiteralAST *asCompoundLiteral();
CompoundStatementAST *asCompoundStatement();
ConditionAST *asCondition();
ConditionalExpressionAST *asConditionalExpression();
......@@ -429,6 +430,24 @@ protected:
virtual void accept0(ASTVisitor *visitor);
};
class CPLUSPLUS_EXPORT CompoundLiteralAST: public ExpressionAST
{
public:
unsigned lparen_token;
ExpressionAST *type_id;
unsigned rparen_token;
ExpressionAST *initializer;
public:
virtual unsigned firstToken() const;
virtual unsigned lastToken() const;
virtual CompoundLiteralAST *clone(MemoryPool *pool) const;
protected:
virtual void accept0(ASTVisitor *visitor);
};
class CPLUSPLUS_EXPORT QtMethodAST: public ExpressionAST
{
public:
......
......@@ -104,6 +104,7 @@ public:
virtual bool visit(CastExpressionAST *) { return true; }
virtual bool visit(CatchClauseAST *) { return true; }
virtual bool visit(ClassSpecifierAST *) { return true; }
virtual bool visit(CompoundLiteralAST *) { return true; }
virtual bool visit(CompoundStatementAST *) { return true; }
virtual bool visit(ConditionAST *) { return true; }
virtual bool visit(ConditionalExpressionAST *) { return true; }
......
......@@ -77,6 +77,7 @@ class CaseStatementAST;
class CastExpressionAST;
class CatchClauseAST;
class ClassSpecifierAST;
class CompoundLiteralAST;
class CompoundStatementAST;
class ConditionAST;
class ConditionalExpressionAST;
......
......@@ -333,6 +333,13 @@ bool CheckExpression::visit(QtMethodAST *ast)
return false;
}
bool CheckExpression::visit(CompoundLiteralAST *ast)
{
/*FullySpecifiedType exprTy = */ semantic()->check(ast->type_id, _scope);
/*FullySpecifiedType initTy = */ semantic()->check(ast->initializer, _scope);
return false;
}
bool CheckExpression::visit(CallAST *ast)
{
for (ExpressionListAST *it = ast->expression_list; it; it = it->next) {
......
......@@ -98,6 +98,7 @@ protected:
virtual bool visit(TypeIdAST *ast);
virtual bool visit(UnaryExpressionAST *ast);
virtual bool visit(QtMethodAST *ast);
virtual bool visit(CompoundLiteralAST *ast);
//names
virtual bool visit(QualifiedNameAST *ast);
......
......@@ -1621,8 +1621,7 @@ bool Parser::parseInitializerClause(ExpressionAST *&node)
ArrayInitializerAST *ast = new (_pool) ArrayInitializerAST;
ast->lbrace_token = consumeToken();
parseInitializerList(ast->expression_list);
if (LA() == T_RBRACE)
ast->rbrace_token = consumeToken();
match(T_RBRACE, &ast->rbrace_token);
node = ast;
return true;
}
......@@ -2702,8 +2701,30 @@ bool Parser::parseCorePostfixExpression(ExpressionAST *&node)
return true;
}
}
blockErrors(blocked);
rewind(start);
// look for compound literals
if (LA() == T_LPAREN) {
unsigned lparen_token = consumeToken();
ExpressionAST *type_id = 0;
if (parseTypeId(type_id) && LA() == T_RPAREN) {
unsigned rparen_token = consumeToken();
if (LA() == T_LBRACE) {
blockErrors(blocked);
CompoundLiteralAST *ast = new (_pool) CompoundLiteralAST;
ast->lparen_token = lparen_token;
ast->type_id = type_id;
ast->rparen_token = rparen_token;
parseInitializerClause(ast->initializer);
node = ast;
return true;
}
}
rewind(start);
}
blockErrors(blocked);
return parsePrimaryExpression(node);
}
}
......@@ -3552,6 +3573,9 @@ bool Parser::parseObjClassInstanceVariables()
bool Parser::parseObjCInterfaceMemberDeclaration()
{
switch (LA()) {
case T_AT_END:
return false;
case T_AT_REQUIRED:
case T_AT_OPTIONAL:
consumeToken();
......@@ -3570,9 +3594,20 @@ bool Parser::parseObjCInterfaceMemberDeclaration()
case T_MINUS:
return parseObjCMethodPrototype();
default:
return false;
case T_ENUM:
case T_CLASS:
case T_STRUCT:
case T_UNION: {
DeclarationAST *declaration = 0;
return parseSimpleDeclaration(declaration, /*accept struct declarators */ true);
}
default: {
DeclarationAST *declaration = 0;
return parseSimpleDeclaration(declaration, /*accept struct declarators */ true);
} // default
} // switch
}
// objc-instance-variable-declaration ::= objc-visibility-specifier
......@@ -3589,7 +3624,7 @@ bool Parser::parseObjCInstanceVariableDeclaration(DeclarationAST *&node)
return true;
default:
return parseBlockDeclaration(node);
return parseSimpleDeclaration(node, true);
}
}
......@@ -3612,7 +3647,7 @@ bool Parser::parseObjCPropertyDeclaration(DeclarationAST *&, SpecifierAST *)
}
DeclarationAST *simple_declaration = 0;
parseSimpleDeclaration(simple_declaration, /*accept-struct-declarators = */ false);
parseSimpleDeclaration(simple_declaration, /*accept-struct-declarators = */ true);
return true;
}
......@@ -3736,6 +3771,19 @@ bool Parser::parseObjCKeywordDeclaration()
bool Parser::parseObjCTypeQualifiers()
{
if (LA() != T_IDENTIFIER)
return false;
Identifier *id = tok().identifier;
if (! strcmp("in", id->chars()) ||
! strcmp("out", id->chars()) ||
! strcmp("inout", id->chars()) ||
! strcmp("bycopy", id->chars()) ||
! strcmp("byref", id->chars()) ||
! strcmp("oneway", id->chars())) {
consumeToken();
return true;
}
return false;
}
......
......@@ -1281,3 +1281,13 @@ bool PrettyPrinter::visit(QtMethodAST *ast)
out << ')';
return false;
}
bool PrettyPrinter::visit(CompoundLiteralAST *ast)
{
out << '(';
accept(ast->type_id);
out << ')';
out << ' ';
accept(ast->initializer);
return false;
}
......@@ -66,6 +66,7 @@ protected:
virtual bool visit(CastExpressionAST *ast);
virtual bool visit(CatchClauseAST *ast);
virtual bool visit(ClassSpecifierAST *ast);
virtual bool visit(CompoundLiteralAST *ast);
virtual bool visit(CompoundStatementAST *ast);
virtual bool visit(ConditionAST *ast);
virtual bool visit(ConditionalExpressionAST *ast);
......
......@@ -46,7 +46,7 @@
#include <coreplugin/coreconstants.h>
#include <coreplugin/mimedatabase.h>
#include <coreplugin/uniqueidmanager.h>
#include <coreplugin/actionmanager/actionmanagerinterface.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/editormanager/editormanager.h>
#include <texteditor/texteditorsettings.h>
#include <texteditor/fontsettings.h>
......
......@@ -42,7 +42,7 @@
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/uniqueidmanager.h>
#include <coreplugin/actionmanager/actionmanagerinterface.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <QtCore/qplugin.h>
#include <QtCore/QDebug>
......@@ -68,7 +68,7 @@ void BookmarksPlugin::extensionsInitialized()
bool BookmarksPlugin::initialize(const QStringList & /*arguments*/, QString *)
{
m_core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>();
Core::ActionManagerInterface *am = m_core->actionManager();
Core::ActionManager *am = m_core->actionManager();
QList<int> context = QList<int>() << m_core->uniqueIDManager()->
uniqueIdentifier(Constants::BOOKMARKS_CONTEXT);
......
......@@ -32,6 +32,8 @@
***************************************************************************/
#include "actioncontainer.h"
#include "actionmanager_p.h"
#include "command.h"
#include "coreimpl.h"
......@@ -181,7 +183,7 @@ void ActionContainer::appendGroup(const QString &group, bool global)
int gid = idmanager->uniqueIdentifier(group);
m_groups << gid;
if (global)
ActionManager::instance()->registerGlobalGroup(gid, m_id);
ActionManagerPrivate::instance()->registerGlobalGroup(gid, m_id);
}
/*!
......@@ -220,7 +222,7 @@ void ActionContainer::addAction(ICommand *action, const QString &group)
if (!canAddAction(action))
return;
ActionManager *am = ActionManager::instance();
ActionManagerPrivate *am = ActionManagerPrivate::instance();
Action *a = static_cast<Action *>(action);
if (a->stateFlags() & Command::CS_PreLocation) {
QList<CommandLocation> locs = a->locations();
......@@ -251,7 +253,7 @@ void ActionContainer::addMenu(IActionContainer *menu, const QString &group)
if (!canAddMenu(menu))
return;
ActionManager *am = ActionManager::instance();
ActionManagerPrivate *am = ActionManagerPrivate::instance();
MenuActionContainer *mc = static_cast<MenuActionContainer *>(menu);
if (mc->hasState(ActionContainer::CS_PreLocation)) {
CommandLocation loc = mc->location();
......@@ -396,7 +398,7 @@ void ActionContainer::addMenu(IActionContainer *menu, int pos, bool setpos)
*/
QAction *ActionContainer::beforeAction(int pos, int *prevKey) const
{
ActionManager *am = ActionManager::instance();
ActionManagerPrivate *am = ActionManagerPrivate::instance();
int baId = -1;
......
......@@ -34,7 +34,7 @@
#ifndef ACTIONCONTAINER_H
#define ACTIONCONTAINER_H
#include "actionmanager.h"
#include "actionmanager_p.h"
#include <coreplugin/actionmanager/iactioncontainer.h>
#include <coreplugin/actionmanager/icommand.h>
......
......@@ -31,7 +31,7 @@
**
***************************************************************************/
#include "actionmanager.h"
#include "actionmanager_p.h"
#include "mainwindow.h"
#include "actioncontainer.h"
#include "command.h"
......@@ -52,15 +52,15 @@ namespace {
}
/*!
\class Core::ActionManagerInterface
\class Core::ActionManager
\mainclass
\ingroup qwb
\inheaderfile actionmanagerinterface.h
\inheaderfile actionmanager.h
\brief All actions should be registered in the ActionManager, since this enables the user to
e.g. change their shortcuts at a central place.
The ActionManagerInterface is the central bookkeeper of actions and their shortcuts and layout.
The ActionManager is the central bookkeeper of actions and their shortcuts and layout.
You get the only implementation of this class from the core interface (ICore::actionManager()).
The main reasons for the need of this class is to provide a central place where the user
......@@ -94,59 +94,59 @@ namespace {
*/
/*!
\fn virtual IActionContainer *ActionManagerInterface::createMenu(const QString &id) = 0
\fn virtual IActionContainer *ActionManager::createMenu(const QString &id) = 0
...
*/
/*!
\fn virtual IActionContainer *ActionManagerInterface::createMenuBar(const QString &id) = 0
\fn virtual IActionContainer *ActionManager::createMenuBar(const QString &id) = 0
...
*/
/*!
\fn virtual ICommand *ActionManagerInterface::registerAction(QAction *action, const QString &id, const QList<int> &context) = 0
\fn virtual ICommand *ActionManager::registerAction(QAction *action, const QString &id, const QList<int> &context) = 0
...
*/
/*!
\fn virtual ICommand *ActionManagerInterface::registerShortcut(QShortcut *shortcut, const QString &id, const QList<int> &context) = 0
\fn virtual ICommand *ActionManager::registerShortcut(QShortcut *shortcut, const QString &id, const QList<int> &context) = 0
...
*/
/*!
\fn virtual ICommand *ActionManagerInterface::registerAction(QAction *action, const QString &id) = 0
\fn virtual ICommand *ActionManager::registerAction(QAction *action, const QString &id) = 0
...
*/
/*!
\fn virtual void ActionManagerInterface::addAction(ICommand *action, const QString &globalGroup) = 0
\fn virtual void ActionManager::addAction(ICommand *action, const QString &globalGroup) = 0
...
*/
/*!
\fn virtual void ActionManagerInterface::addMenu(IActionContainer *menu, const QString &globalGroup) = 0
\fn virtual void ActionManager::addMenu(IActionContainer *menu, const QString &globalGroup) = 0
...
*/
/*!
\fn virtual ICommand *ActionManagerInterface::command(const QString &id) const = 0
\fn virtual ICommand *ActionManager::command(const QString &id) const = 0
...
*/
/*!
\fn virtual IActionContainer *ActionManagerInterface::actionContainer(const QString &id) const = 0
\fn virtual IActionContainer *ActionManager::actionContainer(const QString &id) const = 0
...
*/
/*!
\fn virtual ActionManagerInterface::~ActionManagerInterface()
\fn virtual ActionManager::~ActionManager()
...
*/
using namespace Core;
using namespace Core::Internal;
ActionManager* ActionManager::m_instance = 0;
ActionManagerPrivate* ActionManagerPrivate::m_instance = 0;
/*!
\class ActionManager
......@@ -159,8 +159,8 @@ ActionManager* ActionManager::m_instance = 0;
/*!
...
*/
ActionManager::ActionManager(MainWindow *mainWnd, UniqueIDManager *uidmgr) :
ActionManagerInterface(mainWnd),
ActionManagerPrivate::ActionManagerPrivate(MainWindow *mainWnd, UniqueIDManager *uidmgr) :
ActionManager(mainWnd),
m_mainWnd(mainWnd)
{
m_defaultGroups << uidmgr->uniqueIdentifier(Constants::G_DEFAULT_ONE);
......@@ -173,7 +173,7 @@ ActionManager::ActionManager(MainWindow *mainWnd, UniqueIDManager *uidmgr) :
/*!
...
*/
ActionManager::~ActionManager()
ActionManagerPrivate::~ActionManagerPrivate()
{
qDeleteAll(m_idCmdMap.values());
qDeleteAll(m_idContainerMap.values());
......@@ -182,7 +182,7 @@ ActionManager::~ActionManager()
/*!
...
*/
ActionManager* ActionManager::instance()
ActionManagerPrivate* ActionManagerPrivate::instance()
{
return m_instance;
}
......@@ -190,7 +190,7 @@ ActionManager* ActionManager::instance()
/*!
...
*/
QList<int> ActionManager::defaultGroups() const
QList<int> ActionManagerPrivate::defaultGroups() const
{
return m_defaultGroups;
}
......@@ -198,7 +198,7 @@ QList<int> ActionManager::defaultGroups() const
/*!
...
*/
QList<Command *> ActionManager::commands() const
QList<Command *> ActionManagerPrivate::commands() const
{
return m_idCmdMap.values();
}
......@@ -206,7 +206,7 @@ QList<Command *> ActionManager::commands() const
/*!
...
*/
QList<ActionContainer *> ActionManager::containers() const
QList<ActionContainer *> ActionManagerPrivate::containers() const
{
return m_idContainerMap.values();
}
......@@ -214,7 +214,7 @@ QList<ActionContainer *> ActionManager::containers() const
/*!
...
*/
void ActionManager::registerGlobalGroup(int groupId, int containerId)
void ActionManagerPrivate::registerGlobalGroup(int groupId, int containerId)
{
if (m_globalgroups.contains(groupId)) {
qWarning() << "registerGlobalGroup: Global group "
......@@ -228,7 +228,7 @@ void ActionManager::registerGlobalGroup(int groupId, int containerId)
/*!
...
*/
bool ActionManager::hasContext(int context) const
bool ActionManagerPrivate::hasContext(int context) const
{
return m_context.contains(context);
}
......@@ -236,7 +236,7 @@ bool ActionManager::hasContext(int context) const
/*!
...
*/
void ActionManager::setContext(const QList<int> &context)
void ActionManagerPrivate::setContext(const QList<int> &context)
{
// here are possibilities for speed optimization if necessary:
// let commands (de-)register themselves for contexts
......@@ -254,7 +254,7 @@ void ActionManager::setContext(const QList<int> &context)
/*!
\internal
*/
bool ActionManager::hasContext(QList<int> context) const
bool ActionManagerPrivate::hasContext(QList<int> context) const
{
for (int i=0; i<m_context.count(); ++i) {
if (context.contains(m_context.at(i)))
......@@ -266,7 +266,7 @@ bool ActionManager::hasContext(QList<int> context) const
/*!
...
*/
IActionContainer *ActionManager::createMenu(const QString &id)
IActionContainer *ActionManagerPrivate::createMenu(const QString &id)
{
const int uid = m_mainWnd->uniqueIDManager()->uniqueIdentifier(id);
const IdContainerMap::const_iterator it = m_idContainerMap.constFind(uid);
......@@ -287,7 +287,7 @@ IActionContainer *ActionManager::createMenu(const QString &id)
/*!
...
*/
IActionContainer *ActionManager::createMenuBar(const QString &id)
IActionContainer *ActionManagerPrivate::createMenuBar(const QString &id)
{
const int uid = m_mainWnd->uniqueIDManager()->uniqueIdentifier(id);
const IdContainerMap::const_iterator it = m_idContainerMap.constFind(uid);
......@@ -308,7 +308,7 @@ IActionContainer *ActionManager::createMenuBar(const QString &id)
/*!
...
*/
ICommand *ActionManager::registerAction(QAction *action, const QString &id, const QList<int> &context)
ICommand *ActionManagerPrivate::registerAction(QAction *action, const QString &id, const QList<int> &context)
{
OverrideableAction *a = 0;
ICommand *c = registerOverridableAction(action, id, false);
......@@ -321,7 +321,7 @@ ICommand *ActionManager::registerAction(QAction *action, const QString &id, cons
/*!
...
*/
ICommand *ActionManager::registerAction(QAction *action, const QString &id)
ICommand *ActionManagerPrivate::registerAction(QAction *action, const QString &id)
{
return registerOverridableAction(action, id, true);
}
......@@ -329,7 +329,7 @@ ICommand *ActionManager::registerAction(QAction *action, const QString &id)
/*!
\internal
*/
ICommand *ActionManager::registerOverridableAction(QAction *action, const QString &id, bool checkUnique)
ICommand *ActionManagerPrivate::registerOverridableAction(QAction *action, const QString &id, bool checkUnique)
{
OverrideableAction *a = 0;
const int uid = m_mainWnd->uniqueIDManager()->uniqueIdentifier(id);
......@@ -378,7 +378,7 @@ ICommand *ActionManager::registerOverridableAction(QAction *action, const QStrin
/*!
...
*/
ICommand *ActionManager::registerShortcut(QShortcut *shortcut, const QString &id, const QList<int> &context)
ICommand *ActionManagerPrivate::registerShortcut(QShortcut *shortcut, const QString &id, const QList<int> &context)
{
Shortcut *sc = 0;
int uid = m_mainWnd->uniqueIDManager()->uniqueIdentifier(id);
......@@ -416,9 +416,9 @@ ICommand *ActionManager::registerShortcut(QShortcut *shortcut, const QString &id
}
/*!
\fn void ActionManager::addAction(Core::ICommand *action, const QString &globalGroup)
\fn void ActionManagerPrivate::addAction(Core::ICommand *action, const QString &globalGroup)
*/