diff generator/dgenerator.cpp @ 337:5896535a03cd

moved enums back to classes
author maxter <spambox@d-coding.com>
date Sat, 13 Mar 2010 00:38:42 +0200
parents 1defd6a98364
children 4920ef9206fe
line wrap: on
line diff
--- a/generator/dgenerator.cpp	Thu Feb 11 12:59:25 2010 +0200
+++ b/generator/dgenerator.cpp	Sat Mar 13 00:38:42 2010 +0200
@@ -289,7 +289,7 @@
 void DGenerator::writeEnumAlias(QTextStream &s, const AbstractMetaEnum *d_enum)
 {
     // aliases for enums to be used in easier way like QFont.Bold instead of QFont.Weight.Bold
-    s << QString("    alias %1 %2;").arg(d_enum->typeEntry()->qualifiedTargetLangName()).arg(d_enum->name()) << endl << endl;
+    //s << QString("    alias %1 %2;").arg(d_enum->typeEntry()->qualifiedTargetLangName()).arg(d_enum->name()) << endl << endl;
     const AbstractMetaEnumValueList &values = d_enum->values();
     for (int i=0; i<values.size(); ++i) {
         AbstractMetaEnumValue *enum_value = values.at(i);
@@ -297,7 +297,7 @@
         if (d_enum->typeEntry()->isEnumValueRejected(enum_value->name()))
             continue;
 
-        s << QString("    alias %1.%2 %2;").arg(d_enum->typeEntry()->qualifiedTargetLangName()).arg(enum_value->name()) << endl;
+        s << QString("    alias %1.%2 %2;").arg(d_enum->name()).arg(enum_value->name()) << endl;
     }
     s << endl;
 }
@@ -322,7 +322,7 @@
     }
 */
     // Generates Java 1.5 type enums
-    s << "public enum " << d_enum->enclosingClass()->name() << "_" << d_enum->name() << " {" << endl;
+    s << "public enum " << d_enum->name() << " {" << endl;
     const AbstractMetaEnumValueList &values = d_enum->values();
     EnumTypeEntry *entry = d_enum->typeEntry();
 
@@ -566,7 +566,6 @@
     }
 }
 
-
 void DGenerator::writeJavaCallThroughContents(QTextStream &s, const AbstractMetaFunction *d_function, uint attributes)
 {
     Q_UNUSED(attributes);
@@ -1941,13 +1940,6 @@
         }
     }
 
-    // Enums aliases outside of the class - hack
-    if (!d_class->enums().isEmpty()) {
-        auxFile.isDone = false;
-        foreach (AbstractMetaEnum *d_enum, d_class->enums())
-            writeEnum(auxFile.stream, d_enum);
-    }
-
     // Auxiliary file contents should have been written at this point
     if (!auxFile.isDone)
     {
@@ -2114,6 +2106,12 @@
 
     Indentation indent(INDENT);
 
+    // Enums
+    if (!d_class->enums().isEmpty()) {
+        foreach (AbstractMetaEnum *d_enum, d_class->enums())
+            writeEnum(s, d_enum);
+    }
+
     // Define variables for reference count mechanism
     if (!d_class->isInterface() && !d_class->isNamespace()) {
         QHash<QString, int> variables;