Mercurial > projects > qtd
comparison generator/cppimplgenerator.cpp @ 298:adae77fdc1ea signals
Native QList implementation is now used throughout QtD
author | eldar |
---|---|
date | Sun, 06 Dec 2009 17:26:37 +0000 |
parents | bb37b0ed94c9 |
children | 4d8481385c71 |
comparison
equal
deleted
inserted
replaced
297:bc783e20da2b | 298:adae77fdc1ea |
---|---|
719 << "extern \"C\" DLL_PUBLIC void* qtd_" << java_class->name() << "_staticMetaObject() {" << endl | 719 << "extern \"C\" DLL_PUBLIC void* qtd_" << java_class->name() << "_staticMetaObject() {" << endl |
720 << " return (void*)&" << java_class->name() << "::staticMetaObject;" << endl | 720 << " return (void*)&" << java_class->name() << "::staticMetaObject;" << endl |
721 << "}" << endl; | 721 << "}" << endl; |
722 } | 722 } |
723 | 723 |
724 if (java_class->typeEntry()->isValue() && java_class->hasCloneOperator()) | 724 if (java_class->typeEntry()->isValue()) |
725 { | 725 { |
726 AbstractMetaFunction *ctor = java_class->copyConstructor(); | |
727 if(ctor) | |
728 { | 726 { |
729 QString argName = ctor->arguments().at(0)->indexedName(); | 727 QString argName = "orig"; |
730 s << endl << endl | 728 s << endl << endl |
731 << "extern \"C\" DLL_PUBLIC void* qtd_" << java_class->name() << "_placed_copy(void* " | 729 << "extern \"C\" DLL_PUBLIC void qtd_" << java_class->name() << "_placed_copy(void* " |
732 << argName << ", " << "void* place) {" << endl | 730 << argName << ", void* place) {" << endl |
733 << QString(" const %1& __qt_%2 = (const %1& ) *(%1 *)%2;").arg(java_class->name()).arg(argName) << endl; | 731 << QString(" const %1& __qt_%2 = (const %1& ) *(%1 *)%2;").arg(shellClassName(java_class)).arg(argName) << endl |
734 | 732 << QString(" %1 *result = new (place) %1 (__qt_%2);").arg(java_class->qualifiedCppName()).arg(argName) << endl; |
735 writeFinalConstructor(s, ctor, "result", "original", "(place)"); | 733 // writeFinalConstructor(s, ctor, "result", "original", "(place)"); |
734 s << "}"; | |
735 | |
736 s << endl << endl | |
737 << "extern \"C\" DLL_PUBLIC void* qtd_" << java_class->name() << "_native_copy(void* " << argName << ") {" << endl | |
738 << QString(" const %1& __qt_%2 = (const %1& ) *(%1 *)%2;").arg(shellClassName(java_class)).arg(argName) << endl | |
739 << QString(" %1 *result = new %1 (__qt_%2);").arg(java_class->qualifiedCppName()).arg(argName) << endl | |
740 << " return result;" << endl; | |
736 s << "}"; | 741 s << "}"; |
737 } | 742 } |
738 } | 743 } |
739 | 744 |
740 s << endl << endl; | 745 s << endl << endl; |
742 priGenerator->addSource(java_class->package(), fileNameForClass(java_class)); | 747 priGenerator->addSource(java_class->package(), fileNameForClass(java_class)); |
743 } | 748 } |
744 | 749 |
745 void CppImplGenerator::writeValueFunctions(QTextStream &s, const AbstractMetaClass *java_class) | 750 void CppImplGenerator::writeValueFunctions(QTextStream &s, const AbstractMetaClass *java_class) |
746 { | 751 { |
747 s << QString("extern \"C\" DLL_PUBLIC bool qtd_%1_QTypeInfo_isComplex() { return (bool) QTypeInfo<%1>::isComplex; }\n").arg(java_class->name()); | 752 s << QString("extern \"C\" DLL_PUBLIC bool qtd_%1_QTypeInfo_isComplex() { return (bool) QTypeInfo<%2>::isComplex; }\n").arg(java_class->name()).arg(java_class->qualifiedCppName()); |
748 s << QString("extern \"C\" DLL_PUBLIC bool qtd_%1_QTypeInfo_isStatic() { return (bool) QTypeInfo<%1>::isStatic; }\n").arg(java_class->name()); | 753 s << QString("extern \"C\" DLL_PUBLIC bool qtd_%1_QTypeInfo_isStatic() { return (bool) QTypeInfo<%2>::isStatic; }\n").arg(java_class->name()).arg(java_class->qualifiedCppName()); |
749 s << QString("extern \"C\" DLL_PUBLIC bool qtd_%1_QTypeInfo_isLarge() { return (bool) QTypeInfo<%1>::isLarge; }\n").arg(java_class->name()); | 754 s << QString("extern \"C\" DLL_PUBLIC bool qtd_%1_QTypeInfo_isLarge() { return (bool) QTypeInfo<%2>::isLarge; }\n").arg(java_class->name()).arg(java_class->qualifiedCppName()); |
750 s << QString("extern \"C\" DLL_PUBLIC bool qtd_%1_QTypeInfo_isPointer() { return (bool) QTypeInfo<%1>::isPointer; }\n").arg(java_class->name()); | 755 s << QString("extern \"C\" DLL_PUBLIC bool qtd_%1_QTypeInfo_isPointer() { return (bool) QTypeInfo<%2>::isPointer; }\n").arg(java_class->name()).arg(java_class->qualifiedCppName()); |
751 s << QString("extern \"C\" DLL_PUBLIC bool qtd_%1_QTypeInfo_isDummy() { return (bool) QTypeInfo<%1>::isDummy; }\n").arg(java_class->name()); | 756 s << QString("extern \"C\" DLL_PUBLIC bool qtd_%1_QTypeInfo_isDummy() { return (bool) QTypeInfo<%2>::isDummy; }\n").arg(java_class->name()).arg(java_class->qualifiedCppName()); |
752 } | 757 } |
753 | 758 |
754 void CppImplGenerator::writeVirtualDispatchFunction(QTextStream &s, const AbstractMetaFunction *function, bool d_export) | 759 void CppImplGenerator::writeVirtualDispatchFunction(QTextStream &s, const AbstractMetaFunction *function, bool d_export) |
755 { | 760 { |
756 uint options2 = ReturnType | ExternC; | 761 uint options2 = ReturnType | ExternC; |
809 s << INDENT << "QModelIndexAccessor __d_return_value;" << endl; | 814 s << INDENT << "QModelIndexAccessor __d_return_value;" << endl; |
810 else if (f_type->typeEntry()->isStructInD()) | 815 else if (f_type->typeEntry()->isStructInD()) |
811 s << INDENT << f_type->typeEntry()->qualifiedCppName() << " __d_return_value;" << endl; | 816 s << INDENT << f_type->typeEntry()->qualifiedCppName() << " __d_return_value;" << endl; |
812 | 817 |
813 if (f_type->isContainer()) | 818 if (f_type->isContainer()) |
814 s << INDENT << "void* __d_return_value;" << endl | 819 { |
815 << INDENT << "size_t __d_return_value_size;" << endl; | 820 if (isNativeContainer(f_type)) |
821 { | |
822 s << INDENT; | |
823 writeTypeInfo(s, f_type, ForceValueType); | |
824 s << "__d_return_value;" << endl; | |
825 } | |
826 else | |
827 s << INDENT << "void* __d_return_value;" << endl | |
828 << INDENT << "size_t __d_return_value_size;" << endl; | |
829 } | |
816 } | 830 } |
817 | 831 |
818 AbstractMetaArgumentList arguments = function->arguments(); | 832 AbstractMetaArgumentList arguments = function->arguments(); |
819 foreach (AbstractMetaArgument *argument, arguments) { | 833 foreach (AbstractMetaArgument *argument, arguments) { |
820 if (!function->argumentRemoved(argument->argumentIndex()+1)) { | 834 if (!function->argumentRemoved(argument->argumentIndex()+1)) { |
821 if (!argument->type()->isPrimitive() | 835 AbstractMetaType *atype = argument->type(); |
836 if (!atype->isPrimitive() | |
822 || !function->conversionRule(TypeSystem::NativeCode, argument->argumentIndex()+1).isEmpty()) { | 837 || !function->conversionRule(TypeSystem::NativeCode, argument->argumentIndex()+1).isEmpty()) { |
823 if(argument->type()->isContainer()) { | 838 if(atype->isContainer()) { |
824 QString arg_name = argument->indexedName(); | 839 QString arg_name = argument->indexedName(); |
825 s << INDENT << QString("DArray %1_arr;").arg(arg_name) << endl | 840 if(!isNativeContainer(atype)) |
826 << INDENT << QString("DArray *__d_%1 = &%1_arr;").arg(arg_name); | 841 writeQtToJava(s, |
827 | 842 argument->type(), |
828 writeQtToJava(s, | 843 arg_name, |
829 argument->type(), | 844 "__d_" + arg_name, |
830 arg_name, | 845 function, |
831 "__d_" + arg_name, | 846 argument->argumentIndex() + 1, |
832 function, | 847 Option(VirtualDispatch)); |
833 argument->argumentIndex() + 1, | |
834 Option(VirtualDispatch)); | |
835 } | 848 } |
836 } | 849 } |
837 } | 850 } |
838 } | 851 } |
839 | 852 |
865 | 878 |
866 if (f_type) { | 879 if (f_type) { |
867 if (f_type->isTargetLangString()) | 880 if (f_type->isTargetLangString()) |
868 s << ", &ret_str"; | 881 s << ", &ret_str"; |
869 if (f_type->name() == "QModelIndex" || f_type->typeEntry()->isStructInD()) | 882 if (f_type->name() == "QModelIndex" || f_type->typeEntry()->isStructInD()) |
870 s << ", &__d_return_value"; | 883 s << ", &__d_return_value"; // TODO should both be refactored into isNativeType function |
871 if (f_type->isContainer()) | 884 if (f_type->isContainer()) { |
872 s << ", &__d_return_value, &__d_return_value_size"; | 885 if ( ((const ContainerTypeEntry *)f_type->typeEntry())->isQList() ) |
886 s << ", &__d_return_value"; | |
887 else | |
888 s << ", &__d_return_value, &__d_return_value_size"; | |
889 } | |
873 } | 890 } |
874 | 891 |
875 if (function->arguments().size() > 0) | 892 if (function->arguments().size() > 0) |
876 s << ", "; | 893 s << ", "; |
877 writeFunctionCallArguments(s, function, QString(), Option(options | ForceEnumCast | SkipRemovedArguments | ExcludeConst | VirtualDispatch)); | 894 writeFunctionCallArguments(s, function, QString(), Option(options | ForceEnumCast | SkipRemovedArguments | ExcludeConst | VirtualDispatch)); |
889 s << INDENT << "return __qt_return_value;" << endl; | 906 s << INDENT << "return __qt_return_value;" << endl; |
890 } else if (f_type->typeEntry()->isStructInD()) | 907 } else if (f_type->typeEntry()->isStructInD()) |
891 s << INDENT << "return __d_return_value;" << endl; | 908 s << INDENT << "return __d_return_value;" << endl; |
892 | 909 |
893 if (f_type->isContainer()) { | 910 if (f_type->isContainer()) { |
894 writeJavaToQt(s, f_type, "__qt_return_value", "__d_return_value", | 911 if (isNativeContainer(f_type)) |
895 function, 0, GlobalRefJObject); | 912 s << INDENT << "return __d_return_value;" << endl; |
896 s << INDENT << "return __qt_return_value;" << endl; | 913 else |
914 { | |
915 writeJavaToQt(s, f_type, "__qt_return_value", "__d_return_value", | |
916 function, 0, GlobalRefJObject); | |
917 s << INDENT << "return __qt_return_value;" << endl; | |
918 } | |
897 } | 919 } |
898 | 920 |
899 if (f_type->isTargetLangString()) | 921 if (f_type->isTargetLangString()) |
900 s << INDENT << "return " << "QString::fromUtf8((const char*) ret_str.ptr, ret_str.length);" << endl; | 922 s << INDENT << "return " << "QString::fromUtf8((const char*) ret_str.ptr, ret_str.length);" << endl; |
901 | 923 |
925 if (ret_type->name() == "QModelIndex") | 947 if (ret_type->name() == "QModelIndex") |
926 s << ", QModelIndexAccessor *__d_return_value"; | 948 s << ", QModelIndexAccessor *__d_return_value"; |
927 else if(ret_type->typeEntry()->isStructInD()) | 949 else if(ret_type->typeEntry()->isStructInD()) |
928 s << ", " << ret_type->typeEntry()->qualifiedCppName() << " *__d_return_value"; | 950 s << ", " << ret_type->typeEntry()->qualifiedCppName() << " *__d_return_value"; |
929 | 951 |
930 if (ret_type->isContainer()) | 952 if (ret_type->isContainer()) { |
931 s << ", void** __d_arr_ptr, size_t* __d_arr_size"; | 953 if(isNativeContainer(ret_type)) { |
954 if(d_export) | |
955 s << ", " << DGenerator::translateType(ret_type, d_function->ownerClass(), NoOption) << "* __d_arr"; | |
956 else | |
957 s << ", void * __d_arr"; | |
958 } | |
959 else | |
960 s << ", void** __d_arr_ptr, size_t* __d_arr_size"; | |
961 } | |
932 } | 962 } |
933 | 963 |
934 if (d_function->arguments().size() > 0) | 964 if (d_function->arguments().size() > 0) |
935 s << ", "; | 965 s << ", "; |
936 | 966 |
946 QString arg_name = argument->indexedName(); | 976 QString arg_name = argument->indexedName(); |
947 | 977 |
948 if (d_type->name() == "QModelIndex") | 978 if (d_type->name() == "QModelIndex") |
949 s << "QModelIndexAccessor" << QString(d_type->actualIndirections(), '*') << " " << arg_name; | 979 s << "QModelIndexAccessor" << QString(d_type->actualIndirections(), '*') << " " << arg_name; |
950 else if (d_type->isContainer()) { | 980 else if (d_type->isContainer()) { |
951 if (d_export) { | 981 if ( isNativeContainer(d_type) ) |
982 s << "void* "; | |
983 else if (d_export) | |
952 s << DGenerator::translateType(d_type, d_function->ownerClass(), NoOption) << "* "; | 984 s << DGenerator::translateType(d_type, d_function->ownerClass(), NoOption) << "* "; |
953 } else | 985 else |
954 s << "DArray* "; | 986 s << "DArray* "; |
955 s << arg_name; | 987 s << arg_name; |
956 } else if (d_type->typeEntry()->isStructInD()) | 988 } else if (d_type->typeEntry()->isStructInD()) |
957 s << d_type->typeEntry()->qualifiedCppName() << QString(d_type->actualIndirections(), '*') | 989 s << d_type->typeEntry()->qualifiedCppName() << QString(d_type->actualIndirections(), '*') |
958 << " " << arg_name; | 990 << " " << arg_name; |
1978 else | 2010 else |
1979 s << "DArray " << arg_name; | 2011 s << "DArray " << arg_name; |
1980 } else if (d_type->isContainer()) { | 2012 } else if (d_type->isContainer()) { |
1981 const ContainerTypeEntry *cte = | 2013 const ContainerTypeEntry *cte = |
1982 static_cast<const ContainerTypeEntry *>(te); | 2014 static_cast<const ContainerTypeEntry *>(te); |
1983 if(isLinearContainer(cte)) | 2015 if(cte->isQList()) |
1984 s << QString("void *%1, size_t %1_size").arg(arg_name); | 2016 s << "void* " << arg_name; |
2017 else if(isLinearContainer(cte)) | |
2018 s << "DArray* " << arg_name; | |
1985 } else { | 2019 } else { |
1986 if (!d_type->hasNativeId()) { | 2020 if (!d_type->hasNativeId()) { |
1987 if(d_type->isVariant()) { | 2021 if(d_type->isVariant()) { |
1988 if (d_export) s << "void*"; | 2022 if (d_export) s << "void*"; |
1989 else s << "QVariant*"; | 2023 else s << "QVariant*"; |
2348 << INDENT << " delete (" << shellClassName(cls) << " *)ptr;" << endl | 2382 << INDENT << " delete (" << shellClassName(cls) << " *)ptr;" << endl |
2349 << INDENT << "}" << endl << endl; | 2383 << INDENT << "}" << endl << endl; |
2350 | 2384 |
2351 s << INDENT << "extern \"C\" DLL_PUBLIC void qtd_" << cls->name() << "_call_destructor(" << shellClassName(cls) << " *ptr)" << endl | 2385 s << INDENT << "extern \"C\" DLL_PUBLIC void qtd_" << cls->name() << "_call_destructor(" << shellClassName(cls) << " *ptr)" << endl |
2352 << INDENT << "{" << endl | 2386 << INDENT << "{" << endl |
2353 << INDENT << QString (" ptr->~%1();").arg(shellClassName(cls)) << endl | 2387 << INDENT << " call_destructor(ptr);" << endl |
2354 << INDENT << "}" << endl << endl; | 2388 << INDENT << "}" << endl << endl; |
2355 } | 2389 } |
2356 } | 2390 } |
2357 | 2391 |
2358 void CppImplGenerator::writeFinalConstructor(QTextStream &s, | 2392 void CppImplGenerator::writeFinalConstructor(QTextStream &s, |
3186 | 3220 |
3187 Q_ASSERT(java_type->isContainer()); | 3221 Q_ASSERT(java_type->isContainer()); |
3188 const ContainerTypeEntry *type = | 3222 const ContainerTypeEntry *type = |
3189 static_cast<const ContainerTypeEntry *>(java_type->typeEntry()); | 3223 static_cast<const ContainerTypeEntry *>(java_type->typeEntry()); |
3190 | 3224 |
3191 if (type->type() == ContainerTypeEntry::ListContainer | 3225 if (type->type() == ContainerTypeEntry::VectorContainer |
3192 || type->type() == ContainerTypeEntry::VectorContainer | |
3193 || type->type() == ContainerTypeEntry::StringListContainer | |
3194 || type->type() == ContainerTypeEntry::LinkedListContainer | 3226 || type->type() == ContainerTypeEntry::LinkedListContainer |
3195 || type->type() == ContainerTypeEntry::StackContainer | 3227 || type->type() == ContainerTypeEntry::StackContainer |
3196 || type->type() == ContainerTypeEntry::SetContainer | 3228 || type->type() == ContainerTypeEntry::SetContainer |
3197 || type->type() == ContainerTypeEntry::QueueContainer) { | 3229 || type->type() == ContainerTypeEntry::QueueContainer) { |
3198 | 3230 |
3201 | 3233 |
3202 QString cls_name = getTypeName(targ->typeEntry(), EnumAsInts); | 3234 QString cls_name = getTypeName(targ->typeEntry(), EnumAsInts); |
3203 cls_name.remove("_ConcreteWrapper"); | 3235 cls_name.remove("_ConcreteWrapper"); |
3204 | 3236 |
3205 s << endl | 3237 s << endl |
3206 // << INDENT << "{" << endl // qtd2 hack, additional scope for avoiding duplicating of "i" | |
3207 << INDENT; | 3238 << INDENT; |
3208 | 3239 |
3209 switch (type->type()) { | 3240 switch (type->type()) { |
3210 case ContainerTypeEntry::LinkedListContainer: | 3241 case ContainerTypeEntry::LinkedListContainer: |
3211 case ContainerTypeEntry::QueueContainer: | 3242 case ContainerTypeEntry::QueueContainer: |
3249 | 3280 |
3250 s << INDENT << "qtd_assign_" << cls_name << "_array_element(" << java_name << ", " << index << ", __java_tmp);" << endl; | 3281 s << INDENT << "qtd_assign_" << cls_name << "_array_element(" << java_name << ", " << index << ", __java_tmp);" << endl; |
3251 s << INDENT << "++" << index << ";" << endl; | 3282 s << INDENT << "++" << index << ";" << endl; |
3252 } | 3283 } |
3253 s << INDENT << "}" << endl; | 3284 s << INDENT << "}" << endl; |
3254 // << INDENT << "}" << endl; | 3285 |
3286 } else if (type->isQList()) { | |
3287 // QList<QObject*> & list2 = (*(QList<QObject*> *)nativeId); | |
3288 writeTypeInfo(s, java_type, ForceValueType); | |
3289 s << "&" << java_name << "_tmp = (*("; | |
3290 writeTypeInfo(s, java_type, ForceValueType); | |
3291 s << "*)" << java_name << ");" << endl | |
3292 << INDENT << java_name << "_tmp = " << qt_name << ";" << endl; | |
3255 | 3293 |
3256 } else if (type->type() == ContainerTypeEntry::PairContainer) { | 3294 } else if (type->type() == ContainerTypeEntry::PairContainer) { |
3257 QList<AbstractMetaType *> args = java_type->instantiations(); | 3295 QList<AbstractMetaType *> args = java_type->instantiations(); |
3258 Q_ASSERT(args.size() == 2); | 3296 Q_ASSERT(args.size() == 2); |
3259 | 3297 |
3376 | 3414 |
3377 Q_ASSERT(java_type->isContainer()); | 3415 Q_ASSERT(java_type->isContainer()); |
3378 const ContainerTypeEntry *type = | 3416 const ContainerTypeEntry *type = |
3379 static_cast<const ContainerTypeEntry *>(java_type->typeEntry()); | 3417 static_cast<const ContainerTypeEntry *>(java_type->typeEntry()); |
3380 | 3418 |
3381 if (type->type() == ContainerTypeEntry::ListContainer | 3419 if (type->type() == ContainerTypeEntry::VectorContainer |
3382 || type->type() == ContainerTypeEntry::VectorContainer | |
3383 || type->type() == ContainerTypeEntry::StringListContainer | |
3384 || type->type() == ContainerTypeEntry::LinkedListContainer | 3420 || type->type() == ContainerTypeEntry::LinkedListContainer |
3385 || type->type() == ContainerTypeEntry::StackContainer | 3421 || type->type() == ContainerTypeEntry::StackContainer |
3386 || type->type() == ContainerTypeEntry::SetContainer | 3422 || type->type() == ContainerTypeEntry::SetContainer |
3387 || type->type() == ContainerTypeEntry::QueueContainer) { | 3423 || type->type() == ContainerTypeEntry::QueueContainer) { |
3388 Q_ASSERT(java_type->instantiations().size() == 1); | 3424 Q_ASSERT(java_type->instantiations().size() == 1); |
3392 | 3428 |
3393 s << INDENT; | 3429 s << INDENT; |
3394 writeTypeInfo(s, java_type, ForceValueType); | 3430 writeTypeInfo(s, java_type, ForceValueType); |
3395 s << qt_name << ";" << endl; | 3431 s << qt_name << ";" << endl; |
3396 | 3432 |
3397 // qtd s << INDENT << "if (" << java_name << " != 0) {" << endl; | |
3398 { | 3433 { |
3399 /* qtd Indentation indent(INDENT); | |
3400 s << INDENT << "jobjectArray __qt__array = qtjambi_collection_toArray(__jni_env, " | |
3401 << java_name << ");" << endl | |
3402 << INDENT << "jsize __qt__size = __jni_env->GetArrayLength(__qt__array);" << endl; | |
3403 */ | |
3404 if (type->type() == ContainerTypeEntry::VectorContainer | 3434 if (type->type() == ContainerTypeEntry::VectorContainer |
3405 || type->type() == ContainerTypeEntry::StackContainer) | 3435 || type->type() == ContainerTypeEntry::StackContainer) |
3406 s << INDENT << qt_name << ".reserve(" << java_name << "_size);" << endl; | 3436 s << INDENT << qt_name << ".reserve(" << java_name << "->length);" << endl; |
3407 | 3437 |
3408 s << INDENT << "for (int i=0; i<" << java_name << "_size; ++i) {" << endl; | 3438 s << INDENT << "for (int i=0; i<" << java_name << "->length; ++i) {" << endl; |
3409 { | 3439 { |
3410 Indentation indent(INDENT); | 3440 Indentation indent(INDENT); |
3411 if(targ->isTargetLangString()) | 3441 if(targ->isTargetLangString()) |
3412 s << INDENT << "DArray __d_element;" << endl | 3442 s << INDENT << "DArray __d_element;" << endl |
3413 << INDENT << "qtd_get_string_from_array(" << java_name << ", i, &__d_element);" << endl; | 3443 << INDENT << "qtd_get_string_from_array(" << java_name << "->ptr, i, &__d_element);" << endl; |
3414 else { | 3444 else { |
3415 s << INDENT; | 3445 s << INDENT; |
3416 writeTypeInfo(s, targ, Option(VirtualDispatch | ForcePointer | EnumAsInts)); | 3446 writeTypeInfo(s, targ, Option(VirtualDispatch | ForcePointer | EnumAsInts)); |
3417 QString cast_string = ""; | 3447 QString cast_string = ""; |
3418 const TypeEntry* centry = targ->typeEntry(); | 3448 const TypeEntry* centry = targ->typeEntry(); |
3419 if (centry->isComplex() && (centry->isObject() || centry->isValue() || centry->isInterface())) | 3449 if (centry->isComplex() && (centry->isObject() || centry->isValue() || centry->isInterface())) |
3420 cast_string = "(void**)"; | 3450 cast_string = "(void**)"; |
3421 s << "__d_element;" << endl | 3451 s << "__d_element;" << endl |
3422 << INDENT << "qtd_get_" << elem_type << "_from_array(" << java_name << ", i, &__d_element);" << endl; | 3452 << INDENT << "qtd_get_" << elem_type << "_from_array(" << java_name << ", i, &__d_element);" << endl; |
3423 } | 3453 } |
3424 /* qtd s << INDENT << "jobject __d_element = " | |
3425 << "__jni_env->GetObjectArrayElement(__qt__array, i);" << endl;*/ | |
3426 writeJavaToQt(s, targ, "__qt_element", "__d_element", 0, -1, BoxedPrimitive); | 3454 writeJavaToQt(s, targ, "__qt_element", "__d_element", 0, -1, BoxedPrimitive); |
3427 QString cont_element = "__qt_element"; | 3455 QString cont_element = "__qt_element"; |
3428 if(targ->typeEntry()->isStructInD() && targ->name() != "QModelIndex") | 3456 if(targ->typeEntry()->isStructInD() && targ->name() != "QModelIndex") |
3429 cont_element = "__d_element"; | 3457 cont_element = "__d_element"; |
3430 s << INDENT << qt_name << " << " << cont_element << ";" << endl; | 3458 s << INDENT << qt_name << " << " << cont_element << ";" << endl; |
3431 } | 3459 } |
3432 // qtd s << INDENT << "}" << endl; | 3460 // qtd s << INDENT << "}" << endl; |
3433 } | 3461 } |
3434 s << INDENT << "}" << endl; | 3462 s << INDENT << "}" << endl; |
3463 } else if (type->isQList()) { | |
3464 writeTypeInfo(s, java_type, ForceValueType); | |
3465 s << qt_name << " = (*("; | |
3466 writeTypeInfo(s, java_type, ForceValueType); | |
3467 s << "*)" << java_name << ");" << endl; | |
3435 } else if (type->type() == ContainerTypeEntry::PairContainer) { | 3468 } else if (type->type() == ContainerTypeEntry::PairContainer) { |
3436 QList<AbstractMetaType *> targs = java_type->instantiations(); | 3469 QList<AbstractMetaType *> targs = java_type->instantiations(); |
3437 Q_ASSERT(targs.size() == 2); | 3470 Q_ASSERT(targs.size() == 2); |
3438 | 3471 |
3439 s << INDENT; | 3472 s << INDENT; |
3595 } | 3628 } |
3596 } | 3629 } |
3597 | 3630 |
3598 if ( (options & VirtualDispatch) | 3631 if ( (options & VirtualDispatch) |
3599 && a_type->isContainer()) { | 3632 && a_type->isContainer()) { |
3600 s << "__d_" << argument->indexedName(); | 3633 if ( ((const ContainerTypeEntry *)a_type->typeEntry())->isQList() ) |
3634 s << "(void*)&" << argument->indexedName(); | |
3635 else | |
3636 s << "__d_" << argument->indexedName(); | |
3601 continue; | 3637 continue; |
3602 } | 3638 } |
3603 | 3639 |
3604 if ((!(options & NoCasts) && !enum_as_int) || ((options & ForceEnumCast) && a_type->isEnum())) { | 3640 if ((!(options & NoCasts) && !enum_as_int) || ((options & ForceEnumCast) && a_type->isEnum())) { |
3605 | 3641 |