Skip to content

Commit

Permalink
generator: call Reporthandler::setContext more (#131)
Browse files Browse the repository at this point in the history
This adds 'context' to ReportHandler warning messages; just a string
saying what is being done.
  • Loading branch information
jbowler authored and mrbean-bremen committed Oct 29, 2023
1 parent 7e22516 commit ffb5845
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions generator/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
**
****************************************************************************/

#include <cstdio>

#include "main.h"
#include "asttoxml.h"
#include "reporthandler.h"
Expand All @@ -53,6 +55,8 @@ void displayHelp(GeneratorSet *generatorSet);
#include <QDebug>
int main(int argc, char *argv[])
{
ReportHandler::setContext("Arguments");

QScopedPointer<GeneratorSet> gs(GeneratorSet::getInstance());

QString default_file = ":/trolltech/generator/qtscript_masterinclude.h";
Expand Down Expand Up @@ -135,11 +139,13 @@ int main(int argc, char *argv[])
printf("Please wait while source files are being generated...\n");

printf("Parsing typesystem file [%s]\n", qPrintable(typesystemFileName));
ReportHandler::setContext("Typesystem");
if (!TypeDatabase::instance()->parseFile(typesystemFileName))
qFatal("Cannot parse file: '%s'", qPrintable(typesystemFileName));

printf("PreProcessing - Generate [%s] using [%s] and include-paths [%s]\n",
qPrintable(pp_file), qPrintable(fileName), qPrintable(args.value("include-paths")));
ReportHandler::setContext("Preprocess");
if (!Preprocess::preprocess(fileName, pp_file, args.value("include-paths"))) {
fprintf(stderr, "Preprocessor failed on file: '%s'\n", qPrintable(fileName));
return 1;
Expand All @@ -148,16 +154,19 @@ int main(int argc, char *argv[])
if (args.contains("ast-to-xml")) {
printf("Running ast-to-xml on file [%s] using pp_file [%s] and include-paths [%s]\n",
qPrintable(fileName), qPrintable(pp_file), qPrintable(args.value("include-paths")));
ReportHandler::setContext(QString("AST-to-XML"));
astToXML(pp_file);
return 0;
}

printf("Building model using [%s]\n", qPrintable(pp_file));
ReportHandler::setContext("Build");
gs->buildModel(pp_file);
if (args.contains("dump-object-tree")) {
gs->dumpObjectTree();
return 0;
}
ReportHandler::setContext("Generate");
printf("%s\n", qPrintable(gs->generate()));

printf("Done, %d warnings (%d known issues)\n", ReportHandler::warningCount(),
Expand Down

0 comments on commit ffb5845

Please sign in to comment.