Commit 394fa863 authored by David Nolden's avatar David Nolden

- Adapt TemplateParameterDeclaration to the shared data scheme

- Make ClassDeclarationData public so it can be extended
- Add some needed constructors

Now kdevelop compiles again.
parent d1265b4f
......@@ -19,7 +19,6 @@
#include "classdeclaration.h"
#include <duchain/identifier.h>
#include <duchain/declaration.h>
#include <duchain/declarationdata.h>
#include <appendedlist.h>
#include "duchainregister.h"
......@@ -30,30 +29,6 @@ namespace Cpp {
DEFINE_LIST_MEMBER_HASH(ClassDeclarationData, baseClasses, BaseClassInstance)
class ClassDeclarationData : public DeclarationData
{
public:
ClassDeclarationData() {
initializeAppendedLists(true);
}
~ClassDeclarationData() {
freeAppendedLists();
}
ClassDeclarationData(const ClassDeclarationData& rhs) : DeclarationData(rhs) {
initializeAppendedLists(true);
copyListsFrom(rhs);
}
static size_t classSize() {
return sizeof(ClassDeclarationData);
}
START_APPENDED_LISTS(ClassDeclarationData);
APPENDED_LIST_FIRST(ClassDeclarationData, BaseClassInstance, baseClasses);
END_APPENDED_LISTS(ClassDeclarationData, baseClasses);
};
ClassDeclaration::ClassDeclaration(const KDevelop::SimpleRange& range, DUContext* context)
: Declaration(*new ClassDeclarationData, range)
......
......@@ -20,6 +20,7 @@
#define CLASSDECLARATION_H
#include <declaration.h>
#include <duchain/declarationdata.h>
#include "cppduchainexport.h"
#include "cpptypes.h"
......@@ -40,7 +41,32 @@ struct BaseClassInstance
bool virtualInheritance;
};
class ClassDeclarationData;
DECLARE_LIST_MEMBER_HASH(ClassDeclarationData, baseClasses, BaseClassInstance)
class ClassDeclarationData : public KDevelop::DeclarationData
{
public:
ClassDeclarationData() {
initializeAppendedLists(true);
}
~ClassDeclarationData() {
freeAppendedLists();
}
ClassDeclarationData(const ClassDeclarationData& rhs) : KDevelop::DeclarationData(rhs) {
initializeAppendedLists(true);
copyListsFrom(rhs);
}
static size_t classSize() {
return sizeof(ClassDeclarationData);
}
START_APPENDED_LISTS(ClassDeclarationData);
APPENDED_LIST_FIRST(ClassDeclarationData, BaseClassInstance, baseClasses);
END_APPENDED_LISTS(ClassDeclarationData, baseClasses);
};
/**
* Represents a single template-parameter definition
......
......@@ -19,6 +19,7 @@
#include "cppducontext.h"
#include "navigationwidget.h"
#include <duchainregister.h>
#include <topducontextdata.h>
namespace Cpp {
......@@ -27,7 +28,7 @@ QMutex cppDuContextInstantiationsMutex(QMutex::Recursive);
typedef CppDUContext<TopDUContext> CppTopDUContext;
REGISTER_DUCHAIN_ITEM_WITH_DATA(CppTopDUContext, TopDUContextData);
typedef CppDUContext<TopDUContext> CppNormalDUContext;
typedef CppDUContext<DUContext> CppNormalDUContext;
REGISTER_DUCHAIN_ITEM_WITH_DATA(CppNormalDUContext, DUContextData);
template<>
......
......@@ -173,6 +173,10 @@ extern QMutex cppDuContextInstantiationsMutex;
template<class BaseContext>
class CppDUContext : public BaseContext {
public:
template<class Data>
CppDUContext(Data& data) : BaseContext(data) {
}
///Parameters will be reached to the base-class
template<class Param1, class Param2>
CppDUContext( const Param1& p1, const Param2& p2, bool isInstantiationContext ) : BaseContext(p1, p2, isInstantiationContext), m_instantiatedFrom(0) {
......
......@@ -24,6 +24,7 @@
#include <kglobal.h>
#include <duchain/declaration.h>
#include <duchain/declarationdata.h>
#include <duchain/forwarddeclaration.h>
#include <duchain/aliasdeclaration.h>
#include <duchain/functiondeclaration.h>
......@@ -40,10 +41,12 @@
using namespace KDevelop;
using namespace Cpp;
#define REGISTER_TEMPLATE_DECLARATION(Declaration) typedef TemplateDeclaration<Declaration> Template ## Declaration; REGISTER_DUCHAIN_ITEM_WITH_DATA(Template ## Declaration, Declaration ## Data);
#define REGISTER_TEMPLATE_DECLARATION(Declaration) typedef SpecialTemplateDeclaration<Declaration> TheTemplate ## Declaration; \
REGISTER_DUCHAIN_ITEM_WITH_DATA(TheTemplate ## Declaration, Declaration ## Data);
REGISTER_TEMPLATE_DECLARATION(Declaration);
REGISTER_TEMPLATE_DECLARATION(ClassDeclaration);
REGISTER_TEMPLATE_DECLARATION(TemplateParameterDeclaration);
REGISTER_TEMPLATE_DECLARATION(ClassFunctionDeclaration);
REGISTER_TEMPLATE_DECLARATION(ClassMemberDeclaration);
REGISTER_TEMPLATE_DECLARATION(FunctionDeclaration);
......
......@@ -188,6 +188,9 @@ namespace Cpp {
template<class BaseDeclaration>
class KDEVCPPDUCHAIN_EXPORT SpecialTemplateDeclaration : public BaseDeclaration, public TemplateDeclaration {
public:
template<class Data>
SpecialTemplateDeclaration(Data& data) : BaseDeclaration(data) {
}
///Copy-constructor for cloning
SpecialTemplateDeclaration(const SpecialTemplateDeclaration<BaseDeclaration>& rhs) : BaseDeclaration(rhs), TemplateDeclaration(rhs) {
}
......
......@@ -19,18 +19,14 @@
#include "templateparameterdeclaration.h"
#include <duchain/identifier.h>
#include <duchain/declaration.h>
#include <duchainregister.h>
using namespace KDevelop;
class TemplateParameterDeclarationPrivate
{
public:
QualifiedIdentifier m_defaultParameter;
};
REGISTER_DUCHAIN_ITEM(TemplateParameterDeclaration);
TemplateParameterDeclaration::TemplateParameterDeclaration(const KDevelop::SimpleRange& range, DUContext* context)
: Declaration(range, context), d_ptr(new TemplateParameterDeclarationPrivate)
: Declaration(*new TemplateParameterDeclarationData, range)
{
if(context)
setContext(context);
......@@ -41,16 +37,18 @@ TemplateParameterDeclaration::~TemplateParameterDeclaration()
}
QualifiedIdentifier TemplateParameterDeclaration::defaultParameter() const {
return d_func()->m_defaultParameter;
return d_func()->m_defaultParameter.identifier();
}
void TemplateParameterDeclaration::setDefaultParameter(const QualifiedIdentifier& str) {
d_func()->m_defaultParameter = str;
d_func_dynamic()->m_defaultParameter = str;
}
TemplateParameterDeclaration::TemplateParameterDeclaration(TemplateParameterDeclarationData& data) : Declaration(data) {
}
TemplateParameterDeclaration::TemplateParameterDeclaration(const TemplateParameterDeclaration& rhs) : Declaration(rhs),
d_ptr(new TemplateParameterDeclarationPrivate) {
d_func()->m_defaultParameter = rhs.d_func()->m_defaultParameter;
TemplateParameterDeclaration::TemplateParameterDeclaration(const TemplateParameterDeclaration& rhs) : Declaration(rhs) {
d_func_dynamic()->m_defaultParameter = rhs.d_func()->m_defaultParameter;
setIsTypeAlias(true);
}
......
......@@ -20,6 +20,8 @@
#define TEMPLATEPARAMETERDECLARATION_H
#include <declaration.h>
#include <declarationdata.h>
#include <identifier.h>
#include "cppduchainexport.h"
namespace KDevelop {
......@@ -30,7 +32,11 @@ namespace KDevelop {
class DUContext;
}
class TemplateParameterDeclarationPrivate;
class TemplateParameterDeclarationData : public KDevelop::DeclarationData
{
public:
KDevelop::IndexedQualifiedIdentifier m_defaultParameter;
};
/**
* Represents a single template-parameter definition
......@@ -38,6 +44,7 @@ class TemplateParameterDeclarationPrivate;
class KDEVCPPDUCHAIN_EXPORT TemplateParameterDeclaration : public KDevelop::Declaration
{
public:
TemplateParameterDeclaration(TemplateParameterDeclarationData& data);
TemplateParameterDeclaration(const TemplateParameterDeclaration& rhs);
TemplateParameterDeclaration(const KDevelop::SimpleRange& range, KDevelop::DUContext* context);
~TemplateParameterDeclaration();
......@@ -51,9 +58,12 @@ public:
virtual Declaration* clone() const;
enum {
Identity = 18
};
private:
TemplateParameterDeclarationPrivate* const d_ptr;
Q_DECLARE_PRIVATE(TemplateParameterDeclaration)
DUCHAIN_DECLARE_DATA(TemplateParameterDeclaration)
};
#endif // FUNCTIONDECLARATION_H
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment