# HG changeset patch # User eldar # Date 1245525269 0 # Node ID ae06da58ec255b655ad74c09784c04b1857a5df6 # Parent 52da31f967f076743923f2b6746eb5da0de7fa1c fixed hacky conversion of arguments when emmitting a signal diff -r 52da31f967f0 -r ae06da58ec25 Makefile --- a/Makefile Thu Jun 18 16:09:18 2009 +0000 +++ b/Makefile Sat Jun 20 19:14:29 2009 +0000 @@ -56,7 +56,7 @@ NAME_PREFIX = qtd endif ifndef $(PACKAGES) -PACKAGES = core gui +PACKAGES = core network endif LIB_PREFIX = lib CC_INCLUDE += include $(QTDIR_INC) $(QTDIR_INC)$(SL)Qt $(QTDIR_INC)$(SL)QtCore $(QTDIR_INC)$(SL)QtGui $(QTDIR_INC)$(SL)QtOpenGL $(QTDIR_INC)$(SL)QtSvg @@ -151,7 +151,7 @@ cd generator && qmake && $(MAKE) dgen: make_gen - cd generator && $(GEN) $(GEN_OPT) --d-target=$(D_TARGET) --output-directory=../ qtjambi_masterinclude.h build_gui.txt + cd generator && $(GEN) $(GEN_OPT) --d-target=$(D_TARGET) --output-directory=../ qtjambi_masterinclude.h build_network.txt ## DGenerator ## end mkdir: diff -r 52da31f967f0 -r ae06da58ec25 build/core.makefile --- a/build/core.makefile Thu Jun 18 16:09:18 2009 +0000 +++ b/build/core.makefile Sat Jun 20 19:14:29 2009 +0000 @@ -21,7 +21,7 @@ core_cpp_files += cpp/qt_qtd/qtd_core.cpp cpp/qt_qtd/ArrayOpsPrimitive_shell.cpp ## Module specific d files. -core_d_files += $(QTD_CORE:%=qt/%.d) +core_d_files += $(QTD_CORE:%=qt/%.d) qt/core/ArrayOps2 ## Classes. ## TODO: use list that genareted by dgen. diff -r 52da31f967f0 -r ae06da58ec25 build/core.txt --- a/build/core.txt Thu Jun 18 16:09:18 2009 +0000 +++ b/build/core.txt Sat Jun 20 19:14:29 2009 +0000 @@ -8,6 +8,7 @@ qt_core/QModelIndex_shell qt_core/QMetaType_shell) ## Module specific d files. set (d_files qtd/Array qtd/Str QtDObject qtd/ArrayOpsPrimitive + core/ArrayOps2 core/QPoint core/QPointF core/QSize core/QSizeF core/QLine core/QLineF diff -r 52da31f967f0 -r ae06da58ec25 build/gui.makefile --- a/build/gui.makefile Thu Jun 18 16:09:18 2009 +0000 +++ b/build/gui.makefile Sat Jun 20 19:14:29 2009 +0000 @@ -11,7 +11,7 @@ gui_cpp_files += ## Module specific d files. -gui_d_files += +gui_d_files += qt/gui/ArrayOps2 ## Classes. ## TODO: use list that generated by dgen. diff -r 52da31f967f0 -r ae06da58ec25 build/gui.txt --- a/build/gui.txt Thu Jun 18 16:09:18 2009 +0000 +++ b/build/gui.txt Sat Jun 20 19:14:29 2009 +0000 @@ -1,6 +1,6 @@ set(required Core) set (cpp_files qt_gui/UrlHandler_shell) -set (d_files gui/UrlHandler) +set (d_files gui/UrlHandler gui/ArrayOps2) set(classes QPushButton QFileIconProvider diff -r 52da31f967f0 -r ae06da58ec25 generator/containergenerator.cpp --- a/generator/containergenerator.cpp Thu Jun 18 16:09:18 2009 +0000 +++ b/generator/containergenerator.cpp Sat Jun 20 19:14:29 2009 +0000 @@ -45,8 +45,8 @@ static Indentor INDENT; -ContainerGenerator::ContainerGenerator(): - DGenerator() +ContainerGenerator::ContainerGenerator(CppImplGenerator *cpp_impl_generator): + DGenerator(), m_cpp_impl_generator(cpp_impl_generator) { setFilenameStub("ArrayOps"); @@ -133,6 +133,7 @@ processFunction(function); } + AbstractMetaFieldList fields = d_class->fields(); foreach (const AbstractMetaField *field, fields) { if (field->wasPublic() || (field->wasProtected() && !d_class->isFinal())) { @@ -141,6 +142,27 @@ } } + AbstractMetaFunctionList signal_funcs = signalFunctions(d_class); + for(int i = 0; i < signal_funcs.size(); i++) { + AbstractMetaFunction *signal = signal_funcs.at(i); + + AbstractMetaArgumentList arguments = signal->arguments(); + foreach (AbstractMetaArgument *argument, arguments) { + if(argument->type()->isContainer()) { + bool inList = false; + foreach(AbstractMetaType* type, signalEntries[d_class->package()]) { + const TypeEntry *teInList = type->instantiations().first()->typeEntry(); + const TypeEntry *te = argument->type()->instantiations().first()->typeEntry(); + + if ((te == teInList) && (argument->type()->typeEntry() == type->typeEntry())) + inList = true; + } + if (!inList) + (signalEntries[d_class->package()]) << argument->type(); +// (signalEntries[d_class->package()])[argument->type()->instantiations().first()->typeEntry()] = argument->type(); + } + } + } } } @@ -151,6 +173,7 @@ writeFile(cppFilename(), CppDirectory, &ContainerGenerator::writeCppContent); // cpp file writeFile("ArrayOps_%1.h", HDirectory, &ContainerGenerator::writeHeaderContent); // header file writeFile(dFilename(), DDirectory, &ContainerGenerator::writeDContent); // d file + writeFile("ArrayOps2.d", DDirectory, &ContainerGenerator::writeDContent2); // d file } void ContainerGenerator::writeFile(const QString& fileName, OutputDirectoryType dirType, WriteOut writeOut) @@ -193,8 +216,13 @@ QString package = cls->package().replace(".", "_"); s << "// stuff for passing D function pointers" << endl << endl - << "#ifdef CPP_SHARED" << endl << endl - << "#include \"ArrayOps_" << package << ".h\"" << endl << endl; + << "#include \"qtd_masterinclude.h\"" << endl << endl + << "#include \"qtd_core.h\"" << endl + << "#include \"ArrayOps_" << package << ".h\"" << endl + << "#include \"ArrayOps_qt_core.h\"" << endl + << "#include \"ArrayOpsPrimitive.h\"" << endl << endl + << "#ifdef CPP_SHARED" << endl << endl; + foreach (const TypeEntry *te, containerTypes) { if (te->javaPackage() == cls->package()) { @@ -228,6 +256,38 @@ } s << "}" << endl << "#endif" << endl; +/* + QMap typeList = signalEntries[cls->package()]; + + QMapIterator i(typeList); + while (i.hasNext()) { + i.next(); + s << "// " << i.key()->targetLangName() << endl + << "extern \"C\" DLL_PUBLIC void qtd_" << package << "_" << i.key()->targetLangName() << "_to_d_array(void *cpp_ptr, DArray* __d_container) {" << endl; + + AbstractMetaType *arg_type = i.value(); + m_cpp_impl_generator->writeTypeInfo(s, arg_type, NoOption); + s << "container = (*reinterpret_cast< "; + m_cpp_impl_generator->writeTypeInfo(s, arg_type, ExcludeReference); + s << "(*)>(cpp_ptr));" << endl; + + m_cpp_impl_generator->writeQtToJavaContainer(s, arg_type, "container", "__d_container", 0, -1); + s << "}" << endl; + }*/ + + foreach(AbstractMetaType* arg_type, signalEntries[cls->package()]) { + const TypeEntry *te = arg_type->instantiations().first()->typeEntry(); + s << "// " << te->targetLangName() << endl + << "extern \"C\" DLL_PUBLIC void " << fromCppContainerName(cls, arg_type) << "(void *cpp_ptr, DArray* __d_container) {" << endl; + + m_cpp_impl_generator->writeTypeInfo(s, arg_type, NoOption); + s << "container = (*reinterpret_cast< "; + m_cpp_impl_generator->writeTypeInfo(s, arg_type, ExcludeReference); + s << "(*)>(cpp_ptr));" << endl; + + m_cpp_impl_generator->writeQtToJavaContainer(s, arg_type, "container", "__d_container", 0, -1); + s << "}" << endl; + } } void ContainerGenerator::writeHeaderContent(QTextStream &s, AbstractMetaClass *cls) @@ -334,6 +394,20 @@ s << " qtd_" << cls->package().replace(".", "_") << "_ArrayOps_initCallBacks(callbacks.ptr);" << endl << " }" << endl << "}" << endl; + + +} + +void ContainerGenerator::writeDContent2(QTextStream &s, AbstractMetaClass *cls) +{ + s << "module " << cls->package() << ".ArrayOps2;" << endl << endl; + + foreach(AbstractMetaType* arg_type, signalEntries[cls->package()]) { + const TypeEntry *te = arg_type->instantiations().first()->typeEntry(); + if(!te->isPrimitive() && !te->isString()) + writeImportString(s, te); + s << "extern (C) void " << fromCppContainerName(cls, arg_type) << "(void *cpp_ptr, " << te->targetLangName() << "[]* __d_container);" << endl; + } } void ContainerGenerator::writeNotice(QTextStream &s) diff -r 52da31f967f0 -r ae06da58ec25 generator/containergenerator.h --- a/generator/containergenerator.h Thu Jun 18 16:09:18 2009 +0000 +++ b/generator/containergenerator.h Sat Jun 20 19:14:29 2009 +0000 @@ -61,7 +61,7 @@ typedef void (ContainerGenerator::*WriteOut)(QTextStream &s, AbstractMetaClass *cls); - ContainerGenerator(); + ContainerGenerator(CppImplGenerator *cpp_impl_generator); virtual void generate(); virtual void write(QTextStream &s, const AbstractMetaClass *java_class); @@ -71,6 +71,7 @@ void writeHeaderContent(QTextStream &s, AbstractMetaClass *cls); void writeCppContent(QTextStream &s, AbstractMetaClass *cls); void writeDContent(QTextStream &s, AbstractMetaClass *cls); + void writeDContent2(QTextStream &s, AbstractMetaClass *cls); void buildTypeList(); @@ -100,6 +101,10 @@ AbstractMetaClass* m_class; QString all_name, ass_name, get_name; +// QMap > signalEntries; + QMap > signalEntries; + + CppImplGenerator *m_cpp_impl_generator; }; #endif // CONTAINERGENERATOR_H diff -r 52da31f967f0 -r ae06da58ec25 generator/cppimplgenerator.cpp --- a/generator/cppimplgenerator.cpp Thu Jun 18 16:09:18 2009 +0000 +++ b/generator/cppimplgenerator.cpp Sat Jun 20 19:14:29 2009 +0000 @@ -1382,7 +1382,7 @@ // D-side signal callbacks for(int i = 0; i < signal_funcs.size(); i++) { AbstractMetaFunction *signal = signal_funcs.at(i); - writeSignalHandler(s, java_class, signal); + s << "extern \"C\" DLL_PUBLIC void " << signalExternName(java_class, signal) << "_handle(void* d_entity, void** args);" << endl; } if(signal_funcs.size() > 0) @@ -3239,7 +3239,7 @@ cls_name.remove("_ConcreteWrapper"); s << endl - << INDENT << "{" << endl // qtd2 hack, additional scope for avoiding duplicating of "i" +// << INDENT << "{" << endl // qtd2 hack, additional scope for avoiding duplicating of "i" << INDENT; switch (type->type()) { @@ -3264,8 +3264,9 @@ writeTypeInfo(s, java_type, ForceValueType); + QString index = "i_" + qt_name; s << "::const_iterator " << qt_name << "_end_it = " << qt_name << ".constEnd();" << endl - << INDENT << "int i = 0;" << endl + << INDENT << QString("int %0 = 0;").arg(index) << endl << INDENT; s << "for ("; writeTypeInfo(s, java_type, ForceValueType); @@ -3278,15 +3279,15 @@ s << " __qt_tmp = *" << qt_name << "_it;" << endl; if(targ->isTargetLangString()) - s << INDENT << "void *__java_tmp = qtd_string_from_array(" << java_name << ", i);" << endl; + s << INDENT << "void *__java_tmp = qtd_string_from_array(" << java_name << ", " << index << ");" << endl; writeQtToJava(s, targ, "__qt_tmp", "__java_tmp", 0, -1, BoxedPrimitive); - s << INDENT << "qtd_assign_" << cls_name << "_array_element(" << java_name << ", i, __java_tmp);" << endl; - s << INDENT << "++i;" << endl; + s << INDENT << "qtd_assign_" << cls_name << "_array_element(" << java_name << ", " << index << ", __java_tmp);" << endl; + s << INDENT << "++" << index << ";" << endl; } - s << INDENT << "}" << endl - << INDENT << "}" << endl; + s << INDENT << "}" << endl; +// << INDENT << "}" << endl; } else if (type->type() == ContainerTypeEntry::PairContainer) { QList args = java_type->instantiations(); diff -r 52da31f967f0 -r ae06da58ec25 generator/dgenerator.cpp --- a/generator/dgenerator.cpp Thu Jun 18 16:09:18 2009 +0000 +++ b/generator/dgenerator.cpp Sat Jun 20 19:14:29 2009 +0000 @@ -43,7 +43,6 @@ #include "reporthandler.h" #include "docparser.h" #include "jumptable.h" -#include "cppimplgenerator.h" #include "fileout.h" #include @@ -1717,10 +1716,9 @@ s << "private " << attr << "extern(C) void " << sigExternName << "_connect(void* native_id);" << endl; s << "private " << attr << "extern(C) void " << sigExternName << "_disconnect(void* native_id);" << endl; - +/* QString extra_args; - AbstractMetaArgumentList arguments = signal->arguments(); foreach (AbstractMetaArgument *argument, arguments) { if(argument->type()->isContainer()) { QString arg_name = argument->indexedName(); @@ -1729,8 +1727,10 @@ extra_args += ", " + type_string + " " + arg_name; } } - - s << "private extern(C) void " << sigExternName << "_handle_in_d(void* d_entity, void** args" << extra_args<< ") {" << endl; +*/ + AbstractMetaArgumentList arguments = signal->arguments(); + + s << "private extern(C) void " << sigExternName << "_handle(void* d_entity, void** args) {" << endl; { Indentation indent(INDENT); s << INDENT << "auto d_object = cast(" << d_class->name() << ") d_entity;" << endl; @@ -1744,10 +1744,13 @@ QString arg_ptr = QString("args[%1]").arg(argument->argumentIndex() + 1); - if (type->isTargetLangString()) + if (type->isContainer()) { + s << INDENT << translateType(type, signal->implementingClass(), BoxedPrimitive) << " " << arg_name << ";" << endl + << INDENT << fromCppContainerName(d_class, type) << "(" << arg_ptr << ", &" << arg_name << ");" << endl; + } else if (type->isTargetLangString()) { s << INDENT << "auto " << arg_name << "_ptr = " << arg_ptr << ";" << endl << INDENT << "string " << arg_name << " = QString.toNativeString(" << arg_name << "_ptr);"; - else if(type->isPrimitive() || type->isEnum() || type->isFlags() || type->typeEntry()->isStructInD()) { + } else if(type->isPrimitive() || type->isEnum() || type->isFlags() || type->typeEntry()->isStructInD()) { QString type_name = argument->type()->typeEntry()->qualifiedTargetLangName(); if (type->isFlags()) type_name = "int"; @@ -1755,14 +1758,14 @@ } else if(type->isObject() || type->isQObject() || (type->typeEntry()->isValue() && type->isNativePointer()) || type->isValue()) { - QString type_name = type->name(); - const ComplexTypeEntry *ctype = static_cast(type->typeEntry()); - if(ctype->isAbstract()) - type_name = type_name + "_ConcreteWrapper"; - s << INDENT << "scope " << arg_name << " = new " << type_name - << "(cast(void*)(" << arg_ptr << "), true);" << endl - << INDENT << arg_name << ".__no_real_delete = true;"; - } + QString type_name = type->name(); + const ComplexTypeEntry *ctype = static_cast(type->typeEntry()); + if(ctype->isAbstract()) + type_name = type_name + "_ConcreteWrapper"; + s << INDENT << "scope " << arg_name << " = new " << type_name + << "(cast(void*)(" << arg_ptr << "), true);" << endl + << INDENT << arg_name << ".__no_real_delete = true;"; + } s << endl; } // s << INDENT << "Stdout(\"" << d_class->name() << "\", \"" << signal->name() << "\").newline;" << endl; @@ -1886,6 +1889,8 @@ else if (d_class->name() == "QApplication") s << "private import qt.gui.ArrayOps;" << endl; + s << "private import " << d_class->package() << ".ArrayOps2;" << endl; + if (!d_class->enums().isEmpty()) s << "public import " << d_class->package() << "." << d_class->name() << "_enum;" << endl << endl; diff -r 52da31f967f0 -r ae06da58ec25 generator/dgenerator.h --- a/generator/dgenerator.h Thu Jun 18 16:09:18 2009 +0000 +++ b/generator/dgenerator.h Sat Jun 20 19:14:29 2009 +0000 @@ -44,6 +44,7 @@ #include "generator.h" #include "metajava.h" +#include "cppimplgenerator.h" #include diff -r 52da31f967f0 -r ae06da58ec25 generator/generator.h --- a/generator/generator.h Thu Jun 18 16:09:18 2009 +0000 +++ b/generator/generator.h Sat Jun 20 19:14:29 2009 +0000 @@ -160,6 +160,14 @@ return "qtd_" + cls->name() + "_" + signal->name(); } +inline QString fromCppContainerName(const AbstractMetaClass *cls, const AbstractMetaType *type) +{ + QString package = cls->package().replace(".", "_"); + const TypeEntry *te = type->instantiations().first()->typeEntry(); + + return "qtd_" + package + "_" + te->targetLangName() + "_from_" + type->typeEntry()->qualifiedCppName(); +} + bool notWrappedYet(const AbstractMetaFunction *java_function); bool isLinearContainer(const ContainerTypeEntry *type); AbstractMetaFunctionList signalFunctions(const AbstractMetaClass *cls); diff -r 52da31f967f0 -r ae06da58ec25 generator/generatorsetd.cpp --- a/generator/generatorsetd.cpp Thu Jun 18 16:09:18 2009 +0000 +++ b/generator/generatorsetd.cpp Sat Jun 20 19:14:29 2009 +0000 @@ -147,7 +147,7 @@ // Code generation QList generators; PriGenerator *priGenerator = new PriGenerator; - ContainerGenerator *cointainerGenerator = new ContainerGenerator; + ContainerGenerator *cointainerGenerator; DGenerator *d_generator = 0; CppHeaderGenerator *cpp_header_generator = 0; CppImplGenerator *cpp_impl_generator = 0; @@ -209,6 +209,9 @@ contexts << "ClassListGenerator"; } + cointainerGenerator = new ContainerGenerator(cpp_impl_generator); + + generators << priGenerator; contexts << "PriGenerator"; diff -r 52da31f967f0 -r ae06da58ec25 generator/qtjambi_masterinclude.h --- a/generator/qtjambi_masterinclude.h Thu Jun 18 16:09:18 2009 +0000 +++ b/generator/qtjambi_masterinclude.h Sat Jun 20 19:14:29 2009 +0000 @@ -59,13 +59,6 @@ # include #endif -#include <../qtjambi_designer/designer.h> - -#include <../qtjambi_gui/qtreemodel.h> -#include <../qtjambi_gui/qguisignalmapper.h> - -#include <../qtjambi_core/qtjambiconcurrent.h> - #ifndef QT_NO_OPENGL #define GL_ACCUM 0x0100 #define GL_LOAD 0x0101 diff -r 52da31f967f0 -r ae06da58ec25 qt/QGlobal.d --- a/qt/QGlobal.d Thu Jun 18 16:09:18 2009 +0000 +++ b/qt/QGlobal.d Sat Jun 20 19:14:29 2009 +0000 @@ -401,9 +401,15 @@ void qSwap(T)(ref T value1, ref T value2) { +<<<<<<< .mine + const T.nativeId t = value1.nativeId; + value1.nativeId = value2.nativeId; + value2.nativeId = t; +======= T t = value1; value1 = value2; value2 = t; +>>>>>>> .r170 } /*