void doWalkFunction(Function* func) {
   // if there isn't a label variable, nothing for us to do
   if (func->localIndices.count(LABEL)) {
     labelIndex = func->getLocalIndex(LABEL);
     LabelUseFinder finder(labelIndex, labelChecks, labelSets);
     finder.walk(func->body);
     WalkerPass<ExpressionStackWalker<RelooperJumpThreading, Visitor<RelooperJumpThreading>>>::doWalkFunction(func);
   }
 }
Ejemplo n.º 2
0
void IDEWidget::weaponTableCellDoubleClicked(int row, int col)
{
	QTableWidgetItem* item = ui.weaponTable->item(row, col);

	if (col == 1) {
		// Model Name
		QString fname = item->text();
		fname.append(".dff");
		DefaultFileFinder finder(fname.toLocal8Bit().constData(), false);
		GUI::getInstance()->findAndOpenFile(&finder, this);
	} else if (col == 2) {
		// TXD Name
		QString fname = item->text();
		fname.append(".txd");
		DefaultFileFinder finder(fname.toLocal8Bit().constData(), false);
		GUI::getInstance()->findAndOpenFile(&finder, this);
	}
}
    void Test2dVariableFibres() throw(Exception)
    {
        PlaneStimulusCellFactory<CellLuoRudy1991FromCellML, 2> cell_factory(-1000*1000);

        TetrahedralMesh<2,2> electrics_mesh;
        electrics_mesh.ConstructRegularSlabMesh(1.0/96.0/*stepsize*/, 1.0/*length*/, 1.0/*width*/, 1.0/*depth*/);

        QuadraticMesh<2> mechanics_mesh;
        mechanics_mesh.ConstructRegularSlabMesh(0.2, 1.0, 1.0, 1.0 /*as above with a different stepsize*/);

        std::vector<unsigned> fixed_nodes
            = NonlinearElasticityTools<2>::GetNodesByComponentValue(mechanics_mesh, 0, 0.0); // all the X=0.0 nodes

        ElectroMechanicsProblemDefinition<2> problem_defn(mechanics_mesh);
        problem_defn.SetContractionModel(NHS,1.0);
        problem_defn.SetUseDefaultCardiacMaterialLaw(INCOMPRESSIBLE);
        problem_defn.SetZeroDisplacementNodes(fixed_nodes);
        problem_defn.SetMechanicsSolveTimestep(1.0);

        FileFinder finder("heart/test/data/fibre_tests/5by5mesh_curving_fibres.ortho",RelativeTo::ChasteSourceRoot);
        problem_defn.SetVariableFibreSheetDirectionsFile(finder, false);

        HeartConfig::Instance()->SetSimulationDuration(125.0);

        CardiacElectroMechanicsProblem<2,1> problem(INCOMPRESSIBLE,
                                                  MONODOMAIN,
                                                  &electrics_mesh,
                                                  &mechanics_mesh,
                                                  &cell_factory,
                                                  &problem_defn,
                                                  "TestCardiacEmVaryingFibres");


//        // fibres going from (1,0) at X=0 to (1,1)-direction at X=1
//        // the fibres file was created with the code (inside a class that owns a mesh)
//        for(unsigned elem_index=0; elem_index<mechanics_mesh.GetNumElements(); elem_index++)
//        {
//            double X = mechanics_mesh.GetElement(elem_index)->CalculateCentroid()[0];
//            double theta = M_PI*X/4;
//            std::cout << cos(theta) << " " << sin(theta) << " " << -sin(theta) << " " << cos(theta) << "\n" << std::flush;
//        }
//        assert(0);

        // problem.SetNoElectricsOutput();
        problem.Solve();

        // test by checking the length of the tissue against hardcoded value
        std::vector<c_vector<double,2> >& r_deformed_position = problem.rGetDeformedPosition();
        // visualised, looks good - contracts in X-direction near the fixed surface,
        // but on the other side the fibres are in the (1,1) direction, so contraction
        // pulls the tissue downward a bit
        TS_ASSERT_DELTA(r_deformed_position[5](0), 0.9055, 2e-3);
        //IntelProduction differs by about 1.6e-3...

        MechanicsEventHandler::Headings();
        MechanicsEventHandler::Report();
    }
