Mercurial > projects > qtd
comparison generator/cppimplgenerator.cpp @ 357:9784459f0750
An attempt (failed due to optlink) to improve locality of declarations exported from QtD executables
Q_CLASSINFO implementation
Now Qtd can be built on Windows
author | Max Samukha <maxter@spambox.com> |
---|---|
date | Wed, 02 Jun 2010 19:38:05 +0300 |
parents | 08c1ca7975ab |
children | beaf4a2974d7 |
comparison
equal
deleted
inserted
replaced
356:12cec2d14e1c | 357:9784459f0750 |
---|---|
380 uint options = CppImplGenerator::StandardJNISignature) | 380 uint options = CppImplGenerator::StandardJNISignature) |
381 { | 381 { |
382 QString s; | 382 QString s; |
383 | 383 |
384 if (options & CppImplGenerator::ExternC) | 384 if (options & CppImplGenerator::ExternC) |
385 s += "extern \"C\" DLL_PUBLIC "; | 385 s += "QTD_EXTERN QTD_DLL_PUBLIC "; |
386 /* qtd | 386 /* qtd |
387 if (options & CppImplGenerator::JNIExport) | 387 if (options & CppImplGenerator::JNIExport) |
388 s += "Q_DECL_EXPORT "; | 388 s += "Q_DECL_EXPORT "; |
389 */ | 389 */ |
390 if (options & CppImplGenerator::ReturnType) | 390 if (options & CppImplGenerator::ReturnType) |
476 | 476 |
477 // in case of renamed class | 477 // in case of renamed class |
478 InterfaceTypeEntry *ite = static_cast<InterfaceTypeEntry*>(iface->typeEntry()); | 478 InterfaceTypeEntry *ite = static_cast<InterfaceTypeEntry*>(iface->typeEntry()); |
479 QString real_name = ite->origin()->qualifiedCppName(); | 479 QString real_name = ite->origin()->qualifiedCppName(); |
480 | 480 |
481 s << "extern \"C\" DLL_PUBLIC " << real_name << "* qtd_" << java_class->name() << "_cast_to_" << iface->qualifiedCppName() | 481 s << "QTD_EXTERN QTD_DLL_PUBLIC " << real_name << "* qtd_" << java_class->name() << "_cast_to_" << iface->qualifiedCppName() |
482 << "(" << java_class->qualifiedCppName() << " *ptr)" << endl << "{" << endl; | 482 << "(" << java_class->qualifiedCppName() << " *ptr)" << endl << "{" << endl; |
483 Indentation indent(INDENT); | 483 Indentation indent(INDENT); |
484 s << INDENT << "return dynamic_cast<" << real_name << "*>(ptr);" << endl; | 484 s << INDENT << "return dynamic_cast<" << real_name << "*>(ptr);" << endl; |
485 s << "}" << endl << endl; | 485 s << "}" << endl << endl; |
486 } | 486 } |
487 } | 487 } |
488 } | 488 } |
489 | |
490 void CppImplGenerator::writeInitCallbacks(QTextStream &s, const AbstractMetaClass *java_class) | |
491 { | |
492 QString initArgs = "pfunc_abstr *virts"; | |
493 if (java_class->isQObject()) | |
494 initArgs += ", pfunc_abstr *sigs, pfunc_abstr qobj_del"; | |
495 | |
496 s << "extern \"C\" DLL_PUBLIC void qtd_" << java_class->name() | |
497 << QString("_initCallBacks(%1) {").arg(initArgs) << endl; | |
498 | |
499 // virtual functions handlers | |
500 AbstractMetaFunctionList virtualFunctions = java_class->virtualFunctions(); | |
501 for (int pos = 0; pos<virtualFunctions.size(); ++pos) { | |
502 const AbstractMetaFunction *function = virtualFunctions.at(pos); | |
503 if (!notWrappedYet(function) && java_class == function->declaringClass()) { // qtd2 | |
504 s << " " << function->marshalledName(false) << "_dispatch = " | |
505 "(pf" << function->marshalledName(false) << "_dispatch) virts[" << pos << "];" << endl; | |
506 } | |
507 } | |
508 // D-side signal callbacks | |
509 if (java_class->name() == "QObject") { | |
510 s << " qtd_QObject_qt_metacall_dispatch = (QtMetacallCallback)sigs[0];" << endl | |
511 << " qtd_QObject_metaObject_dispatch = (MetaObjectCallback)sigs[1];" << endl; | |
512 } | |
513 s << "}" << endl; | |
514 } | |
515 | |
516 | 489 |
517 void CppImplGenerator::write(QTextStream &s, const AbstractMetaClass *java_class) | 490 void CppImplGenerator::write(QTextStream &s, const AbstractMetaClass *java_class) |
518 { | 491 { |
519 | 492 |
520 bool shellClass = java_class->generateShellClass(); | 493 bool shellClass = java_class->generateShellClass(); |
573 if (hasCustomDestructor(java_class)) */ | 546 if (hasCustomDestructor(java_class)) */ |
574 | 547 |
575 writeFinalDestructor(s, java_class); | 548 writeFinalDestructor(s, java_class); |
576 | 549 |
577 if (java_class->isQObject()) { | 550 if (java_class->isQObject()) { |
578 writeQObjectEntity(s, java_class); | 551 writeQObjectEntity(s, java_class); |
579 writeSignalsHandling(s, java_class); | |
580 } | 552 } |
581 if (shellClass) { | 553 if (shellClass) { |
582 foreach (AbstractMetaFunction *function, java_class->functions()) { | 554 foreach (AbstractMetaFunction *function, java_class->functions()) { |
583 if (function->isConstructor() && !function->isPrivate()) | 555 if (function->isConstructor() && !function->isPrivate()) |
584 writeShellConstructor(s, function); | 556 writeShellConstructor(s, function); |
697 writeValueFunctions(s, java_class); | 669 writeValueFunctions(s, java_class); |
698 | 670 |
699 if (java_class->isQObject()) | 671 if (java_class->isQObject()) |
700 { | 672 { |
701 s << endl << endl | 673 s << endl << endl |
702 << "extern \"C\" DLL_PUBLIC void* qtd_" << java_class->name() << "_staticMetaObject() {" << endl | 674 << "QTD_EXTERN QTD_DLL_PUBLIC void* qtd_" << java_class->name() << "_staticMetaObject() {" << endl |
703 << " return (void*)&" << java_class->name() << "::staticMetaObject;" << endl | 675 << " return (void*)&" << java_class->name() << "::staticMetaObject;" << endl |
704 << "}" << endl; | 676 << "}" << endl; |
705 } | 677 } |
706 | 678 |
707 if (java_class->typeEntry()->isValue()) | 679 if (java_class->typeEntry()->isValue()) |
708 { | 680 { |
709 if (!java_class->typeEntry()->hasPrivateCopyConstructor()) // can do a copy if we have a public ctor or don't have any | 681 if (!java_class->typeEntry()->hasPrivateCopyConstructor()) // can do a copy if we have a public ctor or don't have any |
710 { | 682 { |
711 QString argName = "orig"; | 683 QString argName = "orig"; |
712 s << endl << endl | 684 s << endl << endl |
713 << "extern \"C\" DLL_PUBLIC void qtd_" << java_class->name() << "_placed_copy(void* " | 685 << "QTD_EXTERN QTD_DLL_PUBLIC void qtd_" << java_class->name() << "_placed_copy(void* " |
714 << argName << ", void* place) {" << endl | 686 << argName << ", void* place) {" << endl |
715 << QString(" const %1& __qt_%2 = (const %1& ) *(%1 *)%2;").arg(shellClassName(java_class)).arg(argName) << endl | 687 << QString(" const %1& __qt_%2 = (const %1& ) *(%1 *)%2;").arg(shellClassName(java_class)).arg(argName) << endl |
716 << QString(" %1 *result = new (place) %1 (__qt_%2);").arg(java_class->qualifiedCppName()).arg(argName) << endl; | 688 << QString(" %1 *result = new (place) %1 (__qt_%2);").arg(java_class->qualifiedCppName()).arg(argName) << endl; |
717 // writeFinalConstructor(s, ctor, "result", "original", "(place)"); | 689 // writeFinalConstructor(s, ctor, "result", "original", "(place)"); |
718 s << "}"; | 690 s << "}"; |
719 | 691 |
720 s << endl << endl | 692 s << endl << endl |
721 << "extern \"C\" DLL_PUBLIC void* qtd_" << java_class->name() << "_native_copy(void* " << argName << ") {" << endl | 693 << "QTD_EXTERN QTD_DLL_PUBLIC void* qtd_" << java_class->name() << "_native_copy(void* " << argName << ") {" << endl |
722 << QString(" const %1& __qt_%2 = (const %1& ) *(%1 *)%2;").arg(shellClassName(java_class)).arg(argName) << endl | 694 << QString(" const %1& __qt_%2 = (const %1& ) *(%1 *)%2;").arg(shellClassName(java_class)).arg(argName) << endl |
723 << QString(" %1 *result = new %1 (__qt_%2);").arg(java_class->qualifiedCppName()).arg(argName) << endl | 695 << QString(" %1 *result = new %1 (__qt_%2);").arg(java_class->qualifiedCppName()).arg(argName) << endl |
724 << " return result;" << endl; | 696 << " return result;" << endl; |
725 s << "}"; | 697 s << "}"; |
726 } | 698 } |
731 priGenerator->addSource(java_class->package(), fileNameForClass(java_class)); | 703 priGenerator->addSource(java_class->package(), fileNameForClass(java_class)); |
732 } | 704 } |
733 | 705 |
734 void CppImplGenerator::writeValueFunctions(QTextStream &s, const AbstractMetaClass *java_class) | 706 void CppImplGenerator::writeValueFunctions(QTextStream &s, const AbstractMetaClass *java_class) |
735 { | 707 { |
736 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()); | 708 s << QString("QTD_EXTERN QTD_DLL_PUBLIC bool qtd_%1_QTypeInfo_isComplex() { return (bool) QTypeInfo<%2>::isComplex; }\n").arg(java_class->name()).arg(java_class->qualifiedCppName()); |
737 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()); | 709 s << QString("QTD_EXTERN QTD_DLL_PUBLIC bool qtd_%1_QTypeInfo_isStatic() { return (bool) QTypeInfo<%2>::isStatic; }\n").arg(java_class->name()).arg(java_class->qualifiedCppName()); |
738 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()); | 710 s << QString("QTD_EXTERN QTD_DLL_PUBLIC bool qtd_%1_QTypeInfo_isLarge() { return (bool) QTypeInfo<%2>::isLarge; }\n").arg(java_class->name()).arg(java_class->qualifiedCppName()); |
739 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()); | 711 s << QString("QTD_EXTERN QTD_DLL_PUBLIC bool qtd_%1_QTypeInfo_isPointer() { return (bool) QTypeInfo<%2>::isPointer; }\n").arg(java_class->name()).arg(java_class->qualifiedCppName()); |
740 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()); | 712 s << QString("QTD_EXTERN QTD_DLL_PUBLIC bool qtd_%1_QTypeInfo_isDummy() { return (bool) QTypeInfo<%2>::isDummy; }\n").arg(java_class->name()).arg(java_class->qualifiedCppName()); |
741 } | 713 } |
742 | 714 |
743 void CppImplGenerator::writeVirtualDispatchFunction(QTextStream &s, const AbstractMetaFunction *function, const AbstractMetaClass *java_class, bool d_export) | 715 void CppImplGenerator::writeVirtualDispatchFunction(QTextStream &s, const AbstractMetaFunction *function, const AbstractMetaClass *java_class, bool d_export) |
744 { | 716 { |
745 uint options2 = ReturnType | ExternC; | 717 uint options2 = ReturnType | ExternC; |
746 QString return_type = jniReturnName(function, options2); | 718 QString return_type = jniReturnName(function, options2); |
747 QString f_name = function->marshalledName(false) + "_dispatch"; | 719 |
748 | 720 AbstractMetaFunction::Options opts(AbstractMetaFunction::NoExternNamespace | AbstractMetaFunction::DeclaringClass); |
749 if(!d_export) | 721 QString f_name = function->marshalledName(opts) + "_dispatch"; |
750 s << "extern \"C\" "; | 722 |
751 | 723 if (d_export) { |
752 if (!cpp_shared || d_export) { | 724 QString qtdExtern = "extern(C)"; // TODO: should be settable via a generator switch |
753 s << return_type << " " << f_name; | 725 if (cpp_shared) { |
754 writeVirtualDispatchArguments(s, function, d_export); | 726 |
755 if(!d_export) | 727 s << qtdExtern << "{ extern export " << return_type << " function"; |
756 s << ";"; | 728 writeVirtualDispatchArguments(s, function, d_export); |
757 } else if (cpp_shared) { | 729 s << " qtd_" << f_name << "; }" << endl; |
758 if (function->declaringClass() == java_class) { | 730 |
759 s << "typedef " << return_type << " " << "(*pf" << f_name << ")"; | 731 s << qtdExtern << " " << return_type << " qtd_export_" << f_name; |
760 writeVirtualDispatchArguments(s, function, false); | 732 writeVirtualDispatchArguments(s, function, d_export); |
761 s << ";" << endl | 733 |
762 << "pf" << f_name << " " << f_name << ";"; | 734 } else { |
763 } else { | 735 s << qtdExtern << " " << return_type << " qtd_" << f_name; |
764 s << "extern pf" << f_name << " " << f_name << ";"; | 736 writeVirtualDispatchArguments(s, function, d_export); |
765 } | 737 } |
766 } | 738 } else { |
767 | 739 QString module = packageToQtModule(java_class->package()); |
768 s << endl; | 740 s << "QTD_EXPORT_DECL(" << module << ", " << return_type << ", " << f_name << ", "; |
741 writeVirtualDispatchArguments(s, function, d_export); | |
742 s << ")" << endl; | |
743 | |
744 if (function->declaringClass() == java_class) { | |
745 s << "QTD_EXPORT(" << module << ", " << f_name << ")" << endl; | |
746 } | |
747 } | |
769 } | 748 } |
770 | 749 |
771 void CppImplGenerator::writeShellVirtualFunction(QTextStream &s, const AbstractMetaFunction *function, | 750 void CppImplGenerator::writeShellVirtualFunction(QTextStream &s, const AbstractMetaFunction *function, |
772 const AbstractMetaClass *implementor, int id) | 751 const AbstractMetaClass *implementor, int id) |
773 { | 752 { |
859 | 838 |
860 if (f_type->isEnum() || f_type->isFlags()) | 839 if (f_type->isEnum() || f_type->isFlags()) |
861 s << "(" << f_type->typeEntry()->qualifiedCppName() <<") "; | 840 s << "(" << f_type->typeEntry()->qualifiedCppName() <<") "; |
862 } | 841 } |
863 | 842 |
864 s << function->marshalledName(false) << "_dispatch("; | 843 s << function->marshalledName(AbstractMetaFunction::DeclaringClass) << "_dispatch("; |
865 if (implementor->isQObject()) | 844 if (implementor->isQObject()) |
866 s << "QObjectLink::getLink(this)->dId"; | 845 s << "QObjectLink::getLink(this)->dId"; |
867 else | 846 else |
868 s << "this->dId"; | 847 s << "this->dId"; |
869 | 848 |
889 //s << "std::cout << \"leaving " << function->marshalledName() << " \\n\"; " << endl; | 868 //s << "std::cout << \"leaving " << function->marshalledName() << " \\n\"; " << endl; |
890 | 869 |
891 if (f_type) { | 870 if (f_type) { |
892 if (f_type->name() == "QModelIndex") { | 871 if (f_type->name() == "QModelIndex") { |
893 s << INDENT << "QModelIndex __qt_return_value = qtd_to_QModelIndex( __d_return_value );" << endl; | 872 s << INDENT << "QModelIndex __qt_return_value = qtd_to_QModelIndex( __d_return_value );" << endl; |
894 #ifdef Q_OS_WIN32 | |
895 s << "qtd_dummy();" << endl; // hack!!! | |
896 #endif | |
897 s << INDENT << "return __qt_return_value;" << endl; | 873 s << INDENT << "return __qt_return_value;" << endl; |
898 } else if (f_type->typeEntry()->isStructInD()) | 874 } else if (f_type->typeEntry()->isStructInD()) |
899 s << INDENT << "return __d_return_value;" << endl; | 875 s << INDENT << "return __d_return_value;" << endl; |
900 | 876 |
901 if (f_type->isContainer()) { | 877 if (f_type->isContainer()) { |
917 } | 893 } |
918 } | 894 } |
919 | 895 |
920 s << "}" << endl << endl; | 896 s << "}" << endl << endl; |
921 // ---------------------------- | 897 // ---------------------------- |
898 } | |
899 | |
900 void CppImplGenerator::writeInitCallbacks(QTextStream &s, const AbstractMetaClass *java_class) | |
901 { | |
902 QString initArgs = "pfunc_abstr *virts"; | |
903 if (java_class->name() == "QObject") | |
904 initArgs += ", pfunc_abstr *sigs"; | |
905 | |
906 s << "QTD_EXTERN QTD_DLL_EXPORT void qtd_" << java_class->name() | |
907 << QString("_initCallBacks(%1) {").arg(initArgs) << endl; | |
908 | |
909 // virtual functions handlers | |
910 AbstractMetaFunctionList virtualFunctions = java_class->virtualFunctions(); | |
911 AbstractMetaFunction::Options opts(AbstractMetaFunction::DeclaringClass | AbstractMetaFunction::NoExternNamespace); | |
912 for (int pos = 0; pos<virtualFunctions.size(); ++pos) { | |
913 const AbstractMetaFunction *function = virtualFunctions.at(pos); | |
914 if (!notWrappedYet(function) && java_class == function->declaringClass()) { // qtd2 | |
915 QString mName = function->marshalledName(opts); | |
916 s << " qtd_" << mName << "_dispatch = " | |
917 "(qtd_" << mName << "_dispatch_t) virts[" << pos << "];" << endl; | |
918 } | |
919 } | |
920 // D-side signal callbacks | |
921 if (java_class->name() == "QObject") { | |
922 s << " qtd_QObject_qt_metacall_dispatch = (QtMetacallCallback)sigs[0];" << endl | |
923 << " qtd_QObject_metaObject_dispatch = (MetaObjectCallback)sigs[1];" << endl; | |
924 } | |
925 s << "}" << endl; | |
922 } | 926 } |
923 | 927 |
924 void CppImplGenerator::writeVirtualDispatchArguments(QTextStream &s, const AbstractMetaFunction *d_function, bool d_export) | 928 void CppImplGenerator::writeVirtualDispatchArguments(QTextStream &s, const AbstractMetaFunction *d_function, bool d_export) |
925 { | 929 { |
926 uint nativeArgCount = 0; | 930 uint nativeArgCount = 0; |
1282 << " return _id;" << endl | 1286 << " return _id;" << endl |
1283 << " emit_callbacks_" << java_class->name() << "[_id](dId, _a);" << endl | 1287 << " emit_callbacks_" << java_class->name() << "[_id](dId, _a);" << endl |
1284 << " return -1;" << endl | 1288 << " return -1;" << endl |
1285 << "}" << endl << endl; | 1289 << "}" << endl << endl; |
1286 */ | 1290 */ |
1287 s << "extern \"C\" DLL_PUBLIC void qtd_" << className << "_createEntity(void *nativeId, void* dId)" << endl | 1291 s << "QTD_EXTERN QTD_DLL_PUBLIC void qtd_" << className << "_createEntity(void *nativeId, void* dId)" << endl |
1288 << "{" << endl | 1292 << "{" << endl |
1289 << " new " << entityName << "((QObject*)nativeId, dId);" << endl | 1293 << " new " << entityName << "((QObject*)nativeId, dId);" << endl |
1290 << "}" << endl << endl; | 1294 << "}" << endl << endl; |
1291 } | 1295 } |
1292 | 1296 |
1342 << " emit_callbacks_" << java_class->name() << "[_id](this->dId, _a);" << endl | 1346 << " emit_callbacks_" << java_class->name() << "[_id](this->dId, _a);" << endl |
1343 << " return -1;" << endl | 1347 << " return -1;" << endl |
1344 << "}" << endl << endl; | 1348 << "}" << endl << endl; |
1345 */ | 1349 */ |
1346 | 1350 |
1347 if(cpp_shared) { | 1351 QString module = packageToQtModule(java_class->package()); |
1348 QString attr; | 1352 |
1349 if (java_class->name() == "QObject") | 1353 s << "QTD_EXPORT_DECL(" << module << ", const QMetaObject*, QObject_metaObject_dispatch, (void *dId))" << endl |
1350 attr = "extern "; | 1354 << "QTD_EXPORT_DECL(" << module << ", int, QObject_qt_metacall_dispatch, (void *dId, QMetaObject::Call _c, int _id, void **_a))" << endl; |
1351 | 1355 |
1352 s << attr << "MetaObjectCallback qtd_QObject_metaObject_dispatch;" << endl | 1356 if (java_class->name() == "QObject") { |
1353 << attr << "QtMetacallCallback qtd_QObject_qt_metacall_dispatch;" << endl; | 1357 s << "QTD_EXPORT(" << module << ", QObject_metaObject_dispatch)" << endl |
1354 } else { | 1358 << "QTD_EXPORT(" << module << ", QObject_qt_metacall_dispatch)" << endl; |
1355 s << "extern \"C\" const QMetaObject* qtd_QObject_metaObject_dispatch(void *dId);" << endl | |
1356 << "extern \"C\" int qtd_QObject_qt_metacall_dispatch(void *dId, QMetaObject::Call _c, int _id, void **_a);" << endl; | |
1357 } | 1359 } |
1358 | 1360 |
1359 // TODO: QMetaObject should be included in the typesystem | 1361 // TODO: QMetaObject should be included in the typesystem |
1360 s << endl | 1362 s << endl |
1361 << "const QMetaObject * " << shellClassName(java_class) << "::metaObject() const" << endl | 1363 << "const QMetaObject * " << shellClassName(java_class) << "::metaObject() const" << endl |
1378 << "int " << shellClassName(java_class) << "::__override_qt_metacall(QMetaObject::Call _c, int _id, void **_a)" << endl | 1380 << "int " << shellClassName(java_class) << "::__override_qt_metacall(QMetaObject::Call _c, int _id, void **_a)" << endl |
1379 << "{" << endl | 1381 << "{" << endl |
1380 << " return " << java_class->qualifiedCppName() << "::qt_metacall(_c, _id, _a);" | 1382 << " return " << java_class->qualifiedCppName() << "::qt_metacall(_c, _id, _a);" |
1381 << "}" << endl << endl | 1383 << "}" << endl << endl |
1382 | 1384 |
1383 << "extern \"C\" DLL_PUBLIC int qtd_" << java_class->name() << "_qt_metacall(void* __this_nativeId, QMetaObject::Call _c, int _id, void **_a)" | 1385 << "QTD_EXTERN QTD_DLL_PUBLIC int qtd_" << java_class->name() << "_qt_metacall(void* __this_nativeId, QMetaObject::Call _c, int _id, void **_a)" |
1384 << "{" << endl | 1386 << "{" << endl |
1385 << " " << shellClassName(java_class) << " *__qt_this = (" << shellClassName(java_class) << " *) __this_nativeId;" << endl | 1387 << " " << shellClassName(java_class) << " *__qt_this = (" << shellClassName(java_class) << " *) __this_nativeId;" << endl |
1386 << " return __qt_this->__override_qt_metacall(_c, _id, _a);" << endl | 1388 << " return __qt_this->__override_qt_metacall(_c, _id, _a);" << endl |
1387 << "}" << endl << endl; | 1389 << "}" << endl << endl; |
1388 } | 1390 } |
1429 } | 1431 } |
1430 */ | 1432 */ |
1431 s << endl << "}"; | 1433 s << endl << "}"; |
1432 s << endl << endl; | 1434 s << endl << endl; |
1433 } | 1435 } |
1434 | |
1435 void CppImplGenerator::writeSignalsHandling(QTextStream &s, const AbstractMetaClass *java_class) | |
1436 { | |
1437 return; // #TODO probably don't need this function at all | |
1438 | |
1439 s << "extern \"C\" typedef void (*EmitCallback)(void*, void**);" << endl; | |
1440 AbstractMetaFunctionList signal_funcs = signalFunctions(java_class); | |
1441 | |
1442 if (cpp_shared) | |
1443 if(signal_funcs.size() > 0) | |
1444 s << "EmitCallback emit_callbacks_" << java_class->name() << "[" << signal_funcs.size() << "];" << endl; | |
1445 else | |
1446 s << "EmitCallback emit_callbacks_" << java_class->name() << "[1];" << endl; // Hack for msvc. | |
1447 else { | |
1448 // D-side signal callbacks | |
1449 for(int i = 0; i < signal_funcs.size(); i++) { | |
1450 AbstractMetaFunction *signal = signal_funcs.at(i); | |
1451 s << "extern \"C\" DLL_PUBLIC void " << signalExternName(java_class, signal) << "_handle(void* dId, void** args);" << endl; | |
1452 } | |
1453 | |
1454 if(signal_funcs.size() > 0) | |
1455 s << "EmitCallback emit_callbacks_" << java_class->name() << "[" << signal_funcs.size() << "] = {" << endl; | |
1456 else | |
1457 s << "EmitCallback emit_callbacks_" << java_class->name() << "[1] = {" << endl; // Hack for msvc. | |
1458 for(int i = 0; i < signal_funcs.size(); i++) { | |
1459 AbstractMetaFunction *signal = signal_funcs.at(i); | |
1460 s << endl; | |
1461 if (i != 0) | |
1462 s << ", "; | |
1463 s << "&" << signalExternName(java_class, signal) << "_handle"; | |
1464 } | |
1465 s << endl << "};" << endl << endl; | |
1466 } | |
1467 } | |
1468 | |
1469 | 1436 |
1470 void CppImplGenerator::writeShellConstructor(QTextStream &s, const AbstractMetaFunction *java_function) | 1437 void CppImplGenerator::writeShellConstructor(QTextStream &s, const AbstractMetaFunction *java_function) |
1471 { | 1438 { |
1472 if (java_function->isModifiedRemoved(TypeSystem::ShellCode)) | 1439 if (java_function->isModifiedRemoved(TypeSystem::ShellCode)) |
1473 return; | 1440 return; |
1832 s << "}" << endl << endl; | 1799 s << "}" << endl << endl; |
1833 } | 1800 } |
1834 | 1801 |
1835 void CppImplGenerator::writeQtdEntityFunction(QTextStream &s, const AbstractMetaClass *java_class) | 1802 void CppImplGenerator::writeQtdEntityFunction(QTextStream &s, const AbstractMetaClass *java_class) |
1836 { | 1803 { |
1837 s << "extern \"C\" DLL_PUBLIC void *__" << java_class->name() << "_entity(void *q_ptr)" << endl; | 1804 s << "QTD_EXTERN QTD_DLL_PUBLIC void *__" << java_class->name() << "_entity(void *q_ptr)" << endl; |
1838 s << "{" << endl; | 1805 s << "{" << endl; |
1839 { | 1806 { |
1840 Indentation indent(INDENT); | 1807 Indentation indent(INDENT); |
1841 s << INDENT << "QtdObjectLink* a = dynamic_cast<QtdObjectLink*>((" << java_class->qualifiedCppName() << "*)q_ptr);" << endl | 1808 s << INDENT << "QtdObjectLink* a = dynamic_cast<QtdObjectLink*>((" << java_class->qualifiedCppName() << "*)q_ptr);" << endl |
1842 << INDENT << "if (a != NULL)" << endl | 1809 << INDENT << "if (a != NULL)" << endl |
2391 } | 2358 } |
2392 | 2359 |
2393 void CppImplGenerator::writeFinalDestructor(QTextStream &s, const AbstractMetaClass *cls) | 2360 void CppImplGenerator::writeFinalDestructor(QTextStream &s, const AbstractMetaClass *cls) |
2394 { | 2361 { |
2395 if (cls->hasConstructors() && cls->isDestructorBase()) { | 2362 if (cls->hasConstructors() && cls->isDestructorBase()) { |
2396 s << INDENT << "extern \"C\" DLL_PUBLIC void qtd_" << cls->name() << "_delete(void* nativeId)" << endl | 2363 s << INDENT << "QTD_EXTERN QTD_DLL_PUBLIC void qtd_" << cls->name() << "_delete(void* nativeId)" << endl |
2397 << INDENT << "{" << endl | 2364 << INDENT << "{" << endl |
2398 << INDENT << " delete (" << shellClassName(cls) << "*)nativeId;" << endl | 2365 << INDENT << " delete (" << shellClassName(cls) << "*)nativeId;" << endl |
2399 << INDENT << "}" << endl << endl; | 2366 << INDENT << "}" << endl << endl; |
2400 | 2367 |
2401 s << INDENT << "extern \"C\" DLL_PUBLIC void qtd_" << cls->name() << "_destroy(void* nativeId)" << endl | 2368 s << INDENT << "QTD_EXTERN QTD_DLL_PUBLIC void qtd_" << cls->name() << "_destroy(void* nativeId)" << endl |
2402 << INDENT << "{" << endl | 2369 << INDENT << "{" << endl |
2403 << INDENT << " call_destructor((" << shellClassName(cls) << "*)nativeId);" << endl | 2370 << INDENT << " call_destructor((" << shellClassName(cls) << "*)nativeId);" << endl |
2404 << INDENT << "}" << endl << endl; | 2371 << INDENT << "}" << endl << endl; |
2405 } | 2372 } |
2406 } | 2373 } |