aboutsummaryrefslogtreecommitdiffstats
path: root/typesystem.cpp
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-07-20 11:53:01 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-09 19:10:18 -0300
commite486e0bbe2065bbc228f84f93178e0636475021b (patch)
tree68477e77776beb0c4c1766b186e0072a35679876 /typesystem.cpp
parentb3644ccd1f52073ed70ce8b6e0ed4f58a07632d7 (diff)
Added default constructor option for value types.
The unit test is in place and the 'value-type' tag documentation was update with information about the 'default-constructor' attribute. Reviewed by Hugo Parente <hugo.lima@openbossa.org> Reviewed by Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'typesystem.cpp')
-rw-r--r--typesystem.cpp41
1 files changed, 34 insertions, 7 deletions
diff --git a/typesystem.cpp b/typesystem.cpp
index c54a12db2..66feacd59 100644
--- a/typesystem.cpp
+++ b/typesystem.cpp
@@ -431,8 +431,10 @@ bool Handler::startElement(const QString &, const QString &n,
attributes["extensible"] = "no";
attributes["identified-by-value"] = QString();
break;
- case StackElement::ObjectTypeEntry:
case StackElement::ValueTypeEntry:
+ attributes["default-constructor"] = QString();
+ // fall throooough
+ case StackElement::ObjectTypeEntry:
attributes["force-abstract"] = QString("no");
attributes["deprecated"] = QString("no");
attributes["hash-function"] = QString("");
@@ -646,20 +648,25 @@ bool Handler::startElement(const QString &, const QString &n,
element->entry = otype;
}
// fall through
+ case StackElement::ValueTypeEntry: {
+ if (!element->entry) {
+ ValueTypeEntry* typeEntry = new ValueTypeEntry(name, since);
+ QString defaultConstructor = attributes["default-constructor"];
+ if (!defaultConstructor.isEmpty())
+ typeEntry->setDefaultConstructor(defaultConstructor);
+ element->entry = typeEntry;
+ }
+
+ // fall through
case StackElement::NamespaceTypeEntry:
if (!element->entry)
element->entry = new NamespaceTypeEntry(name, since);
- // fall through
+ // fall through
case StackElement::ObjectTypeEntry:
if (!element->entry)
element->entry = new ObjectTypeEntry(name, since);
- // fall through
- case StackElement::ValueTypeEntry: {
- if (!element->entry)
- element->entry = new ValueTypeEntry(name, since);
-
element->entry->setStream(attributes["stream"] == QString("yes"));
ComplexTypeEntry *ctype = static_cast<ComplexTypeEntry *>(element->entry);
@@ -1745,6 +1752,26 @@ FieldModification ComplexTypeEntry::fieldModification(const QString &name) const
return mod;
}
+// The things we do not to break the ABI...
+typedef QHash<const ComplexTypeEntry*, QString> ComplexTypeEntryDefaultConstructorMap;
+Q_GLOBAL_STATIC(ComplexTypeEntryDefaultConstructorMap, complexTypeEntryDefaultConstructors);
+
+void ComplexTypeEntry::setDefaultConstructor(const QString& defaultConstructor)
+{
+ if (!defaultConstructor.isEmpty())
+ complexTypeEntryDefaultConstructors()->insert(this, defaultConstructor);
+}
+QString ComplexTypeEntry::defaultConstructor() const
+{
+ if (!complexTypeEntryDefaultConstructors()->contains(this))
+ return QString();
+ return complexTypeEntryDefaultConstructors()->value(this);
+}
+bool ComplexTypeEntry::hasDefaultConstructor() const
+{
+ return complexTypeEntryDefaultConstructors()->contains(this);
+}
+
QString ContainerTypeEntry::targetLangPackage() const
{
return QString();