Ejemplo n.º 4
0
int
set (char *big, BIGNUM index)
{
  deref dr;

  finder (index, &dr);
  big[dr.index] += dr.spot;

  return 0;
}
Ejemplo n.º 5
0
Star* Star::buildFromXMLNode(XMLNode& node)
{
	XMLChildFinder finder(node);

	return new Star(
		finder.required("Name", buildStringFromXMLNode),
		finder.required("Position", Position::buildFromXMLNode),
		finder.required("Colour", buildFVec3FromXMLNode)
	);
}
Ejemplo n.º 6
0
/* Use this to search thru the list of attached boards. 
	Send one of the above Finder functions for comparison of the desired field within the 
	board structure.  Thus use this to Find board Instance number, or the MappedID 
	(for motor board vectorizing)  */
struct stBoardInfo* FindBoard(byte mValue, BOOL (*finder)(struct stBoardInfo* mboard, byte mInstance))
{
	struct stBoardInfo* board = boards_present_head;
	while (board)
	{
		if (finder(board, mValue))
			return board;
		board = board->Next;
	}
}
Ejemplo n.º 7
0
Gtk::TreeModel::iterator StimTypes::getIterForName(const std::string& name)
{
	// Setup the selectionfinder to search for the name string
	gtkutil::TreeModel::SelectionFinder finder(name, _columns.name.index());

	_listStore->foreach_iter(
		sigc::mem_fun(finder, &gtkutil::TreeModel::SelectionFinder::forEach));

	return finder.getIter();
}
Ejemplo n.º 8
0
 typename std::vector<T>::iterator findStructIteratorByName(std::vector<T>& vec,
                                                            const std::string& name,
                                                            bool caseSensitive=false)
 {
   boost::optional<int> index;
   StructNameFinder<T> finder(name,caseSensitive);
   typename std::vector<T>::iterator it;
   it = find_if(vec.begin(),vec.end(),finder);
   return it;
 }
Ejemplo n.º 9
0
uint32_t Downloader::choose( const PluginRegistry& from,
                             const uint32_t internalFormat,
                             const float minQuality, const bool ignoreAlpha,
                             const uint64_t capabilities,
                             const GLEWContext* gl )
{
    Finder finder( internalFormat, minQuality, ignoreAlpha, capabilities, gl );
    from.accept( finder );
    return finder.current.name;
}
Ejemplo n.º 10
0
Gtk::TreeModel::iterator StimTypes::getIterForId(int id)
{
	// Setup the selectionfinder to search for the id
	gtkutil::TreeModel::SelectionFinder finder(id, _columns.id.index());

	_listStore->foreach_iter(
		sigc::mem_fun(finder, &gtkutil::TreeModel::SelectionFinder::forEach));

	return finder.getIter();
}
Ejemplo n.º 11
0
void wcDocEnumerate(wcCtx* Ctx, wcDocEnumFn pfn, int Intparm, void *Voidparm)
{
struct EnumParms E;
	E.Ctx = Ctx;
	E.pfn = pfn;
	E.Intparm = Intparm;
	E.Voidparm = Voidparm;
	HTMLGenericFinder finder(wcDocEnumerateFinderCallback,0,(void **) &E);
	((HTMLDocument *) Ctx->hdoc)->FindElement(&finder);
}
int KstTimezone::offset(const QDateTime &dateTime) const
{
    OffsetFind finder(dateTime.toTime_t());
    int result = 0;
    if (parse(finder))
    {
        result = finder.offset();
    }
    return result;
}
Ejemplo n.º 13
0
 void removeElement(const Key& k)			// remove using key
     throw(NonexistentElementException) {
   BTPosition u = finder(k, BST::T.root());			// find the node
   if (u.isNull())					// not found?
     throw NonexistentElementException("Remove nonexistent element");
   BTPosition r = remover(u);				// remove u
   if (BST::T.isRoot(r) || isRed(r) || wasParentRed(r))
     setBlack(r);					// fix by color change
   else 						// r, parent both black
     remedyDoubleBlack(r);				// fix double-black r
 }
