Mercurial > projects > qtd
comparison generator/dgenerator.cpp @ 111:2a85b786fa3a
same thing for Objects
author | eldar |
---|---|
date | Mon, 01 Jun 2009 23:46:16 +0000 |
parents | 136c9ee83ee5 |
children | e416c5215366 |
comparison
equal
deleted
inserted
replaced
110:136c9ee83ee5 | 111:2a85b786fa3a |
---|---|
864 if (return_type->isObject()) { | 864 if (return_type->isObject()) { |
865 if(d_function->storeResult()) | 865 if(d_function->storeResult()) |
866 s << INDENT << QString("__m_%1.nativeId = __qt_return_value;").arg(d_function->name()) << endl | 866 s << INDENT << QString("__m_%1.nativeId = __qt_return_value;").arg(d_function->name()) << endl |
867 << INDENT << QString("return __m_%1;").arg(d_function->name()) << endl; | 867 << INDENT << QString("return __m_%1;").arg(d_function->name()) << endl; |
868 else { | 868 else { |
869 QString type_name = return_type->name(); | 869 s << INDENT << "return qtd_" << return_type->name() << "_from_ptr(__qt_return_value);" << endl; |
870 /* QString type_name = return_type->name(); | |
870 const ComplexTypeEntry *ctype = static_cast<const ComplexTypeEntry *>(return_type->typeEntry()); | 871 const ComplexTypeEntry *ctype = static_cast<const ComplexTypeEntry *>(return_type->typeEntry()); |
871 if(ctype->isAbstract()) | 872 if(ctype->isAbstract()) |
872 type_name = type_name + "_ConcreteWrapper"; | 873 type_name = type_name + "_ConcreteWrapper"; |
873 | 874 |
874 QString return_type_name = return_type->name(); | 875 QString return_type_name = return_type->name(); |
892 << INDENT << "}"; | 893 << INDENT << "}"; |
893 } else { | 894 } else { |
894 s << INDENT << "auto return_value = new " << type_name << "(__qt_return_value, true);" << endl | 895 s << INDENT << "auto return_value = new " << type_name << "(__qt_return_value, true);" << endl |
895 << INDENT << "return_value.__no_real_delete = true;" << endl | 896 << INDENT << "return_value.__no_real_delete = true;" << endl |
896 << INDENT << "return return_value;" << endl; | 897 << INDENT << "return return_value;" << endl; |
897 } | 898 }*/ |
898 } | 899 } |
899 s << endl; | 900 s << endl; |
900 } | 901 } |
901 if (return_type->isArray()) { | 902 if (return_type->isArray()) { |
902 s << INDENT << "return __qt_return_value[0 .. " << return_type->arrayElementCount() << "];" << endl; | 903 s << INDENT << "return __qt_return_value[0 .. " << return_type->arrayElementCount() << "];" << endl; |
2598 | 2599 |
2599 void DGenerator::writeConversionFunction(QTextStream &s, const AbstractMetaClass *d_class) | 2600 void DGenerator::writeConversionFunction(QTextStream &s, const AbstractMetaClass *d_class) |
2600 { | 2601 { |
2601 const ComplexTypeEntry *ctype = d_class->typeEntry(); | 2602 const ComplexTypeEntry *ctype = d_class->typeEntry(); |
2602 QString class_name = ctype->name(); | 2603 QString class_name = ctype->name(); |
2604 QString return_type_name = class_name; | |
2605 if(ctype->designatedInterface()) | |
2606 return_type_name = ctype->designatedInterface()->name(); | |
2607 s << return_type_name << " qtd_" << class_name << "_from_ptr(void* __qt_return_value) {" << endl; | |
2603 | 2608 |
2604 if(ctype->isQObject()) { | 2609 if(ctype->isQObject()) { |
2605 s << class_name << " qtd_" << class_name << "_from_ptr(void* __qt_return_value) {" << endl; | |
2606 QString type_name = class_name; | 2610 QString type_name = class_name; |
2607 if(ctype->isAbstract()) | 2611 if(ctype->isAbstract()) |
2608 type_name = type_name + "_ConcreteWrapper"; | 2612 type_name = type_name + "_ConcreteWrapper"; |
2609 | 2613 |
2610 s << INDENT << "if (__qt_return_value is null)" << endl | 2614 s << INDENT << "if (__qt_return_value is null)" << endl |
2615 << INDENT << " qtd_" << class_name << "_create_link(new_obj.nativeId, cast(void*) new_obj);" << endl | 2619 << INDENT << " qtd_" << class_name << "_create_link(new_obj.nativeId, cast(void*) new_obj);" << endl |
2616 << INDENT << " new_obj.__no_real_delete = true;" << endl | 2620 << INDENT << " new_obj.__no_real_delete = true;" << endl |
2617 << INDENT << " return new_obj;" << endl | 2621 << INDENT << " return new_obj;" << endl |
2618 << INDENT << "} else" << endl | 2622 << INDENT << "} else" << endl |
2619 << INDENT << " return cast(" << class_name << ") d_obj;" << endl; | 2623 << INDENT << " return cast(" << class_name << ") d_obj;" << endl; |
2620 s << "}" << endl << endl; | 2624 } else if (ctype->isObject()) { |
2621 | |
2622 } /* else if (ctype->isObject()) { | |
2623 QString type_name = class_name; | 2625 QString type_name = class_name; |
2624 if(ctype->isAbstract()) | 2626 if(ctype->isAbstract()) |
2625 type_name = type_name + "_ConcreteWrapper"; | 2627 type_name = type_name + "_ConcreteWrapper"; |
2626 | |
2627 QString return_type_name = ctype->name(); | |
2628 if(ctype->designatedInterface()) | |
2629 return_type_name = ctype->designatedInterface()->name(); | |
2630 | 2628 |
2631 // if class has virtual functions then it has classname_entity function so | 2629 // if class has virtual functions then it has classname_entity function so |
2632 // we can look for D Object pointer. otherwise create new wrapper | 2630 // we can look for D Object pointer. otherwise create new wrapper |
2633 if (d_class->hasVirtualFunctions()) { | 2631 if (d_class->hasVirtualFunctions()) { |
2634 s << INDENT << "void* d_obj = __" << ctype->name() << "_entity(__qt_return_value);" << endl | 2632 s << INDENT << "void* d_obj = __" << ctype->name() << "_entity(__qt_return_value);" << endl |
2643 } else { | 2641 } else { |
2644 s << INDENT << "auto return_value = new " << type_name << "(__qt_return_value, true);" << endl | 2642 s << INDENT << "auto return_value = new " << type_name << "(__qt_return_value, true);" << endl |
2645 << INDENT << "return_value.__no_real_delete = true;" << endl | 2643 << INDENT << "return_value.__no_real_delete = true;" << endl |
2646 << INDENT << "return return_value;" << endl; | 2644 << INDENT << "return return_value;" << endl; |
2647 } | 2645 } |
2648 }*/ | 2646 } |
2647 s << "}" << endl << endl; | |
2649 } | 2648 } |
2650 | 2649 |
2651 | 2650 |
2652 void DGenerator::writeQObjectFunctions(QTextStream &s, const AbstractMetaClass *d_class) | 2651 void DGenerator::writeQObjectFunctions(QTextStream &s, const AbstractMetaClass *d_class) |
2653 { | 2652 { |