bool ThreadSearchThread::AddNewItem(wxSortedArrayString& sortedArrayString, const wxString& newItem, const wxArrayString& mask)
{
    // Adds item to array only if it does not exist
    bool added = false;
    if ( sortedArrayString.Index(newItem.c_str()) == wxNOT_FOUND )
    {
        // Looks if current file matches one of the file patterns
        size_t maskCount = mask.GetCount();
        if (maskCount == 0)
        {
            sortedArrayString.Add(newItem);
            added = true;
        }
        else
        {
            for (size_t i = 0; i < maskCount; ++i)
            {
                if ( newItem.Matches(mask[i].c_str() ) )
                {
                    sortedArrayString.Add(newItem);
                    added = true;
                    break;
                }
            }
        }
    }
    return added;
}
Пример #2
0
MFolder *MFolderCache::Get(const String& name)
{
   Check();

   int index = ms_aFolderNames.Index(name);
   return index == wxNOT_FOUND ? NULL : ms_aFolders[(size_t)index];
}
Пример #3
0
static void LoadLadspaEffect(wxSortedArrayString &uniq, wxString fname,
                             DL_Array &dls)
{
   wxLogNull logNo;
   LADSPA_Descriptor_Function mainFn = NULL;

   // Since we now have builtin VST support, ignore the VST bridge as it
   // causes duplicate menu entries to appear.
   wxFileName f(fname);
   if (f.GetName().CmpNoCase(wxT("vst-bridge")) == 0) {
      return;
   }

   // As a courtesy to some plug-ins that might be bridges to
   // open other plug-ins, we set the current working
   // directory to be the plug-in's directory.

   wxString saveOldCWD = ::wxGetCwd();
   wxString prefix = ::wxPathOnly(fname);
   ::wxSetWorkingDirectory(prefix);

   wxDynamicLibrary* pDLL = new wxDynamicLibrary();
   dls.push_back(pDLL);
   if (pDLL && pDLL->Load(fname, wxDL_LAZY)) {
      mainFn = (LADSPA_Descriptor_Function)(pDLL->GetSymbol(wxT(descriptorFnName)));
   }

   if (mainFn) {
      int index = 0;
      const LADSPA_Descriptor *data;

      data = mainFn(index);
      while(data) {

         wxString uniqid = wxString::Format(wxT("%08x-%s"), data->UniqueID, LAT1CTOWX(data->Label).c_str());
         if (uniq.Index(uniqid) == wxNOT_FOUND) {
            uniq.Add(uniqid);
            std::set<wxString> categories;

#if defined(USE_LIBLRDF) && defined(EFFECT_CATEGORIES)
            std::multimap<unsigned long, wxString>::const_iterator iter;
            iter = gPluginCategories.lower_bound(data->UniqueID);
            for ( ; (iter != gPluginCategories.end() &&
                     iter->first == data->UniqueID); ++iter)
               categories.insert(iter->second);
#endif

            LadspaEffect *effect = new LadspaEffect(data, categories);
            EffectManager::Get().RegisterEffect(effect);
         }
            
         // Get next plugin
         index++;
         data = mainFn(index);            
      }
   }

   ::wxSetWorkingDirectory(saveOldCWD);
}
Пример #4
0
/* static */
void MFolderCache::RenameAll(const String& oldName, const String& newName)
{
   int index = ms_aFolderNames.Index(oldName);
   if ( index != wxNOT_FOUND )
   {
      size_t n = (size_t)index;

      ms_aFolderNames[n] = newName;
      MFolderFromProfile *folder = (MFolderFromProfile *)ms_aFolders[n];

      folder->m_folderName = newName;
      SafeDecRef(folder->m_profile);
      folder->m_profile = Profile::CreateFolderProfile(newName);
   }
}
Пример #5
0
wxString wxLuaCheckStack::DumpTable(int stack_idx, const wxString& tablename, const wxString& msg, wxSortedArrayString& tableArray, int indent)
{
    wxCHECK_MSG(m_luaState, wxEmptyString, wxT("Invalid lua_State"));

    lua_State* L = m_luaState;
    wxLuaState wxlState(L);
    wxString indentStr;
    wxString s;

    // We only do tables, return error message
    if (!lua_istable(L, stack_idx))
    {
        s.Printf(wxT("wxLuaCheckStack::DumpTable(L=%p) stack idx %d is not a table.\n"), L, stack_idx);
        OutputMsg(s);
        return s;
    }

    if (indent == 0)
    {
        // First time through print header
        s.Printf(wxT("wxLuaCheckStack::DumpTable(L=%p) Table: '%s'\n"), L, tablename.c_str());
        OutputMsg(s);
    }
    else if (indent > 10)
    {
        // Don't let things get out of hand...
        s.Printf(wxT("wxLuaCheckStack::DumpTable(L=%p) Table depth > 10! Truncating: '%s'\n"), L, tablename.c_str());
        OutputMsg(s);
        return s;
    }
    else
    {
        indentStr = wxString(wxT(' '), indent*2) + wxT(">");
    }

    wxString title = wxString::Format(wxT("%sTable Level %d : name '%s'\n"), indentStr.c_str(), indent, tablename.c_str());
    s += title;
    OutputMsg(title);

    lua_pushvalue(L, stack_idx); // push the table to read the top of the stack

    lua_pushnil(L);
    while (lua_next(L, -2) != 0)
    {
        int keyType = 0, valueType = 0;
        wxString key, value;

        wxLuaDebugData::GetTypeValue(L, -2, &keyType,   key);
        wxLuaDebugData::GetTypeValue(L, -1, &valueType, value);

        wxString info = wxString::Format(wxT("%s%-32s\t%-16s\t%-20s\t%-16s\n"),
                indentStr.c_str(), key.c_str(), wxluaT_typename(L, keyType).c_str(), value.c_str(), wxluaT_typename(L, valueType).c_str());
        s += info;
        OutputMsg(info);

        if (tableArray.Index(value) == wxNOT_FOUND)
        {
            if (valueType == WXLUA_TTABLE)
            {
                tableArray.Add(value);
                s += DumpTable(lua_gettop(L), tablename + wxT(".") + key, msg, tableArray, indent+1);
            }
            else
            {
                tableArray.Add(value);
            }
        }

        lua_pop(L, 1); // pop value
    }

    lua_pop(L, 1); // pop pushed table

    return s;
}
Пример #6
0
int BenchApp::OnRun()
{
    int rc = EXIT_SUCCESS;
    for ( Bench::Function *func = Bench::Function::GetFirst();
          func;
          func = func->GetNext() )
    {
        if ( m_toRun.Index(func->GetName()) == wxNOT_FOUND )
            continue;

        wxString params;
        if ( m_numParam )
            params += wxString::Format(" with N=%ld", m_numParam);
        if ( !m_strParam.empty() )
        {
            if ( !params.empty() )
                params += " and";
            params += wxString::Format(" with s=\"%s\"", m_strParam);
        }

        wxPrintf("Benchmarking %s%s: ", func->GetName(), params);

        long timeMin = LONG_MAX,
             timeMax = 0,
             timeTotal = 0;
        bool ok = func->Init();
        for ( long a = 0; ok && a < m_avgCount; a++ )
        {
            wxStopWatch sw;
            for ( long n = 0; n < m_numRuns && ok; n++ )
            {
                ok = func->Run();
            }

            sw.Pause();

            const long t = sw.Time();
            if ( t < timeMin )
                timeMin = t;
            if ( t > timeMax )
                timeMax = t;
            timeTotal += t;
        }

        func->Done();

        if ( !ok )
        {
            wxPrintf("ERROR\n");
            rc = EXIT_FAILURE;
        }
        else
        {
            wxPrintf("%ldms total, ", timeTotal);

            long times = m_avgCount;
            if ( m_avgCount > 2 )
            {
                timeTotal -= timeMin + timeMax;
                times -= 2;
            }

            wxPrintf("%.2f avg (min=%ld, max=%ld)\n",
                     (float)timeTotal / times, timeMin, timeMax);
        }
    }

    return rc;
}