Ejemplo n.º 14
0
  bool matchesRuleSet(Element& element, RuleSet* ruleSet) {
    if (!ruleSet)
      return false;

    ElementResolveContext context(element);
    SharedStyleFinder finder(context, m_ruleSet->features(), m_siblingRuleSet,
                             m_uncommonAttributeRuleSet,
                             document().ensureStyleResolver());

    return finder.matchesRuleSet(ruleSet);
  }
void CFirstStartWizardLanguage::OnBnClickedRefresh()
{
	UpdateData();
	m_LanguageCombo.ResetContent();

	// set up the language selecting combobox
	TCHAR buf[MAX_PATH] = { 0 };
	GetLocaleInfo(1033, LOCALE_SNATIVELANGNAME, buf, _countof(buf));
	m_LanguageCombo.AddString(buf);
	m_LanguageCombo.SetItemData(0, 1033);
	CString path = CPathUtils::GetAppParentDirectory();
	path = path + L"Languages\\";
	CSimpleFileFind finder(path, L"*.dll");
	int langcount = 0;
	while (finder.FindNextFileNoDirectories())
	{
		CString file = finder.GetFilePath();
		CString filename = finder.GetFileName();
		if (CStringUtils::StartsWithI(filename, L"TortoiseProc"))
		{
			CString sVer = _T(STRPRODUCTVER);
			sVer = sVer.Left(sVer.ReverseFind('.'));
			CString sFileVer = CPathUtils::GetVersionFromFile(file);
			sFileVer = sFileVer.Left(sFileVer.ReverseFind('.'));
			if (sFileVer.Compare(sVer) != 0)
				continue;
			CString sLoc = filename.Mid(static_cast<int>(wcslen(L"TortoiseProc")));
			sLoc = sLoc.Left(sLoc.GetLength() - static_cast<int>(wcslen(L".dll"))); // cut off ".dll"
			if (CStringUtils::StartsWith(sLoc, L"32") && (sLoc.GetLength() > 5))
				continue;
			DWORD loc = _wtoi(filename.Mid(static_cast<int>(wcslen(L"TortoiseProc"))));
			GetLocaleInfo(loc, LOCALE_SNATIVELANGNAME, buf, _countof(buf));
			CString sLang = buf;
			GetLocaleInfo(loc, LOCALE_SNATIVECTRYNAME, buf, _countof(buf));
			if (buf[0])
			{
				sLang += L" (";
				sLang += buf;
				sLang += L')';
			}
			m_LanguageCombo.AddString(sLang);
			m_LanguageCombo.SetItemData(++langcount, loc);
		}
	}

	m_regLanguage.read();
	m_dwLanguage = m_regLanguage;
	for (int i = 0; i < m_LanguageCombo.GetCount(); ++i)
	{
		if (m_LanguageCombo.GetItemData(i) == m_dwLanguage)
			m_LanguageCombo.SetCurSel(i);
	}
	UpdateData(FALSE);
}
Ejemplo n.º 16
0
void tst_QTextBoundaryFinder::graphemeBoundaries()
{
    QFile file("data/GraphemeBreakTest.txt");
    file.open(QFile::ReadOnly);

    int lines = 0;
    while (!file.atEnd()) {
        QByteArray line = file.readLine();
        if (line.startsWith('#'))
            continue;

        lines++;
        QString test = QString::fromUtf8(line);
        int hash = test.indexOf('#');
        if (hash > 0)
            test = test.left(hash);
        test = test.simplified();
        test = test.replace(QLatin1String(" "), QString());

        QList<int> breakPositions;
        QString testString;
        int pos = 0;
        int strPos = 0;
        while (pos < test.length()) {
            if (test.at(pos).unicode() == 0xf7)
                breakPositions.append(strPos);
            else
                QVERIFY(test.at(pos).unicode() == 0xd7);
            ++pos;
            if (pos < test.length()) {
                QVERIFY(pos < test.length() - 4);
                QString hex = test.mid(pos, 4);
                bool ok = true;
                testString.append(QChar(hex.toInt(&ok, 16)));
                QVERIFY(ok);
                pos += 4;
            }
            ++strPos;
        }

        QTextBoundaryFinder finder(QTextBoundaryFinder::Grapheme, testString);
        for (int i = 0; i < breakPositions.size(); ++i) {
            QCOMPARE(finder.position(), breakPositions.at(i));
            finder.toNextBoundary();
        }
        QCOMPARE(finder.toNextBoundary(), -1);

        for (int i = 0; i < testString.length(); ++i) {
            finder.setPosition(i);
            QCOMPARE(finder.isAtBoundary(), breakPositions.contains(i) == true);
        }
    }
    QCOMPARE(lines, 100); // to see it actually found the file and all.
}
Ejemplo n.º 17
0
QString Completer::findWord(const QString& text, int selStart, int selEnd, int* wordStart, int* wordEnd)
{
    QTextBoundaryFinder finder(QTextBoundaryFinder::Word, text);
    finder.setPosition(selStart);
    if (!finder.isAtBoundary() || finder.boundaryReasons() & QTextBoundaryFinder::EndWord)
        finder.toPreviousBoundary();

    *wordStart = finder.position();
    *wordEnd = (selStart == selEnd) ? finder.toNextBoundary() : selStart;
    return text.mid(*wordStart, *wordEnd - *wordStart);
}
Ejemplo n.º 18
0
void Registry::loadCache()
{
	tstring templatePath;
	OPTIONS->GetPNPath(templatePath, PNPATH_PROJECTTEMPLATES);
	PNASSERT(templatePath.size() > 0);

	FileFinder<Registry> finder(this, &Registry::_onFoundFile);

	// Find all *.pnpt files in the project template directory, don't recurse.
	finder.Find(templatePath.c_str(), _T("*.pnpt"), false);
}
Ejemplo n.º 19
0
float WSWorld::heightAt(const float& x, const float& z) const
{
	WorldPage finder(0,0);
	if( x + m_maxScaledX < 0 || z + m_maxScaledZ < 0 )
		return 0.0;
	finder.m_x = (uint)((x + m_maxScaledX) / m_scaledPage);
	finder.m_z = (uint)((z + m_maxScaledZ) / m_scaledPage);
	std::set<WorldPage>::const_iterator it = m_pages.find(finder);
	if( it != m_pages.end() )
		return (*it).heightAt(x + m_maxScaledX - (*it).m_x * m_scaledPage,z + m_maxScaledZ - (*it).m_z * m_scaledPage );
	return 0.0;
};
Ejemplo n.º 20
0
        void operator () ( const adcontrols::MassSpectrum& data
                           , adportable::counting::counting_result& result
                           , std::vector< double >& processed ) {

            assert ( method.algo_ == adcontrols::threshold_method::Differential );
            assert ( findPositive == ( method.slope == adcontrols::threshold_method::CrossUp ) );

            double level = method.threshold_level;

            adportable::counting::peak_finder< findPositive > finder;

            finder( data.getIntensityArray(), data.getIntensityArray() + data.size(), result.indices2(), level );
        }
