aboutsummaryrefslogtreecommitdiffstats
path: root/typesystem.h
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.lima@openbossa.org>2010-04-15 11:29:12 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-09 19:09:59 -0300
commitdd7f06be4d8687cd4ed45a41aac674ec50e645ed (patch)
tree928e78da928ee758e4daf0ed71cbaad4a03c43b8 /typesystem.h
parent74d3c1bb12280ffb2b810ee4bd1272ba6fb8127f (diff)
TypeDatabase class moved to its own header/cpp.
Diffstat (limited to 'typesystem.h')
-rw-r--r--typesystem.h266
1 files changed, 0 insertions, 266 deletions
diff --git a/typesystem.h b/typesystem.h
index 662cb53e1..34f60b0d5 100644
--- a/typesystem.h
+++ b/typesystem.h
@@ -1758,272 +1758,6 @@ struct TypeRejection
QString enum_name;
};
-class APIEXTRACTOR_API TypeDatabase
-{
- TypeDatabase();
- TypeDatabase(const TypeDatabase&);
- TypeDatabase& operator=(const TypeDatabase&);
-public:
-
- /**
- * Return the type system instance.
- * \param newInstance This parameter is usefull just for unit testing, because singletons causes
- * too many side effects on unit testing.
- */
- static TypeDatabase *instance(bool newInstance = false);
-
- static QString normalizedSignature(const char* signature);
-
- QStringList requiredTargetImports()
- {
- return m_requiredTargetImports;
- }
-
- void addRequiredTargetImport(const QString &moduleName)
- {
- if (!m_requiredTargetImports.contains(moduleName))
- m_requiredTargetImports << moduleName;
- }
-
- QStringList typesystemPaths()
- {
- return m_typesystemPaths;
- }
- void addTypesystemPath(const QString &typesystem_paths)
- {
-#if defined(Q_OS_WIN32)
- char *path_splitter = const_cast<char *>(";");
-#else
- char *path_splitter = const_cast<char *>(":");
-#endif
- m_typesystemPaths += typesystem_paths.split(path_splitter);
- }
-
- IncludeList extraIncludes(const QString &className);
-
- inline PrimitiveTypeEntry *findPrimitiveType(const QString &name);
- inline ComplexTypeEntry *findComplexType(const QString &name);
- inline ObjectTypeEntry *findObjectType(const QString &name);
- inline NamespaceTypeEntry *findNamespaceType(const QString &name);
- ContainerTypeEntry *findContainerType(const QString &name);
- FunctionTypeEntry* findFunctionType(const QString& name);
-
- TypeEntry *findType(const QString &name) const
- {
- QList<TypeEntry *> entries = findTypes(name);
- foreach (TypeEntry *entry, entries) {
- if (entry &&
- (!entry->isPrimitive() || static_cast<PrimitiveTypeEntry *>(entry)->preferredTargetLangType())) {
- return entry;
- }
- }
- return 0;
- }
- QList<TypeEntry *> findTypes(const QString &name) const
- {
- return m_entries.value(name);
- }
- TypeEntryHash allEntries()
- {
- return m_entries;
- }
-
- SingleTypeEntryHash entries()
- {
- TypeEntryHash entries = allEntries();
-
- SingleTypeEntryHash returned;
- QList<QString> keys = entries.keys();
-
- foreach (QString key, keys)
- returned[key] = findType(key);
-
- return returned;
- }
-
- PrimitiveTypeEntry *findTargetLangPrimitiveType(const QString &targetLangName);
-
- QList<const PrimitiveTypeEntry*> primitiveTypes() {
- TypeEntryHash entries = allEntries();
- QList<const PrimitiveTypeEntry*> returned;
- foreach(QString key, entries.keys()) {
- foreach(const TypeEntry* typeEntry, entries[key]) {
- if (typeEntry->isPrimitive())
- returned.append((PrimitiveTypeEntry*) typeEntry);
- }
- }
- return returned;
- }
- QList<const ContainerTypeEntry*> containerTypes() {
- TypeEntryHash entries = allEntries();
- QList<const ContainerTypeEntry*> returned;
- foreach(QString key, entries.keys()) {
- foreach(const TypeEntry* typeEntry, entries[key]) {
- if (typeEntry->isContainer())
- returned.append((ContainerTypeEntry*) typeEntry);
- }
- }
- return returned;
- }
-
- void addRejection(const QString &class_name, const QString &function_name,
- const QString &field_name, const QString &enum_name);
- bool isClassRejected(const QString &class_name);
- bool isFunctionRejected(const QString &class_name, const QString &function_name);
- bool isFieldRejected(const QString &class_name, const QString &field_name);
- bool isEnumRejected(const QString &class_name, const QString &enum_name);
-
- void addType(TypeEntry *e)
- {
- m_entries[e->qualifiedCppName()].append(e);
- }
-
- SingleTypeEntryHash flagsEntries() const
- {
- return m_flagsEntries;
- }
- FlagsTypeEntry *findFlagsType(const QString &name) const;
- void addFlagsType(FlagsTypeEntry *fte)
- {
- m_flagsEntries[fte->originalName()] = fte;
- }
-
- TemplateEntry *findTemplate(const QString &name)
- {
- return m_templates[name];
- }
- void addTemplate(TemplateEntry *t)
- {
- m_templates[t->name()] = t;
- }
-
- AddedFunctionList globalUserFunctions() const
- {
- return m_globalUserFunctions;
- }
- void addGlobalUserFunctions(const AddedFunctionList& functions)
- {
- m_globalUserFunctions << functions;
- }
- AddedFunctionList findGlobalUserFunctions(const QString& name) const;
-
- void addGlobalUserFunctionModifications(const FunctionModificationList& functionModifications)
- {
- m_functionMods << functionModifications;
- }
- void addGlobalUserFunctionModification(const FunctionModification& functionModification)
- {
- m_functionMods << functionModification;
- }
- FunctionModificationList functionModifications(const QString& signature) const;
-
- void setSuppressWarnings(bool on)
- {
- m_suppressWarnings = on;
- }
- void addSuppressedWarning(const QString &s)
- {
- m_suppressedWarnings.append(s);
- }
-
- bool isSuppressedWarning(const QString &s)
- {
- if (!m_suppressWarnings)
- return false;
-
- foreach (const QString &_warning, m_suppressedWarnings) {
- QString warning(QString(_warning).replace("\\*", "&place_holder_for_asterisk;"));
-
- QStringList segs = warning.split("*", QString::SkipEmptyParts);
- if (!segs.size())
- continue;
-
- int i = 0;
- int pos = s.indexOf(QString(segs.at(i++)).replace("&place_holder_for_asterisk;", "*"));
- //qDebug() << "s == " << s << ", warning == " << segs;
- while (pos != -1) {
- if (i == segs.size())
- return true;
- pos = s.indexOf(QString(segs.at(i++)).replace("&place_holder_for_asterisk;", "*"), pos);
- }
- }
-
- return false;
- }
-
- void setRebuildClasses(const QStringList &cls)
- {
- m_rebuildClasses = cls;
- }
-
- static QString globalNamespaceClassName(const TypeEntry *te);
- QString filename() const
- {
- return "typesystem.txt";
- }
-
- QString modifiedTypesystemFilepath(const QString &ts_file);
- bool parseFile(const QString &filename, bool generate = true);
- bool parseFile(QIODevice* device, bool generate = true);
-
-private:
- bool m_suppressWarnings;
- TypeEntryHash m_entries;
- SingleTypeEntryHash m_flagsEntries;
- TemplateEntryHash m_templates;
- QStringList m_suppressedWarnings;
-
- AddedFunctionList m_globalUserFunctions;
- FunctionModificationList m_functionMods;
-
- QStringList m_requiredTargetImports;
-
- QStringList m_typesystemPaths;
- QHash<QString, bool> m_parsedTypesystemFiles;
-
- QList<TypeRejection> m_rejections;
- QStringList m_rebuildClasses;
-};
-
-inline PrimitiveTypeEntry *TypeDatabase::findPrimitiveType(const QString &name)
-{
- QList<TypeEntry *> entries = findTypes(name);
-
- foreach (TypeEntry *entry, entries) {
- if (entry && entry->isPrimitive() && static_cast<PrimitiveTypeEntry *>(entry)->preferredTargetLangType())
- return static_cast<PrimitiveTypeEntry *>(entry);
- }
-
- return 0;
-}
-
-inline ComplexTypeEntry *TypeDatabase::findComplexType(const QString &name)
-{
- TypeEntry *entry = findType(name);
- if (entry && entry->isComplex())
- return static_cast<ComplexTypeEntry *>(entry);
- else
- return 0;
-}
-
-inline ObjectTypeEntry *TypeDatabase::findObjectType(const QString &name)
-{
- TypeEntry *entry = findType(name);
- if (entry && entry->isObject())
- return static_cast<ObjectTypeEntry *>(entry);
- else
- return 0;
-}
-
-inline NamespaceTypeEntry *TypeDatabase::findNamespaceType(const QString &name)
-{
- TypeEntry *entry = findType(name);
- if (entry && entry->isNamespace())
- return static_cast<NamespaceTypeEntry *>(entry);
- else
- return 0;
-}
-
QString fixCppTypeName(const QString &name);
#endif // TYPESYSTEM_H