Mercurial > projects > qtd
comparison generator/dgenerator.cpp @ 292:19498f420252 signals
more QList goodness
author | eldar |
---|---|
date | Tue, 10 Nov 2009 19:29:42 +0000 |
parents | f9559a957be9 |
children | 8627891e4556 |
comparison
equal
deleted
inserted
replaced
291:0d2094800bdb | 292:19498f420252 |
---|---|
1818 QString auxModName = d_class->package() + "." + d_class->name() + "_aux"; | 1818 QString auxModName = d_class->package() + "." + d_class->name() + "_aux"; |
1819 FileOut auxFile(outputDirectory() + "/" + subDirectoryForClass(d_class) + "/" + d_class->name() + "_aux.d"); | 1819 FileOut auxFile(outputDirectory() + "/" + subDirectoryForClass(d_class) + "/" + d_class->name() + "_aux.d"); |
1820 auxFile.isDone = true; | 1820 auxFile.isDone = true; |
1821 auxFile.stream << "module " << auxModName << ";" << endl << endl; | 1821 auxFile.stream << "module " << auxModName << ";" << endl << endl; |
1822 | 1822 |
1823 bool staticInit = d_class->isQObject() || (cpp_shared && d_class->generateShellClass() && !d_class->isInterface()); | 1823 bool staticInit = d_class->isQObject() || d_class->typeEntry()->isValue() || (cpp_shared && d_class->generateShellClass() && !d_class->isInterface()); |
1824 if (staticInit) | 1824 if (staticInit) |
1825 { | 1825 { |
1826 auxFile.isDone = false; | 1826 auxFile.isDone = false; |
1827 auxFile.stream << "extern(C) void static_init_" << d_class->name() << "();" << endl; | 1827 auxFile.stream << "extern(C) void static_init_" << d_class->name() << "();" << endl; |
1828 auxFile.stream << "static this() { static_init_" << d_class->name() << "; }" << endl << endl; | 1828 auxFile.stream << "static this() { static_init_" << d_class->name() << "; }" << endl << endl; |
2259 | 2259 |
2260 // flag to mark the type of class (to use in templates to convert arguments) | 2260 // flag to mark the type of class (to use in templates to convert arguments) |
2261 if (d_class->baseClassName().isEmpty()) | 2261 if (d_class->baseClassName().isEmpty()) |
2262 { | 2262 { |
2263 if (d_class->typeEntry()->isQObject()) | 2263 if (d_class->typeEntry()->isQObject()) |
2264 s << INDENT << "public static enum __isQObjectType = true;" << endl << endl; | 2264 s << INDENT << "public alias void __isQObjectType;" << endl << endl; |
2265 else if (d_class->typeEntry()->isObject()) | 2265 else if (d_class->typeEntry()->isObject()) |
2266 s << INDENT << "public static enum __isObjectType = true;" << endl << endl; | 2266 s << INDENT << "public alias void __isObjectType;" << endl << endl; |
2267 else if (d_class->typeEntry()->isValue()) | 2267 else if (d_class->typeEntry()->isValue()) |
2268 s << INDENT << "public static enum __isValueType = true;" << endl << endl; | 2268 s << INDENT << "public alias void __isValueType;" << endl << endl; |
2269 } | 2269 } |
2270 | |
2271 s << INDENT << "public alias void __isQtType_" << d_class->name() << ";" << endl << endl; | |
2270 | 2272 |
2271 // Add dummy constructor for use when constructing subclasses | 2273 // Add dummy constructor for use when constructing subclasses |
2272 if (!d_class->isNamespace() && !d_class->isInterface() && !fakeClass) { | 2274 if (!d_class->isNamespace() && !d_class->isInterface() && !fakeClass) { |
2273 s << endl | 2275 s << endl |
2274 << INDENT << "public " | 2276 << INDENT << "public " |
2375 } | 2377 } |
2376 | 2378 |
2377 writeDestructor(s, d_class); | 2379 writeDestructor(s, d_class); |
2378 } | 2380 } |
2379 | 2381 |
2382 if (d_class->typeEntry()->isValue()) | |
2383 writeValueFunctions(s, d_class); | |
2380 /* qtd | 2384 /* qtd |
2381 // Add a function that converts an array of the value type to a QNativePointer | 2385 // Add a function that converts an array of the value type to a QNativePointer |
2382 if (d_class->typeEntry()->isValue() && !fakeClass) { | 2386 if (d_class->typeEntry()->isValue() && !fakeClass) { |
2383 s << endl | 2387 s << endl |
2384 << INDENT << "public static native QNativePointer nativePointerArray(" << d_class->name() | 2388 << INDENT << "public static native QNativePointer nativePointerArray(" << d_class->name() |
2410 /* qtd | 2414 /* qtd |
2411 if (d_class->hasCloneOperator()) { | 2415 if (d_class->hasCloneOperator()) { |
2412 writeCloneFunction(s, d_class); | 2416 writeCloneFunction(s, d_class); |
2413 } | 2417 } |
2414 */ | 2418 */ |
2415 s << "}" << endl; | 2419 s << "}" << endl; // end of class scope |
2416 | 2420 |
2417 /* ---------------- injected free code ----------------*/ | 2421 /* ---------------- injected free code ----------------*/ |
2418 const ComplexTypeEntry *class_type = d_class->typeEntry(); | 2422 const ComplexTypeEntry *class_type = d_class->typeEntry(); |
2419 Q_ASSERT(class_type); | 2423 Q_ASSERT(class_type); |
2420 | 2424 |
2600 << QString("_initCallBacks(%1);").arg(initArgs) << endl << endl; | 2604 << QString("_initCallBacks(%1);").arg(initArgs) << endl << endl; |
2601 } | 2605 } |
2602 | 2606 |
2603 s << "extern(C) void static_init_" << d_class->name() << "() {" << endl; | 2607 s << "extern(C) void static_init_" << d_class->name() << "() {" << endl; |
2604 | 2608 |
2609 if (d_class->typeEntry()->isValue()) | |
2610 s << INDENT << d_class->name() << ".QTypeInfo.init();" << endl; | |
2611 | |
2605 if (d_class->isQObject()) { | 2612 if (d_class->isQObject()) { |
2606 s << INDENT << "if (!" << d_class->name() << "._staticMetaObject) " << endl | 2613 s << INDENT << "if (!" << d_class->name() << "._staticMetaObject) " << endl |
2607 << INDENT << " " << d_class->name() << ".createStaticMetaObject;" << endl << endl; | 2614 << INDENT << " " << d_class->name() << ".createStaticMetaObject;" << endl << endl; |
2608 } | 2615 } |
2609 | 2616 |
2657 } | 2664 } |
2658 | 2665 |
2659 | 2666 |
2660 if (d_class->isQObject()) | 2667 if (d_class->isQObject()) |
2661 writeQObjectFreeFunctions(s, d_class); | 2668 writeQObjectFreeFunctions(s, d_class); |
2669 | |
2670 if (d_class->typeEntry()->isValue()) | |
2671 writeValueFreeFunctions(s, d_class); | |
2672 } | |
2673 | |
2674 void DGenerator::writeValueFunctions(QTextStream &s, const AbstractMetaClass *d_class) | |
2675 { | |
2676 s << INDENT << "struct QTypeInfo {" << endl; | |
2677 s << INDENT << " static __gshared bool isComplex;" << endl; | |
2678 s << INDENT << " static __gshared bool isStatic;" << endl; | |
2679 s << INDENT << " static __gshared bool isLarge;" << endl; | |
2680 s << INDENT << " static __gshared bool isPointer;" << endl; | |
2681 s << INDENT << " static __gshared bool isDummy;" << endl << endl; | |
2682 | |
2683 s << INDENT << " static init() {" << endl; | |
2684 | |
2685 s << QString(" isComplex = qtd_%1_QTypeInfo_isComplex();\n" | |
2686 " isStatic = qtd_%1_QTypeInfo_isStatic();\n" | |
2687 " isLarge = qtd_%1_QTypeInfo_isLarge();\n" | |
2688 " isPointer = qtd_%1_QTypeInfo_isPointer();\n" | |
2689 " isDummy = qtd_%1_QTypeInfo_isDummy();\n").arg(d_class->name()) | |
2690 << " }" << endl | |
2691 << " }" << endl << endl; | |
2692 } | |
2693 | |
2694 void DGenerator::writeValueFreeFunctions(QTextStream &s, const AbstractMetaClass *d_class) | |
2695 { | |
2696 s << QString("private extern (C) bool qtd_%1_QTypeInfo_isComplex();\n").arg(d_class->name()); | |
2697 s << QString("private extern (C) bool qtd_%1_QTypeInfo_isStatic();\n").arg(d_class->name()); | |
2698 s << QString("private extern (C) bool qtd_%1_QTypeInfo_isLarge();\n").arg(d_class->name()); | |
2699 s << QString("private extern (C) bool qtd_%1_QTypeInfo_isPointer();\n").arg(d_class->name()); | |
2700 s << QString("private extern (C) bool qtd_%1_QTypeInfo_isDummy();\n").arg(d_class->name()); | |
2662 } | 2701 } |
2663 | 2702 |
2664 void DGenerator::writeConversionFunction(QTextStream &s, const AbstractMetaClass *d_class) | 2703 void DGenerator::writeConversionFunction(QTextStream &s, const AbstractMetaClass *d_class) |
2665 { | 2704 { |
2666 const ComplexTypeEntry *ctype = d_class->typeEntry(); | 2705 const ComplexTypeEntry *ctype = d_class->typeEntry(); |