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

Projucer: Code cleanup

This commit is contained in:
ed 2018-01-22 12:30:19 +00:00
parent 1f405d6cd5
commit d668adb81b
15 changed files with 255 additions and 273 deletions

View file

@ -40,16 +40,16 @@ static var parseModuleDesc (const StringArray& lines)
DynamicObject* o = new DynamicObject();
var result (o);
for (int i = 0; i < lines.size(); ++i)
for (auto line : lines)
{
String line = trimCommentCharsFromStartOfLine (lines[i]);
line = trimCommentCharsFromStartOfLine (line);
int colon = line.indexOfChar (':');
auto colon = line.indexOfChar (':');
if (colon >= 0)
{
String key = line.substring (0, colon).trim();
String value = line.substring (colon + 1).trim();
auto key = line.substring (0, colon).trim();
auto value = line.substring (colon + 1).trim();
o->setProperty (key, value);
}
@ -98,7 +98,7 @@ File ModuleDescription::getHeader() const
for (auto e : extensions)
{
File header (moduleFolder.getChildFile (moduleFolder.getFileName() + e));
auto header = moduleFolder.getChildFile (moduleFolder.getFileName() + e);
if (header.existsAsFile())
return header;
@ -178,7 +178,7 @@ Result ModuleList::addAllModulesInFolder (const File& path)
{
if (! tryToAddModuleFromFolder (path))
{
const int subfolders = 2;
int subfolders = 2;
return addAllModulesInSubfoldersRecursively (path, subfolders);
}
@ -259,13 +259,13 @@ static Array<File> getAllPossibleModulePathsFromExporters (Project& project)
if (modules.shouldUseGlobalPath (id))
continue;
const auto path = exporter->getPathForModuleString (id);
auto path = exporter->getPathForModuleString (id);
if (path.isNotEmpty())
paths.addIfNotAlreadyThere (path);
}
String oldPath (exporter->getLegacyModulePath());
auto oldPath = exporter->getLegacyModulePath();
if (oldPath.isNotEmpty())
paths.addIfNotAlreadyThere (oldPath);
@ -345,16 +345,16 @@ LibraryModule::LibraryModule (const ModuleDescription& d)
//==============================================================================
void LibraryModule::writeIncludes (ProjectSaver& projectSaver, OutputStream& out)
{
Project& project = projectSaver.project;
EnabledModuleList& modules = project.getModules();
auto& project = projectSaver.project;
auto& modules = project.getModules();
const String id (getID());
auto id = getID();
if (modules.shouldCopyModuleFilesLocally (id).getValue())
{
const File juceModuleFolder (moduleInfo.getFolder());
auto juceModuleFolder = moduleInfo.getFolder();
const File localModuleFolder (project.getLocalModuleFolder (id));
auto localModuleFolder = project.getLocalModuleFolder (id);
localModuleFolder.createDirectory();
projectSaver.copyFolder (juceModuleFolder, localModuleFolder);
}
@ -377,7 +377,7 @@ void LibraryModule::addSettingsForModuleToExporter (ProjectExporter& exporter, P
{
auto& project = exporter.getProject();
const auto moduleRelativePath = exporter.getModuleFolderRelativeToProject (getID());
auto moduleRelativePath = exporter.getModuleFolderRelativeToProject (getID());
exporter.addToExtraSearchPaths (moduleRelativePath.getParentDirectory());
@ -389,25 +389,24 @@ void LibraryModule::addSettingsForModuleToExporter (ProjectExporter& exporter, P
else
libDirPlatform = exporter.getTargetFolder().getFileName();
const auto libSubdirPath = String (moduleRelativePath.toUnixStyle() + "/libs/") + libDirPlatform;
const auto moduleLibDir = File (project.getProjectFolder().getFullPathName() + "/" + libSubdirPath);
auto libSubdirPath = moduleRelativePath.toUnixStyle() + "/libs/" + libDirPlatform;
auto moduleLibDir = File (project.getProjectFolder().getFullPathName() + "/" + libSubdirPath);
if (moduleLibDir.exists())
exporter.addToModuleLibPaths (RelativePath (libSubdirPath, moduleRelativePath.getRoot()));
exporter.addToModuleLibPaths ({ libSubdirPath, moduleRelativePath.getRoot() });
const auto extraInternalSearchPaths = moduleInfo.getExtraSearchPaths().trim();
auto extraInternalSearchPaths = moduleInfo.getExtraSearchPaths().trim();
if (extraInternalSearchPaths.isNotEmpty())
{
StringArray paths;
paths.addTokens (extraInternalSearchPaths, true);
auto paths = StringArray::fromTokens (extraInternalSearchPaths, true);
for (auto& path : paths)
exporter.addToExtraSearchPaths (moduleRelativePath.getChildFile (path.unquoted()));
}
{
const String extraDefs (moduleInfo.getPreprocessorDefs().trim());
auto extraDefs = moduleInfo.getPreprocessorDefs().trim();
if (extraDefs.isNotEmpty())
exporter.getExporterPreprocessorDefsValue() = exporter.getExporterPreprocessorDefsString() + "\n" + extraDefs;
@ -418,9 +417,8 @@ void LibraryModule::addSettingsForModuleToExporter (ProjectExporter& exporter, P
auto& modules = project.getModules();
auto id = getID();
const File localModuleFolder = modules.shouldCopyModuleFilesLocally (id).getValue()
? project.getLocalModuleFolder (id)
: moduleInfo.getFolder();
auto localModuleFolder = modules.shouldCopyModuleFilesLocally (id).getValue() ? project.getLocalModuleFolder (id)
: moduleInfo.getFolder();
findAndAddCompiledUnits (exporter, &projectSaver, compiled);
@ -435,7 +433,7 @@ void LibraryModule::addSettingsForModuleToExporter (ProjectExporter& exporter, P
if (project.isAUPluginHost())
xcodeExporter.xcodeFrameworks.addTokens (xcodeExporter.isOSX() ? "AudioUnit CoreAudioKit" : "CoreAudioKit", false);
const String frameworks (moduleInfo.moduleInfo [xcodeExporter.isOSX() ? "OSXFrameworks" : "iOSFrameworks"].toString());
auto frameworks = moduleInfo.moduleInfo [xcodeExporter.isOSX() ? "OSXFrameworks" : "iOSFrameworks"].toString();
xcodeExporter.xcodeFrameworks.addTokens (frameworks, ", ", {});
parseAndAddLibs (xcodeExporter.xcodeLibs, moduleInfo.moduleInfo [exporter.isOSX() ? "OSXLibs" : "iOSLibs"].toString());
@ -460,7 +458,7 @@ void LibraryModule::addSettingsForModuleToExporter (ProjectExporter& exporter, P
void LibraryModule::getConfigFlags (Project& project, OwnedArray<Project::ConfigFlag>& flags) const
{
const File header (moduleInfo.getHeader());
auto header = moduleInfo.getHeader();
jassert (header.exists());
StringArray lines;
@ -468,7 +466,7 @@ void LibraryModule::getConfigFlags (Project& project, OwnedArray<Project::Config
for (int i = 0; i < lines.size(); ++i)
{
String line (lines[i].trim());
auto line = lines[i].trim();
if (line.startsWith ("/**") && line.containsIgnoreCase ("Config:"))
{
@ -650,9 +648,9 @@ void LibraryModule::addBrowseableCode (ProjectExporter& exporter, const Array<Fi
if (sourceFiles.isEmpty())
findBrowseableFiles (localModuleFolder, sourceFiles);
Project::Item sourceGroup (Project::Item::createGroup (exporter.getProject(), getID(), "__mainsourcegroup" + getID(), false));
auto sourceGroup = Project::Item::createGroup (exporter.getProject(), getID(), "__mainsourcegroup" + getID(), false);
const RelativePath moduleFromProject (exporter.getModuleFolderRelativeToProject (getID()));
auto moduleFromProject = exporter.getModuleFolderRelativeToProject (getID());
auto moduleHeader = moduleInfo.getHeader();
@ -787,7 +785,7 @@ void EnabledModuleList::addModule (const File& moduleFolder, bool copyLocally, b
if (info.isValid())
{
const String moduleID (info.getID());
auto moduleID = info.getID();
if (! isModuleEnabled (moduleID))
{
@ -812,7 +810,7 @@ void EnabledModuleList::addModule (const File& moduleFolder, bool copyLocally, b
void EnabledModuleList::removeModule (String moduleID) // must be pass-by-value, and not a const ref!
{
for (int i = state.getNumChildren(); --i >= 0;)
for (auto i = state.getNumChildren(); --i >= 0;)
if (state.getChild(i) [Ids::ID] == moduleID)
state.removeChild (i, getUndoManager());
@ -838,7 +836,7 @@ StringArray EnabledModuleList::getAllModules() const
static void getDependencies (Project& project, const String& moduleID, StringArray& dependencies)
{
ModuleDescription info (project.getModules().getModuleInfo (moduleID));
auto info = project.getModules().getModuleInfo (moduleID);
for (auto uid : info.getDependencies())
{
@ -876,7 +874,7 @@ bool EnabledModuleList::doesModuleHaveHigherCppStandardThanProject (const String
bool EnabledModuleList::areMostModulesUsingGlobalPath() const
{
auto numYes = 0, numNo = 0;
int numYes = 0, numNo = 0;
for (auto i = getNumModules(); --i >= 0;)
{
@ -891,7 +889,7 @@ bool EnabledModuleList::areMostModulesUsingGlobalPath() const
bool EnabledModuleList::areMostModulesCopiedLocally() const
{
auto numYes = 0, numNo = 0;
int numYes = 0, numNo = 0;
for (auto i = getNumModules(); --i >= 0;)
{
@ -906,7 +904,7 @@ bool EnabledModuleList::areMostModulesCopiedLocally() const
void EnabledModuleList::setLocalCopyModeForAllModules (bool copyLocally)
{
for (int i = getNumModules(); --i >= 0;)
for (auto i = getNumModules(); --i >= 0;)
shouldCopyModuleFilesLocally (project.getModules().getModuleID (i)) = copyLocally;
}
@ -915,7 +913,7 @@ File EnabledModuleList::findGlobalModulesFolder()
auto& settings = getAppSettings();
auto path = settings.getStoredPath (Ids::defaultJuceModulePath).toString();
if (settings.isGlobalPathValid (File(), Ids::defaultJuceModulePath, path))
if (settings.isGlobalPathValid ({}, Ids::defaultJuceModulePath, path))
return { path };
return {};
@ -931,9 +929,9 @@ File EnabledModuleList::findDefaultModulesFolder (Project& project)
ModuleList available;
available.scanProjectExporterModulePaths (project);
for (int i = available.modules.size(); --i >= 0;)
for (auto i = available.modules.size(); --i >= 0;)
{
File f (available.modules.getUnchecked(i)->getFolder());
auto f = available.modules.getUnchecked(i)->getFolder();
if (f.isDirectory())
return f.getParentDirectory();
@ -974,9 +972,9 @@ bool EnabledModuleList::isJuceModule (const String& moduleID)
void EnabledModuleList::addModuleFromUserSelectedFile()
{
static File lastLocation (findDefaultModulesFolder (project));
static auto lastLocation = findDefaultModulesFolder (project);
FileChooser fc ("Select a module to add...", lastLocation, String());
FileChooser fc ("Select a module to add...", lastLocation, {});
if (fc.browseForDirectory())
{