Ejemplo n.º 21
0
 boost::optional<int> findIndexByName(const std::vector<T>& vec,
                                      const std::string& name,
                                      bool caseSensitive=false)
 {
   boost::optional<int> index;
   NameFinder<T> finder(name,caseSensitive);
   typename std::vector<T>::const_iterator it;
   it = find_if(vec.begin(),vec.end(),finder);
   if (it != vec.end()) {
     index = (int)(it - vec.begin());
   }
   return index;
 }
Ejemplo n.º 22
0
 std::shared_ptr<T> findByName(const std::vector< std::shared_ptr<T> >& vec,
                                 const std::string& name,
                                 bool caseSensitive=false)
 {
   std::shared_ptr<T> result;
   NameFinder<T> finder(name,caseSensitive);
   typename std::vector< std::shared_ptr<T> >::const_iterator it;
   it = find_if(vec.begin(), vec.end(), finder);
   if (it != vec.end()){
     result = *it;
   };
   return result;
 }
Ejemplo n.º 23
0
void Rewriter::rewrite() {
    String::Ptr nm = env_->name(name_);
    UsageFinder::Ptr finder(new UsageFinder(env_, nm));
    for (int i = 0; i < finder->usages(); ++i) {
        TreeNode::Ptr node = finder->usage(i).node();
        if (node) {
            std::cerr << node->file()->path()->string() << ":";
            std::cerr << node->location().first_line << ":";
            std::cerr << node->location().first_column << "-";
            std::cerr << node->location().last_column << std::endl;
        }
    }
}
Ejemplo n.º 24
0
 boost::optional<T> findStructByName(const std::vector<T>& vec,
                                     const std::string& name,
                                     bool caseSensitive=false)
 {
   boost::optional<T> result;
   StructNameFinder<T> finder(name,caseSensitive);
   typename std::vector<T>::const_iterator it;
   it = find_if(vec.begin(), vec.end(), finder);
   if (it != vec.end()){
     result = *it;
   };
   return result;
 }
