1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

A few C++11 modernisations and comment corrections

This commit is contained in:
jules 2017-03-28 12:31:51 +01:00
parent e253b8bea1
commit 44cd80969d
25 changed files with 43 additions and 45 deletions

View file

@ -86,7 +86,7 @@ public:
File getLastDocumentOpened() override
{
// not interested in this for now
return File();
return {};
}
void setLastDocumentOpened (const File& /*file*/) override

View file

@ -456,14 +456,12 @@ namespace
{
File result;
for (int i = 0; i < allFiles.size(); ++i)
for (auto& f : allFiles)
{
const File& f = allFiles.getReference(i);
if (f.getFileName().equalsIgnoreCase (name) && f != sourceFile)
{
if (result.exists())
return File(); // multiple possible results, so don't change it!
return {}; // multiple possible results, so don't change it!
result = f;
}

View file

@ -597,11 +597,11 @@ Project* MainWindowList::getFrontmostProject()
File findDefaultModulesFolder (bool mustContainJuceCoreModule)
{
const MainWindowList& windows = ProjucerApplication::getApp().mainWindowList;
auto& windows = ProjucerApplication::getApp().mainWindowList;
for (int i = windows.windows.size(); --i >= 0;)
{
if (Project* p = windows.windows.getUnchecked (i)->getProject())
if (auto* p = windows.windows.getUnchecked (i)->getProject())
{
const File f (EnabledModuleList::findDefaultModulesFolder (*p));
@ -613,11 +613,11 @@ File findDefaultModulesFolder (bool mustContainJuceCoreModule)
if (mustContainJuceCoreModule)
return findDefaultModulesFolder (false);
File f (File::getSpecialLocation (File::currentApplicationFile));
auto f = File::getSpecialLocation (File::currentApplicationFile);
for (;;)
{
File parent (f.getParentDirectory());
auto parent = f.getParentDirectory();
if (parent == f || ! parent.isDirectory())
break;
@ -628,5 +628,5 @@ File findDefaultModulesFolder (bool mustContainJuceCoreModule)
f = parent;
}
return File();
return {};
}

View file

@ -61,7 +61,7 @@ public:
virtual void fileHasBeenRenamed (const File& newFile) = 0;
virtual String getState() const = 0;
virtual void restoreState (const String& state) = 0;
virtual File getCounterpartFile() const { return File(); }
virtual File getCounterpartFile() const { return {}; }
};
//==============================================================================

View file

@ -64,7 +64,7 @@ public:
return findCounterpart (file, extensions);
}
return File();
return {};
}
static File findCounterpart (const File& file, const char** extensions)
@ -77,7 +77,7 @@ public:
return f;
}
return File();
return {};
}
void reloadFromFile() override;

View file

@ -502,10 +502,10 @@ private:
File getFile() const
{
const String filename (getViewportJucerComponentFile (component));
auto filename = getViewportJucerComponentFile (component);
if (filename.isEmpty())
return File();
return {};
return document.getCppFile().getSiblingFile (filename);
}

View file

@ -69,7 +69,7 @@ static StringArray recursiveFiles;
File TestComponent::findFile() const
{
if (filename.isEmpty())
return File();
return {};
if (ownerDocument != nullptr)
return ownerDocument->getCppFile().getSiblingFile (filename);

View file

@ -346,7 +346,7 @@ struct ClassDatabase
if (m.definition.isValid() && File (m.definition.file).exists())
return m.definition.file;
return File();
return {};
}
Array<File> getAllSourceFiles() const

View file

@ -127,7 +127,7 @@ private:
if (tryFindDLLFileInAppConfigFolder(dllFile))
return dllFile;
return File();
return {};
}
#if JUCE_MAC

View file

@ -284,7 +284,7 @@ public:
return defaultInstallation;
#endif
return File();
return {};
}
protected:

View file

@ -96,21 +96,21 @@ File ModuleDescription::getHeader() const
{
const char* extensions[] = { ".h", ".hpp", ".hxx" };
for (int i = 0; i < numElementsInArray (extensions); ++i)
for (auto e : extensions)
{
File header (moduleFolder.getChildFile (moduleFolder.getFileName() + extensions[i]));
File header (moduleFolder.getChildFile (moduleFolder.getFileName() + e));
if (header.existsAsFile())
return header;
}
}
return File();
return {};
}
StringArray ModuleDescription::getDependencies() const
{
StringArray deps = StringArray::fromTokens (moduleInfo ["dependencies"].toString(), " \t;,", "\"'");
auto deps = StringArray::fromTokens (moduleInfo ["dependencies"].toString(), " \t;,", "\"'");
deps.trim();
deps.removeEmptyStrings();
return deps;
@ -635,7 +635,7 @@ File EnabledModuleList::findLocalModuleFolder (const String& moduleID, bool useE
}
}
return File();
return {};
}
File EnabledModuleList::getModuleFolder (const String& moduleID)

View file

