Browse Source

Projucer: More code cleanup

tags/2021-05-28
ed 7 years ago
parent
commit
c0c709f10b
6 changed files with 107 additions and 118 deletions
  1. +51
    -51
      extras/Projucer/Source/ProjectSaving/jucer_ProjectExporter.cpp
  2. +13
    -20
      extras/Projucer/Source/ProjectSaving/jucer_ProjectExporter.h
  3. +2
    -3
      extras/Projucer/Source/ProjectSaving/jucer_ProjectSaver.cpp
  4. +23
    -24
      extras/Projucer/Source/ProjectSaving/jucer_ProjectSaver.h
  5. +17
    -19
      extras/Projucer/Source/ProjectSaving/jucer_ResourceFile.cpp
  6. +1
    -1
      extras/Projucer/Source/ProjectSaving/jucer_ResourceFile.h

+ 51
- 51
extras/Projucer/Source/ProjectSaving/jucer_ProjectExporter.cpp View File

@@ -219,15 +219,15 @@ ProjectExporter::ProjectExporter (Project& p, const ValueTree& state)
projectType (p.getProjectType()),
projectName (p.getProjectNameString()),
projectFolder (p.getProjectFolder()),
targetLocationValue (settings, Ids::targetFolder, project.getUndoManagerFor (settings)),
extraCompilerFlagsValue (settings, Ids::extraCompilerFlags, project.getUndoManagerFor (settings)),
extraLinkerFlagsValue (settings, Ids::extraLinkerFlags, project.getUndoManagerFor (settings)),
externalLibrariesValue (settings, Ids::externalLibraries, project.getUndoManagerFor (settings)),
userNotesValue (settings, Ids::userNotes, project.getUndoManagerFor (settings)),
gnuExtensionsValue (settings, Ids::enableGNUExtensions, project.getUndoManagerFor (settings)),
bigIconValue (settings, Ids::bigIcon, project.getUndoManagerFor (settings)),
smallIconValue (settings, Ids::smallIcon, project.getUndoManagerFor (settings)),
extraPPDefsValue (settings, Ids::extraDefs, project.getUndoManagerFor (settings))
targetLocationValue (settings, Ids::targetFolder, getUndoManager()),
extraCompilerFlagsValue (settings, Ids::extraCompilerFlags, getUndoManager()),
extraLinkerFlagsValue (settings, Ids::extraLinkerFlags, getUndoManager()),
externalLibrariesValue (settings, Ids::externalLibraries, getUndoManager()),
userNotesValue (settings, Ids::userNotes, getUndoManager()),
gnuExtensionsValue (settings, Ids::enableGNUExtensions, getUndoManager()),
bigIconValue (settings, Ids::bigIcon, getUndoManager()),
smallIconValue (settings, Ids::smallIcon, getUndoManager()),
extraPPDefsValue (settings, Ids::extraDefs, getUndoManager())
{
}
@@ -376,7 +376,7 @@ void ProjectExporter::addCommonAudioPluginSettings()
void ProjectExporter::addVST3FolderToPath()
{
const String vst3Folder (getVST3PathValue().toString());
auto vst3Folder = getVST3PathValue().toString();
if (vst3Folder.isNotEmpty())
addToExtraSearchPaths (RelativePath (vst3Folder, RelativePath::projectFolder), 0);
@@ -384,11 +384,11 @@ void ProjectExporter::addVST3FolderToPath()
void ProjectExporter::addAAXFoldersToPath()
{
const String aaxFolder = getAAXPathValue().toString();
auto aaxFolder = getAAXPathValue().toString();
if (aaxFolder.isNotEmpty())
{
const RelativePath aaxFolderPath (getAAXPathValue().toString(), RelativePath::projectFolder);
RelativePath aaxFolderPath (getAAXPathValue().toString(), RelativePath::projectFolder);
addToExtraSearchPaths (aaxFolderPath);
addToExtraSearchPaths (aaxFolderPath.getChildFile ("Interfaces"));
@@ -399,8 +399,8 @@ void ProjectExporter::addAAXFoldersToPath()
//==============================================================================
StringPairArray ProjectExporter::getAllPreprocessorDefs (const BuildConfiguration& config, const ProjectType::Target::Type targetType) const
{
StringPairArray defs (mergePreprocessorDefs (config.getAllPreprocessorDefs(),
parsePreprocessorDefs (getExporterPreprocessorDefsString())));
auto defs = mergePreprocessorDefs (config.getAllPreprocessorDefs(),
parsePreprocessorDefs (getExporterPreprocessorDefsString()));
addDefaultPreprocessorDefs (defs);
addTargetSpecificPreprocessorDefs (defs, targetType);
@@ -409,8 +409,8 @@ StringPairArray ProjectExporter::getAllPreprocessorDefs (const BuildConfiguratio
StringPairArray ProjectExporter::getAllPreprocessorDefs() const
{
StringPairArray defs (mergePreprocessorDefs (project.getPreprocessorDefs(),
parsePreprocessorDefs (getExporterPreprocessorDefsString())));
auto defs = mergePreprocessorDefs (project.getPreprocessorDefs(),
parsePreprocessorDefs (getExporterPreprocessorDefsString()));
addDefaultPreprocessorDefs (defs);
return defs;
}
@@ -474,9 +474,9 @@ Project::Item& ProjectExporter::getModulesGroup()
void ProjectExporter::addProjectPathToBuildPathList (StringArray& pathList, const RelativePath& pathFromProjectFolder, int index) const
{
const auto localPath = RelativePath (rebaseFromProjectFolderToBuildTarget (pathFromProjectFolder));
auto localPath = RelativePath (rebaseFromProjectFolderToBuildTarget (pathFromProjectFolder));
const auto path = isVisualStudio() ? localPath.toWindowsStyle() : localPath.toUnixStyle();
auto path = isVisualStudio() ? localPath.toWindowsStyle() : localPath.toUnixStyle();
if (! pathList.contains (path))
pathList.insert (index, path);
@@ -494,10 +494,10 @@ void ProjectExporter::addToExtraSearchPaths (const RelativePath& pathFromProject
Value ProjectExporter::getPathForModuleValue (const String& moduleID)
{
UndoManager* um = project.getUndoManagerFor (settings);
auto* um = getUndoManager();
ValueTree paths (settings.getOrCreateChildWithName (Ids::MODULEPATHS, um));
ValueTree m (paths.getChildWithProperty (Ids::ID, moduleID));
auto paths = settings.getOrCreateChildWithName (Ids::MODULEPATHS, um);
auto m = paths.getChildWithProperty (Ids::ID, moduleID);
if (! m.isValid())
{
@@ -533,8 +533,9 @@ String ProjectExporter::getPathForModuleString (const String& moduleID) const
void ProjectExporter::removePathForModule (const String& moduleID)
{
ValueTree paths (settings.getChildWithName (Ids::MODULEPATHS));
ValueTree m (paths.getChildWithProperty (Ids::ID, moduleID));
auto paths = settings.getChildWithName (Ids::MODULEPATHS);
auto m = paths.getChildWithProperty (Ids::ID, moduleID);
paths.removeChild (m, project.getUndoManagerFor (settings));
}
@@ -556,7 +557,7 @@ RelativePath ProjectExporter::getModuleFolderRelativeToProject (const String& mo
return RelativePath (project.getRelativePathForFile (project.getLocalModuleFolder (moduleID)),
RelativePath::projectFolder);
String path (getPathForModuleString (moduleID));
auto path = getPathForModuleString (moduleID);
if (path.isEmpty())
return getLegacyModulePath (moduleID).getChildFile (moduleID);
@@ -576,7 +577,7 @@ RelativePath ProjectExporter::getLegacyModulePath (const String& moduleID) const
.getChildFile ("modules")
.getChildFile (moduleID)), RelativePath::projectFolder);
String oldJucePath (getLegacyModulePath());
auto oldJucePath = getLegacyModulePath();
if (oldJucePath.isEmpty())
return RelativePath();
@@ -590,13 +591,13 @@ RelativePath ProjectExporter::getLegacyModulePath (const String& moduleID) const
void ProjectExporter::updateOldModulePaths()
{
String oldPath (getLegacyModulePath());
auto oldPath = getLegacyModulePath();
if (oldPath.isNotEmpty())
{
for (int i = project.getModules().getNumModules(); --i >= 0;)
{
String modID (project.getModules().getModuleID(i));
auto modID = project.getModules().getModuleID(i);
getPathForModuleValue (modID) = getLegacyModulePath (modID).getParentDirectory().toUnixStyle();
}
@@ -621,7 +622,7 @@ void ProjectExporter::createDefaultModulePaths()
{
for (int i = project.getModules().getNumModules(); --i >= 0;)
{
String modID (project.getModules().getModuleID(i));
auto modID = project.getModules().getModuleID (i);
getPathForModuleValue (modID) = exporter->getPathForModuleValue (modID).getValue();
}
@@ -635,7 +636,7 @@ void ProjectExporter::createDefaultModulePaths()
{
for (int i = project.getModules().getNumModules(); --i >= 0;)
{
String modID (project.getModules().getModuleID(i));
auto modID = project.getModules().getModuleID (i);
getPathForModuleValue (modID) = exporter->getPathForModuleValue (modID).getValue();
}
@@ -645,7 +646,7 @@ void ProjectExporter::createDefaultModulePaths()
for (int i = project.getModules().getNumModules(); --i >= 0;)
{
String modID (project.getModules().getModuleID(i));
auto modID = project.getModules().getModuleID (i);
getPathForModuleValue (modID) = "../../juce";
}
}
@@ -668,7 +669,7 @@ ProjectExporter::BuildConfiguration::Ptr ProjectExporter::getConfiguration (int
bool ProjectExporter::hasConfigurationNamed (const String& nameToFind) const
{
const ValueTree configs (getConfigurations());
auto configs = getConfigurations();
for (int i = configs.getNumChildren(); --i >= 0;)
if (configs.getChild(i) [Ids::name].toString() == nameToFind)
return true;
@@ -678,7 +679,7 @@ bool ProjectExporter::hasConfigurationNamed (const String& nameToFind) const
String ProjectExporter::getUniqueConfigName (String nm) const
{
String nameRoot (nm);
auto nameRoot = nm;
while (CharacterFunctions::isDigit (nameRoot.getLastCharacter()))
nameRoot = nameRoot.dropLastCharacters (1);
@@ -777,19 +778,19 @@ Image ProjectExporter::getBestIconForSize (int size, bool returnNullIfNothingBig
}
if (im == nullptr)
return Image();
return {};
if (returnNullIfNothingBigEnough && im->getWidth() < size && im->getHeight() < size)
return Image();
return {};
return rescaleImageForIcon (*im, size);
}
Image ProjectExporter::rescaleImageForIcon (Drawable& d, const int size)
{
if (DrawableImage* drawableImage = dynamic_cast<DrawableImage*> (&d))
if (auto* drawableImage = dynamic_cast<DrawableImage*> (&d))
{
Image im = SoftwareImageType().convert (drawableImage->getImage());
auto im = SoftwareImageType().convert (drawableImage->getImage());
if (size == im.getWidth() && size == im.getHeight())
return im;
@@ -845,16 +846,16 @@ bool ProjectExporter::ConstConfigIterator::next()
//==============================================================================
ProjectExporter::BuildConfiguration::BuildConfiguration (Project& p, const ValueTree& configNode, const ProjectExporter& e)
: config (configNode), project (p), exporter (e),
isDebugValue (config, Ids::isDebug, getUndoManager(), getValue (Ids::isDebug)),
configNameValue (config, Ids::name, getUndoManager(), "Build Configuration"),
targetNameValue (config, Ids::targetName, getUndoManager(), project.getProjectFilenameRootString()),
targetBinaryPathValue (config, Ids::binaryPath, getUndoManager()),
optimisationLevelValue (config, Ids::optimisation, getUndoManager()),
isDebugValue (config, Ids::isDebug, getUndoManager(), getValue (Ids::isDebug)),
configNameValue (config, Ids::name, getUndoManager(), "Build Configuration"),
targetNameValue (config, Ids::targetName, getUndoManager(), project.getProjectFilenameRootString()),
targetBinaryPathValue (config, Ids::binaryPath, getUndoManager()),
optimisationLevelValue (config, Ids::optimisation, getUndoManager()),
linkTimeOptimisationValue (config, Ids::linkTimeOptimisation, getUndoManager(), ! isDebug()),
ppDefinesValue (config, Ids::defines, getUndoManager()),
headerSearchPathValue (config, Ids::headerPath, getUndoManager()),
librarySearchPathValue (config, Ids::libraryPath, getUndoManager()),
userNotesValue (config, Ids::userNotes, getUndoManager())
ppDefinesValue (config, Ids::defines, getUndoManager()),
headerSearchPathValue (config, Ids::headerPath, getUndoManager()),
librarySearchPathValue (config, Ids::libraryPath, getUndoManager()),
userNotesValue (config, Ids::userNotes, getUndoManager())
{
}
@@ -928,17 +929,17 @@ StringPairArray ProjectExporter::BuildConfiguration::getAllPreprocessorDefs() co
StringPairArray ProjectExporter::BuildConfiguration::getUniquePreprocessorDefs() const
{
StringPairArray perConfigurationDefs (parsePreprocessorDefs (getBuildConfigPreprocessorDefsString()));
const StringPairArray globalDefs (project.getPreprocessorDefs());
auto perConfigurationDefs = parsePreprocessorDefs (getBuildConfigPreprocessorDefsString());
auto globalDefs = project.getPreprocessorDefs();
for (int i = 0; i < globalDefs.size(); ++i)
{
String globalKey = globalDefs.getAllKeys()[i];
auto globalKey = globalDefs.getAllKeys()[i];
int idx = perConfigurationDefs.getAllKeys().indexOf (globalKey);
if (idx >= 0)
{
String globalValue = globalDefs.getAllValues()[i];
auto globalValue = globalDefs.getAllValues()[i];
if (globalValue == perConfigurationDefs.getAllValues()[idx])
perConfigurationDefs.remove (idx);
@@ -966,8 +967,7 @@ StringArray ProjectExporter::BuildConfiguration::getLibrarySearchPaths() const
String ProjectExporter::getExternalLibraryFlags (const BuildConfiguration& config) const
{
StringArray libraries;
libraries.addTokens (getExternalLibrariesString(), ";\n", "\"'");
auto libraries = StringArray::fromTokens (getExternalLibrariesString(), ";\n", "\"'");
libraries.removeEmptyStrings (true);
if (libraries.size() != 0)


+ 13
- 20
extras/Projucer/Source/ProjectSaving/jucer_ProjectExporter.h View File

@@ -134,27 +134,27 @@ public:
String getName() const;
File getTargetFolder() const;
Project& getProject() noexcept { return project; }
const Project& getProject() const noexcept { return project; }
Project& getProject() noexcept { return project; }
const Project& getProject() const noexcept { return project; }
UndoManager* getUndoManager() const { return project.getUndoManagerFor (settings); }
Value getSetting (const Identifier& nm) { return settings.getPropertyAsValue (nm, project.getUndoManagerFor (settings)); }
String getSettingString (const Identifier& nm) const { return settings [nm]; }
Value getTargetLocationValue() { return targetLocationValue.getPropertyAsValue(); }
String getTargetLocationString() const { return targetLocationValue.get(); }
Value getTargetLocationValue() { return targetLocationValue.getPropertyAsValue(); }
String getTargetLocationString() const { return targetLocationValue.get(); }
String getExtraCompilerFlagsString() const { return extraCompilerFlagsValue.get().toString().replaceCharacters ("\r\n", " "); }
String getExtraLinkerFlagsString() const { return extraLinkerFlagsValue.get().toString().replaceCharacters ("\r\n", " "); }
String getExtraCompilerFlagsString() const { return extraCompilerFlagsValue.get().toString().replaceCharacters ("\r\n", " "); }
String getExtraLinkerFlagsString() const { return extraLinkerFlagsValue.get().toString().replaceCharacters ("\r\n", " "); }
String getExternalLibrariesString() const { return getSearchPathsFromString (externalLibrariesValue.get().toString()).joinIntoString (";"); }
String getExternalLibrariesString() const { return getSearchPathsFromString (externalLibrariesValue.get().toString()).joinIntoString (";"); }
bool shouldUseGNUExtensions() const { return gnuExtensionsValue.get();}
bool shouldUseGNUExtensions() const { return gnuExtensionsValue.get();}
Value getVST3PathValue() const { return vst3Path; }
Value getRTASPathValue() const { return rtasPath; }
Value getAAXPathValue() const { return aaxPath; }
Value getVST3PathValue() const { return vst3Path; }
Value getRTASPathValue() const { return rtasPath; }
Value getAAXPathValue() const { return aaxPath; }
// NB: this is the path to the parent "modules" folder that contains the named module, not the
// module folder itself.
@@ -378,15 +378,8 @@ protected:
static String getDefaultBuildsRootFolder() { return "Builds/"; }
static String getStaticLibbedFilename (String name)
{
return addSuffix (addLibPrefix (name), ".a");
}
static String getDynamicLibbedFilename (String name)
{
return addSuffix (addLibPrefix (name), ".so");
}
static String getStaticLibbedFilename (String name) { return addSuffix (addLibPrefix (name), ".a"); }
static String getDynamicLibbedFilename (String name) { return addSuffix (addLibPrefix (name), ".so"); }
virtual void addPlatformSpecificSettingsForProjectType (const ProjectType&) = 0;


+ 2
- 3
extras/Projucer/Source/ProjectSaving/jucer_ProjectSaver.cpp View File

@@ -34,8 +34,7 @@ namespace
{
inline int countMaxPluginChannels (const String& configString, bool isInput)
{
StringArray configs;
configs.addTokens (configString, ", {}", StringRef());
auto configs = StringArray::fromTokens (configString, ", {}", {});
configs.trim();
configs.removeEmptyStrings();
jassert ((configs.size() & 1) == 0); // looks like a syntax error in the configs?
@@ -156,7 +155,7 @@ void ProjectSaver::writeProjects (const OwnedArray<LibraryModule>& modules, cons
ThreadPool threadPool;
// keep a copy of the basic generated files group, as each exporter may modify it.
const ValueTree originalGeneratedGroup (generatedFilesGroup.state.createCopy());
auto originalGeneratedGroup = generatedFilesGroup.state.createCopy();
CLionProjectExporter* clionExporter = nullptr;
OwnedArray<ProjectExporter> exporters;


+ 23
- 24
extras/Projucer/Source/ProjectSaving/jucer_ProjectSaver.h View File

@@ -38,8 +38,7 @@ public:
: project (p),
projectFile (file),
generatedCodeFolder (project.getGeneratedCodeFolder()),
generatedFilesGroup (Project::Item::createGroup (project, getJuceCodeGroupName(), "__generatedcode__", true)),
hasBinaryData (false)
generatedFilesGroup (Project::Item::createGroup (project, getJuceCodeGroupName(), "__generatedcode__", true))
{
generatedFilesGroup.setID (getGeneratedGroupID());
}
@@ -49,7 +48,7 @@ public:
public:
SaveThread (ProjectSaver& ps, bool wait, const String& exp)
: ThreadWithProgressWindow ("Saving...", true, false),
saver (ps), result (Result::ok()),
saver (ps),
shouldWaitAfterSaving (wait),
specifiedExporterToSave (exp)
{}
@@ -61,7 +60,7 @@ public:
}
ProjectSaver& saver;
Result result;
Result result = Result::ok();
bool shouldWaitAfterSaving;
String specifiedExporterToSave;
@@ -77,9 +76,9 @@ public:
return thread.result;
}
const String appConfigUserContent (loadUserContentFromAppConfig());
auto appConfigUserContent = loadUserContentFromAppConfig();
const File oldFile (project.getFile());
auto oldFile = project.getFile();
project.setFile (projectFile);
OwnedArray<LibraryModule> modules;
@@ -138,17 +137,17 @@ public:
return Project::Item (project, ValueTree(), false);
}
const File file (generatedCodeFolder.getChildFile (filePath));
auto file = generatedCodeFolder.getChildFile (filePath);
if (replaceFileIfDifferent (file, newData))
return addFileToGeneratedGroup (file);
return Project::Item (project, ValueTree(), true);
return { project, {}, true };
}
Project::Item addFileToGeneratedGroup (const File& file)
{
Project::Item item (generatedFilesGroup.findItemForFile (file));
auto item = generatedFilesGroup.findItemForFile (file);
if (item.isValid())
return item;
@@ -230,7 +229,7 @@ private:
CriticalSection errorLock;
File appConfigFile;
bool hasBinaryData;
bool hasBinaryData = false;
// Recursively clears out any files in a folder that we didn't create, but avoids
// any folders containing hidden files that might be used by version-control systems.
@@ -243,7 +242,7 @@ private:
bool isFolder;
while (i.next (&isFolder, nullptr, nullptr, nullptr, nullptr, nullptr))
{
const File f (i.getFile());
auto f = i.getFile();
if (filesCreated.contains (f) || shouldFileBeKept (f.getFileName()))
{
@@ -306,10 +305,10 @@ private:
String loadUserContentFromAppConfig() const
{
StringArray lines, userContent;
lines.addLines (getAppConfigFile().loadFileAsString());
StringArray userContent;
bool foundCodeSection = false;
auto lines = StringArray::fromLines (getAppConfigFile().loadFileAsString());
for (int i = 0; i < lines.size(); ++i)
{
if (lines[i].contains ("[BEGIN_USER_CODE_SECTION]"))
@@ -324,9 +323,9 @@ private:
if (! foundCodeSection)
{
userContent.add (String());
userContent.add ({});
userContent.add ("// (You can add your own code in this section, and the Projucer will not overwrite it)");
userContent.add (String());
userContent.add ({});
}
return userContent.joinIntoString (newLine) + newLine;
@@ -343,7 +342,7 @@ private:
for (LibraryModule** moduleIter = modules.begin(); moduleIter != modules.end(); ++moduleIter)
{
if (const LibraryModule* const module = *moduleIter)
if (auto* module = *moduleIter)
{
if (! module->isValid())
{
@@ -417,11 +416,11 @@ private:
out << newLine
<< "//==============================================================================" << newLine;
const int longestName = findLongestModuleName (modules);
auto longestName = findLongestModuleName (modules);
for (int k = 0; k < modules.size(); ++k)
{
LibraryModule* const m = modules.getUnchecked(k);
auto* m = modules.getUnchecked(k);
out << "#define JUCE_MODULE_AVAILABLE_" << m->getID()
<< String::repeatedString (" ", longestName + 5 - m->getID().length()) << " 1" << newLine;
}
@@ -430,7 +429,7 @@ private:
for (int j = 0; j < modules.size(); ++j)
{
LibraryModule* const m = modules.getUnchecked(j);
auto* m = modules.getUnchecked(j);
OwnedArray<Project::ConfigFlag> flags;
m->getConfigFlags (project, flags);
@@ -455,7 +454,7 @@ private:
{
int isStandaloneApplication = 1;
const ProjectType& type = project.getProjectType();
auto& type = project.getProjectType();
if (type.isAudioPlugin() || type.isDynamicLibrary())
isStandaloneApplication = 0;
@@ -563,7 +562,7 @@ private:
void writeBinaryDataFiles()
{
const File binaryDataH (project.getBinaryDataHeaderFile());
auto binaryDataH = project.getBinaryDataHeaderFile();
ResourceFile resourceFile (project);
@@ -577,11 +576,11 @@ private:
Array<File> binaryDataFiles;
int maxSize = project.getMaxBinaryFileSize();
auto maxSize = project.getMaxBinaryFileSize();
if (maxSize <= 0)
maxSize = 10 * 1024 * 1024;
Result r (resourceFile.write (binaryDataFiles, maxSize));
auto r = resourceFile.write (binaryDataFiles, maxSize);
if (r.wasOk())
{
@@ -589,7 +588,7 @@ private:
for (int i = 0; i < binaryDataFiles.size(); ++i)
{
const File& f = binaryDataFiles.getReference(i);
auto& f = binaryDataFiles.getReference(i);
filesCreated.add (f);
generatedFilesGroup.addFileRetainingSortOrder (f, ! f.hasFileExtension (".h"));


+ 17
- 19
extras/Projucer/Source/ProjectSaving/jucer_ResourceFile.cpp View File

@@ -30,9 +30,7 @@
static const char* resourceFileIdentifierString = "JUCER_BINARY_RESOURCE";
//==============================================================================
ResourceFile::ResourceFile (Project& p)
: project (p),
className ("BinaryData")
ResourceFile::ResourceFile (Project& p) : project (p)
{
addResourcesFromProjectItem (project.getMainGroup());
}
@@ -66,8 +64,8 @@ void ResourceFile::addFile (const File& file)
{
files.add (file);
const String variableNameRoot (CodeHelpers::makeBinaryDataIdentifierName (file));
String variableName (variableNameRoot);
auto variableNameRoot = CodeHelpers::makeBinaryDataIdentifierName (file);
auto variableName = variableNameRoot;
int suffix = 2;
while (variableNames.contains (variableName))
@@ -123,14 +121,14 @@ Result ResourceFile::writeHeader (MemoryOutputStream& header)
for (int i = 0; i < files.size(); ++i)
{
const File& file = files.getReference(i);
auto& file = files.getReference(i);
if (! file.existsAsFile())
return Result::fail ("Can't open resource file: " + file.getFullPathName());
const int64 dataSize = file.getSize();
auto dataSize = file.getSize();
const String variableName (variableNames[i]);
auto variableName = variableNames[i];
FileInputStream fileStream (file);
@@ -160,7 +158,7 @@ Result ResourceFile::writeHeader (MemoryOutputStream& header)
Result ResourceFile::writeCpp (MemoryOutputStream& cpp, const File& headerFile, int& i, const int maxFileSize)
{
const bool isFirstFile = (i == 0);
bool isFirstFile = (i == 0);
cpp << "/* ==================================== " << resourceFileIdentifierString << " ===================================="
<< getComment()
@@ -171,8 +169,8 @@ Result ResourceFile::writeCpp (MemoryOutputStream& cpp, const File& headerFile,
while (i < files.size())
{
const File& file = files.getReference(i);
const String variableName (variableNames[i]);
auto& file = files.getReference(i);
auto variableName = variableNames[i];
FileInputStream fileStream (file);
@@ -181,10 +179,10 @@ Result ResourceFile::writeCpp (MemoryOutputStream& cpp, const File& headerFile,
containsAnyImages = containsAnyImages
|| (ImageFileFormat::findImageFormatForStream (fileStream) != nullptr);
const String tempVariable ("temp_binary_data_" + String (i));
auto tempVariable = "temp_binary_data_" + String (i);
cpp << newLine << "//================== " << file.getFileName() << " ==================" << newLine
<< "static const unsigned char " << tempVariable << "[] =" << newLine;
<< "static const unsigned char " << tempVariable << "[] =" << newLine;
{
MemoryBlock data;
@@ -224,8 +222,8 @@ Result ResourceFile::writeCpp (MemoryOutputStream& cpp, const File& headerFile,
StringArray returnCodes;
for (int j = 0; j < files.size(); ++j)
{
const File& file = files.getReference(j);
const int64 dataSize = file.getSize();
auto& file = files.getReference(j);
auto dataSize = file.getSize();
returnCodes.add ("numBytes = " + String (dataSize) + "; return " + variableNames[j] + ";");
}
@@ -252,11 +250,11 @@ Result ResourceFile::writeCpp (MemoryOutputStream& cpp, const File& headerFile,
Result ResourceFile::write (Array<File>& filesCreated, const int maxFileSize)
{
const File headerFile (project.getBinaryDataHeaderFile());
auto headerFile = project.getBinaryDataHeaderFile();
{
MemoryOutputStream mo;
Result r (writeHeader (mo));
auto r = writeHeader (mo);
if (r.failed())
return r;
@@ -272,11 +270,11 @@ Result ResourceFile::write (Array<File>& filesCreated, const int maxFileSize)
for (;;)
{
File cpp (project.getBinaryDataCppFile (fileIndex));
auto cpp = project.getBinaryDataCppFile (fileIndex);
MemoryOutputStream mo;
Result r (writeCpp (mo, headerFile, i, maxFileSize));
auto r = writeCpp (mo, headerFile, i, maxFileSize);
if (r.failed())
return r;


+ 1
- 1
extras/Projucer/Source/ProjectSaving/jucer_ResourceFile.h View File

@@ -56,7 +56,7 @@ private:
Array<File> files;
StringArray variableNames;
Project& project;
String className;
String className { "BinaryData" };
Result writeHeader (MemoryOutputStream&);
Result writeCpp (MemoryOutputStream&, const File& headerFile, int& index, int maxFileSize);


Loading…
Cancel
Save