QUrl Dailymotion::authUrl() const {
    QUrl url(QDailymotion::AUTH_URL);
#if QT_VERSION >= 0x050000
    QUrlQuery query(url);
    query.addQueryItem("client_id", clientId());
    query.addQueryItem("redirect_uri", redirectUri());
    query.addQueryItem("response_type", "code");
    query.addQueryItem("display", "popup");
    
    QStringList s = scopes();
    
    if (!s.isEmpty()) {
        query.addQueryItem("scope", s.join("+"));
    }
    
    url.setQuery(query);
#else
    url.addQueryItem("client_id", clientId());
    url.addQueryItem("redirect_uri", redirectUri());
    url.addQueryItem("response_type", "code");
    url.addQueryItem("display", "popup");
    
    QStringList s = scopes();
    
    if (!s.isEmpty()) {
        url.addQueryItem("scope", s.join("+"));
    }
#endif
    return url;
}
void Dailymotion::setScopes(const QStringList &s) {
    if (s != scopes()) {
        QSettings().setValue("Dailymotion/scopes", s);
        emit scopesChanged();
    }
#ifdef CUTETUBE_DEBUG
    qDebug() << "Dailymotion::setScopes" << s;
#endif
}
Beispiel #3
0
void begin() {
	ibex_lineno=-1;
	if (!setlocale(LC_NUMERIC, "C")) // to accept the dot (instead of the french coma) with numeric numbers
		ibexerror("platform does not support \"C\" locale");

	ibex_lineno=1;

	/*
	 * There may be some pending scopes (if the previous call to the parser failed).
	 */
	while (!scopes().empty()) scopes().pop();

	// Bottom scope.
	// Kept for both parsing and generation (the constants are shared by the two steps)
	scopes().push(Scope());

	// note: a second scope is created for parsing the constraints block,
	// to store temporary variables.
}
Beispiel #4
0
void end_system() {
	if (system==NULL) { // someone tries to load a Function from a file containing a system
		throw SyntaxError("unexpected (global) variable declaration for a function.");
	}
	MainGenerator().generate(source(),*system);
	source().cleanup();
	// TODO: we have to cleanup the data in case of Syntax Error
	// this probably requires a kind of garbage collector during
	// parsing
	scopes().pop();
}
    NamespaceDom defineScope( RefAdaAST namenode ) {
       QStringList scopes( qnamelist( namenode ) );
//        kdDebug() << "defineScope: " << scopes.join(" ") << endl;
       NamespaceDom psc = insertScopeContainer( m_currentContainer, scopes );
//        kdDebug() << "defineScope psc created" << endl;
       psc->setStartPosition(namenode->getLine(), namenode->getColumn());
//        kdDebug() << "defineScope start position set" << endl;
       psc->setFileName(m_fileName);
//        kdDebug() << "defineScope file name set" << endl;
       // psc->setEndPosition (endLine, 0);
//        kdDebug() << "defineScope return" << endl;
       return psc;
    }
Beispiel #6
0
void begin_choco() {
	if (system==NULL) { // someone tries to load a Function from a file with CHOCO constraint syntax
		throw SyntaxError("unexpected constraints declaration for a function.");
	}

	// ----- generate all the variables {i} -----
	Dim dim=Dim::scalar();
	Domain x(dim);
	x.i()=Interval::all_reals();
	for (int i=0; i<system->nb_var; i++) {
		char* name=append_index("\0",'{','}',i);
		scopes().top().add_var(name,&dim,x);
		free(name);
	}
	// ------------------------------------------
}
Beispiel #7
0
    /**
     * @brief View::addElement
     * @param type
     * @param eventPos
     */
    void View::addElement(const QString &marker, const QPoint &eventPos)
    {
        if (auto pr = project()) {
            auto projectDb = G_ASSERT(pr->database());
            if (projectDb->anyScopes()) {
                auto scope = projectDb->defaultScope();
                if (!scope)
                    scope = G_ASSERT(projectDb->scopes().first());

                if (auto stack = pr->commandsStack()) {
                    auto pos = mapToScene(eventPos);
                    if (auto cmd = makeCmd(marker, appModel(), scope->id(), *scene(), pos, nullptr))
                        stack->push(cmd.release());
                }
            }
        } else {
            qWarning() << Q_FUNC_INFO << ": there is no project.";
        }
    }
