Browse Source

A few C++11 modernisations and comment corrections

tags/2021-05-28
jules 8 years ago
parent
commit
44cd80969d
25 changed files with 43 additions and 45 deletions
  1. +1
    -1
      examples/Demo/Source/Demos/MDIDemo.cpp
  2. +2
    -4
      extras/Projucer/Source/Application/jucer_CommandLine.cpp
  3. +5
    -5
      extras/Projucer/Source/Application/jucer_MainWindow.cpp
  4. +1
    -1
      extras/Projucer/Source/Application/jucer_OpenDocumentManager.h
  5. +2
    -2
      extras/Projucer/Source/Code Editor/jucer_SourceCodeEditor.h
  6. +2
    -2
      extras/Projucer/Source/ComponentEditor/components/jucer_ViewportHandler.h
  7. +1
    -1
      extras/Projucer/Source/ComponentEditor/ui/jucer_TestComponent.cpp
  8. +1
    -1
      extras/Projucer/Source/LiveBuildEngine/projucer_ClassDatabase.h
  9. +1
    -1
      extras/Projucer/Source/LiveBuildEngine/projucer_CompileEngineDLL.h
  10. +1
    -1
      extras/Projucer/Source/Project Saving/jucer_ProjectExport_Android.h
  11. +5
    -5
      extras/Projucer/Source/Project/jucer_Module.cpp
  12. +2
    -2
      extras/Projucer/Source/Project/jucer_Project.cpp
  13. +1
    -1
      extras/Projucer/Source/Project/jucer_ProjectTree_File.h
  14. +1
    -1
      extras/Projucer/Source/Utility/jucer_JucerTreeViewBase.h
  15. +1
    -1
      extras/Projucer/Source/Wizards/jucer_NewFileWizard.cpp
  16. +1
    -1
      extras/Projucer/Source/Wizards/jucer_TemplateThumbnailsComponent.h
  17. +1
    -1
      modules/juce_core/files/juce_File.cpp
  18. +1
    -1
      modules/juce_core/native/juce_android_Files.cpp
  19. +3
    -3
      modules/juce_core/native/juce_linux_Files.cpp
  20. +1
    -1
      modules/juce_core/native/juce_mac_Files.mm
  21. +2
    -2
      modules/juce_core/native/juce_win32_Files.cpp
  22. +1
    -1
      modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp
  23. +3
    -3
      modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp
  24. +2
    -2
      modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp
  25. +1
    -1
      modules/juce_gui_basics/widgets/juce_ListBox.h

+ 1
- 1
examples/Demo/Source/Demos/MDIDemo.cpp 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


+ 2
- 4
extras/Projucer/Source/Application/jucer_CommandLine.cpp 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;
}


+ 5
- 5
extras/Projucer/Source/Application/jucer_MainWindow.cpp 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 {};
}

+ 1
- 1
extras/Projucer/Source/Application/jucer_OpenDocumentManager.h 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 {}; }
};
//==============================================================================


+ 2
- 2
extras/Projucer/Source/Code Editor/jucer_SourceCodeEditor.h 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;


+ 2
- 2
extras/Projucer/Source/ComponentEditor/components/jucer_ViewportHandler.h 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);
}


+ 1
- 1
extras/Projucer/Source/ComponentEditor/ui/jucer_TestComponent.cpp 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);


+ 1
- 1
extras/Projucer/Source/LiveBuildEngine/projucer_ClassDatabase.h 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


+ 1
- 1
extras/Projucer/Source/LiveBuildEngine/projucer_CompileEngineDLL.h View File

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


+ 1
- 1
extras/Projucer/Source/Project Saving/jucer_ProjectExport_Android.h View File

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


+ 5
- 5
extras/Projucer/Source/Project/jucer_Module.cpp 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)


+ 2
- 2
extras/Projucer/Source/Project/jucer_Project.cpp 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)


+ 1
- 1
extras/Projucer/Source/Project/jucer_ProjectTree_File.h 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


+ 1
- 1
extras/Projucer/Source/Utility/jucer_JucerTreeViewBase.h 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();


+ 1
- 1
extras/Projucer/Source/Wizards/jucer_NewFileWizard.cpp View File

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


+ 1
- 1
extras/Projucer/Source/Wizards/jucer_TemplateThumbnailsComponent.h View File

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


+ 1
- 1
modules/juce_core/files/juce_File.cpp 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());


+ 1
- 1
modules/juce_core/native/juce_android_Files.cpp View File

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


+ 3
- 3
modules/juce_core/native/juce_linux_Files.cpp 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 {};
}
//==============================================================================


+ 1
- 1
modules/juce_core/native/juce_mac_Files.mm View File

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


+ 2
- 2
modules/juce_core/native/juce_win32_Files.cpp 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);


+ 1
- 1
modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp 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);


+ 3
- 3
modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp 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


+ 2
- 2
modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp 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()


+ 1
- 1
modules/juce_gui_basics/widgets/juce_ListBox.h 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


Loading…
Cancel
Save