@ -400,7 +400,7 @@ bool Project::hasProjectBeenModified()
File Project::resolveFilename (String filename) const
{
if (filename.isEmpty())
return File();
return {};
filename = replacePreprocessorDefs (getPreprocessorDefs(), filename);
@ -863,7 +863,7 @@ File Project::Item::getFile() const
if (isFile())
return project.resolveFilename (state [Ids::file].toString());
return File();
return {};
}
void Project::Item::setFile (const File& file)

View file

@ -43,7 +43,7 @@ public:
if (f.hasFileExtension (sourceFileExtensions)) return f.withFileExtension (".h");
if (f.hasFileExtension (headerFileExtensions)) return f.withFileExtension (".cpp");
return File();
return {};
}
void setName (const String& newName) override

View file

@ -57,7 +57,7 @@ public:
virtual void paintIcon (Graphics& g, Rectangle<int> area) { getIcon().draw (g, area.reduced (2).toFloat(), isIconCrossedOut()); }
virtual void paintContent (Graphics& g, const Rectangle<int>& area);
virtual int getMillisecsAllowedForDragGesture() { return 120; };
virtual File getDraggableFile() const { return File(); }
virtual File getDraggableFile() const { return {}; }
void refreshSubItems();
virtual void deleteItem();

View file

@ -225,7 +225,7 @@ File NewFileWizard::Type::askUserToChooseNewFile (const String& suggestedFilenam
if (fc.browseForFileToSave (true))
return fc.getResult();
return File();
return {};
}
//==============================================================================

View file

@ -253,7 +253,7 @@ public:
appFolder = appFolder.getParentDirectory();
}
return File();
return {};
}
private:

View file

@ -698,7 +698,7 @@ bool File::hasFileExtension (StringRef possibleSuffix) const
File File::withFileExtension (StringRef newExtension) const
{
if (fullPath.isEmpty())
return File();
return {};
String filePart (getFileName());

View file

@ -86,7 +86,7 @@ File File::getSpecialLocation (const SpecialLocationType type)
break;
}
return File();
return {};
}
bool File::moveToTrash() const

View file

@ -114,10 +114,10 @@ File File::getSpecialLocation (const SpecialLocationType type)
if (const char* homeDir = getenv ("HOME"))
return File (CharPointer_UTF8 (homeDir));
if (struct passwd* const pw = getpwuid (getuid()))
if (auto* pw = getpwuid (getuid()))
return File (CharPointer_UTF8 (pw->pw_dir));
return File();
return {};
}
case userDocumentsDirectory: return resolveXDGFolder ("XDG_DOCUMENTS_DIR", "~/Documents");
@ -161,7 +161,7 @@ File File::getSpecialLocation (const SpecialLocationType type)
break;
}
return File();
return {};
}
//==============================================================================

View file

@ -259,7 +259,7 @@ File File::getSpecialLocation (const SpecialLocationType type)
return File (resultPath.convertToPrecomposedUnicode());
}
return File();
return {};
}
//==============================================================================

View file

@ -96,7 +96,7 @@ namespace WindowsFileHelpers
if (SHGetSpecialFolderPath (0, path, type, FALSE))
return File (String (path));
return File();
return {};
}
File getModuleFileName (HINSTANCE moduleHandle)
@ -599,7 +599,7 @@ File JUCE_CALLTYPE File::getSpecialLocation (const SpecialLocationType type)
default:
jassertfalse; // unknown type?
return File();
return {};
}
return WindowsFileHelpers::getSpecialFolderPath (csidlType);

View file

@ -92,7 +92,7 @@ File PropertiesFile::Options::getDefaultFile() const
: File::userApplicationDataDirectory));
if (dir == File())
return File();
return {};
dir = dir.getChildFile (folderName.isNotEmpty() ? folderName
: applicationName);

View file

@ -119,7 +119,7 @@ bool DirectoryContentsList::getFileInfo (const int index, FileInfo& result) cons
{
const ScopedLock sl (fileListLock);
if (const FileInfo* const info = files [index])
if (auto* info = files [index])
{
result = *info;
return true;
@ -132,10 +132,10 @@ File DirectoryContentsList::getFile (const int index) const
{
const ScopedLock sl (fileListLock);
if (const FileInfo* const info = files [index])
if (auto* info = files [index])
return root.getChildFile (info->filename);
return File();
return {};
}
bool DirectoryContentsList::contains (const File& targetFile) const

View file

@ -282,10 +282,10 @@ void FileTreeComponent::refresh()
//==============================================================================
File FileTreeComponent::getSelectedFile (const int index) const
{
if (const FileListTreeItem* const item = dynamic_cast<const FileListTreeItem*> (getSelectedItem (index)))
if (auto* item = dynamic_cast<const FileListTreeItem*> (getSelectedItem (index)))
return item->file;
return File();
return {};
}
void FileTreeComponent::deselectAllFiles()

View file

@ -59,7 +59,7 @@ public:
and handle mouse clicks with listBoxItemClicked().
This method will be called whenever a custom component might need to be updated - e.g.
when the table is changed, or TableListBox::updateContent() is called.
when the list is changed, or ListBox::updateContent() is called.
If you don't need a custom component for the specified row, then return nullptr.
(Bear in mind that even if you're not creating a new component, you may still need to