From 0c142b51b549ac6d6eff75cdd594967fb11a54f6 Mon Sep 17 00:00:00 2001 From: jules Date: Sat, 23 Jun 2012 13:54:38 +0100 Subject: [PATCH] Introjucer: avoided clang warning in generated binary data code. --- .../Project Saving/jucer_ProjectExporter.cpp | 14 ++------------ extras/Introjucer/Source/Project/jucer_Project.cpp | 10 +--------- .../Source/Utility/jucer_CodeHelpers.cpp | 10 +++++----- .../Source/Utility/jucer_MiscUtilities.cpp | 10 ++++++++++ .../Source/Utility/jucer_MiscUtilities.h | 2 ++ 5 files changed, 20 insertions(+), 26 deletions(-) diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.cpp b/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.cpp index cf0560b290..642199ee88 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.cpp +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.cpp @@ -521,22 +521,12 @@ StringPairArray ProjectExporter::BuildConfiguration::getAllPreprocessorDefs() co StringArray ProjectExporter::BuildConfiguration::getHeaderSearchPaths() const { - StringArray s; - s.addTokens (getHeaderSearchPathString(), ";", String::empty); - s.trim(); - s.removeEmptyStrings(); - s.removeDuplicates (false); - return s; + return getSearchPathsFromString (getHeaderSearchPathString()); } StringArray ProjectExporter::BuildConfiguration::getLibrarySearchPaths() const { - StringArray s; - s.addTokens (getLibrarySearchPathString(), ";", String::empty); - s.trim(); - s.removeEmptyStrings(); - s.removeDuplicates (false); - return s; + return getSearchPathsFromString (getLibrarySearchPathString()); } String ProjectExporter::BuildConfiguration::getGCCLibraryPathFlags() const diff --git a/extras/Introjucer/Source/Project/jucer_Project.cpp b/extras/Introjucer/Source/Project/jucer_Project.cpp index 0ebd2b99e0..e6de787c9d 100644 --- a/extras/Introjucer/Source/Project/jucer_Project.cpp +++ b/extras/Introjucer/Source/Project/jucer_Project.cpp @@ -901,15 +901,7 @@ String Project::getModuleID (int index) const //============================================================================== ValueTree Project::getExporters() { - ValueTree exporters (projectRoot.getChildWithName (Tags::exporters)); - - if (! exporters.isValid()) - { - projectRoot.addChild (ValueTree (Tags::exporters), 0, getUndoManagerFor (projectRoot)); - exporters = getExporters(); - } - - return exporters; + return projectRoot.getOrCreateChildWithName (Tags::exporters, nullptr); } int Project::getNumExporters() diff --git a/extras/Introjucer/Source/Utility/jucer_CodeHelpers.cpp b/extras/Introjucer/Source/Utility/jucer_CodeHelpers.cpp index b3e13c1610..c849394b34 100644 --- a/extras/Introjucer/Source/Utility/jucer_CodeHelpers.cpp +++ b/extras/Introjucer/Source/Utility/jucer_CodeHelpers.cpp @@ -339,10 +339,10 @@ namespace CodeHelpers } //============================================================================== - static int calculateHash (const String& s, const int hashMultiplier) + static unsigned int calculateHash (const String& s, const int hashMultiplier) { const char* t = s.toUTF8(); - int hash = 0; + unsigned int hash = 0; while (*t != 0) hash = hashMultiplier * hash + *t++; @@ -360,11 +360,11 @@ namespace CodeHelpers for (;;) { - SortedSet hashes; + SortedSet hashes; bool collision = false; for (int i = allStrings.size(); --i >= 0;) { - const int hash = calculateHash (allStrings[i], v); + const unsigned int hash = calculateHash (allStrings[i], v); if (hashes.contains (hash)) { collision = true; @@ -390,7 +390,7 @@ namespace CodeHelpers const String indent (String::repeatedString (" ", indentLevel)); const int hashMultiplier = findBestHashMultiplier (strings); - out << indent << "int hash = 0;" << newLine + out << indent << "unsigned int hash = 0;" << newLine << indent << "if (" << utf8PointerVariable << " != 0)" << newLine << indent << " while (*" << utf8PointerVariable << " != 0)" << newLine << indent << " hash = " << hashMultiplier << " * hash + *" << utf8PointerVariable << "++;" << newLine diff --git a/extras/Introjucer/Source/Utility/jucer_MiscUtilities.cpp b/extras/Introjucer/Source/Utility/jucer_MiscUtilities.cpp index e95e45ff20..109bff3832 100644 --- a/extras/Introjucer/Source/Utility/jucer_MiscUtilities.cpp +++ b/extras/Introjucer/Source/Utility/jucer_MiscUtilities.cpp @@ -162,6 +162,16 @@ String replacePreprocessorDefs (const StringPairArray& definitions, String sourc return sourceString; } +StringArray getSearchPathsFromString (const String& searchPath) +{ + StringArray s; + s.addTokens (searchPath, ";", String::empty); + s.trim(); + s.removeEmptyStrings(); + s.removeDuplicates (false); + return s; +} + //============================================================================== void autoScrollForMouseEvent (const MouseEvent& e, bool scrollX, bool scrollY) { diff --git a/extras/Introjucer/Source/Utility/jucer_MiscUtilities.h b/extras/Introjucer/Source/Utility/jucer_MiscUtilities.h index 0f73adf127..73b9645de2 100644 --- a/extras/Introjucer/Source/Utility/jucer_MiscUtilities.h +++ b/extras/Introjucer/Source/Utility/jucer_MiscUtilities.h @@ -37,6 +37,8 @@ StringPairArray mergePreprocessorDefs (StringPairArray inheritedDefs, const Stri String createGCCPreprocessorFlags (const StringPairArray& defs); String replacePreprocessorDefs (const StringPairArray& definitions, String sourceString); +StringArray getSearchPathsFromString (const String& searchPath); + void setValueIfVoid (Value value, const var& defaultValue); //==============================================================================