QString GeneratorSetJava::generate() {

    // Ui conversion...
    if (do_ui_convert) {
        UiConverter converter;
        converter.setClasses(builder.classes());
        converter.convertToJui(ui_file_name, custom_widgets);
        return 0;
    } else if (!custom_widgets.isEmpty()) {
        fprintf(stderr, "NOTE: The --custom-widgets option only has an effect when used with --convert-to-jui");
    }

    // Code generation
    QList<Generator *> generators;
    PriGenerator *priGenerator = new PriGenerator;
    JavaGenerator *java_generator = 0;
    CppHeaderGenerator *cpp_header_generator = 0;
    CppImplGenerator *cpp_impl_generator = 0;
    MetaInfoGenerator *metainfo = 0;
    JumpTablePreprocessor *jumpTablePreprocessor = 0;
    JumpTableGenerator *jumpTableGenerator = 0;

    QStringList contexts;
    if (build_qdoc_japi) {
        generators << new QDocGenerator;
        contexts << "QDocGenerator";
    }

    if (native_jump_table) {
        jumpTablePreprocessor = new JumpTablePreprocessor();
        generators << jumpTablePreprocessor;
        contexts << "JumpTablePreprocessor";
    }

    if (!no_java) {
        java_generator = new JavaGenerator;
        java_generator->setDocumentationDirectory(doc_dir);
        java_generator->setDocumentationEnabled(docs_enabled);
        java_generator->setNativeJumpTable(native_jump_table);
        if (!javaOutDir.isNull())
            java_generator->setJavaOutputDirectory(javaOutDir);
        if (!outDir.isNull())
            java_generator->setLogOutputDirectory(outDir);
        generators << java_generator;

        contexts << "JavaGenerator";
    }

    if (!no_cpp_h) {
        cpp_header_generator = new CppHeaderGenerator(priGenerator);
        if (!cppOutDir.isNull())
            cpp_header_generator->setCppOutputDirectory(cppOutDir);
        generators << cpp_header_generator;
        contexts << "CppHeaderGenerator";
    }

    if (!no_cpp_impl) {
        cpp_impl_generator = new CppImplGenerator(priGenerator);
        cpp_impl_generator->setNativeJumpTable(native_jump_table);
        cpp_impl_generator->setQtJambiDebugTools(qtjambi_debug_tools);
        if (!cppOutDir.isNull())
            cpp_impl_generator->setCppOutputDirectory(cppOutDir);
        generators << cpp_impl_generator;
        contexts << "CppImplGenerator";
    }

    if (native_jump_table) {
        jumpTableGenerator = new JumpTableGenerator(jumpTablePreprocessor, priGenerator);
        generators << jumpTableGenerator;
        contexts << "JumpTableGenerator";
    }

    if (!no_metainfo) {
        metainfo = new MetaInfoGenerator(priGenerator);
        metainfo->setQtJambiDebugTools(qtjambi_debug_tools);
        if (!cppOutDir.isNull())
            metainfo->setCppOutputDirectory(cppOutDir);
        if (!javaOutDir.isNull())
            metainfo->setJavaOutputDirectory(javaOutDir);
        if (!outDir.isNull())
            metainfo->setOutputDirectory(outDir);
        generators << metainfo;
        contexts << "MetaInfoGenerator";
    }

    if (build_class_list) {
        generators << new ClassListGenerator;
        contexts << "ClassListGenerator";
    }

    if (!cppOutDir.isNull())
        priGenerator->setCppOutputDirectory(cppOutDir);
    generators << priGenerator;
    contexts << "PriGenerator";

    for (int i = 0; i < generators.size(); ++i) {
        Generator *generator = generators.at(i);
        ReportHandler::setContext(contexts.at(i));

        if (generator->outputDirectory().isNull())
            generator->setOutputDirectory(outDir);
        generator->setClasses(builder.classes());
        if (printStdout)
            generator->printClasses();
        else
            generator->generate();
    }

    QString res;
    res = QString("Classes in typesystem: %1\n"
                  "Generated:\n"
                  "  - java......: %2 (%3)\n"
                  "  - cpp-impl..: %4 (%5)\n"
                  "  - cpp-h.....: %6 (%7)\n"
                  "  - meta-info.: %8 (%9)\n"
                  "  - pri.......: %10 (%11)\n"
                 )
          .arg(builder.classes().size())
          .arg(java_generator ? java_generator->numGenerated() : 0)
          .arg(java_generator ? java_generator->numGeneratedAndWritten() : 0)
          .arg(cpp_impl_generator ? cpp_impl_generator->numGenerated() : 0)
          .arg(cpp_impl_generator ? cpp_impl_generator->numGeneratedAndWritten() : 0)
          .arg(cpp_header_generator ? cpp_header_generator->numGenerated() : 0)
          .arg(cpp_header_generator ? cpp_header_generator->numGeneratedAndWritten() : 0)
          .arg(metainfo ? metainfo->numGenerated() : 0)
          .arg(metainfo ? metainfo->numGeneratedAndWritten() : 0)
          .arg(priGenerator->numGenerated())
          .arg(priGenerator->numGeneratedAndWritten());

    return res;
}
QString GeneratorSetDylan::generate() {

    // Code generation
    QList<Generator *> generators;
    LibraryGenerator *libraryGenerator = new LibraryGenerator;
    LidGenerator *lidGenerator = new LidGenerator;
    DylanGenerator *dylan_generator = 0;
    PlainCppHeaderGenerator *cpp_header_generator = 0;
    PlainCppImplGenerator *cpp_impl_generator = 0;

    QStringList contexts;

    dylan_generator = new DylanGenerator(libraryGenerator, lidGenerator);
    if (!javaOutDir.isNull())
        dylan_generator->setDylanOutputDirectory(javaOutDir);
    if (!outDir.isNull())
        dylan_generator->setLogOutputDirectory(outDir);
    generators << dylan_generator;

    contexts << "DylanGenerator";

    cpp_header_generator = new PlainCppHeaderGenerator(lidGenerator);
    if (!cppOutDir.isNull())
        cpp_header_generator->setCppOutputDirectory(cppOutDir);
    generators << cpp_header_generator;
    contexts << "PlainCppHeaderGenerator";

    cpp_impl_generator = new PlainCppImplGenerator(lidGenerator);
    if (!cppOutDir.isNull())
        cpp_impl_generator->setCppOutputDirectory(cppOutDir);
    generators << cpp_impl_generator;
    contexts << "PlainCppImplGenerator";

    if (!cppOutDir.isNull())
        lidGenerator->setCppOutputDirectory(cppOutDir);
    generators << lidGenerator;
    contexts << "LidGenerator";

    if (!cppOutDir.isNull())
        libraryGenerator->setOutputDirectory(cppOutDir);
    generators << libraryGenerator;
    contexts << "LibraryGenerator";

    for (int i = 0; i < generators.size(); ++i) {
        Generator *generator = generators.at(i);
        ReportHandler::setContext(contexts.at(i));

        if (generator->outputDirectory().isNull())
            generator->setOutputDirectory(outDir);
        generator->setClasses(builder.classes());
        if (printStdout)
            generator->printClasses();
        else
            generator->generate();
    }

    QString res;
    res = QString("Classes in typesystem: %1\n"
                  "Generated:\n"
                  "  - dylan.....: %2 (%3)\n"
                  "  - cpp-impl..: %4 (%5)\n"
                  "  - cpp-h.....: %6 (%7)\n"
                  "  - library...: %8 (%9)\n"
                  "  - lid.......: %10 (%11)\n"
                 )
          .arg(builder.classes().size())
          .arg(dylan_generator ? dylan_generator->numGenerated() : 0)
          .arg(dylan_generator ? dylan_generator->numGeneratedAndWritten() : 0)
          .arg(cpp_impl_generator ? cpp_impl_generator->numGenerated() : 0)
          .arg(cpp_impl_generator ? cpp_impl_generator->numGeneratedAndWritten() : 0)
          .arg(cpp_header_generator ? cpp_header_generator->numGenerated() : 0)
          .arg(cpp_header_generator ? cpp_header_generator->numGeneratedAndWritten() : 0)
          .arg(libraryGenerator->numGenerated())
          .arg(libraryGenerator->numGeneratedAndWritten())
          .arg(lidGenerator->numGenerated())
          .arg(lidGenerator->numGeneratedAndWritten());

    return res;
}