aboutsummaryrefslogtreecommitdiffstats
path: root/typesystem.cpp
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-02-16 08:14:45 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-09 19:10:15 -0300
commiteab5d72e3f7727f5726fa49267985cfcbd8e2c07 (patch)
tree67040918dc9a23e45b598ffbfd7a13bfb31bf4ac /typesystem.cpp
parentf66bede561b7e1b282c835395f14f08437c407f8 (diff)
Type system parser has now the ability to ignore entries as demanded by the user.
The entries that could be dropped are: * Object and Value types * Global functions * Namespaces * Enums The entry name must be fully qualified with scope items separated by a dot (.) and beginning with the module/package name. Example: to drop the class "Bar" inside the namespace "Foo" from the "Pkg" package specify it with: "Pkg.Foo.Bar". TODO: The parser will later complain that dropped entries found on the headers are not found in the type system. That's obviously incorrect, but to fix it all the type entries should store the name of the package from where the came. And that's a needed improvement!
Diffstat (limited to 'typesystem.cpp')
-rw-r--r--typesystem.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/typesystem.cpp b/typesystem.cpp
index 93e81eaa9..3ccb33543 100644
--- a/typesystem.cpp
+++ b/typesystem.cpp
@@ -38,6 +38,7 @@ Handler::Handler(TypeDatabase* database, bool generate)
{
m_currentEnum = 0;
m_current = 0;
+ m_currentOptional = 0;
tagNames["rejection"] = StackElement::Rejection;
tagNames["primitive-type"] = StackElement::PrimitiveTypeEntry;
@@ -123,6 +124,13 @@ void Handler::fetchAttributeValues(const QString &name, const QXmlAttributes &at
bool Handler::endElement(const QString &, const QString &localName, const QString &)
{
+ if (m_currentOptional) {
+ m_current = m_currentOptional->parent;
+ delete m_currentOptional;
+ m_currentOptional = 0;
+ return true;
+ }
+
QString tagName = localName.toLower();
if (tagName == "import-file")
return true;
@@ -208,6 +216,9 @@ bool Handler::endElement(const QString &, const QString &localName, const QStrin
bool Handler::characters(const QString &ch)
{
+ if (m_currentOptional)
+ return true;
+
if (m_current->type == StackElement::Template) {
m_current->value.templateEntry->addCode(ch);
return true;
@@ -345,6 +356,21 @@ static bool convertRemovalAttribute(const QString& removalAttribute, Modificatio
return true;
}
+static void getNamePrefixRecursive(StackElement* element, QStringList& names)
+{
+ if (!element->parent || !element->parent->entry)
+ return;
+ getNamePrefixRecursive(element->parent, names);
+ names << element->parent->entry->name();
+}
+
+static QString getNamePrefix(StackElement* element)
+{
+ QStringList names;
+ getNamePrefixRecursive(element, names);
+ return names.join(".");
+}
+
bool Handler::startElement(const QString &, const QString &n,
const QString &, const QXmlAttributes &atts)
{
@@ -357,6 +383,9 @@ bool Handler::startElement(const QString &, const QString &n,
return false;
}
+ if (m_currentOptional)
+ return true;
+
StackElement* element = new StackElement(m_current);
element->type = tagNames[tagName];
@@ -428,6 +457,16 @@ bool Handler::startElement(const QString &, const QString &n,
QString name = attributes["name"];
double since = attributes["since"].toDouble();
+ if (m_database->hasDroppedTypeEntries()) {
+ QString identifier = getNamePrefix(element) + '.';
+ identifier += (element->type == StackElement::FunctionTypeEntry ? attributes["signature"] : name);
+ if (m_database->shouldDropTypeEntry(identifier)) {
+ m_currentOptional = element;
+ ReportHandler::debugSparse(QString("Optional type system entry '%1' was dropped from generation.").arg(identifier));
+ return true;
+ }
+ }
+
// The top level tag 'function' has only the 'signature' tag
// and we should extract the 'name' value from it.
if (element->type == StackElement::FunctionTypeEntry) {