MCPcopy Create free account
hub / github.com/KDE/kdevelop / AbstractTypeDataRequest

Class AbstractTypeDataRequest

kdevplatform/language/duchain/types/typerepository.cpp:23–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21
22namespace KDevelop {
23class AbstractTypeDataRequest
24{
25public:
26 AbstractTypeDataRequest(const AbstractType& type) : m_item(type)
27 {
28 }
29
30 enum {
31 AverageSize = sizeof(AbstractTypeData) + 12
32 };
33
34 unsigned int hash() const
35 {
36 return m_item.hash();
37 }
38
39 uint itemSize() const
40 {
41 return TypeSystem::self().dynamicSize(*m_item.d_ptr);
42 }
43
44 void createItem(AbstractTypeData* item) const
45 {
46 TypeSystem::self().copy(*m_item.d_ptr, *item, true);
47 Q_ASSERT(!item->m_dynamic);
48#ifdef DEBUG_TYPE_REPOSITORY
49 AbstractType::Ptr otherType(TypeSystem::self().create(const_cast<AbstractTypeData*>(item)));
50 if (!otherType->equals(&m_item)) {
51 //For debugging, so one can trace what happened
52 qCWarning(LANGUAGE) << "created type in repository does not equal source type:" << m_item.toString() <<
53 otherType->toString();
54 TypeSystem::self().copy(*m_item.d_ptr, *item, true);
55 otherType->equals(&m_item);
56 }
57#ifdef ASSERT_ON_PROBLEM
58 Q_ASSERT(otherType->equals(&m_item));
59#endif
60#endif
61 item->inRepository = true;
62 }
63
64 static void destroy(AbstractTypeData* item, KDevelop::AbstractItemRepository&)
65 {
66 TypeSystem::self().callDestructor(item);
67 }
68
69 static bool persistent(const AbstractTypeData* item)
70 {
71 // Don't try to delete release items for which the factory is not loaded, as that will lead to a crash/assertion later
72 return ( bool )item->refCount || !TypeSystem::self().isFactoryLoaded(*item);
73 }
74
75 bool equals(const AbstractTypeData* item) const
76 {
77 if (!TypeSystem::self().isFactoryLoaded(*item))
78 return false;
79
80 AbstractType::Ptr otherType(TypeSystem::self().create(const_cast<AbstractTypeData*>(item)));

Callers 1

indexForTypeMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected