Beispiel #1
0
int QSurfaceFormat_testOption(lua_State* const state)
{
    auto self = lua::get<QSurfaceFormat*>(state, 1);
    #if QT_VERSION >= QT_VERSION_CHECK(5, 3, 0)
    lua::push(state, self->testOption(
        lua::get<QSurfaceFormat::FormatOption>(state, 2)
    ));
    #else
    lua::push(state, self->testOption(
        lua::get<QSurfaceFormat::FormatOptions>(state, 2)
    ));
    #endif
    return 1;
}
Beispiel #2
0
LexicalAnalyzer::Ptr ProjectImpl::analyze(const QString& fileName) {

    LexicalAnalyzer::Ptr la = newAnalyzer(fileName);

    if (la->analyze()) {

        if (testOption(optDumpTokenStreams)) {
            QFileInfo fi(fileName);
            QString tokFileName =
                    fi.absolutePath() %
                    fi.completeBaseName() %
                    QLatin1Literal(".ptokens");

            la->tokenStream()->dump(tokFileName);
        }

        return la;
    }

    if (!hasErrors()) {
        // In case the lexer did fail without setting an error, set one now
        errors()->emitError("Failed to analye source", fileName);
    }

    return NULL;
}
Beispiel #3
0
Model::Root::Ptr ProjectImpl::parseFile(const QString& fileName) {

    LexicalAnalyzer::Ptr la = analyze(fileName);
    if (!hasErrors()) {
        Q_ASSERT(la);

        Model::Root::Ptr model = parseStream(la->tokenStream());
        if (model) {

            if (testOption(optDumpCodeModel)) {
                QFileInfo fi(fileName);
                QString modelFileName =
                        fi.absolutePath() %
                        fi.completeBaseName() %
                        QLatin1Literal(".pmodel");

                if (!model->exportModel(modelFileName)) {
                    errors()->emitError("Could not export model for file.", fileName);
                }
            }

            return model;
        }

    }

    return NULL;
}
/*!
    \since 5.3

    Sets the format option \a option if \a on is true; otherwise, clears the option.

    \sa setOptions(), options(), testOption()
*/
void QSurfaceFormat::setOption(QSurfaceFormat::FormatOption option, bool on)
{
    if (testOption(option) == on)
        return;
    detach();
    if (on)
        d->opts |= option;
    else
        d->opts &= ~option;
}
Beispiel #5
0
void OpenGLContext::Private::printInfo()
{
    const auto format = m_context->format();
    const auto version = format.version();

    auto options = QStringList{};

    if (version >= qMakePair(3, 2))
        options << (format.profile() == QSurfaceFormat::CoreProfile ? "Core" : "Compatibility");

    if (version >= qMakePair(3, 0))
    {
        if (format.testOption(QSurfaceFormat::DeprecatedFunctions))
            options << "forward compatibility";
    }

    if (format.testOption(QSurfaceFormat::DebugContext))
        options << "debug";

    qDebug().nospace() << "OpenGL Version: "
                       << version.first << "." << version.second << " "
                       << "(" << options.join(", ") << ")";
}
Beispiel #6
0
bool ProjectImpl::initialize() {

    if (testOption(optDumpParserFlow)) {

        if (mFlowFileName.isEmpty()) {
            QDir dir(mOutputPath);
            QFileInfo fi(dir.filePath(mInputFile));
            mFlowFileName = dir.filePath(fi.completeBaseName() % QLatin1Literal(".uflow"));
        }

        QScopedPointer<QFile> flowFile(new QFile(mFlowFileName));
        if (!flowFile->open(QFile::WriteOnly)) {
            return false;
        }

        mFlowFile = flowFile.take();
        FlowTracer::instance().setOutput(mFlowFile);
        FlowTracer::instance().setEnabled(true);
    }

    return true;
}
Beispiel #7
0
int main(int argc, char* argv[])
{
	QCoreApplication::setOrganizationName("rapcad");
	QCoreApplication::setOrganizationDomain("rapcad.org");
	QCoreApplication::setApplicationName("RapCAD");
	QCoreApplication::setApplicationVersion(STRINGIFY(RAPCAD_VERSION));

	QCoreApplication* a = new QCoreApplication(argc,argv);

	QCommandLineParser p;
	p.setApplicationDescription(QCoreApplication::translate("main","RapCAD the rapid prototyping IDE"));
	p.addHelpOption();
	p.addVersionOption();
	p.addPositionalArgument("filename", QCoreApplication::translate("main","File to open or process."));

	QCommandLineOption testOption(QStringList() << "t" << "test", QCoreApplication::translate("main","Run through tests in working directory."));
	p.addOption(testOption);

	QCommandLineOption compareOption(QStringList() << "c" << "compare", QCoreApplication::translate("main","Compare two files to see if they are identical."),"filename");
	p.addOption(compareOption);

	QCommandLineOption printOption(QStringList() << "p" << "print", QCoreApplication::translate("main","Print debugging output."));
	p.addOption(printOption);

	QCommandLineOption outputOption(QStringList() << "o" << "output",QCoreApplication::translate("main","Create output file <filename>."),"filename");
	p.addOption(outputOption);

#ifdef USE_READLINE
	QCommandLineOption interactOption(QStringList() << "i" << "interactive",QCoreApplication::translate("main","Start an interactive session"));
	p.addOption(interactOption);
#endif
	p.process(*a);

	QStringList inputFiles=p.positionalArguments();
	QString inputFile;
	if(!inputFiles.isEmpty())
		inputFile=inputFiles.at(0);

	QString outputFile;
	if(p.isSet(outputOption))
		outputFile=p.value(outputOption);
	else if(p.isSet(compareOption))
		outputFile=p.value(compareOption);

	QTextStream output(stdout);
	Strategy* s=NULL;
	if(p.isSet(compareOption)) {
		Comparer* c=new Comparer(output);
		c->setup(inputFile,outputFile);
		s=c;
	} else if(p.isSet(testOption)) {
		s=new Tester(output);
	} else if(p.isSet(outputOption)||p.isSet(printOption)) {
		Worker* w=new Worker(output);
		bool print = p.isSet(printOption);
		w->setup(inputFile,outputFile,print,false);
		s=w;
#ifdef USE_READLINE
    } else if(p.isSet(interactOption)) {
        showVersion(output);
		s=new Interactive(output);
#endif
	}

	if(s) {
		int retcode=s->evaluate();
		a->quit();
		return retcode;
	} else {
		delete a;
		a=new QApplication(argc,argv);
		return showUi(a,inputFiles);
	}
}
/*!
    \obsolete

    Use testOption(\a option) instead.
*/
bool QPageSetupDialog::isOptionEnabled(PageSetupDialogOption option) const
{
    return testOption(option);
}
Beispiel #9
0
QT_USE_NAMESPACE

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    QCommandLineParser parser;
    parser.setApplicationDescription(QLatin1String("winrtrunner installs, runs, and collects test "
                                                   "results for packages made with Qt."));
    parser.addPositionalArgument(QStringLiteral("package [arguments]"),
                                 QLatin1String("The executable or package manifest to act upon. "
                                               "Arguments after the package name will be passed "
                                               "to the application when it starts."));

    QCommandLineOption testOption(QStringLiteral("test"),
                                  QLatin1String("Install, start, collect output, stop (if needed), "
                                                "and uninstall the package. This is the "
                                                "default action of winrtrunner."));
    parser.addOption(testOption);

    QCommandLineOption startOption(QStringLiteral("start"),
                                   QLatin1String("Start the package. The package is installed if "
                                                 "it is not already installed. Pass --install to "
                                                 "force reinstallation."));
    parser.addOption(startOption);

    QCommandLineOption debugOption(QStringLiteral("debug"),
                                   QLatin1String("Start the package with the debugger attached. "
                                                 "The package is installed if it is not already "
                                                 "installed. Pass --install to force "
                                                 "reinstallation."),
                                   QLatin1Literal("debugger"));
    parser.addOption(debugOption);

    QCommandLineOption debuggerArgumentsOption(QStringLiteral("debugger-arguments"),
                                               QLatin1String("Arguments that are passed to the "
                                                             "debugger when --debug is used. If no "
                                                             "debugger was provided this option is "
                                                             "ignored."),
                                               QLatin1String("arguments"));
    parser.addOption(debuggerArgumentsOption);

    QCommandLineOption suspendOption(QStringLiteral("suspend"),
                                     QLatin1String("Suspend a running package. When combined "
                                                   "with --stop or --test, the app will be "
                                                   "suspended before being terminated."));
    parser.addOption(suspendOption);

    QCommandLineOption stopOption(QStringLiteral("stop"),
                                  QLatin1String("Terminate a running package. Can be be "
                                                "combined with --start and --suspend."));
    parser.addOption(stopOption);

    QCommandLineOption waitOption(QStringLiteral("wait"),
                                  QLatin1String("If the package is running, waits the given "
                                                "number of seconds before continuing to the next "
                                                "task. Passing 0 causes the runner to wait "
                                                "indefinitely."),
                                  QStringLiteral("seconds"));
    parser.addOption(waitOption);

    QCommandLineOption installOption(QStringLiteral("install"),
                                     QStringLiteral("(Re)installs the package."));
    parser.addOption(installOption);

    QCommandLineOption removeOption(QStringLiteral("remove"),
                                    QStringLiteral("Uninstalls the package."));
    parser.addOption(removeOption);

    QCommandLineOption deviceOption(QStringLiteral("device"),
                                    QLatin1String("Specifies the device to target as a device name "
                                                  " or index. Use --list-devices to find available "
                                                  "devices. The default device is the first device "
                                                  "found for the active run profile."),
                                    QStringLiteral("name|index"));
    parser.addOption(deviceOption);

    QCommandLineOption profileOption(QStringLiteral("profile"),
                                     QStringLiteral("Force a particular run profile."),
                                     QStringLiteral("name"));
    parser.addOption(profileOption);

    QCommandLineOption listDevicesOption(QStringLiteral("list-devices"),
                                         QLatin1String("List the available devices "
                                                       "(for use with --device)."));
    parser.addOption(listDevicesOption);

    QCommandLineOption verbosityOption(QStringLiteral("verbose"),
                                       QLatin1String("The verbosity level of the message output "
                                                     "(0 - silent, 1 - info, 2 - debug). Defaults to 1."),
                                       QStringLiteral("level"), QStringLiteral("1"));
    parser.addOption(verbosityOption);

    QCommandLineOption ignoreErrorsOption(QStringLiteral("ignore-errors"),
                                          QStringLiteral("Always exit with code 0, regardless of the error state."));
    parser.addOption(ignoreErrorsOption);

    parser.addHelpOption();
    parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
    QStringList arguments = QCoreApplication::arguments();
    parser.parse(arguments);

    QStringList filterRules = QStringList() // Default logging rules
            << QStringLiteral("qt.winrtrunner.warning=true")
            << QStringLiteral("qt.winrtrunner.critical=true")
            << QStringLiteral("qt.winrtrunner.app=true");
    if (parser.isSet(verbosityOption)) {
        bool ok;
        uint verbosity = parser.value(verbosityOption).toUInt(&ok);
        if (!ok || verbosity > 2) {
            qCCritical(lcWinRtRunner) << "Incorrect value specified for verbosity.";
            parser.showHelp(1);
        }
        switch (verbosity) {
        case 2: // Enable debug print
            filterRules.append(QStringLiteral("qt.winrtrunner.debug=true"));
            break;
        case 1: // Remove warnings
            filterRules.removeFirst();
            // fall through
        case 0: // Silent
            filterRules.removeFirst();
            // fall through
        default: // Impossible
            break;
        }
    }
    QLoggingCategory::setFilterRules(filterRules.join(QLatin1Char('\n')));

    if (parser.isSet(listDevicesOption)) {
        std::wcout << "Available devices:\n";
        const QMap<QString, QStringList> deviceNames = Runner::deviceNames();
        foreach (const QString &profile, deviceNames.keys()) {
            std::wcout << reinterpret_cast<const wchar_t *>(profile.utf16()) << ":\n";
            int index = 0;
            foreach (const QString &device, deviceNames.value(profile)) {
                std::wcout << "  " << index++ << ' '
                           << reinterpret_cast<const wchar_t *>(device.utf16()) << '\n';
            }
        }
        std::wcout << std::endl;
        return 0;
    }