Mercurial > projects > qtd
comparison 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 |
comparison
equal
deleted
inserted
replaced
336:b0a7819153bb | 337:5896535a03cd |
---|---|
287 } | 287 } |
288 | 288 |
289 void DGenerator::writeEnumAlias(QTextStream &s, const AbstractMetaEnum *d_enum) | 289 void DGenerator::writeEnumAlias(QTextStream &s, const AbstractMetaEnum *d_enum) |
290 { | 290 { |
291 // aliases for enums to be used in easier way like QFont.Bold instead of QFont.Weight.Bold | 291 // aliases for enums to be used in easier way like QFont.Bold instead of QFont.Weight.Bold |
292 s << QString(" alias %1 %2;").arg(d_enum->typeEntry()->qualifiedTargetLangName()).arg(d_enum->name()) << endl << endl; | 292 //s << QString(" alias %1 %2;").arg(d_enum->typeEntry()->qualifiedTargetLangName()).arg(d_enum->name()) << endl << endl; |
293 const AbstractMetaEnumValueList &values = d_enum->values(); | 293 const AbstractMetaEnumValueList &values = d_enum->values(); |
294 for (int i=0; i<values.size(); ++i) { | 294 for (int i=0; i<values.size(); ++i) { |
295 AbstractMetaEnumValue *enum_value = values.at(i); | 295 AbstractMetaEnumValue *enum_value = values.at(i); |
296 | 296 |
297 if (d_enum->typeEntry()->isEnumValueRejected(enum_value->name())) | 297 if (d_enum->typeEntry()->isEnumValueRejected(enum_value->name())) |
298 continue; | 298 continue; |
299 | 299 |
300 s << QString(" alias %1.%2 %2;").arg(d_enum->typeEntry()->qualifiedTargetLangName()).arg(enum_value->name()) << endl; | 300 s << QString(" alias %1.%2 %2;").arg(d_enum->name()).arg(enum_value->name()) << endl; |
301 } | 301 } |
302 s << endl; | 302 s << endl; |
303 } | 303 } |
304 | 304 |
305 void DGenerator::writeEnum(QTextStream &s, const AbstractMetaEnum *d_enum) | 305 void DGenerator::writeEnum(QTextStream &s, const AbstractMetaEnum *d_enum) |
320 && !d_enum->hasQEnumsDeclaration()) { | 320 && !d_enum->hasQEnumsDeclaration()) { |
321 s << " @QtBlockedEnum" << endl; | 321 s << " @QtBlockedEnum" << endl; |
322 } | 322 } |
323 */ | 323 */ |
324 // Generates Java 1.5 type enums | 324 // Generates Java 1.5 type enums |
325 s << "public enum " << d_enum->enclosingClass()->name() << "_" << d_enum->name() << " {" << endl; | 325 s << "public enum " << d_enum->name() << " {" << endl; |
326 const AbstractMetaEnumValueList &values = d_enum->values(); | 326 const AbstractMetaEnumValueList &values = d_enum->values(); |
327 EnumTypeEntry *entry = d_enum->typeEntry(); | 327 EnumTypeEntry *entry = d_enum->typeEntry(); |
328 | 328 |
329 for (int i=0; i<values.size(); ++i) { | 329 for (int i=0; i<values.size(); ++i) { |
330 AbstractMetaEnumValue *enum_value = values.at(i); | 330 AbstractMetaEnumValue *enum_value = values.at(i); |
563 } | 563 } |
564 s << code << endl; | 564 s << code << endl; |
565 } | 565 } |
566 } | 566 } |
567 } | 567 } |
568 | |
569 | 568 |
570 void DGenerator::writeJavaCallThroughContents(QTextStream &s, const AbstractMetaFunction *d_function, uint attributes) | 569 void DGenerator::writeJavaCallThroughContents(QTextStream &s, const AbstractMetaFunction *d_function, uint attributes) |
571 { | 570 { |
572 Q_UNUSED(attributes); | 571 Q_UNUSED(attributes); |
573 writeInjectedCode(s, d_function, CodeSnip::Beginning); | 572 writeInjectedCode(s, d_function, CodeSnip::Beginning); |
1939 if (inc.type == Include::TargetLangImport) { | 1938 if (inc.type == Include::TargetLangImport) { |
1940 s << inc.toString() << endl; | 1939 s << inc.toString() << endl; |
1941 } | 1940 } |
1942 } | 1941 } |
1943 | 1942 |
1944 // Enums aliases outside of the class - hack | |
1945 if (!d_class->enums().isEmpty()) { | |
1946 auxFile.isDone = false; | |
1947 foreach (AbstractMetaEnum *d_enum, d_class->enums()) | |
1948 writeEnum(auxFile.stream, d_enum); | |
1949 } | |
1950 | |
1951 // Auxiliary file contents should have been written at this point | 1943 // Auxiliary file contents should have been written at this point |
1952 if (!auxFile.isDone) | 1944 if (!auxFile.isDone) |
1953 { | 1945 { |
1954 s << "public import " << auxModName << ";" << endl; | 1946 s << "public import " << auxModName << ";" << endl; |
1955 auxFile.done(); | 1947 auxFile.done(); |
2111 } | 2103 } |
2112 */ | 2104 */ |
2113 s << endl << "{" << endl; | 2105 s << endl << "{" << endl; |
2114 | 2106 |
2115 Indentation indent(INDENT); | 2107 Indentation indent(INDENT); |
2108 | |
2109 // Enums | |
2110 if (!d_class->enums().isEmpty()) { | |
2111 foreach (AbstractMetaEnum *d_enum, d_class->enums()) | |
2112 writeEnum(s, d_enum); | |
2113 } | |
2116 | 2114 |
2117 // Define variables for reference count mechanism | 2115 // Define variables for reference count mechanism |
2118 if (!d_class->isInterface() && !d_class->isNamespace()) { | 2116 if (!d_class->isInterface() && !d_class->isNamespace()) { |
2119 QHash<QString, int> variables; | 2117 QHash<QString, int> variables; |
2120 foreach (AbstractMetaFunction *function, d_class->functions()) { | 2118 foreach (AbstractMetaFunction *function, d_class->functions()) { |