comparison generator/dgenerator.cpp @ 257:17b5e13364b7 lifetime

(none)
author maxter
date Wed, 16 Sep 2009 13:56:02 +0000
parents 073b9153ed8a
children 515d6e1c7b10
comparison
equal deleted inserted replaced
256:b1abe7f57321 257:17b5e13364b7
59 DGenerator::DGenerator() 59 DGenerator::DGenerator()
60 : m_doc_parser(0), 60 : m_doc_parser(0),
61 m_docs_enabled(false), 61 m_docs_enabled(false),
62 m_native_jump_table(false), 62 m_native_jump_table(false),
63 m_recursive(0), 63 m_recursive(0),
64 m_isRecursive(false) 64 m_isRecursive(false)
65 { 65 {
66 excludedTypes << "long long" << "bool" << "int" << "QString" << "char" << "WId" 66 excludedTypes << "long long" << "bool" << "int" << "QString" << "char" << "WId"
67 << "unsigned char" << "uint" << "double" << "short" << "float" 67 << "unsigned char" << "uint" << "double" << "short" << "float"
68 << "signed char" << "unsigned short" << "QBool" << "unsigned int" 68 << "signed char" << "unsigned short" << "QBool" << "unsigned int"
69 << "Qt::HANDLE" << "QChar" << "java.lang.JObjectWrapper" << "void" 69 << "Qt::HANDLE" << "QChar" << "java.lang.JObjectWrapper" << "void"
477 } 477 }
478 478
479 static QString function_call_for_ownership(TypeSystem::Ownership owner) 479 static QString function_call_for_ownership(TypeSystem::Ownership owner)
480 { 480 {
481 if (owner == TypeSystem::CppOwnership) { 481 if (owner == TypeSystem::CppOwnership) {
482 return "__setFlags(QtdObjectFlags.nativeOwnership, true)"; 482 return "__nativeOwnership = true";
483 } else /* qtd 2 if (owner == TypeSystem::TargetLangOwnership) */ { 483 } else /* qtd 2 if (owner == TypeSystem::TargetLangOwnership) */ {
484 return "__setFlags(QtdObjectFlags.nativeOwnership, false)"; 484 return "__nativeOwnership = false";
485 }/* else if (owner == TypeSystem::DefaultOwnership) { 485 }/* else if (owner == TypeSystem::DefaultOwnership) {
486 return "__no_real_delete = false"; 486 return "__no_real_delete = false";
487 487
488 } else { 488 } else {
489 Q_ASSERT(false); 489 Q_ASSERT(false);
637 s << INDENT << "/*if (" << arguments.at(i)->argumentName() << " is null)" << endl 637 s << INDENT << "/*if (" << arguments.at(i)->argumentName() << " is null)" << endl
638 << INDENT << " throw new NullPointerException(\"Argument '" << arguments.at(i)->argumentName() << "': null not expected.\"); */" << endl; 638 << INDENT << " throw new NullPointerException(\"Argument '" << arguments.at(i)->argumentName() << "': null not expected.\"); */" << endl;
639 } 639 }
640 } 640 }
641 641
642 /*
642 QList<ReferenceCount> referenceCounts; 643 QList<ReferenceCount> referenceCounts;
643 for (int i=0; i<arguments.size() + 1; ++i) { 644 for (int i=0; i<arguments.size() + 1; ++i) {
644 referenceCounts = d_function->referenceCounts(d_function->implementingClass(), 645 referenceCounts = d_function->referenceCounts(d_function->implementingClass(),
645 i == 0 ? -1 : i); 646 i == 0 ? -1 : i);
646 647
647 foreach (ReferenceCount refCount, referenceCounts) 648 foreach (ReferenceCount refCount, referenceCounts)
648 writeReferenceCount(s, refCount, i == 0 ? "this" : arguments.at(i-1)->argumentName()); 649 writeReferenceCount(s, refCount, i == 0 ? "this" : arguments.at(i-1)->argumentName());
649 } 650 }
650 651
651 referenceCounts = d_function->referenceCounts(d_function->implementingClass(), 0); 652 referenceCounts = d_function->referenceCounts(d_function->implementingClass(), 0);
653 */
654
652 AbstractMetaType *return_type = d_function->type(); 655 AbstractMetaType *return_type = d_function->type();
653 QString new_return_type = QString(d_function->typeReplaced(0)).replace('$', '.'); 656 QString new_return_type = QString(d_function->typeReplaced(0)).replace('$', '.');
654 bool has_return_type = new_return_type != "void" 657 bool has_return_type = new_return_type != "void"
655 && (!new_return_type.isEmpty() || return_type != 0); 658 && (!new_return_type.isEmpty() || return_type != 0);
656 // qtd TypeSystem::Ownership owner = d_function->ownership(d_function->implementingClass(), TypeSystem::TargetLangCode, 0); 659 // qtd TypeSystem::Ownership owner = d_function->ownership(d_function->implementingClass(), TypeSystem::TargetLangCode, 0);
878 TypeSystem::Ownership owner = d_function->ownership(d_function->implementingClass(), TypeSystem::TargetLangCode, -1); 881 TypeSystem::Ownership owner = d_function->ownership(d_function->implementingClass(), TypeSystem::TargetLangCode, -1);
879 if (owner != TypeSystem::InvalidOwnership && d_function->isConstructor()) 882 if (owner != TypeSystem::InvalidOwnership && d_function->isConstructor())
880 s << INDENT << "this." << function_call_for_ownership(owner) << ";" << endl; 883 s << INDENT << "this." << function_call_for_ownership(owner) << ";" << endl;
881 } 884 }
882 885
883 // return value marschalling 886 // return value marshalling
884 if(return_type) { 887 if(return_type) {
885 if (!returnImmediately && !d_function->storeResult()) { 888 if (!returnImmediately && !d_function->storeResult()) {
886 s << INDENT; 889 s << INDENT;
887 QString modified_type = d_function->typeReplaced(0); 890 QString modified_type = d_function->typeReplaced(0);
888 if (modified_type.isEmpty()) 891 if (modified_type.isEmpty())
890 else 893 else
891 s << modified_type.replace('$', '.'); 894 s << modified_type.replace('$', '.');
892 s << " __d_return_value = "; 895 s << " __d_return_value = ";
893 } 896 }
894 897
895 if ( ( has_return_type && d_function->argumentReplaced(0).isEmpty() )) // qtd 898 if(return_type->isQObject())
896 { 899 s << return_type->name() << ".__wrap(ret);" << endl;
897 if(return_type->isQObject()) 900
898 s << return_type->name() << ".__getObject(ret);" << endl; 901
899 } 902 if (return_type->isValue() && !return_type->typeEntry()->isStructInD()
900 903 || return_type->isNativePointer() && return_type->typeEntry()->isValue()
901 if (return_type->isValue() && !return_type->typeEntry()->isStructInD()) 904 || return_type->name() == "QVariant")
902 s << "new " << return_type->name() << "(ret);" << endl; 905 s << "new " << return_type->name() << "(ret);" << endl;
903 906
904 if (return_type->isVariant())
905 s << "new QVariant(ret);" << endl;
906
907 if (return_type->isNativePointer() && return_type->typeEntry()->isValue())
908 s << "new " << return_type->name() << "(ret, QtdObjectFlags.nativeOwnership);" << endl;
909
910 if (return_type->isObject()) { 907 if (return_type->isObject()) {
911 if(d_function->storeResult()) 908 if(d_function->storeResult())
912 s << INDENT << QString("__m_%1.__nativeId = ret;").arg(d_function->name()) << endl 909 {
913 << INDENT << QString("return __m_%1;").arg(d_function->name()) << endl; 910 QString fieldName = QString("__m_%1;").arg(d_function->name());
911 s << INDENT << "if (!" << fieldName << " || " << fieldName << ".__nativeId != ret) {" << endl
912 << INDENT << " " << fieldName << " = " << return_type->name() << ".__wrap(ret);" << endl
913 << INDENT << "return " << fieldName << ";" << endl;
914 }
914 else 915 else
915 s << "qtd_" << return_type->name() << "_from_ptr(ret);" << endl; 916 s << return_type->name() << ".__wrap(ret);" << endl;
916 s << endl;
917 } 917 }
918 918
919 if (return_type->isArray()) { 919 if (return_type->isArray()) {
920 s << "ret[0 .. " << return_type->arrayElementCount() << "];" << endl; 920 s << "ret[0 .. " << return_type->arrayElementCount() << "];" << endl;
921 } 921 }
922 922
923 /*
923 foreach (ReferenceCount referenceCount, referenceCounts) { 924 foreach (ReferenceCount referenceCount, referenceCounts) {
924 writeReferenceCount(s, referenceCount, "__d_return_value"); 925 writeReferenceCount(s, referenceCount, "__d_return_value");
925 } 926 }
927 */
926 928
927 if (!returnImmediately && !d_function->storeResult()) 929 if (!returnImmediately && !d_function->storeResult())
928 s << INDENT << "return __d_return_value;" << endl; 930 s << INDENT << "return __d_return_value;" << endl;
929 } 931 }
930 writeInjectedCode(s, d_function, CodeSnip::End); 932 writeInjectedCode(s, d_function, CodeSnip::End);
1680 void DGenerator::writeDestructor(QTextStream &s, const AbstractMetaClass *d_class) 1682 void DGenerator::writeDestructor(QTextStream &s, const AbstractMetaClass *d_class)
1681 { 1683 {
1682 if (!d_class->hasConstructors()) 1684 if (!d_class->hasConstructors())
1683 return; 1685 return;
1684 1686
1685 bool isTheQObject = d_class->name() == "QObject"; 1687 s << " override void __deleteNative() {" << endl
1686 if (isTheQObject || !d_class->isQObject()) 1688 << " qtd_" << d_class->name() << "_destructor(__nativeId);" << endl
1687 { 1689 << " }" << endl;
1688 s << INDENT << "protected override void __deleteNative() {" << endl; 1690 }
1689 { 1691
1690 if (isTheQObject) 1692 void DGenerator::writeOwnershipSetter(QTextStream &s, const AbstractMetaClass *d_class)
1691 s << INDENT << "qtd_delete_qobject(__nativeId);" << endl;
1692 else if (!d_class->isQObject())
1693 s << INDENT << "qtd_" << d_class->name() << "_destructor(__nativeId);" << endl;
1694 }
1695 s << INDENT << "}" << endl << endl;
1696 }
1697 }
1698
1699 void DGenerator::writeFlagsSetter(QTextStream &s, const AbstractMetaClass *d_class)
1700 { 1693 {
1701 if (d_class->isInterface() || d_class->isNamespace()) 1694 if (d_class->isInterface() || d_class->isNamespace())
1702 s << INDENT << "void __setFlags(QtdObjectFlags flags, bool val);"; 1695 s << INDENT << "void __nativeOwnership(bool value);";
1703 else // COMPILER BUG: 1696 else if (d_class->typeEntry()->isObject())
1704 s << INDENT << "void __setFlags(QtdObjectFlags flags, bool val) { super.__setFlags(flags, val); }"; 1697 {// COMPILER BUG:
1698 s << INDENT << "void __nativeOwnership(bool value) { super.__nativeOwnership = value; }";
1699 }
1705 } 1700 }
1706 1701
1707 void DGenerator::writeSignalHandlers(QTextStream &s, const AbstractMetaClass *d_class) 1702 void DGenerator::writeSignalHandlers(QTextStream &s, const AbstractMetaClass *d_class)
1708 { 1703 {
1709 AbstractMetaFunctionList signal_funcs = signalFunctions(d_class); 1704 AbstractMetaFunctionList signal_funcs = signalFunctions(d_class);
1761 QString type_name = type->name(); 1756 QString type_name = type->name();
1762 const ComplexTypeEntry *ctype = static_cast<const ComplexTypeEntry *>(type->typeEntry()); 1757 const ComplexTypeEntry *ctype = static_cast<const ComplexTypeEntry *>(type->typeEntry());
1763 if(ctype->isAbstract()) 1758 if(ctype->isAbstract())
1764 type_name = type_name + "_ConcreteWrapper"; 1759 type_name = type_name + "_ConcreteWrapper";
1765 s << INDENT << "scope " << arg_name << " = new " << type_name 1760 s << INDENT << "scope " << arg_name << " = new " << type_name
1766 << "(cast(void*)(" << arg_ptr << "), QtdObjectFlags.nativeOwnership);" << endl; 1761 << "(cast(void*)(" << arg_ptr << "), QtdObjectFlags.skipNativeDelete);" << endl;
1767 } 1762 }
1768 s << endl; 1763 s << endl;
1769 } 1764 }
1770 // s << INDENT << "Stdout(\"" << d_class->name() << "\", \"" << signal->name() << "\").newline;" << endl; 1765 // s << INDENT << "Stdout(\"" << d_class->name() << "\", \"" << signal->name() << "\").newline;" << endl;
1771 s << INDENT << "d_object." << signal->name() << ".emit("; 1766 s << INDENT << "d_object." << signal->name() << ".emit(";
1783 } 1778 }
1784 } 1779 }
1785 1780
1786 void DGenerator::write(QTextStream &s, const AbstractMetaClass *d_class) 1781 void DGenerator::write(QTextStream &s, const AbstractMetaClass *d_class)
1787 { 1782 {
1788 ReportHandler::debugSparse("Generating class: " + d_class->fullName()); 1783 ReportHandler::debugSparse("Generating class: " + d_class->fullName());
1789 1784
1790 bool fakeClass = d_class->attributes() & AbstractMetaAttributes::Fake; 1785 bool fakeClass = d_class->attributes() & AbstractMetaAttributes::Fake;
1791 1786
1792 1787
1793 QString auxModName = d_class->package() + "." + d_class->name() + "_aux"; 1788 QString auxModName = d_class->package() + "." + d_class->name() + "_aux";
1794 FileOut auxFile(outputDirectory() + "/" + subDirectoryForClass(d_class) + "/" + d_class->name() + "_aux.d"); 1789 FileOut auxFile(outputDirectory() + "/" + subDirectoryForClass(d_class) + "/" + d_class->name() + "_aux.d");
1795 auxFile.isDone = true; 1790 auxFile.isDone = true;
1796 auxFile.stream << "module " << auxModName << ";" << endl << endl; 1791 auxFile.stream << "module " << auxModName << ";" << endl << endl;
1797 1792
1798 bool staticInit = d_class->isQObject() || (cpp_shared && d_class->generateShellClass() && !d_class->isInterface()); 1793 bool staticInit = (d_class->typeEntry()->isObject() && d_class->hasVirtualFunctions()) || (cpp_shared && d_class->generateShellClass() && !d_class->isInterface());
1799 if (staticInit) 1794 if (staticInit)
1800 { 1795 {
1801 auxFile.isDone = false; 1796 auxFile.isDone = false;
1802 auxFile.stream << "extern(C) void static_init_" << d_class->name() << "();" << endl; 1797 auxFile.stream << "extern(C) void static_init_" << d_class->name() << "();" << endl;
1803 auxFile.stream << "static this() { static_init_" << d_class->name() << "; }" << endl << endl; 1798 auxFile.stream << "static this() { static_init_" << d_class->name() << "; }" << endl << endl;
1899 } 1894 }
1900 1895
1901 if (!m_isRecursive) { 1896 if (!m_isRecursive) {
1902 s << "public import qt.QGlobal;" << endl 1897 s << "public import qt.QGlobal;" << endl
1903 << "public import qt.core.Qt;" << endl 1898 << "public import qt.core.Qt;" << endl
1904 << "private import qt.QtdObject;" << endl 1899 << "public import qt.QtdObject;" << endl
1905 << "private import qt.core.QString;" << endl 1900 << "private import qt.core.QString;" << endl
1906 << "private import qt.qtd.Array;" << endl; 1901 << "private import qt.qtd.Array;" << endl;
1907 if (d_class->isQObject()) { 1902 if (d_class->isQObject()) {
1908 s << "public import qt.Signal;" << endl 1903 s << "public import qt.Signal;" << endl;
1909 << "public import qt.core.QMetaObject;" << endl
1910 << "public import qt.qtd.Traits;" << endl;
1911
1912 if (d_class->name() != "QObject") 1904 if (d_class->name() != "QObject")
1913 s << "public import qt.core.QObject;" << endl; 1905 s << "public import qt.core.QObject;" << endl;
1914 } 1906 }
1907
1908 if (d_class->typeEntry()->isObject() && d_class->hasVirtualFunctions())
1909 s << "public import qt.core.QMetaObject;" << endl;
1915 1910
1916 // qtd2 hack! 1911 // qtd2 hack!
1917 if (d_class->name() == "QCoreApplication") 1912 if (d_class->name() == "QCoreApplication")
1918 s << "private import qt.core.ArrayOps;" << endl; 1913 s << "private import qt.core.ArrayOps;" << endl;
1919 else if (d_class->name() == "QApplication") 1914 else if (d_class->name() == "QApplication")
2001 } 1996 }
2002 s << ">"; 1997 s << ">";
2003 } 1998 }
2004 1999
2005 if (!d_class->isNamespace() && !d_class->isInterface()) { 2000 if (!d_class->isNamespace() && !d_class->isInterface()) {
2006 if (!d_class->baseClassName().isEmpty()) { 2001 s << " : ";
2007 s << " : " << d_class->baseClass()->name(); 2002 if (d_class->baseClass()) {
2008 } else { 2003 s << d_class->baseClass()->name();
2009 QString sc = type->defaultSuperclass(); 2004 } else {
2010 if ((sc != d_class->name()) && !sc.isEmpty()) 2005 if (d_class->typeEntry()->isValue())
2011 s << " : " << sc; 2006 s << "QtdObjectBase";
2007 else if (d_class->typeEntry()->isObject())
2008 s << "QtdObject";
2009
2012 } 2010 }
2013 }/* qtd else if (d_class->isInterface()) { 2011 }/* qtd else if (d_class->isInterface()) {
2014 s << " extends QtJambiInterface"; 2012 s << " extends QtJambiInterface";
2015 }*/ 2013 }*/
2016 2014
2192 // s << function->minimalSignature() << endl; 2190 // s << function->minimalSignature() << endl;
2193 } 2191 }
2194 if(d_class->isInterface()) 2192 if(d_class->isInterface())
2195 s << endl << INDENT << "public void* __ptr_" << d_class->name() << "();" << endl << endl; 2193 s << endl << INDENT << "public void* __ptr_" << d_class->name() << "();" << endl << endl;
2196 2194
2197
2198 s << "// Field accessors" << endl; 2195 s << "// Field accessors" << endl;
2199 // Field accessors 2196 // Field accessors
2200 AbstractMetaFieldList fields = d_class->fields(); 2197 AbstractMetaFieldList fields = d_class->fields();
2201 foreach (const AbstractMetaField *field, fields) { 2198 foreach (const AbstractMetaField *field, fields) {
2202 if (field->wasPublic() || (field->wasProtected() && !d_class->isFinal())) 2199 if (field->wasPublic() || (field->wasProtected() && !d_class->isFinal()))
2203 writeFieldAccessors(s, field); 2200 writeFieldAccessors(s, field);
2204 } 2201 }
2205 2202
2206 /* qtd 2203 if (d_class->typeEntry()->isObject() && d_class->hasVirtualFunctions())
2207 2204 {
2208 // the static fromNativePointer function... 2205 if (d_class->isQObject())
2209 if (!d_class->isNamespace() && !d_class->isInterface() && !fakeClass) { 2206 writeQObjectFunctions(s, d_class);
2210 s << endl 2207 else
2211 << INDENT << "public static native " << d_class->name() << " fromNativePointer(" 2208 writeObjectFunctions(s, d_class);
2212 << "QNativePointer nativePointer);" << endl; 2209
2213 } 2210 s << " static QtdObjectBase __createWrapper(void* nativeId, QtdObjectFlags flags) {" << endl
2214 2211 << " return new(flags) " << d_class->name() << "(nativeId, flags);" << endl
2215 if (d_class->isQObject()) { 2212 << " }" << endl << endl;
2216 s << endl; 2213 }
2217 if (TypeDatabase::instance()->includeEclipseWarnings()) 2214
2218 s << INDENT << "@SuppressWarnings(\"unused\")" << endl; 2215 if (d_class->hasPublicDestructor() && (!d_class->baseClass() || !d_class->hasVirtualFunctions()))
2219 2216 writeDestructor(s, d_class);
2220 s << INDENT << "private static native long originalMetaObject();" << endl;
2221 }
2222
2223 // The __qt_signalInitialization() function
2224 if (signal_funcs.size() > 0) {
2225 s << endl
2226 << INDENT << "@Override" << endl
2227 << INDENT << "@QtBlockedSlot protected boolean __qt_signalInitialization(String name) {" << endl
2228 << INDENT << " return (__qt_signalInitialization(nativeId(), name)" << endl
2229 << INDENT << " || super.__qt_signalInitialization(name));" << endl
2230 << INDENT << "}" << endl
2231 << endl
2232 << INDENT << "@QtBlockedSlot" << endl
2233 << INDENT << "private native boolean __qt_signalInitialization(long ptr, String name);" << endl;
2234 }
2235 */
2236 if (d_class->isQObject())
2237 writeQObjectFunctions(s, d_class);
2238 2217
2239 // Add dummy constructor for use when constructing subclasses 2218 // Add dummy constructor for use when constructing subclasses
2240 if (!d_class->isNamespace() && !d_class->isInterface() && !fakeClass) { 2219 if (!d_class->isNamespace() && !d_class->isInterface() && !fakeClass) {
2241 s << endl 2220 s << endl
2242 << INDENT << "public " 2221 << INDENT << "public "
2243 << "this"; 2222 << "this";
2244 2223
2245 2224
2246 Indentation indent(INDENT); 2225 Indentation indent(INDENT);
2247 2226
2248 s << "(void* native_id, QtdObjectFlags flags = QtdObjectFlags.none) {" << endl 2227
2249 << INDENT << "super(native_id, flags);" << endl; 2228 QString flags = d_class->hasVirtualFunctions() && d_class->typeEntry()->isObject() ? "QtdObjectFlags.hasDId" : "QtdObjectFlags.none";
2250 2229 s << "(void* nativeId, QtdObjectFlags flags = " << flags << ") {" << endl
2230 << INDENT << "super(nativeId, flags);" << endl;
2231
2251 if (d_class->name() == "QObject") 2232 if (d_class->name() == "QObject")
2252 { 2233 {
2253 // To prevent GC from collecting the object, add it to the statically rooted linked list 2234 s << INDENT << "if (!(__flags & QtdObjectFlags.hasDId))" << endl
2254 s << INDENT << " __next = __root;" << endl 2235 << INDENT << " __createEntity;" << endl;
2255 << INDENT << " __root = this;" << endl 2236 }
2256 << INDENT << " if (__next) {" << endl 2237
2257 << INDENT << " __next.__prev = this;" << endl 2238
2258 << INDENT << " }" << endl << endl;
2259 }
2260
2261 /* 2239 /*
2262 if (cpp_shared) { 2240 if (cpp_shared) {
2263 if (d_class->generateShellClass() && !d_class->isInterface()) 2241 if (d_class->generateShellClass() && !d_class->isInterface())
2264 s << INDENT << "if (!static_inited)" << endl 2242 s << INDENT << "if (!static_inited)" << endl
2265 << INDENT << " static_init_" << d_class->name() << "();" << endl << endl; 2243 << INDENT << " static_init_" << d_class->name() << "();" << endl << endl;
2266 } 2244 }
2267 */ 2245 */
2268 2246
2247
2269 // customized store-result instances 2248 // customized store-result instances
2270 d_funcs = d_class->functionsInTargetLang(); 2249 d_funcs = d_class->functionsInTargetLang();
2271 for (int i=0; i<d_funcs.size(); ++i) { 2250 for (int i=0; i<d_funcs.size(); ++i) {
2272 AbstractMetaFunction *d_function = d_funcs.at(i); 2251 AbstractMetaFunction *d_function = d_funcs.at(i);
2273 uint included_attributes = 0; 2252 uint included_attributes = 0;
2283 QString type_name = d_function->type()->name(); 2262 QString type_name = d_function->type()->name();
2284 const ComplexTypeEntry *ctype = static_cast<const ComplexTypeEntry *>(d_function->type()->typeEntry()); 2263 const ComplexTypeEntry *ctype = static_cast<const ComplexTypeEntry *>(d_function->type()->typeEntry());
2285 if(ctype->isAbstract()) 2264 if(ctype->isAbstract())
2286 type_name = type_name + "_ConcreteWrapper"; 2265 type_name = type_name + "_ConcreteWrapper";
2287 2266
2288 s << INDENT << " __m_" << d_function->name() << " = new " 2267 s << INDENT << " __m_" << d_function->name() << ";" << endl;
2289 << type_name << "(cast(void*)null);" << endl;
2290 if (d_function->type()->isQObject())
2291 s << INDENT << " __m_" << d_function->name() << ".__setFlags(QtdObjectFlags.nativeOwnership, true);" << endl;
2292 } 2268 }
2293 } 2269 }
2294 2270
2295 // pointers to native interface objects for classes that implement interfaces 2271 // pointers to native interface objects for classes that implement interfaces
2296 // initializing 2272 // initializing
2338 AbstractMetaClass *iface = interfaces.at(i); 2314 AbstractMetaClass *iface = interfaces.at(i);
2339 2315
2340 s << INDENT << "private void* __m_ptr_" << iface->name() << ";" << endl 2316 s << INDENT << "private void* __m_ptr_" << iface->name() << ";" << endl
2341 << INDENT << "public void* __ptr_" << iface->name() << "() { return __m_ptr_" << iface->name() << "; }" << endl << endl; 2317 << INDENT << "public void* __ptr_" << iface->name() << "() { return __m_ptr_" << iface->name() << "; }" << endl << endl;
2342 } 2318 }
2343 } 2319 }
2344
2345 writeDestructor(s, d_class);
2346 } 2320 }
2347 2321
2348 /* qtd 2322 /* qtd
2349 // Add a function that converts an array of the value type to a QNativePointer 2323 // Add a function that converts an array of the value type to a QNativePointer
2350 if (d_class->typeEntry()->isValue() && !fakeClass) { 2324 if (d_class->typeEntry()->isValue() && !fakeClass) {
2369 } 2343 }
2370 */ 2344 */
2371 2345
2372 /* qtd writeJavaLangObjectOverrideFunctions(s, d_class); 2346 /* qtd writeJavaLangObjectOverrideFunctions(s, d_class);
2373 */ 2347 */
2374 writeFlagsSetter(s, d_class); 2348 writeOwnershipSetter(s, d_class);
2375 s << "// Injected code in class" << endl; 2349 s << "// Injected code in class" << endl;
2376 writeExtraFunctions(s, d_class); 2350 writeExtraFunctions(s, d_class);
2377 // qtd2 writeToStringFunction(s, d_class); 2351 // qtd2 writeToStringFunction(s, d_class);
2378 /* qtd 2352 /* qtd
2379 if (d_class->hasCloneOperator()) { 2353 if (d_class->hasCloneOperator()) {
2409 s << endl; 2383 s << endl;
2410 2384
2411 s << INDENT << "public class " << d_class->name() << "_ConcreteWrapper : " << d_class->name() << " {" << endl; 2385 s << INDENT << "public class " << d_class->name() << "_ConcreteWrapper : " << d_class->name() << " {" << endl;
2412 2386
2413 { 2387 {
2414 Indentation indent(INDENT); 2388 Indentation indent(INDENT);
2415 QString hasShellFlag = d_class->generateShellClass() ? " | QtdObjectFlags.hasShell" : ""; 2389 s << INDENT << "public this(void* native_id, QtdObjectFlags flags) {" << endl
2416 s << INDENT << "public this(void* native_id, QtdObjectFlags flags = QtdObjectFlags.nativeOwnership) {" << endl
2417 << INDENT << " super(native_id, flags);" << endl << endl; 2390 << INDENT << " super(native_id, flags);" << endl << endl;
2418 2391
2419 /******************!!!DUPLICATE!!!*********************/ 2392 /******************!!!DUPLICATE!!!*********************/
2420 d_funcs = d_class->functionsInTargetLang(); 2393 d_funcs = d_class->functionsInTargetLang();
2421 for (int i=0; i<d_funcs.size(); ++i) { 2394 for (int i=0; i<d_funcs.size(); ++i) {
2430 QString type_name = d_function->type()->name(); 2403 QString type_name = d_function->type()->name();
2431 const ComplexTypeEntry *ctype = static_cast<const ComplexTypeEntry *>(d_function->type()->typeEntry()); 2404 const ComplexTypeEntry *ctype = static_cast<const ComplexTypeEntry *>(d_function->type()->typeEntry());
2432 if(ctype->isAbstract()) 2405 if(ctype->isAbstract())
2433 type_name = type_name + "_ConcreteWrapper"; 2406 type_name = type_name + "_ConcreteWrapper";
2434 s << INDENT << " __m_" << d_function->name() << " = new " 2407 s << INDENT << " __m_" << d_function->name() << " = new "
2435 << type_name << "(cast(void*)null);" << endl; 2408 << type_name << "(cast(void*)null);" << endl;
2436 if (d_function->type()->isQObject())
2437 s << INDENT << " __m_" << d_function->name() << ".__setFlags(QtdObjectFlags.nativeOwnership, true);" << endl;
2438 } 2409 }
2439 } 2410 }
2440 2411
2441 s << INDENT << "}" << endl << endl; 2412 s << INDENT << "}" << endl << endl;
2442 2413
2487 } 2458 }
2488 } 2459 }
2489 s << INDENT << "}" << endl << endl; 2460 s << INDENT << "}" << endl << endl;
2490 } 2461 }
2491 2462
2492 if (d_class->generateShellClass()) { // qtd2 2463 if (d_class->typeEntry()->isObject() && d_class->hasVirtualFunctions())
2493 if (d_class->hasVirtualFunctions() 2464 {
2494 && (d_class->typeEntry()->isObject() && !d_class->typeEntry()->isQObject()) ) 2465 if (!d_class->typeEntry()->isQObject())
2495 s << endl << "extern (C) void *__" << d_class->name() << "_entity(void *q_ptr);" << endl << endl; 2466 {
2496 } 2467 s << "extern(C) void* qtd_" << d_class->name() << "_dId(void *q_ptr);" << endl << endl;
2497 2468 s << "extern(C) void* qtd_" << d_class->name() << "_typeId(void* nativeId);" << endl;
2469 }
2470
2471 s << "extern(C) void* qtd_" << d_class->name() << "_staticTypeId();" << endl;
2472 }
2498 2473
2499 // if (d_class->needsConversionFunc) 2474 // if (d_class->needsConversionFunc)
2500 writeConversionFunction(s, d_class); 2475 // writeConversionFunction(s, d_class);
2501 2476
2502 if (d_class->hasConstructors() && !d_class->isQObject()) 2477 if (d_class->hasConstructors())
2503 s << "extern (C) void qtd_" << d_class->name() << "_destructor(void *ptr);" << endl << endl; 2478 s << "extern(C) void qtd_" << d_class->name() << "_destructor(void *ptr);" << endl << endl;
2504 2479
2505 // qtd 2480 // qtd
2506 s << endl << "// C wrappers" << endl; 2481 s << endl << "// C wrappers" << endl;
2507 d_funcs = d_class->functionsInTargetLang(); 2482 d_funcs = d_class->functionsInTargetLang();
2508 if (!d_class->isInterface()) 2483 if (!d_class->isInterface())
2523 if (d_function->implementingClass() != d_class) { 2498 if (d_function->implementingClass() != d_class) {
2524 s << endl; 2499 s << endl;
2525 writePrivateNativeFunction(s, d_function); 2500 writePrivateNativeFunction(s, d_function);
2526 } 2501 }
2527 } 2502 }
2528 } 2503 }
2529 2504
2530 2505
2531 foreach (const AbstractMetaField *field, fields) { 2506 foreach (const AbstractMetaField *field, fields) {
2532 if (field->wasPublic() || (field->wasProtected() && !d_class->isFinal())) 2507 if (field->wasPublic() || (field->wasProtected() && !d_class->isFinal()))
2533 writeNativeField(s, field); 2508 writeNativeField(s, field);
2556 << QString("_initCallBacks(%1);").arg(initArgs) << endl << endl; 2531 << QString("_initCallBacks(%1);").arg(initArgs) << endl << endl;
2557 } 2532 }
2558 2533
2559 s << "extern(C) void static_init_" << d_class->name() << "() {" << endl; 2534 s << "extern(C) void static_init_" << d_class->name() << "() {" << endl;
2560 2535
2561 if (d_class->isQObject()) { 2536 if (d_class->typeEntry()->isObject() && d_class->hasVirtualFunctions()) {
2562 s << INDENT << "if (!" << d_class->name() << "._staticMetaObject) " << endl 2537 s << INDENT << "if (!" << d_class->name() << "._staticMetaObject) " << endl
2563 << INDENT << " " << d_class->name() << ".createStaticMetaObject;" << endl << endl; 2538 << INDENT << " " << d_class->name() << ".createStaticMetaObject;" << endl << endl;
2564 } 2539 }
2565 2540
2566 if (cpp_shared) { 2541 if (cpp_shared) {
2618 s << "private extern(C) void* qtd_" << d_class->name() << "_staticMetaObject();" << endl << endl 2593 s << "private extern(C) void* qtd_" << d_class->name() << "_staticMetaObject();" << endl << endl
2619 << "private extern(C) void qtd_" << d_class->name() << "_createEntity(void* nativeId, void* dId);" << endl << endl; 2594 << "private extern(C) void qtd_" << d_class->name() << "_createEntity(void* nativeId, void* dId);" << endl << endl;
2620 } 2595 }
2621 } 2596 }
2622 2597
2598 /*
2623 void DGenerator::writeConversionFunction(QTextStream &s, const AbstractMetaClass *d_class) 2599 void DGenerator::writeConversionFunction(QTextStream &s, const AbstractMetaClass *d_class)
2624 { 2600 {
2625 const ComplexTypeEntry *ctype = d_class->typeEntry(); 2601 const ComplexTypeEntry *ctype = d_class->typeEntry();
2626 if(ctype->isQObject() || !ctype->isObject()) 2602 if(ctype->isQObject() || !ctype->isObject())
2627 return; 2603 return;
2638 type_name = ctype->targetLangName() + "_ConcreteWrapper"; 2614 type_name = ctype->targetLangName() + "_ConcreteWrapper";
2639 2615
2640 // if class has virtual functions then it has classname_entity function so 2616 // if class has virtual functions then it has classname_entity function so
2641 // we can look for D Object pointer. otherwise create new wrapper 2617 // we can look for D Object pointer. otherwise create new wrapper
2642 if (d_class->hasVirtualFunctions()) { 2618 if (d_class->hasVirtualFunctions()) {
2643 s << INDENT << "void* d_obj = __" << ctype->targetLangName() << "_entity(ret);" << endl 2619 s << INDENT << "void* d_obj = qtd_" << ctype->targetLangName() << "_dId(ret);" << endl
2644 << INDENT << "if (d_obj !is null) {" << endl 2620 << INDENT << "if (d_obj !is null) {" << endl
2645 << INDENT << " auto d_obj_ref = cast (Object) d_obj;" << endl 2621 << INDENT << " auto d_obj_ref = cast (Object) d_obj;" << endl
2646 << INDENT << " return cast(" << return_type_name << ") d_obj_ref;" << endl 2622 << INDENT << " return cast(" << return_type_name << ") d_obj_ref;" << endl
2647 << INDENT << "} else {" << endl 2623 << INDENT << "} else {" << endl
2648 << INDENT << " auto return_value = new " << type_name << "(ret, QtdObjectFlags.nativeOwnership);" << endl 2624 << INDENT << " auto return_value = new " << type_name << "(ret, QtdObjectFlags.skipNativeDelete);" << endl
2649 << INDENT << " return return_value;" << endl 2625 << INDENT << " return return_value;" << endl
2650 << INDENT << "}" << endl; 2626 << INDENT << "}" << endl;
2651 } else { 2627 } else {
2652 s << INDENT << "auto return_value = new " << type_name << "(ret, QtdObjectFlags.nativeOwnership);" << endl 2628 s << INDENT << "auto return_value = new " << type_name << "(ret, QtdObjectFlags.skipNativeDelete);" << endl
2653 << INDENT << "return return_value;" << endl; 2629 << INDENT << "return return_value;" << endl;
2654 } 2630 }
2655 s << "}" << endl << endl; 2631 s << "}" << endl << endl;
2632 }
2633 */
2634
2635 // Polymorphic non-QObject
2636 void DGenerator::writeObjectFunctions(QTextStream &s, const AbstractMetaClass *d_class)
2637 {
2638 QString rootClassName = d_class->rootClass()->name();
2639 QString concreteArg;
2640 if (d_class->isAbstract())
2641 concreteArg += ", " + d_class->name() + "_ConcreteWrapper";
2642
2643 s << " private static QtdMetaObject _staticMetaObject;" << endl
2644 //<< " private static QtdMetaObject[void*] _nativeToTargetMap;" << endl
2645
2646 << " protected static void createStaticMetaObject() {" << endl
2647 << " assert(!_staticMetaObject);" << endl
2648 << " QtdMetaObject base;" << endl;
2649
2650 if (d_class->baseClass())
2651 {
2652 QString baseName = d_class->baseClassName();
2653 s << " if (!" << baseName << "._staticMetaObject)" << endl
2654 << " " << baseName << ".createStaticMetaObject;" << endl
2655 << " base = " << baseName << "._staticMetaObject;" << endl;
2656 }
2657
2658 s << " _staticMetaObject = new QtdMetaObject(qtd_" << d_class->name() << "_staticTypeId, base);" << endl
2659 << " _staticMetaObject.construct!(" << d_class->name() << concreteArg << ");" << endl
2660 << " }" << endl << endl
2661
2662 << " QtdMetaObject metaObject() {" << endl
2663 << " return _staticMetaObject;" << endl
2664 << " }" << endl << endl
2665
2666 << " static QtdMetaObject staticMetaObject() {" << endl
2667 << " return _staticMetaObject;" << endl
2668 << " }" << endl << endl
2669
2670 << " static " << d_class->name() << " __wrap(void* nativeId, QtdObjectFlags flags = QtdObjectFlags.skipNativeDelete) {" << endl
2671 << " auto obj = cast(" << d_class->name() << ") qtd_" << rootClassName << "_dId(nativeId);" << endl
2672 << " if (!obj)" << endl
2673 << " obj = static_cast!(" << d_class->name() << ")(_staticMetaObject.wrap(nativeId,"
2674 "qtd_" << rootClassName << "_typeId(nativeId), flags));" << endl
2675 << " return obj;" << endl
2676 << " }" << endl << endl;
2677 /*
2678 << " overrive protected void __addMapping() {" << endl
2679 << " _nativeToTargetMap[__nativeId] = this;" << endl
2680 << " }" << endl << endl
2681
2682 << " override protected void __removeMapping() {" << endl
2683 << " _nativeToTargetMap.remove(__nativeId);" << endl
2684 << " }" << endl << endl
2685 */
2656 } 2686 }
2657 2687
2658 void DGenerator::writeQObjectFunctions(QTextStream &s, const AbstractMetaClass *d_class) 2688 void DGenerator::writeQObjectFunctions(QTextStream &s, const AbstractMetaClass *d_class)
2659 { 2689 {
2660 QString concreteArg; 2690 QString concreteArg;
2684 2714
2685 << " static QMetaObject staticMetaObject() {" << endl 2715 << " static QMetaObject staticMetaObject() {" << endl
2686 << " return _staticMetaObject;" << endl 2716 << " return _staticMetaObject;" << endl
2687 << " }" << endl << endl 2717 << " }" << endl << endl
2688 2718
2689 << " static " << d_class->name() << " __getObject(void* nativeId) {" << endl 2719 << " static " << d_class->name() << " __wrap(void* nativeId, QtdObjectFlags flags = QtdObjectFlags.none) {" << endl
2690 << " return static_cast!(" << d_class->name() << ")(_staticMetaObject.getObject(nativeId));" << endl 2720 << " return static_cast!(" << d_class->name() << ")(_staticMetaObject.wrap(nativeId, flags));" << endl
2691 << " }" << endl << endl 2721 << " }" << endl << endl
2692 2722
2693 << " static void __createEntity(void* nativeId, void* dId) {" << endl 2723 << " void __createEntity() {" << endl
2694 << " return qtd_" << d_class->name() << "_createEntity(nativeId, dId);" << endl 2724 << " return qtd_" << d_class->name() << "_createEntity(__nativeId, cast(void*)this);" << endl
2695 << " }" << endl << endl; 2725 << " }" << endl << endl;
2696 } 2726 }
2697 2727
2698 /* 2728 /*
2699 void DGenerator::writeMarshallFunction(QTextStream &s, const AbstractMetaClass *d_class) 2729 void DGenerator::writeMarshallFunction(QTextStream &s, const AbstractMetaClass *d_class)
2700 { 2730 {
2701 2731
2702 } 2732 }
2703 */ 2733 */
2704 void DGenerator::marshallFromCppToD(QTextStream &s, const ComplexTypeEntry* ctype) 2734
2705 { 2735 // Returns the name of the resulting variable
2706 if(ctype->isQObject()) { 2736 QString DGenerator::marshalToD(QTextStream &s, QString argName, const TypeEntry* type, MarshalFlags flags)
2707 QString type_name = ctype->name(); 2737 {
2708 if (ctype->isAbstract()) 2738 if (type->isBasicValue())
2709 type_name += "_ConcreteWrapper"; 2739 return argName;
2710 s << "return " << type_name << ".__getObject(ret);" << endl; 2740
2711 } else if (ctype->isValue() && !ctype->isStructInD()) { 2741 QString qtdObjFlags = "QtdObjectFlags.none";
2712 s << INDENT << "return new " << ctype->name() << "(ret);" << endl; 2742 const ObjectTypeEntry *ctype = 0;
2713 } else if (ctype->isVariant()) { 2743 bool stackObject = false;
2714 s << INDENT << "return new QVariant(ret);" << endl; 2744
2745 if (type->isObject())
2746 ctype = static_cast<const ObjectTypeEntry *>(ctype);
2747
2748 if (type->isValue())
2749 flags |= MarshalScope;
2750
2751 if (flags & MarshalScope)
2752 {
2753 if (type->isObject() && type->hasVirtualDestructor())
2754 {
2755 qtdObjectFlags += " | QtdObjectFlags.stackAllocated";
2756 bool stackObject = true;
2757 }
2758 else
2759 s << INDENT << "scope ";
2760
2761 qtdObjectFlags += "| QtdObjectFlags.skipNativeDelete";
2762 }
2763 else
2764 s << INDENT << "auto ";
2765
2766 s << resultName << " = ";
2767
2768
2769 if (ctype->isObject() && type->hasVirtualDestructor()) {
2770 exp = type->name() + ".__wrap(ret);" + endl;
2771 }
2772 else if (type->isValue())
2773 {
2774 if (type->actualIndirections() == 0)
2775 s << "new " << type->name() << "(" << argName << ");" << endl;
2776 else if (type->actualIndirections() == 1)
2777 s << "new "
2778 }
2779
2780
2715 } else if (ctype->name() == "QModelIndex" || ctype->isStructInD()) { 2781 } else if (ctype->name() == "QModelIndex" || ctype->isStructInD()) {
2716 s << INDENT << "return ret;" << endl; 2782 s << INDENT << "return ret;" << endl;
2717 } else if (ctype->isObject()) { 2783 }
2718 QString type_name = ctype->name(); 2784
2719 s << "return qtd_" << type_name << "_from_ptr(ret);" << endl; 2785 if (stackObject)
2720 } 2786 {
2787 s << ""
2788 }
2789
2721 } 2790 }
2722 2791
2723 void DGenerator::writeNativeField(QTextStream &s, const AbstractMetaField *field) 2792 void DGenerator::writeNativeField(QTextStream &s, const AbstractMetaField *field)
2724 { 2793 {
2725 Q_ASSERT(field->isPublic() || field->isProtected()); 2794 Q_ASSERT(field->isPublic() || field->isProtected());
2848 s << INDENT << "string " << arg_name << "_d_ref = toUTF8(" 2917 s << INDENT << "string " << arg_name << "_d_ref = toUTF8("
2849 << arg_name << "[0.." << arg_name << "_size]);"; 2918 << arg_name << "[0.." << arg_name << "_size]);";
2850 else if (type->typeEntry()->isValue() && type->isNativePointer() && type->typeEntry()->name() == "QString") { 2919 else if (type->typeEntry()->isValue() && type->isNativePointer() && type->typeEntry()->name() == "QString") {
2851 s << INDENT << "auto " << arg_name << "_d_qstr = QString(" << arg_name << ", true);" << endl 2920 s << INDENT << "auto " << arg_name << "_d_qstr = QString(" << arg_name << ", true);" << endl
2852 << INDENT << "string " << arg_name << "_d_ref = " << arg_name << "_d_qstr.toNativeString();"; 2921 << INDENT << "string " << arg_name << "_d_ref = " << arg_name << "_d_qstr.toNativeString();";
2853 } else if(type->isVariant()) 2922 }
2854 s << INDENT << "scope " << arg_name << "_d_ref = new QVariant(" << arg_name << ", QtdObjectFlags.nativeOwnership);";
2855 else if (type->typeEntry()->isStructInD()) 2923 else if (type->typeEntry()->isStructInD())
2856 continue; 2924 continue;
2857 else if (!type->hasNativeId() && !(type->typeEntry()->isValue() && type->isNativePointer())) 2925 else if ((type->typeEntry()->isValue() && type->isNativePointer())
2926 || type->isValue() || type->isVariant()){
2927 s << INDENT << "scope " << arg_name << "_d_ref = new " << type->typeEntry()->name() << "(" << arg_name << ");" << endl;
2928
2929 (*logstream) << type->name() << ", " << argument->argumentIndex() + 1 << ", "
2930 << implementor->name() << "::" << d_function->name();
2931
2932 if (type->typeEntry()->isValue())
2933 (*logstream) << ", type entry value";
2934
2935 if (type->typeEntry()->isValue())
2936 (*logstream) << ", value";
2937
2938 if (type->isNativePointer())
2939 (*logstream) << ", native pointer";
2940
2941 const ComplexTypeEntry* ctype = dynamic_cast<const ComplexTypeEntry*>(type->typeEntry());
2942 if (ctype && ctype->hasVirtualFunctions())
2943 (*logstream) << ", polymorphic";
2944
2945 (*logstream) << endl;
2946 }
2947 else if (!type->hasNativeId())
2858 continue; 2948 continue;
2859 else if(type->isObject() 2949 else if (type->isObject() || type->isQObject())
2860 || (type->typeEntry()->isValue() && type->isNativePointer()) 2950 {
2861 || type->isValue() || type->isVariant()) { 2951 if (!type->isQObject())
2862 QString type_name = type->typeEntry()->name(); 2952 {
2863 const ComplexTypeEntry *ctype = static_cast<const ComplexTypeEntry *>(type->typeEntry()); 2953 (*logstream) << type->name() << ", " << argument->argumentIndex() + 1 << ", "
2864 if(ctype->isAbstract()) 2954 << implementor->name() << "::" << d_function->name();
2865 type_name = type_name + "_ConcreteWrapper"; 2955
2866 s << INDENT << "scope " << arg_name << "_d_ref = new " << type_name << "(" << arg_name << ", QtdObjectFlags.nativeOwnership);"; 2956 (*logstream) << ", object";
2957
2958 const ComplexTypeEntry* ctype = dynamic_cast<const ComplexTypeEntry*>(type->typeEntry());
2959 if (ctype && ctype->hasVirtualFunctions())
2960 (*logstream) << ", polymorphic";
2961
2962 (*logstream) << endl;
2963 }
2964
2965 if (((ComplexTypeEntry*)type->typeEntry())->hasVirtualFunctions() || !d_function->resetObjectAfterUse(argument->argumentIndex() + 1))
2966 s << INDENT << "auto " << arg_name << "_d_ref = " << type->typeEntry()->name() << ".__wrap(" << arg_name << ");";
2967 else
2968 s << INDENT << "scope " << arg_name << "_d_ref = new " << type->typeEntry()->name() << "(" << arg_name << ", QtdObjectFlags.skipNativeDelete);";
2867 } 2969 }
2868 else if (type->isQObject()) { 2970 else
2869 QString type_name = type->name(); 2971 qFatal(qPrintable(type->typeEntry()->name()));
2870 const ComplexTypeEntry *ctype = static_cast<const ComplexTypeEntry *>(type->typeEntry()); 2972
2871 if(ctype->isAbstract())
2872 type_name = type_name + "_ConcreteWrapper";
2873
2874 s << INDENT << "scope " << arg_name << "_d_ref = new " << type_name << "(" << arg_name << ", QtdObjectFlags.nativeOwnership);" << endl;
2875 }
2876 s << endl; 2973 s << endl;
2877 } 2974 }
2878 } 2975 }
2879 2976
2880 s << INDENT; 2977 s << INDENT;
2971 s << "}" << endl << endl; 3068 s << "}" << endl << endl;
2972 } 3069 }
2973 3070
2974 void DGenerator::generate() 3071 void DGenerator::generate()
2975 { 3072 {
3073 log = new QFile("arglog.txt");
3074 log->open(QFile::ReadWrite);
3075 logstream = new QTextStream(log);
2976 // qtd 3076 // qtd
2977 // code for including classses in 1 module for avoiding circular imports 3077 // code for including classses in 1 module for avoiding circular imports
2978 foreach (AbstractMetaClass *cls, m_classes) { 3078 foreach (AbstractMetaClass *cls, m_classes) {
2979 const ComplexTypeEntry *ctype = cls->typeEntry(); 3079 ComplexTypeEntry *ctype = const_cast<ComplexTypeEntry *>(cls->typeEntry());
2980 3080
2981 if (!cls->isInterface() && cls->isAbstract()) { 3081 if (!cls->isInterface() && cls->isAbstract())
2982 ComplexTypeEntry *ctype_m = (ComplexTypeEntry *)ctype; 3082 ctype->setAbstract(true);
2983 ctype_m->setAbstract(true); 3083
2984 } 3084 ctype->setHasVirtualFunctions(cls->hasVirtualFunctions());
2985 3085
2986 foreach(QString child, ctype->includedClasses) { 3086 foreach(QString child, ctype->includedClasses) {
2987 ComplexTypeEntry *ctype_child = TypeDatabase::instance()->findComplexType(child); 3087 ComplexTypeEntry *ctype_child = TypeDatabase::instance()->findComplexType(child);
2988 ctype_child->addedTo = cls->name(); 3088 ctype_child->addedTo = cls->name();
2989 } 3089 }
2990 3090
2991 foreach (AbstractMetaFunction *function, cls->functions()) 3091 foreach (AbstractMetaFunction *function, cls->functions())
2992 function->checkStoreResult(); 3092 function->checkStoreResult();
2993 /* we don't need this anymore
2994 // generate QObject conversion functions only those that are required
2995 AbstractMetaFunctionList d_funcs = cls->functionsInTargetLang();
2996 for (int i=0; i<d_funcs.size(); ++i) {
2997 AbstractMetaType *f_type = d_funcs.at(i)->type();
2998 if (!f_type)
2999 continue;
3000 if (f_type->isQObject() || f_type->isObject()) {
3001 const ComplexTypeEntry* cte = static_cast<const ComplexTypeEntry *>(f_type->typeEntry());
3002 AbstractMetaClass* d_class = ClassFromEntry::get(cte);
3003 if (d_class)
3004 d_class->needsConversionFunc = true;
3005 }
3006 }*/
3007 } 3093 }
3008 3094
3009 Generator::generate(); 3095 Generator::generate();
3010 3096
3011 { 3097 {
3077 s << f->implementingClass()->fullName() << " : " << f->minimalSignature() << endl; 3163 s << f->implementingClass()->fullName() << " : " << f->minimalSignature() << endl;
3078 } 3164 }
3079 } 3165 }
3080 file.close(); 3166 file.close();
3081 } 3167 }
3168
3169 delete logstream;
3170 delete log;
3082 } 3171 }
3083 3172
3084 void DGenerator::writeFunctionAttributes(QTextStream &s, const AbstractMetaFunction *d_function, 3173 void DGenerator::writeFunctionAttributes(QTextStream &s, const AbstractMetaFunction *d_function,
3085 uint included_attributes, uint excluded_attributes, 3174 uint included_attributes, uint excluded_attributes,
3086 uint options) 3175 uint options)