Ejemplo n.º 25
0
void MessageModel::receive(IrcMessage* message)
{
    MessageData data;
    data.plaintext = m_formatter->formatMessage(message, Qt::PlainText);
    if (!data.plaintext.isEmpty()) {
        data.timestamp = message->timeStamp().toString("hh:mm");
        data.date = message->timeStamp().date();
        data.type = message->type();
        data.own = message->flags() & IrcMessage::Own;
        data.event = (message->type() != IrcMessage::Private && message->type() != IrcMessage::Notice);
        data.sender = message->nick();
        if (!data.event && !data.own) {
            int pos = 0;
            QString nick = message->connection()->nickName();
            QString content = message->property("content").toString();
            while (!data.hilite && (pos = content.indexOf(nick, pos, Qt::CaseInsensitive)) != -1) {
                // #60: more precise nick alerts
                QTextBoundaryFinder finder(QTextBoundaryFinder::Word, content);
                finder.setPosition(pos);
                if (finder.isAtBoundary()) {
                    finder.setPosition(pos + nick.length());
                    data.hilite = finder.isAtBoundary();
                }
                pos += nick.length();
            }
        }
        data.richtext = m_formatter->formatMessage(message, Qt::RichText);
        foreach (const QUrl& url, m_formatter->textFormat()->urls()) {
            QString pretty = url.toString(QUrl::PrettyDecoded | QUrl::RemoveScheme | QUrl::StripTrailingSlash);
            while (pretty.startsWith("/"))
                pretty.remove(0, 1);
            if (!data.urls.contains(pretty)) {
                data.urls += pretty;
                data.rawUrls += url.toString();
            }
        }
        bool seen = (m_current && m_visible) || !message->connection()->isConnected();
        append(data, seen);
        if (!m_current || !m_visible) {
            bool priv = message->property("private").toBool() && !message->property("forwarded").toBool();
            if (data.hilite || priv) {
                setActiveHighlights(m_highlights + 1);
                if (priv)
                    emit messageMissed(data.plaintext);
                else
                    emit messageHighlighted(data.sender, data.plaintext);
            }
            if (!data.event) // TODO: create a setting for this?
                setBadge(m_badge + 1);
        }
    }
Ejemplo n.º 26
0
void CustomStimEditor::selectId(int id)
{
	// Setup the selectionfinder to search for the id
	gtkutil::TreeModel::SelectionFinder finder(id, _stimTypes.getColumns().id.index());

	_customStimStore->foreach_iter(
		sigc::mem_fun(finder, &gtkutil::TreeModel::SelectionFinder::forEach));

	if (finder.getIter())
	{
		// Set the active row of the list to the given stim
		_list->get_selection()->select(finder.getIter());
	}
}
Ejemplo n.º 27
0
void ClassEditor::selectId(int id)
{
	// Setup the selectionfinder to search for the id
	gtkutil::TreeModel::SelectionFinder finder(id, SREntity::getColumns().id.index());

	_list->get_model()->foreach_iter(
		sigc::mem_fun(finder, &gtkutil::TreeModel::SelectionFinder::forEach));

	if (finder.getIter())
	{
		// Set the active row of the list to the given effect
		_list->get_selection()->select(finder.getIter());
	}
}
Ejemplo n.º 28
0
static void RemoveOldAutoSelectFailFiles(const wxString& prefix, unsigned int keep_files)
{
    AutoSelectFailFinder finder(prefix);
    wxDir dir(Debug.GetLogDir());
    dir.Traverse(finder);

    finder.files.Sort();

    while (finder.files.size() >= keep_files)
    {
        wxRemoveFile(finder.files[0]);
        finder.files.RemoveAt(0);
    }
}
Ejemplo n.º 29
0
void tst_QTextBoundaryFinder::isAtWordStart()
{
    QString txt("The quick brown fox jumped over $the lazy. dog  I win!");
    QList<int> start, end;
    start << 0 << 4 << 10 << 16 << 20 << 27 << 32 << 33 << 37 << 41 << 43 << 48 << 50 << 53;
    end << 3 << 9 << 15 << 19 << 26 << 31 << 33 << 36 << 41 << 42 << 46 << 49 << 53 << 54;
    QTextBoundaryFinder finder(QTextBoundaryFinder::Word, txt);
    for(int i=0; i < txt.length(); ++i) {
        finder.setPosition(i);
        QTextBoundaryFinder::BoundaryReasons r = finder.boundaryReasons();
        QCOMPARE((r & QTextBoundaryFinder::StartWord) != 0, start.contains(i) == true);
        QCOMPARE((r & QTextBoundaryFinder::EndWord) != 0, end.contains(i) == true);
    }
}
Ejemplo n.º 30
0
 bool hasIrreducibleControlFlow(If* iff, Expression* origin) {
   // Gather the checks in this if chain. If all the label values checked are only set in origin,
   // then since origin is right before us, this is not irreducible - we can replace all sets
   // in origin with jumps forward to us, and since there is nothing else, this is safe and complete.
   // We must also have the property that there is just one check for the label value, as otherwise
   // node splitting has complicated things.
   std::map<Index, Index> labelChecksInOrigin;
   std::map<Index, Index> labelSetsInOrigin;
   LabelUseFinder finder(labelIndex, labelChecksInOrigin, labelSetsInOrigin);
   finder.walk(origin);
   while (iff) {
     auto num = getCheckedLabelValue(iff);
     assert(labelChecks[num] > 0);
     if (labelChecks[num] > 1) return true; // checked more than once, somewhere in function
     assert(labelChecksInOrigin[num] == 0);
     if (labelSetsInOrigin[num] != labelSets[num]) {
       assert(labelSetsInOrigin[num] < labelSets[num]);
       // the label is set outside of the origin
       // if the only other location is inside the if body, then it is ok - it must be in a loop
       // and returning to the top of the loop body, so we don't need to do anything for that
       // label setting anyhow
       std::map<Index, Index> labelChecksInIfTrue;
       std::map<Index, Index> labelSetsInIfTrue;
       LabelUseFinder finder(labelIndex, labelChecksInIfTrue, labelSetsInIfTrue);
       finder.walk(iff->ifTrue);
       if (labelSetsInOrigin[num] + labelSetsInIfTrue[num] < labelSets[num]) {
         // label set somewhere we can't see now, could be irreducible control flow
         // TODO: one case where this happens is instead of an if-chain, we have
         //       ifs and a switch on label|0, in separate elements. perhaps not
         //       emitting switches on label|0 in the relooper would avoid that.
         return true;
       }
     }
     iff = isLabelCheckingIf(iff->ifFalse, labelIndex);
   }
   return false;
 }