Mercurial > projects > qtd
comparison generator/cppimplgenerator.cpp @ 260:b5773ccab07d lifetime
closer
author | maxter |
---|---|
date | Fri, 18 Sep 2009 18:52:03 +0000 |
parents | 515d6e1c7b10 |
children | 90131f64c9c9 |
comparison
equal
deleted
inserted
replaced
259:515d6e1c7b10 | 260:b5773ccab07d |
---|---|
599 foreach (AbstractMetaFunction *function, java_class->functions()) { | 599 foreach (AbstractMetaFunction *function, java_class->functions()) { |
600 if (function->isConstructor()) | 600 if (function->isConstructor()) |
601 writeShellConstructor(s, function); | 601 writeShellConstructor(s, function); |
602 } | 602 } |
603 | 603 |
604 if (java_class->hasVirtualDestructor()) | 604 if (java_class->isPolymorphic()) |
605 writeShellDestructor(s, java_class); | 605 writeShellDestructor(s, java_class); |
606 | 606 |
607 if (java_class->isQObject()) | 607 if (java_class->isQObject()) |
608 writeQObjectFunctions(s, java_class); | 608 writeQObjectFunctions(s, java_class); |
609 else if (java_class->typeEntry()->isObject()) | 609 else if (java_class->typeEntry()->isObject()) |
1389 } | 1389 } |
1390 s << ")"; | 1390 s << ")"; |
1391 | 1391 |
1392 if (cls->isQObject()) | 1392 if (cls->isQObject()) |
1393 s << "," << endl << " QtD_QObjectEntity(this, d_ptr)"; | 1393 s << "," << endl << " QtD_QObjectEntity(this, d_ptr)"; |
1394 else if (cls->hasVirtualDestructor()) | 1394 else if (cls->isPolymorphic()) |
1395 s << "," << endl << " QtD_Entity(d_ptr)"; | 1395 s << "," << endl << " QtD_Entity(d_ptr)"; |
1396 /* qtd s << " m_meta_object(0)," << endl; | 1396 /* qtd s << " m_meta_object(0)," << endl; |
1397 s << " m_vtable(0)," << endl | 1397 s << " m_vtable(0)," << endl |
1398 << " m_link(0)" << endl; | 1398 << " m_link(0)" << endl; |
1399 */ | 1399 */ |
1734 s << "}" << endl << endl; | 1734 s << "}" << endl << endl; |
1735 } | 1735 } |
1736 | 1736 |
1737 void CppImplGenerator::writeObjectFunctions(QTextStream &s, const AbstractMetaClass *java_class) | 1737 void CppImplGenerator::writeObjectFunctions(QTextStream &s, const AbstractMetaClass *java_class) |
1738 { | 1738 { |
1739 if (java_class->hasVirtualDestructor()) | 1739 if (java_class->isPolymorphic()) |
1740 { | 1740 { |
1741 s << "extern \"C\" DLL_PUBLIC const void* qtd_" << java_class->name() << "_staticTypeId()" << endl; | 1741 s << "extern \"C\" DLL_PUBLIC const void* qtd_" << java_class->name() << "_staticTypeId()" << endl; |
1742 s << "{" << endl; | 1742 s << "{" << endl; |
1743 { | 1743 { |
1744 Indentation indent(INDENT); | 1744 Indentation indent(INDENT); |
1745 s << INDENT << "return &typeid(" << java_class->qualifiedCppName() << ");" << endl; | 1745 s << INDENT << "return &typeid(" << java_class->qualifiedCppName() << ");" << endl; |
1746 } | 1746 } |
1747 s << "}" << endl << endl; | 1747 s << "}" << endl << endl; |
1748 | 1748 |
1749 if (!java_class->baseClass()) | 1749 if (!java_class->baseClass()) |
1750 { | 1750 { |
1751 s << "extern \"C\" DLL_PUBLIC void* qtd_" << java_class->name() << "_dId(void *q_ptr)" << endl; | 1751 s << "extern \"C\" DLL_PUBLIC void* qtd_" << java_class->name() << "_dId(void *nativeId)" << endl |
1752 s << "{" << endl; | 1752 << "{" << endl |
1753 { | 1753 << " QtD_Entity *a = dynamic_cast<QtD_Entity*>((" << java_class->qualifiedCppName() << "*)nativeId);" << endl |
1754 Indentation indent(INDENT); | 1754 << " return a ? a->dId : NULL;" << endl |
1755 s << INDENT << "QtD_Entity* a = dynamic_cast<QtD_Entity*>((" << java_class->qualifiedCppName() << "*)q_ptr);" << endl | 1755 << "}" << endl << endl |
1756 << INDENT << "if (a != NULL)" << endl | |
1757 << INDENT << " return a->dId;" << endl | |
1758 << INDENT << "else" << endl | |
1759 << INDENT << " return NULL;" << endl; | |
1760 } | |
1761 s << "}" << endl << endl; | |
1762 | 1756 |
1763 s << "extern \"C\" DLL_PUBLIC const void* qtd_" << java_class->name() << "_typeId(void *nativeId)" << endl; | 1757 << "extern \"C\" DLL_PUBLIC const void* qtd_" << java_class->name() << "_typeId(void *nativeId)" << endl |
1764 s << "{" << endl; | 1758 << "{" << endl |
1765 { | 1759 << " return &typeid((" << java_class->qualifiedCppName() << "*)nativeId);" << endl |
1766 Indentation indent(INDENT); | 1760 << "}" << endl << endl; |
1767 s << INDENT << "return &typeid((" << java_class->qualifiedCppName() << "*)nativeId);" << endl; | |
1768 } | |
1769 s << "}" << endl << endl; | |
1770 } | 1761 } |
1771 } | 1762 } |
1772 } | 1763 } |
1773 | 1764 |
1774 void CppImplGenerator::writeVirtualFunctionOverride(QTextStream &s, | 1765 void CppImplGenerator::writeVirtualFunctionOverride(QTextStream &s, |
1890 */ | 1881 */ |
1891 uint nativeArgCount = 0; | 1882 uint nativeArgCount = 0; |
1892 const AbstractMetaClass *cls = java_function->ownerClass(); | 1883 const AbstractMetaClass *cls = java_function->ownerClass(); |
1893 | 1884 |
1894 if (java_function->isConstructor() && | 1885 if (java_function->isConstructor() && |
1895 cls->typeEntry()->isObject()) | 1886 cls->isPolymorphic()) |
1896 { | 1887 { |
1897 s << "void *d_ptr"; | 1888 s << "void *d_ptr"; |
1898 nativeArgCount++; | 1889 nativeArgCount++; |
1899 } | 1890 } |
1900 | 1891 |
3538 { | 3529 { |
3539 AbstractMetaArgumentList arguments = java_function->arguments(); | 3530 AbstractMetaArgumentList arguments = java_function->arguments(); |
3540 | 3531 |
3541 int written_arguments = 0; | 3532 int written_arguments = 0; |
3542 const AbstractMetaClass *cls = java_function->ownerClass(); | 3533 const AbstractMetaClass *cls = java_function->ownerClass(); |
3543 if (java_function->isConstructor() && cls->typeEntry()->isObject()) { | 3534 if (java_function->isConstructor() && cls->isPolymorphic()) { |
3544 s << "d_ptr"; | 3535 s << "d_ptr"; |
3545 written_arguments++; | 3536 written_arguments++; |
3546 } | 3537 } |
3547 for (int i=0; i<arguments.size(); ++i) { | 3538 for (int i=0; i<arguments.size(); ++i) { |
3548 const AbstractMetaArgument *argument = arguments.at(i); | 3539 const AbstractMetaArgument *argument = arguments.at(i); |