void QsCodeParser::parseHeaderFile(const Location& location, const QString& filePath, Tree *tree) { qsTre = tree; FILE *in = fopen(QFile::encodeName(filePath), "r"); if (in == 0) { location.error(tr("Cannot open Qt Script class list '%1'") .arg(filePath)); return; } Location fileLocation(filePath); Tokenizer fileTokenizer(fileLocation, in); int tok = fileTokenizer.getToken(); while (tok != Tok_Eoi) { if (tok == Tok_Ident) { ClassNode *quickClass = new ClassNode(qsTre->root(), fileTokenizer.lexeme()); quickClass->setLocation(fileTokenizer.location()); } else { fileTokenizer.location().error(tr("Unexpected token '%1' in Qt" " Script class list") .arg(fileTokenizer.lexeme())); break; } tok = fileTokenizer.getToken(); } fclose(in); }
void QmlCodeParser::parseSourceFile(const Location& location, const QString& filePath, Tree *tree) { QFile in(filePath); if (!in.open(QIODevice::ReadOnly)) { location.error(tr("Cannot open QML file '%1'").arg(filePath)); return; } QString document = in.readAll(); in.close(); Location fileLocation(filePath); QString newCode = document; extractPragmas(newCode); lexer->setCode(newCode, 1); QSet<QString> topicCommandsAllowed = topicCommands(); QSet<QString> otherMetacommandsAllowed = otherMetaCommands(); QSet<QString> metacommandsAllowed = topicCommandsAllowed + otherMetacommandsAllowed; QDeclarativeJS::NodePool m_nodePool(filePath, &engine); if (parser->parse()) { QDeclarativeJS::AST::UiProgram *ast = parser->ast(); QmlDocVisitor visitor(filePath, newCode, &engine, tree, metacommandsAllowed); QDeclarativeJS::AST::Node::accept(ast, &visitor); } }
/*! Parses the source file identified by \a filePath and adds its parsed contents to the database. The \a location is used for reporting errors. */ void PureDocParser::parseSourceFile(const Location& location, const QString& filePath) { QFile in(filePath); currentFile_ = filePath; if (!in.open(QIODevice::ReadOnly)) { location.error(tr("Can't open source file '%1' (%2)").arg(filePath).arg(strerror(errno))); currentFile_.clear(); return; } reset(); Location fileLocation(filePath); Tokenizer fileTokenizer(fileLocation, in); tokenizer = &fileTokenizer; readToken(); /* The set of open namespaces is cleared before parsing each source file. The word "source" here means cpp file. */ qdb_->clearOpenNamespaces(); processQdocComments(); in.close(); currentFile_.clear(); }
void MachinekitHalRemoteControlsPlugin::registerTypes(const char *uri) { initResources(); // @uri Machinekit.HalRemote.Controls Q_ASSERT(uri == QLatin1String("Machinekit.HalRemote.Controls")); const QString filesLocation = fileLocation(); for (int i = 0; i < int(sizeof(qmldir)/sizeof(qmldir[0])); i++) { qmlRegisterType(QUrl(filesLocation + "/" + qmldir[i].type + ".qml"), uri, qmldir[i].major, qmldir[i].minor, qmldir[i].type); } }
void QtQuickControlsPlugin::registerTypes(const char *uri) { initResources(); qmlRegisterType<QQuickAction>(uri, 1, 0, "Action"); qmlRegisterType<QQuickExclusiveGroup>(uri, 1, 0, "ExclusiveGroup"); qmlRegisterType<QQuickMenu>(uri, 1, 0, "MenuPrivate"); qmlRegisterType<QQuickMenuBar>(uri, 1, 0, "MenuBarPrivate"); qmlRegisterType<QQuickMenuItem>(uri, 1, 0, "MenuItem"); qmlRegisterUncreatableType<QQuickMenuItemType>(uri, 1, 0, "MenuItemType", QLatin1String("Do not create objects of type MenuItemType")); qmlRegisterType<QQuickMenuSeparator>(uri, 1, 0, "MenuSeparator"); qmlRegisterUncreatableType<QQuickMenuBase>(uri, 1, 0, "MenuBase", QLatin1String("Do not create objects of type MenuBase")); qmlRegisterUncreatableType<QQuickStack>(uri, 1, 0, "Stack", QLatin1String("Do not create objects of type Stack")); qmlRegisterUncreatableType<QQuickSelectionMode>(uri, 1, 1, "SelectionMode", QLatin1String("Do not create objects of type SelectionMode")); const QString filesLocation = fileLocation(); for (int i = 0; i < int(sizeof(qmldir)/sizeof(qmldir[0])); i++) qmlRegisterType(QUrl(filesLocation + "/" + qmldir[i].type + ".qml"), uri, qmldir[i].major, qmldir[i].minor, qmldir[i].type); }
void Module::AddSound(std::string filename, size_t soundId) { // Get file location std::string fileLocation(filename); // Open file std::ifstream soundFile(fileLocation); // Check file validity if(!soundFile.good()) throw - 1; soundFile.seekg (0, std::ios::end); // Get file size in bytes int fileSize = soundFile.tellg(); short* soundData = new short[fileSize]; soundFile.seekg(0, std::ios::beg); int i = 0; while(soundFile.read((char*)&soundData[i], sizeof(short))) i++; SoundParams sndParameters; sndParameters.length = fileSize*sizeof(char)/sizeof(short); sndParameters.data = soundData; sndParameters.id = soundId; // Add sound to lib sndParams.push_back(sndParameters); // Close file soundFile.close(); return; }
void MachinekitApplicationPlugin::registerTypes(const char *uri) { initResources(); // Verify that the version of the library that we linked against is // compatible with the version of the headers we compiled against. GOOGLE_PROTOBUF_VERIFY_VERSION; // @uri Machinekit.Application qmlRegisterType<QApplicationConfig>(uri, 1, 0, "ApplicationConfig"); qmlRegisterType<QApplicationConfigItem>(uri, 1, 0, "ApplicationConfigItem"); qmlRegisterType<QApplicationConfigFilter>(uri, 1, 0, "ApplicationConfigFilter"); qmlRegisterType<QApplicationDescription>(uri, 1, 0, "ApplicationDescription"); qmlRegisterType<QApplicationStatus>(uri, 1, 0, "ApplicationStatus"); qmlRegisterType<QApplicationCommand>(uri, 1, 0, "ApplicationCommand"); qmlRegisterType<QApplicationError>(uri, 1, 0, "ApplicationError"); qmlRegisterType<QApplicationFile>(uri, 1, 0, "ApplicationFile"); qmlRegisterType<QLocalSettings>(uri, 1, 0, "LocalSettings"); const QString filesLocation = fileLocation(); for (int i = 0; i < int(sizeof(qmldir)/sizeof(qmldir[0])); i++) { qmlRegisterType(QUrl(filesLocation + "/" + qmldir[i].type + ".qml"), uri, qmldir[i].major, qmldir[i].minor, qmldir[i].type); } }
DataManipulation::DataManipulation() { fileLocation(); }