From 5179bca73955373e087d6b51edcabf038c964ac8 Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Mon, 20 Sep 2010 11:36:45 -0300 Subject: Anonymous enums now supported. --- typesystem.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'typesystem.cpp') diff --git a/typesystem.cpp b/typesystem.cpp index f92ea01dd..1cc9f1927 100644 --- a/typesystem.cpp +++ b/typesystem.cpp @@ -372,6 +372,7 @@ bool Handler::startElement(const QString &, const QString &n, attributes["lower-bound"] = QString(); attributes["force-integer"] = "no"; attributes["extensible"] = "no"; + attributes["identified-by-value"] = QString(); break; case StackElement::ObjectTypeEntry: case StackElement::ValueTypeEntry: @@ -425,6 +426,15 @@ bool Handler::startElement(const QString &, const QString &n, ReportHandler::warning(QString("Duplicate type entry: '%1'").arg(name)); } + if (element->type == StackElement::EnumTypeEntry) { + if (name.isEmpty()) { + name = attributes["identified-by-value"]; + } else if (!attributes["identified-by-value"].isEmpty()) { + m_error = "can't specify both 'name' and 'identified-by-value' attributes"; + return false; + } + } + if (name.isEmpty()) { m_error = "no 'name' attribute specified"; return false; @@ -485,6 +495,7 @@ bool Handler::startElement(const QString &, const QString &n, m_currentEnum = new EnumTypeEntry(QStringList(names.mid(0, names.size() - 1)).join("::"), names.last(), since); + m_currentEnum->setAnonymous(!attributes["identified-by-value"].isEmpty()); element->entry = m_currentEnum; m_currentEnum->setCodeGeneration(m_generate); m_currentEnum->setTargetLangPackage(m_defaultPackage); -- cgit v1.2.3