Beispiel #8
0
void end_function() {
	if (function==NULL) { // someone tries to load a system from a file containing a function only
		throw SyntaxError("a system requires declaration of variables.");
	}
	if (source().func.empty()) {
		throw SyntaxError("no function declared in file");
	}
	const Function& f=(*source().func[0]);
	Array<const ExprSymbol> x(f.nb_arg());
	varcopy(f.args(),x);
	const ExprNode& y=ExprCopy().copy(f.args(),x,f.expr());

	function->init(x,y,f.name);

	source().cleanup();
	delete source().func[0]; // This is an ugly stuff but we are obliged (see destructor of ParserSource)
	// TODO: see end_system()
	scopes().pop();
}
Beispiel #9
0
void ProblemReader::readUAI(char* filename) {

  igzstream in(filename);
  assert(in);

  // Problem type indicator
  string s;
  in >> s;
  if (! (s=="MARKOV" || s=="BAYES")) {
    fprintf(stderr, "Problem type not supported.\n");
    exit(-1);
  }

  // read num_vars
  in >> num_vars;

  // read domain sizes and store locally for now
  vector<int> doms(num_vars,-1);
  for (int i=0; i<num_vars; ++i)
    in >> doms[i];

  // read num_pots
  in >> num_pots;

  // now that num_vars and num_pots is read, we can allocate the memory
  allocateVarsAndPTs(false);

  // set domain sizes
  for (int i=0; i<num_vars; ++i)
    variables[i]->setDomainSize(doms[i]);

  // read and set function scopes
  vector<vector<int> > scopes(num_pots);
  vector<int> tabSizes(num_pots,-1);
  for (int i=0; i<num_pots; ++i) {
    int var, z, num_vars_in_pot;
    in >> num_vars_in_pot;
    z = num_vars_in_pot;
    while (z--) {
      in >> var;
      scopes[i].push_back(var);
    }
    // allocate and init function table
    probTables[i]->init(scopes[i].size());
    int numEntries = 1;
    for(int j=0; j<num_vars_in_pot; ++j){
            probTables[i]->setVar(j, scopes[i][j]);
            numEntries *= doms[scopes[i][j]]; //variables[scopes[i][j]]->domSize;
    }
    tabSizes[i] = numEntries;
    probTables[i]->setNumEntries(numEntries);
  }

  // read function tables
  double d;
  for (int i=0; i<num_pots; ++i) {
    int numEntries;
    in >> numEntries;
    assert(numEntries == tabSizes[i]);

    for (int j=0; j<numEntries; ++j) {
      in >> d;
      probTables[i]->setEntry(j,d);
    }
  }

}
Beispiel #10
0
    /**
     * @brief ComponentsMaker::makeType
     * @param tokens
     * @return
     */
    OptionalEntity ComponentsMaker::makeType(const Tokens &tokens)
    {
        Q_ASSERT(!tokens.isEmpty() && tokens[int(TypeGroups::Typename)]->isSingle() &&
                 !tokens[int(TypeGroups::Typename)]->token().isEmpty());

        // Check common type
        const QString &typeName = tokens[int(TypeGroups::Typename)]->token();
        entity::SharedType type;
        if (!tokens[int(TypeGroups::Namespaces)]->token().isEmpty()) {
            // TODO: should be already splitted i.e. is not single
            Q_ASSERT(tokens[int(TypeGroups::Namespaces)]->isSingle());
            auto names = tokens[int(TypeGroups::Namespaces)]->token()
                         .split("::", QString::SkipEmptyParts);
            auto scope = m_Model->globalDatabase()->chainScopeSearch(names);
            if (!scope)
                scope = m_Model->currentProject()->database()->chainScopeSearch(names);

            if (scope)
                type = scope->type(typeName);
        } else {
            // First of all check in all scopes of global database
            const entity::ScopesList &scopes = m_Model->globalDatabase()->scopes();
            range::find_if(scopes, [&](auto scope){ type = scope->type(typeName); return !!type; });

            // If not found, try to check project database
            if (!type) {
                auto db = m_Model->currentProject()->database();
                range::find_if(db->scopes(), [&](auto scope){ type = scope->type(typeName); return !!type; });
            }
        }

        if (!type)
            return {tr("Wrong type: %1.").arg(typeName), nullptr};

        // Check extra stuff
        entity::SharedExtendedType extType = std::make_shared<entity::ExtendedType>();
        extType->setTypeId(type->id());
        extType->setScopeId(m_Scope->id());
        Q_ASSERT(tokens[int(TypeGroups::ConstStatus)]->isSingle());
        extType->setConstStatus(!tokens[int(TypeGroups::ConstStatus)]->token().isEmpty());

        Q_ASSERT(tokens[int(TypeGroups::PLC)]->isSingle());
        if (!tokens[int(TypeGroups::PLC)]->token().isEmpty()) {
            QString plc = tokens[int(TypeGroups::PLC)]->token();
            plc.remove(QChar::Space);

            if (plc.startsWith("const")) {
                extType->setConstStatus(true);
                plc.remove(0, 4);
            }

            while (!plc.isEmpty()) {
                if (plc.startsWith("const")) {
                    plc.remove(0, 5);
                } else if (plc.startsWith("*const")) {
                    extType->addPointerStatus(true);
                    plc.remove(0, 6);
                } else if (plc.startsWith("*")) {
                    extType->addPointerStatus();
                    plc.remove(0, 1);
                } else if (plc.startsWith("&")) {
                    extType->addLinkStatus();
                    plc.remove(0, 1);
                } else {
                    break;
                }
            }
        }

        // TODO: should be already splitted too
        Q_ASSERT(tokens[int(TypeGroups::TemplateArgs)]->isSingle());
        if (!tokens[int(TypeGroups::TemplateArgs)]->token().isEmpty()) {
            QStringList arguments = tokens[int(TypeGroups::TemplateArgs)]->token()
                                    .remove(QChar::Space)
                                    .split(",", QString::SkipEmptyParts);
            entity::ScopesList scopes = m_Model->currentProject()->database()->scopes();
            for (auto && s : m_Model->globalDatabase()->scopes())
                scopes << s;

            // TODO: add namespaces, * and const
            for (auto &&name : arguments) {
                entity::SharedType t;
                range::find_if(scopes, [&](auto &&sc){ t = sc->type(name); return !!t; });
                if (t)
                    extType->addTemplateParameter(t->id());
                else
                    return {tr("Template parameter \"%1\" not found.").arg(name), nullptr};
            }
        }

        if (extType->isConst() || !extType->templateParameters().isEmpty() || !extType->pl().isEmpty()) {
            const entity::TypesList &types = m_Scope->types();
            auto it = range::find_if(types, [=](const entity::SharedType &type) {
                                                  return extType->isEqual(*type, false);
                                              });
            if (it == cend(types))
                m_Model->addExistsType(m_Model->currentProject()->name(), m_Scope->id(), extType);

            return {"", extType};
         } else {
            return {"", type};
         }
    }
Beispiel #11
0
void end_choco() {
	MainGenerator().generate(source(),*system);
	source().cleanup();
	// TODO: see end_system()
	scopes().pop();
}