From d7108bb5ba5e9989099af1ff0a449d646798436b Mon Sep 17 00:00:00 2001 From: Julian Storer Date: Wed, 17 Mar 2010 14:46:03 +0000 Subject: [PATCH] Jucer VC6 support + misc VC6 compatibility hacks. --- .../JuceLibraryCode/BinaryData.cpp | 8 +- .../JuceLibraryCode/BinaryData.h | 2 +- .../Source/model/jucer_Project.cpp | 6 +- .../Source/model/jucer_ProjectExport_MSVC.h | 287 ++++++- .../Source/model/jucer_ProjectExport_Make.h | 9 +- .../Source/model/jucer_ProjectExport_XCode.h | 5 +- .../Source/model/jucer_ProjectExporter.cpp | 10 +- .../Source/model/jucer_ProjectExporter.h | 6 +- .../Source/model/jucer_ProjectSaver.h | 7 +- .../Source/model/jucer_ResourceFile.cpp | 22 +- .../ui/Drawable Editor/jucer_DrawableEditor.h | 1 + .../jucer_DrawableObjectComponent.h | 7 +- .../ui/jucer_ProjectInformationComponent.cpp | 2 +- .../Source/ui/jucer_ProjectTreeViewBase.cpp | 2 +- .../Source/utility/jucer_UtilityFunctions.cpp | 3 +- juce_amalgamated.cpp | 808 ++++++++++-------- juce_amalgamated.h | 217 ++--- src/containers/juce_Value.cpp | 4 + src/containers/juce_Value.h | 3 + src/containers/juce_ValueTree.h | 4 +- .../special/juce_OpenGLComponent.cpp | 47 +- .../components/special/juce_OpenGLComponent.h | 8 +- src/text/juce_String.cpp | 17 +- src/utilities/juce_PropertiesFile.cpp | 2 +- src/utilities/juce_PropertiesFile.h | 2 +- 25 files changed, 966 insertions(+), 523 deletions(-) diff --git a/extras/Jucer (experimental)/JuceLibraryCode/BinaryData.cpp b/extras/Jucer (experimental)/JuceLibraryCode/BinaryData.cpp index 7e44b6cab1..27d750d033 100644 --- a/extras/Jucer (experimental)/JuceLibraryCode/BinaryData.cpp +++ b/extras/Jucer (experimental)/JuceLibraryCode/BinaryData.cpp @@ -8,12 +8,12 @@ #include "BinaryData.h" -const char* BinaryData::getNamedResource (const wchar_t* resourceName, int& numBytes) throw() +const char* BinaryData::getNamedResource (const char* resourceNameUTF8, int& numBytes) throw() { int hash = 0; - if (resourceName != 0) - while (*resourceName != 0) - hash = 31 * hash + *resourceName++; + if (resourceNameUTF8 != 0) + while (*resourceNameUTF8 != 0) + hash = 31 * hash + *resourceNameUTF8++; switch (hash) { diff --git a/extras/Jucer (experimental)/JuceLibraryCode/BinaryData.h b/extras/Jucer (experimental)/JuceLibraryCode/BinaryData.h index ae8e4274c8..31473f6a02 100644 --- a/extras/Jucer (experimental)/JuceLibraryCode/BinaryData.h +++ b/extras/Jucer (experimental)/JuceLibraryCode/BinaryData.h @@ -45,5 +45,5 @@ namespace BinaryData // If you provide the name of one of the binary resource variables above, this function will // return the corresponding data and its size (or a null pointer if the name isn't found). - const char* getNamedResource (const wchar_t* resourceName, int& dataSizeInBytes) throw(); + const char* getNamedResource (const char* resourceNameUTF8, int& dataSizeInBytes) throw(); } diff --git a/extras/Jucer (experimental)/Source/model/jucer_Project.cpp b/extras/Jucer (experimental)/Source/model/jucer_Project.cpp index f9ba8d8bd6..f099ef12eb 100644 --- a/extras/Jucer (experimental)/Source/model/jucer_Project.cpp +++ b/extras/Jucer (experimental)/Source/model/jucer_Project.cpp @@ -845,7 +845,7 @@ void Project::BuildConfiguration::createPropertyEditors (Array setAttribute ("AdditionalIncludeDirectories", getHeaderSearchPaths (config).joinIntoString (";")); - compiler->setAttribute ("PreprocessorDefinitions", getPreprocessorDefs (config)); + compiler->setAttribute ("PreprocessorDefinitions", getPreprocessorDefs (config, ";")); compiler->setAttribute ("RuntimeLibrary", isRTAS() ? (isDebug ? 3 : 2) // MT DLL : (isDebug ? 1 : 0)); // MT static compiler->setAttribute ("RuntimeTypeInfo", "true"); @@ -559,12 +589,13 @@ private: } out << newLine << "Project(\"" << createGUID (project.getProjectName().toString() + "sln_guid") << "\") = \"" << project.getProjectName().toString() << "\", \"" - << getVCProjFile().getFileName() << "\", \"" << projectGUID << "\"" << newLine + << getVCProjFile().getFileName() << "\", \"" << projectGUID << '"' << newLine << "EndProject" << newLine << "Global" << newLine << "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution" << newLine; - for (int i = 0; i < project.getNumConfigurations(); ++i) + int i; + for (i = 0; i < project.getNumConfigurations(); ++i) { Project::BuildConfiguration config (project.getConfiguration (i)); out << "\t\t" << createConfigName (config) << " = " << createConfigName (config) << newLine; @@ -573,7 +604,7 @@ private: out << "\tEndGlobalSection" << newLine << "\tGlobalSection(ProjectConfigurationPlatforms) = postSolution" << newLine; - for (int i = 0; i < project.getNumConfigurations(); ++i) + for (i = 0; i < project.getNumConfigurations(); ++i) { Project::BuildConfiguration config (project.getConfiguration (i)); out << "\t\t" << projectGUID << "." << createConfigName (config) << ".ActiveCfg = " << createConfigName (config) << newLine; @@ -586,6 +617,216 @@ private: << "\tEndGlobalSection" << newLine << "EndGlobal" << newLine; } + + //============================================================================== + const String createConfigNameVC6 (const Project::BuildConfiguration& config) const + { + return project.getProjectName().toString() + " - Win32 " + config.getName().toString(); + } + + void writeVC6Project (OutputStream& out) + { + String defaultConfig (createConfigNameVC6 (project.getConfiguration (0))); + + const bool isDLL = project.isAudioPlugin() || project.isBrowserPlugin(); + String targetType, targetCode; + + if (isDLL) { targetType = "\"Win32 (x86) Dynamic-Link Library\""; targetCode = "0x0102"; } + else if (project.isLibrary()) { targetType = "\"Win32 (x86) Static Library\""; targetCode = "0x0104"; } + else if (project.isCommandLineApp()) { targetType = "\"Win32 (x86) Console Application\""; targetCode = "0x0103"; } + else { targetType = "\"Win32 (x86) Application\""; targetCode = "0x0101"; } + + out << "# Microsoft Developer Studio Project File - Name=\"" << project.getProjectName() + << "\" - Package Owner=<4>" << newLine + << "# Microsoft Developer Studio Generated Build File, Format Version 6.00" << newLine + << "# ** DO NOT EDIT **" << newLine + << "# TARGTYPE " << targetType << " " << targetCode << newLine + << "CFG=" << defaultConfig << newLine + << "!MESSAGE This is not a valid makefile. To build this project using NMAKE," << newLine + << "!MESSAGE use the Export Makefile command and run" << newLine + << "!MESSAGE " << newLine + << "!MESSAGE NMAKE /f \"" << project.getProjectName() << ".mak.\"" << newLine + << "!MESSAGE " << newLine + << "!MESSAGE You can specify a configuration when running NMAKE" << newLine + << "!MESSAGE by defining the macro CFG on the command line. For example:" << newLine + << "!MESSAGE " << newLine + << "!MESSAGE NMAKE /f \"" << project.getProjectName() << ".mak\" CFG=\"" << defaultConfig << '"' << newLine + << "!MESSAGE " << newLine + << "!MESSAGE Possible choices for configuration are:" << newLine + << "!MESSAGE " << newLine; + + int i; + for (i = 0; i < project.getNumConfigurations(); ++i) + out << "!MESSAGE \"" << createConfigNameVC6 (project.getConfiguration (i)) << "\" (based on " << targetType << ")" << newLine; + + out << "!MESSAGE " << newLine + << "# Begin Project" << newLine + << "# PROP AllowPerConfigDependencies 0" << newLine + << "# PROP Scc_ProjName \"\"" << newLine + << "# PROP Scc_LocalPath \"\"" << newLine + << "CPP=cl.exe" << newLine + << "MTL=midl.exe" << newLine + << "RSC=rc.exe" << newLine; + + String targetList; + + for (i = 0; i < project.getNumConfigurations(); ++i) + { + const Project::BuildConfiguration config (project.getConfiguration (i)); + const String configName (createConfigNameVC6 (config)); + targetList << "# Name \"" << configName << '"' << newLine; + + const String outFile (windowsStylePath (getConfigTargetPath(config) + "/" + config.getTargetBinaryName().toString() + getTargetBinarySuffix())); + const String optimisationFlag (((int) config.getOptimisationLevel().getValue() <= 1) ? "Od" : (config.getOptimisationLevel() == 2 ? "O2" : "O3")); + const String defines (getPreprocessorDefs (config, " /D ")); + const bool isDebug = (bool) config.isDebug().getValue(); + const String extraDebugFlags (isDebug ? "/Gm /ZI /GZ" : ""); + const String includes (getHeaderSearchPaths (config).joinIntoString (" /I ")); + + out << (i == 0 ? "!IF" : "!ELSEIF") << " \"$(CFG)\" == \"" << configName << '"' << newLine + << "# PROP BASE Use_MFC 0" << newLine + << "# PROP BASE Use_Debug_Libraries " << (isDebug ? "1" : "0") << newLine + << "# PROP BASE Output_Dir \"" << getConfigTargetPath (config) << '"' << newLine + << "# PROP BASE Intermediate_Dir \"" << getIntermediatesPath (config) << '"' << newLine + << "# PROP BASE Target_Dir \"\"" << newLine + << "# PROP Use_MFC 0" << newLine + << "# PROP Use_Debug_Libraries " << (isDebug ? "1" : "0") << newLine + << "# PROP Output_Dir \"" << getConfigTargetPath (config) << '"' << newLine + << "# PROP Intermediate_Dir \"" << getIntermediatesPath (config) << '"' << newLine + << "# PROP Ignore_Export_Lib 0" << newLine + << "# PROP Target_Dir \"\"" << newLine + << "# ADD BASE CPP /nologo /W3 /GX /" << optimisationFlag << " /D " << defines + << " /YX /FD /c " << extraDebugFlags << " /Zm1024" << newLine + << "# ADD CPP /nologo " << (isDebug ? "/MTd" : "/MT") << " /W3 /GR /GX /" << optimisationFlag + << " /I " << includes << " /D " << defines << " /D \"_UNICODE\" /D \"UNICODE\" /FD /c " << extraDebugFlags << " /Zm1024" << newLine; + + if (! isDebug) + out << "# SUBTRACT CPP /YX" << newLine; + + if (! project.isLibrary()) + out << "# ADD BASE MTL /nologo /D " << defines << " /mktyplib203 /win32" << newLine + << "# ADD MTL /nologo /D " << defines << " /mktyplib203 /win32" << newLine; + + out << "# ADD BASE RSC /l 0x40c /d " << defines << newLine + << "# ADD RSC /l 0x40c /d " << defines << newLine + << "BSC32=bscmake.exe" << newLine + << "# ADD BASE BSC32 /nologo" << newLine + << "# ADD BSC32 /nologo" << newLine; + + if (project.isLibrary()) + { + out << "LIB32=link.exe -lib" << newLine + << "# ADD BASE LIB32 /nologo" << newLine + << "# ADD LIB32 /nologo /out:\"" << outFile << '"' << newLine; + } + else + { + out << "LINK32=link.exe" << newLine + << "# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386" << newLine + << "# ADD LINK32 \"C:\\Program Files\\Microsoft Visual Studio\\VC98\\LIB\\shell32.lib\" " // This is avoid debug information corruption when mixing Platform SDK + << "kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib " + << (isDebug ? " /debug" : "") + << " /nologo /machine:I386 /out:\"" << outFile << "\" " + << (isDLL ? "/dll" : (project.isCommandLineApp() ? "/subsystem:console" + : "/subsystem:windows")) << newLine; + } + } + + out << "!ENDIF" << newLine + << "# Begin Target" << newLine + << targetList; + + writeFilesVC6 (out, project.getMainGroup()); + writeGroupVC6 (out, project.getJuceCodeGroupName(), juceWrapperFiles); + writeGroupVC6 (out, "Juce VST Wrapper", getVSTFilesRequired()); + + out << "# End Target" << newLine + << "# End Project" << newLine; + } + + void writeFileVC6 (OutputStream& out, const RelativePath& file, const bool excludeFromBuild) + { + jassert (file.getRoot() == RelativePath::buildTargetFolder); + + out << "# Begin Source File" << newLine + << "SOURCE=" << file.toWindowsStyle().quoted() << newLine; + + if (excludeFromBuild) + out << "# PROP Exclude_From_Build 1" << newLine; + + out << "# End Source File" << newLine; + } + + void writeFilesVC6 (OutputStream& out, const Project::Item& projectItem) + { + if (projectItem.isGroup()) + { + out << "# Begin Group \"" << projectItem.getName() << '"' << newLine + << "# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"" << newLine; + + for (int i = 0; i < projectItem.getNumChildren(); ++i) + writeFilesVC6 (out, projectItem.getChild (i)); + + out << "# End Group" << newLine; + } + else if (projectItem.shouldBeAddedToTargetProject()) + { + const RelativePath path (projectItem.getFile(), getTargetFolder(), RelativePath::buildTargetFolder); + writeFileVC6 (out, path, projectItem.shouldBeAddedToBinaryResources() || (shouldFileBeCompiledByDefault (path) && ! projectItem.shouldBeCompiled())); + } + } + + void writeGroupVC6 (OutputStream& out, const String& groupName, const Array& files) + { + if (files.size() > 0) + { + out << "# Begin Group \"" << groupName << '"' << newLine; + for (int i = 0; i < files.size(); ++i) + if (files.getReference(i).hasFileExtension ("cpp;c;h")) + writeFileVC6 (out, files.getReference(i), false); + + out << "# End Group" << newLine; + } + } + + void writeDSWFile (OutputStream& out) + { + out << "Microsoft Developer Studio Workspace File, Format Version 6.00 " << newLine; + + if (! project.isUsingWrapperFiles()) + { + out << "Project: \"JUCE\"= ..\\JUCE.dsp - Package Owner=<4>" << newLine + << "Package=<5>" << newLine + << "{{{" << newLine + << "}}}" << newLine + << "Package=<4>" << newLine + << "{{{" << newLine + << "}}}" << newLine; + } + + out << "Project: \"" << project.getProjectName() << "\" = .\\" << getDSPFile().getFileName() << " - Package Owner=<4>" << newLine + << "Package=<5>" << newLine + << "{{{" << newLine + << "}}}" << newLine + << "Package=<4>" << newLine + << "{{{" << newLine; + + if (! project.isUsingWrapperFiles()) + { + out << " Begin Project Dependency" << newLine + << " Project_Dep_Name JUCE" << newLine + << " End Project Dependency" << newLine; + } + + out << "}}}" << newLine + << "Global:" << newLine + << "Package=<5>" << newLine + << "{{{" << newLine + << "}}}" << newLine + << "Package=<3>" << newLine + << "{{{" << newLine + << "}}}" << newLine; + } }; diff --git a/extras/Jucer (experimental)/Source/model/jucer_ProjectExport_Make.h b/extras/Jucer (experimental)/Source/model/jucer_ProjectExport_Make.h index 67b7e8e82a..03f8f1841b 100644 --- a/extras/Jucer (experimental)/Source/model/jucer_ProjectExport_Make.h +++ b/extras/Jucer (experimental)/Source/model/jucer_ProjectExport_Make.h @@ -263,7 +263,8 @@ private: << "DEPFLAGS := $(if $(word 2, $(TARGET_ARCH)), , -MMD)" << newLine << newLine; - for (int i = 0; i < project.getNumConfigurations(); ++i) + int i; + for (i = 0; i < project.getNumConfigurations(); ++i) writeConfig (out, project.getConfiguration(i)); writeObjects (out, files); @@ -272,7 +273,7 @@ private: << newLine; out << "$(OUTDIR)/$(TARGET): $(OBJECTS) $(LDDEPS) $(RESOURCES)" << newLine - << "\t@echo Linking " << project.getProjectName().toString() << newLine + << "\t@echo Linking " << project.getProjectName() << newLine << "\t-@mkdir -p $(BINDIR)" << newLine << "\t-@mkdir -p $(LIBDIR)" << newLine << "\t-@mkdir -p $(OUTDIR)" << newLine @@ -280,13 +281,13 @@ private: << newLine; out << "clean:" << newLine - << "\t@echo Cleaning " << project.getProjectName().toString() << newLine + << "\t@echo Cleaning " << project.getProjectName() << newLine << "\t-@rm -f $(OUTDIR)/$(TARGET)" << newLine << "\t-@rm -rf $(OBJDIR)/*" << newLine << "\t-@rm -rf $(OBJDIR)" << newLine << newLine; - for (int i = 0; i < files.size(); ++i) + for (i = 0; i < files.size(); ++i) { if (shouldFileBeCompiledByDefault (files.getReference(i))) { diff --git a/extras/Jucer (experimental)/Source/model/jucer_ProjectExport_XCode.h b/extras/Jucer (experimental)/Source/model/jucer_ProjectExport_XCode.h index 1054193643..0e7fd59abc 100644 --- a/extras/Jucer (experimental)/Source/model/jucer_ProjectExport_XCode.h +++ b/extras/Jucer (experimental)/Source/model/jucer_ProjectExport_XCode.h @@ -919,8 +919,8 @@ private: const char* files[] = { "extras/audio plugins/wrapper/AU/juce_AU_Resources.r", "extras/audio plugins/wrapper/AU/juce_AU_Wrapper.mm" }; - - for (int i = 0; i < numElementsInArray (files); ++i) + int i; + for (i = 0; i < numElementsInArray (files); ++i) auWrappers.add (getJucePathFromTargetFolder().getChildFile (files[i])); const char* appleAUFiles[] = { "Extras/CoreAudio/PublicUtility/CADebugMacros.h", @@ -976,7 +976,6 @@ private: StringArray fileIDs, appleFileIDs; - int i; for (i = 0; i < auWrappers.size(); ++i) { addFile (auWrappers.getReference(i), shouldFileBeCompiledByDefault (auWrappers.getReference(i)), false); diff --git a/extras/Jucer (experimental)/Source/model/jucer_ProjectExporter.cpp b/extras/Jucer (experimental)/Source/model/jucer_ProjectExporter.cpp index b0b01f753f..1570f4406b 100644 --- a/extras/Jucer (experimental)/Source/model/jucer_ProjectExporter.cpp +++ b/extras/Jucer (experimental)/Source/model/jucer_ProjectExporter.cpp @@ -42,7 +42,7 @@ ProjectExporter::~ProjectExporter() //============================================================================== int ProjectExporter::getNumExporters() { - return 5; + return 6; } const StringArray ProjectExporter::getExporterNames() @@ -50,6 +50,7 @@ const StringArray ProjectExporter::getExporterNames() StringArray s; s.add (XCodeProjectExporter::getNameMac()); s.add (XCodeProjectExporter::getNameiPhone()); + s.add (MSVCProjectExporter::getNameVC6()); s.add (MSVCProjectExporter::getName2005()); s.add (MSVCProjectExporter::getName2008()); s.add (MakefileProjectExporter::getNameLinux()); @@ -64,9 +65,10 @@ ProjectExporter* ProjectExporter::createNewExporter (Project& project, const int { case 0: exp = new XCodeProjectExporter (project, ValueTree (XCodeProjectExporter::getValueTreeTypeName (false)), false); break; case 1: exp = new XCodeProjectExporter (project, ValueTree (XCodeProjectExporter::getValueTreeTypeName (true)), true); break; - case 2: exp = new MSVCProjectExporter (project, ValueTree (MSVCProjectExporter::getValueTreeTypeName (MSVCProjectExporter::visualStudio2005)), MSVCProjectExporter::visualStudio2005); break; - case 3: exp = new MSVCProjectExporter (project, ValueTree (MSVCProjectExporter::getValueTreeTypeName (MSVCProjectExporter::visualStudio2008)), MSVCProjectExporter::visualStudio2008); break; - case 4: exp = new MakefileProjectExporter (project, ValueTree (MakefileProjectExporter::getValueTreeTypeName())); break; + case 2: exp = new MSVCProjectExporter (project, ValueTree (MSVCProjectExporter::getValueTreeTypeName (MSVCProjectExporter::visualStudio6)), MSVCProjectExporter::visualStudio6); break; + case 3: exp = new MSVCProjectExporter (project, ValueTree (MSVCProjectExporter::getValueTreeTypeName (MSVCProjectExporter::visualStudio2005)), MSVCProjectExporter::visualStudio2005); break; + case 4: exp = new MSVCProjectExporter (project, ValueTree (MSVCProjectExporter::getValueTreeTypeName (MSVCProjectExporter::visualStudio2008)), MSVCProjectExporter::visualStudio2008); break; + case 5: exp = new MakefileProjectExporter (project, ValueTree (MakefileProjectExporter::getValueTreeTypeName())); break; default: jassertfalse; return 0; } diff --git a/extras/Jucer (experimental)/Source/model/jucer_ProjectExporter.h b/extras/Jucer (experimental)/Source/model/jucer_ProjectExporter.h index 4af824cb92..d43e65cd80 100644 --- a/extras/Jucer (experimental)/Source/model/jucer_ProjectExporter.h +++ b/extras/Jucer (experimental)/Source/model/jucer_ProjectExporter.h @@ -71,9 +71,9 @@ public: Value getRTASFolder() const { return getSetting ("rtasFolder"); } Value getAUFolder() const { return getSetting ("auFolder"); } - bool isVST() const { return project.isAudioPlugin() && project.shouldBuildVST().getValue(); } - bool isRTAS() const { return project.isAudioPlugin() && project.shouldBuildRTAS().getValue(); } - bool isAU() const { return project.isAudioPlugin() && project.shouldBuildAU().getValue(); } + bool isVST() const { return (bool) project.isAudioPlugin() && (bool) project.shouldBuildVST().getValue(); } + bool isRTAS() const { return (bool) project.isAudioPlugin() && (bool) project.shouldBuildRTAS().getValue(); } + bool isAU() const { return (bool) project.isAudioPlugin() && (bool) project.shouldBuildAU().getValue(); } Array juceWrapperFiles; diff --git a/extras/Jucer (experimental)/Source/model/jucer_ProjectSaver.h b/extras/Jucer (experimental)/Source/model/jucer_ProjectSaver.h index 815d0de033..514c260fbc 100644 --- a/extras/Jucer (experimental)/Source/model/jucer_ProjectSaver.h +++ b/extras/Jucer (experimental)/Source/model/jucer_ProjectSaver.h @@ -270,7 +270,8 @@ private: } else { - for (int i = paths.size(); --i >= 0;) + int i = paths.size(); + for (; --i >= 0;) { for (int j = i; --j >= 0;) { @@ -282,7 +283,7 @@ private: } } - for (int i = 0; i < paths.size(); ++i) + for (i = 0; i < paths.size(); ++i) { out << (i == 0 ? "#if " : "#elif ") << guards[i] << newLine << " #include " << paths[i].quoted() << newLine; @@ -310,7 +311,7 @@ private: static const String createVersionCode (const String& version) { StringArray configs; - configs.addTokens (version, T(",.")); + configs.addTokens (version, T(",."), String::empty); configs.trim(); configs.removeEmptyStrings(); diff --git a/extras/Jucer (experimental)/Source/model/jucer_ResourceFile.cpp b/extras/Jucer (experimental)/Source/model/jucer_ResourceFile.cpp index 891dd3231d..9f6ed76583 100644 --- a/extras/Jucer (experimental)/Source/model/jucer_ResourceFile.cpp +++ b/extras/Jucer (experimental)/Source/model/jucer_ResourceFile.cpp @@ -177,6 +177,16 @@ static void writeCppData (InputStream& in, OutputStream& out) } } +static int calcResourceHashCode (const String& s) +{ + const char* t = s.toUTF8(); + int hash = 0; + while (*t != 0) + hash = 31 * hash + *t++; + + return hash; +} + bool ResourceFile::write (const File& cppFile, OutputStream& cpp, OutputStream& header) { String comment; @@ -216,19 +226,19 @@ bool ResourceFile::write (const File& cppFile, OutputStream& cpp, OutputStream& cpp << createIncludeStatement (cppFile.withFileExtension (".h"), cppFile) << newLine << newLine << newLine - << "const char* " << namespaceName << "::getNamedResource (const wchar_t* resourceName, int& numBytes) throw()" << newLine + << "const char* " << namespaceName << "::getNamedResource (const char* resourceNameUTF8, int& numBytes) throw()" << newLine << "{" << newLine << " int hash = 0;" << newLine - << " if (resourceName != 0)" << newLine - << " while (*resourceName != 0)" << newLine - << " hash = 31 * hash + *resourceName++;" << newLine + << " if (resourceNameUTF8 != 0)" << newLine + << " while (*resourceNameUTF8 != 0)" << newLine + << " hash = 31 * hash + *resourceNameUTF8++;" << newLine << newLine << " switch (hash)" << newLine << " {" << newLine; for (i = 0; i < files.size(); ++i) { - cpp << " case 0x" << hexString8Digits (variableNames[i].hashCode()) + cpp << " case 0x" << hexString8Digits (calcResourceHashCode (variableNames[i])) << ": numBytes = " << namespaceName << "::" << variableNames[i] << "Size; return " << namespaceName << "::" << variableNames[i] << ";" << newLine; } @@ -273,7 +283,7 @@ bool ResourceFile::write (const File& cppFile, OutputStream& cpp, OutputStream& header << " // If you provide the name of one of the binary resource variables above, this function will" << newLine << " // return the corresponding data and its size (or a null pointer if the name isn't found)." << newLine - << " const char* getNamedResource (const wchar_t* resourceName, int& dataSizeInBytes) throw();" << newLine + << " const char* getNamedResource (const char* resourceNameUTF8, int& dataSizeInBytes) throw();" << newLine << "}" << newLine; return true; diff --git a/extras/Jucer (experimental)/Source/ui/Drawable Editor/jucer_DrawableEditor.h b/extras/Jucer (experimental)/Source/ui/Drawable Editor/jucer_DrawableEditor.h index ab72973fe8..5d5b223623 100644 --- a/extras/Jucer (experimental)/Source/ui/Drawable Editor/jucer_DrawableEditor.h +++ b/extras/Jucer (experimental)/Source/ui/Drawable Editor/jucer_DrawableEditor.h @@ -86,6 +86,7 @@ public: juce_UseDebuggingNewOperator private: + friend class Canvas; Project* project; DrawableDocument* drawableDocument; diff --git a/extras/Jucer (experimental)/Source/ui/Drawable Editor/jucer_DrawableObjectComponent.h b/extras/Jucer (experimental)/Source/ui/Drawable Editor/jucer_DrawableObjectComponent.h index fe3ed5ea8c..07aff4124e 100644 --- a/extras/Jucer (experimental)/Source/ui/Drawable Editor/jucer_DrawableObjectComponent.h +++ b/extras/Jucer (experimental)/Source/ui/Drawable Editor/jucer_DrawableObjectComponent.h @@ -246,7 +246,8 @@ public: deleteAllChildren(); Rectangle childBounds; - for (int i = 0; i < dc->getNumDrawables(); ++i) + int i; + for (i = 0; i < dc->getNumDrawables(); ++i) { Drawable* d = dc->getDrawable (i); jassert (d != 0); @@ -271,12 +272,12 @@ public: } } - for (int i = dc->getNumDrawables(); --i >= 0;) + for (i = dc->getNumDrawables(); --i >= 0;) dc->removeDrawable (i, false); setBounds (childBounds); - for (int i = getNumChildComponents(); --i >= 0;) + for (i = getNumChildComponents(); --i >= 0;) { DrawableObjectComponent* dc = dynamic_cast (getChildComponent (i)); diff --git a/extras/Jucer (experimental)/Source/ui/jucer_ProjectInformationComponent.cpp b/extras/Jucer (experimental)/Source/ui/jucer_ProjectInformationComponent.cpp index 787cb0a209..7e7089be3f 100644 --- a/extras/Jucer (experimental)/Source/ui/jucer_ProjectInformationComponent.cpp +++ b/extras/Jucer (experimental)/Source/ui/jucer_ProjectInformationComponent.cpp @@ -147,7 +147,7 @@ private: String lastTip; int tabIndex; - const String findTip (Component* c) const + const String findTip (Component* c) { while (c != 0 && c != this) { diff --git a/extras/Jucer (experimental)/Source/ui/jucer_ProjectTreeViewBase.cpp b/extras/Jucer (experimental)/Source/ui/jucer_ProjectTreeViewBase.cpp index 4e49736d49..21600eba47 100644 --- a/extras/Jucer (experimental)/Source/ui/jucer_ProjectTreeViewBase.cpp +++ b/extras/Jucer (experimental)/Source/ui/jucer_ProjectTreeViewBase.cpp @@ -288,7 +288,7 @@ void ProjectTreeViewBase::moveItems (OwnedArray & selectedNodes, } // Remove and re-insert them one at a time.. - for (int i = 0; i < selectedNodes.size(); ++i) + for (i = 0; i < selectedNodes.size(); ++i) { Project::Item* selectedNode = selectedNodes.getUnchecked(i); diff --git a/extras/Jucer (experimental)/Source/utility/jucer_UtilityFunctions.cpp b/extras/Jucer (experimental)/Source/utility/jucer_UtilityFunctions.cpp index 75938fe4d1..802c982bbe 100644 --- a/extras/Jucer (experimental)/Source/utility/jucer_UtilityFunctions.cpp +++ b/extras/Jucer (experimental)/Source/utility/jucer_UtilityFunctions.cpp @@ -132,8 +132,7 @@ const String randomHexString (Random& random, int numChars) const String hexString8Digits (int value) { - String s (String::toHexString (value)); - return String::repeatedString (T("0"), 8 - s.length()) + s; + return String::toHexString (value).paddedLeft ('0', 8); } diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index c3427e2855..3f63b23fcd 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -176,7 +176,7 @@ #endif #ifndef JUCE_ASIO - #define JUCE_ASIO 1 + #define JUCE_ASIO 0 #endif #ifndef JUCE_WASAPI @@ -196,7 +196,7 @@ #endif #if ! (defined (JUCE_QUICKTIME) || JUCE_LINUX || JUCE_IPHONE || (JUCE_WINDOWS && ! JUCE_MSVC)) - #define JUCE_QUICKTIME 1 + #define JUCE_QUICKTIME 0 #endif #ifndef JUCE_OPENGL @@ -212,7 +212,7 @@ #endif #if (! defined (JUCE_USE_CDBURNER)) && ! (JUCE_WINDOWS && ! JUCE_MSVC) - #define JUCE_USE_CDBURNER 1 + #define JUCE_USE_CDBURNER 0 #endif #ifndef JUCE_USE_CDREADER @@ -252,7 +252,7 @@ #endif #ifndef JUCE_WEB_BROWSER - #define JUCE_WEB_BROWSER 1 + #define JUCE_WEB_BROWSER 0 #endif #ifndef JUCE_SUPPORT_CARBON @@ -10395,6 +10395,11 @@ BEGIN_JUCE_NAMESPACE class StringHolder { public: + StringHolder() + : refCount (0x3fffffff), allocatedNumChars (0) + { + text[0] = 0; + } static juce_wchar* create (const size_t numChars) { @@ -10473,11 +10478,13 @@ public: private: static inline StringHolder* bufferFromText (juce_wchar* const text) throw() { - return reinterpret_cast (reinterpret_cast (text) - offsetof (StringHolder, StringHolder::text)); + // (Can't use offsetof() here because of warnings about this not being a POD) + return reinterpret_cast (reinterpret_cast (text) + - (reinterpret_cast (reinterpret_cast (1)->text) - 1)); } }; -StringHolder StringHolder::empty = { 0x3fffffff, 0, { 0 } }; +StringHolder StringHolder::empty; const String String::empty; void String::createInternal (const juce_wchar* const t, const size_t numChars) @@ -10689,7 +10696,11 @@ namespace NumberToStringConverters static juce_wchar getDecimalPoint() { +#if JUCE_WINDOWS && _MSC_VER < 1400 + static juce_wchar dp = std::_USE (std::locale(), std::numpunct ).decimal_point(); +#else static juce_wchar dp = std::use_facet > (std::locale()).decimal_point(); +#endif return dp; } @@ -11420,6 +11431,7 @@ const String String::repeatedString (const juce_wchar* const stringToRepeat, int const int len = CharacterFunctions::length (stringToRepeat); String result ((size_t) (len * numberOfTimesToRepeat + 1), (int) 0); juce_wchar* n = result.text; + *n = 0; while (--numberOfTimesToRepeat >= 0) { @@ -16736,6 +16748,11 @@ const var Value::getValue() const return value->getValue(); } +Value::operator const var() const +{ + return getValue(); +} + void Value::setValue (const var& newValue) { value->setValue (newValue); @@ -16807,6 +16824,11 @@ void Value::callListeners() listeners.call (&Listener::valueChanged, v); } +OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const Value& value) +{ + return stream << value.toString(); +} + END_JUCE_NAMESPACE /*** End of inlined file: juce_Value.cpp ***/ @@ -17828,19 +17850,23 @@ END_JUCE_NAMESPACE /*** Start of inlined file: juce_PropertiesFile.cpp ***/ BEGIN_JUCE_NAMESPACE -static const int propFileMagicNumber = ((int) ByteOrder::littleEndianInt ("PROP")); -static const int propFileMagicNumberCompressed = ((int) ByteOrder::littleEndianInt ("CPRP")); +namespace PropertyFileConstants +{ + static const int magicNumber = (int) ByteOrder::littleEndianInt ("PROP"); + static const int magicNumberCompressed = (int) ByteOrder::littleEndianInt ("CPRP"); -static const tchar* const propertyFileXmlTag = T("PROPERTIES"); -static const tchar* const propertyTagName = T("VALUE"); + static const char* const fileTag = "PROPERTIES"; + static const char* const valueTag = "VALUE"; + static const char* const nameAttribute = "name"; + static const char* const valueAttribute = "val"; +} -PropertiesFile::PropertiesFile (const File& f, - const int millisecondsBeforeSaving, - const int options_) +PropertiesFile::PropertiesFile (const File& f, const int millisecondsBeforeSaving, const int options_) : PropertySet (ignoreCaseOfKeyNames), file (f), timerInterval (millisecondsBeforeSaving), options (options_), + loadedOk (false), needsWriting (false) { // You need to correctly specify just one storage format for the file @@ -17848,22 +17874,21 @@ PropertiesFile::PropertiesFile (const File& f, || (options_ & (storeAsBinary | storeAsCompressedBinary | storeAsXML)) == storeAsCompressedBinary || (options_ & (storeAsBinary | storeAsCompressedBinary | storeAsXML)) == storeAsXML); - ScopedPointer fileStream (f.createInputStream()); + ScopedPointer fileStream (f.createInputStream()); if (fileStream != 0) { int magicNumber = fileStream->readInt(); - if (magicNumber == propFileMagicNumberCompressed) + if (magicNumber == PropertyFileConstants::magicNumberCompressed) { - fileStream = new GZIPDecompressorInputStream (new SubregionStream (fileStream.release(), 4, -1, true), - true); - - magicNumber = propFileMagicNumber; + fileStream = new GZIPDecompressorInputStream (new SubregionStream (fileStream.release(), 4, -1, true), true); + magicNumber = PropertyFileConstants::magicNumber; } - if (magicNumber == propFileMagicNumber) + if (magicNumber == PropertyFileConstants::magicNumber) { + loadedOk = true; BufferedInputStream in (fileStream.release(), 2048, true); int numValues = in.readInt(); @@ -17884,24 +17909,26 @@ PropertiesFile::PropertiesFile (const File& f, fileStream = 0; XmlDocument parser (f); - ScopedPointer doc (parser.getDocumentElement (true)); + ScopedPointer doc (parser.getDocumentElement (true)); - if (doc != 0 && doc->hasTagName (propertyFileXmlTag)) + if (doc != 0 && doc->hasTagName (PropertyFileConstants::fileTag)) { doc = parser.getDocumentElement(); if (doc != 0) { - forEachXmlChildElementWithTagName (*doc, e, propertyTagName) + loadedOk = true; + + forEachXmlChildElementWithTagName (*doc, e, PropertyFileConstants::valueTag) { - const String name (e->getStringAttribute (T("name"))); + const String name (e->getStringAttribute (PropertyFileConstants::nameAttribute)); if (name.isNotEmpty()) { getAllProperties().set (name, e->getFirstChildElement() != 0 ? e->getFirstChildElement()->createDocument (String::empty, true) - : e->getStringAttribute (T("val"))); + : e->getStringAttribute (PropertyFileConstants::valueAttribute)); } } } @@ -17913,6 +17940,10 @@ PropertiesFile::PropertiesFile (const File& f, } } } + else + { + loadedOk = ! f.exists(); + } } PropertiesFile::~PropertiesFile() @@ -17932,6 +17963,12 @@ bool PropertiesFile::needsToBeSaved() const return needsWriting; } +void PropertiesFile::setNeedsToBeSaved (const bool needsToBeSaved) +{ + const ScopedLock sl (getLock()); + needsWriting = needsToBeSaved; +} + bool PropertiesFile::save() { const ScopedLock sl (getLock()); @@ -17945,12 +17982,12 @@ bool PropertiesFile::save() if ((options & storeAsXML) != 0) { - XmlElement doc (propertyFileXmlTag); + XmlElement doc (PropertyFileConstants::fileTag); for (int i = 0; i < getAllProperties().size(); ++i) { - XmlElement* const e = doc.createNewChildElement (propertyTagName); - e->setAttribute (T("name"), getAllProperties().getAllKeys() [i]); + XmlElement* const e = doc.createNewChildElement (PropertyFileConstants::valueTag); + e->setAttribute (PropertyFileConstants::nameAttribute, getAllProperties().getAllKeys() [i]); // if the value seems to contain xml, store it as such.. XmlDocument xmlContent (getAllProperties().getAllValues() [i]); @@ -17959,22 +17996,26 @@ bool PropertiesFile::save() if (childElement != 0) e->addChildElement (childElement); else - e->setAttribute (T("val"), getAllProperties().getAllValues() [i]); + e->setAttribute (PropertyFileConstants::valueAttribute, + getAllProperties().getAllValues() [i]); } - return doc.writeToFile (file, String::empty); + if (doc.writeToFile (file, String::empty)) + { + needsWriting = false; + return true; + } } else { TemporaryFile tempFile (file); - ScopedPointer out (tempFile.getFile().createOutputStream()); if (out != 0) { if ((options & storeAsCompressedBinary) != 0) { - out->writeInt (propFileMagicNumberCompressed); + out->writeInt (PropertyFileConstants::magicNumberCompressed); out->flush(); out = new GZIPCompressorOutputStream (out.release(), 9, true); @@ -17984,7 +18025,7 @@ bool PropertiesFile::save() // have you set up the storage option flags correctly? jassert ((options & storeAsBinary) != 0); - out->writeInt (propFileMagicNumber); + out->writeInt (PropertyFileConstants::magicNumber); } const int numProperties = getAllProperties().size(); @@ -18044,9 +18085,9 @@ const File PropertiesFile::getDefaultAppSettingsFile (const String& applicationN #endif #ifdef JUCE_LINUX - const File dir ((commonToAllUsers ? T("/var/") : T("~/")) + const File dir ((commonToAllUsers ? "/var/" : "~/") + (folderName.isNotEmpty() ? folderName - : (T(".") + applicationName))); + : ("." + applicationName))); #endif #if JUCE_WIN32 @@ -29879,7 +29920,7 @@ BEGIN_JUCE_NAMESPACE static int insideCallback = 0; -static const String osTypeToString (OSType type) throw() +static const String osTypeToString (OSType type) { char s[4]; s[0] = (char) (((uint32) type) >> 24); @@ -29889,7 +29930,7 @@ static const String osTypeToString (OSType type) throw() return String (s, 4); } -static OSType stringToOSType (const String& s1) throw() +static OSType stringToOSType (const String& s1) { const String s (s1 + " "); @@ -29918,10 +29959,8 @@ static const String createAUPluginIdentifier (const ComponentDescription& desc) else if (desc.componentType == kAudioUnitType_Panner) s << "Panners/"; - s << osTypeToString (desc.componentType) - << T(",") - << osTypeToString (desc.componentSubType) - << T(",") + s << osTypeToString (desc.componentType) << "," + << osTypeToString (desc.componentSubType) << "," << osTypeToString (desc.componentManufacturer); return s; @@ -29944,7 +29983,7 @@ static void getAUDetails (ComponentRecord* comp, String& name, String& manufactu if (nameString != 0 && nameString[0] != 0) { const String all ((const char*) nameString + 1, nameString[0]); -DBG ("name: "+ all); + DBG ("name: "+ all); manufacturer = all.upToFirstOccurrenceOf (T(":"), false, false).trim(); name = all.fromFirstOccurrenceOf (T(":"), false, false).trim(); @@ -29952,8 +29991,7 @@ DBG ("name: "+ all); if (infoString != 0 && infoString[0] != 0) { - const String all ((const char*) infoString + 1, infoString[0]); -DBG ("info: " + all); + DBG ("info: " + String ((const char*) infoString + 1, infoString[0])); } if (name.isEmpty()) @@ -30203,17 +30241,15 @@ AudioUnitPluginInstance::AudioUnitPluginInstance (const String& fileOrIdentifier AudioUnitPluginInstance::~AudioUnitPluginInstance() { + const ScopedLock sl (lock); + + jassert (insideCallback == 0); + + if (audioUnit != 0) { - const ScopedLock sl (lock); - - jassert (insideCallback == 0); - - if (audioUnit != 0) - { - AudioUnitUninitialize (audioUnit); - CloseComponent (audioUnit); - audioUnit = 0; - } + AudioUnitUninitialize (audioUnit); + CloseComponent (audioUnit); + audioUnit = 0; } } @@ -37360,27 +37396,27 @@ bool InterprocessConnection::readNextMessageInt() if (bytes == sizeof (messageHeader) && ByteOrder::swapIfBigEndian (messageHeader[0]) == magicMessageHeader) { - const int bytesInMessage = (int) ByteOrder::swapIfBigEndian (messageHeader[1]); + int bytesInMessage = (int) ByteOrder::swapIfBigEndian (messageHeader[1]); if (bytesInMessage > 0 && bytesInMessage < maximumMessageSize) { MemoryBlock messageData (bytesInMessage, true); int bytesRead = 0; - while (bytesRead < bytesInMessage) + while (bytesInMessage > 0) { if (threadShouldExit()) return false; const int numThisTime = jmin (bytesInMessage, 65536); - const int bytesIn = (socket != 0) ? socket->read (((char*) messageData.getData()) + bytesRead, numThisTime, true) - : pipe->read (((char*) messageData.getData()) + bytesRead, numThisTime, - pipeReceiveMessageTimeout); + const int bytesIn = (socket != 0) ? socket->read (static_cast (messageData.getData()) + bytesRead, numThisTime, true) + : pipe->read (static_cast (messageData.getData()) + bytesRead, numThisTime, pipeReceiveMessageTimeout); if (bytesIn <= 0) break; bytesRead += bytesIn; + bytesInMessage -= bytesIn; } if (bytesRead >= 0) @@ -74789,7 +74825,7 @@ extern void juce_glViewport (const int w, const int h); OpenGLPixelFormat::OpenGLPixelFormat (const int bitsPerRGBComponent, const int alphaBits_, const int depthBufferBits_, - const int stencilBufferBits_) throw() + const int stencilBufferBits_) : redBits (bitsPerRGBComponent), greenBits (bitsPerRGBComponent), blueBits (bitsPerRGBComponent), @@ -74804,9 +74840,50 @@ OpenGLPixelFormat::OpenGLPixelFormat (const int bitsPerRGBComponent, { } -bool OpenGLPixelFormat::operator== (const OpenGLPixelFormat& other) const throw() +OpenGLPixelFormat::OpenGLPixelFormat (const OpenGLPixelFormat& other) + : redBits (other.redBits), + greenBits (other.greenBits), + blueBits (other.blueBits), + alphaBits (other.alphaBits), + depthBufferBits (other.depthBufferBits), + stencilBufferBits (other.stencilBufferBits), + accumulationBufferRedBits (other.accumulationBufferRedBits), + accumulationBufferGreenBits (other.accumulationBufferGreenBits), + accumulationBufferBlueBits (other.accumulationBufferBlueBits), + accumulationBufferAlphaBits (other.accumulationBufferAlphaBits), + fullSceneAntiAliasingNumSamples (other.fullSceneAntiAliasingNumSamples) { - return memcmp (this, &other, sizeof (other)) == 0; +} + +OpenGLPixelFormat& OpenGLPixelFormat::operator= (const OpenGLPixelFormat& other) +{ + redBits = other.redBits; + greenBits = other.greenBits; + blueBits = other.blueBits; + alphaBits = other.alphaBits; + depthBufferBits = other.depthBufferBits; + stencilBufferBits = other.stencilBufferBits; + accumulationBufferRedBits = other.accumulationBufferRedBits; + accumulationBufferGreenBits = other.accumulationBufferGreenBits; + accumulationBufferBlueBits = other.accumulationBufferBlueBits; + accumulationBufferAlphaBits = other.accumulationBufferAlphaBits; + fullSceneAntiAliasingNumSamples = other.fullSceneAntiAliasingNumSamples; + return *this; +} + +bool OpenGLPixelFormat::operator== (const OpenGLPixelFormat& other) const +{ + return redBits == other.redBits + && greenBits == other.greenBits + && blueBits == other.blueBits + && alphaBits == other.alphaBits + && depthBufferBits == other.depthBufferBits + && stencilBufferBits == other.stencilBufferBits + && accumulationBufferRedBits == other.accumulationBufferRedBits + && accumulationBufferGreenBits == other.accumulationBufferGreenBits + && accumulationBufferBlueBits == other.accumulationBufferBlueBits + && accumulationBufferAlphaBits == other.accumulationBufferAlphaBits + && fullSceneAntiAliasingNumSamples == other.fullSceneAntiAliasingNumSamples; } static VoidArray knownContexts; @@ -87573,15 +87650,57 @@ BEGIN_JUCE_NAMESPACE #define CHECK_COORDS_ARE_VALID(x, y) \ jassert (x == x && y == y); +namespace PathHelpers +{ + static const float ellipseAngularIncrement = 0.05f; + + static void perpendicularOffset (const float x1, const float y1, + const float x2, const float y2, + const float offsetX, const float offsetY, + float& resultX, float& resultY) throw() + { + const float dx = x2 - x1; + const float dy = y2 - y1; + const float len = juce_hypotf (dx, dy); + + if (len == 0) + { + resultX = x1; + resultY = y1; + } + else + { + resultX = x1 + ((dx * offsetX) - (dy * offsetY)) / len; + resultY = y1 + ((dy * offsetX) + (dx * offsetY)) / len; + } + } + + static const String nextToken (const tchar*& t) + { + while (CharacterFunctions::isWhitespace (*t)) + ++t; + + const tchar* const start = t; + + while (*t != 0 && ! CharacterFunctions::isWhitespace (*t)) + ++t; + + const int length = (int) (t - start); + + while (CharacterFunctions::isWhitespace (*t)) + ++t; + + return String (start, length); + } +} + const float Path::lineMarker = 100001.0f; const float Path::moveMarker = 100002.0f; const float Path::quadMarker = 100003.0f; const float Path::cubicMarker = 100004.0f; const float Path::closeSubPathMarker = 100005.0f; -static const int defaultGranularity = 32; - -Path::Path() throw() +Path::Path() : numElements (0), pathXMin (0), pathXMax (0), @@ -87591,11 +87710,11 @@ Path::Path() throw() { } -Path::~Path() throw() +Path::~Path() { } -Path::Path (const Path& other) throw() +Path::Path (const Path& other) : numElements (other.numElements), pathXMin (other.pathXMin), pathXMax (other.pathXMax), @@ -87610,7 +87729,7 @@ Path::Path (const Path& other) throw() } } -Path& Path::operator= (const Path& other) throw() +Path& Path::operator= (const Path& other) { if (this != &other) { @@ -87642,7 +87761,7 @@ void Path::clear() throw() void Path::swapWithPath (Path& other) { data.swapWith (other.data); - swapVariables (numElements, other.numElements); + swapVariables (numElements, other.numElements); swapVariables (pathXMin, other.pathXMin); swapVariables (pathXMax, other.pathXMax); swapVariables (pathYMin, other.pathYMin); @@ -87663,7 +87782,7 @@ void Path::scaleToFit (const float x, const float y, const float w, const float bool Path::isEmpty() const throw() { - int i = 0; + size_t i = 0; while (i < numElements) { @@ -87684,7 +87803,7 @@ bool Path::isEmpty() const throw() return true; } -const Rectangle Path::getBounds () const throw() +const Rectangle Path::getBounds() const throw() { return Rectangle (pathXMin, pathYMin, pathXMax - pathXMin, @@ -87696,8 +87815,7 @@ const Rectangle Path::getBoundsTransformed (const AffineTransform& transf return getBounds().transformed (transform); } -void Path::startNewSubPath (const float x, - const float y) throw() +void Path::startNewSubPath (const float x, const float y) { CHECK_COORDS_ARE_VALID (x, y); @@ -87721,7 +87839,7 @@ void Path::startNewSubPath (const float x, data.elements [numElements++] = y; } -void Path::lineTo (const float x, const float y) throw() +void Path::lineTo (const float x, const float y) { CHECK_COORDS_ARE_VALID (x, y); @@ -87741,7 +87859,7 @@ void Path::lineTo (const float x, const float y) throw() } void Path::quadraticTo (const float x1, const float y1, - const float x2, const float y2) throw() + const float x2, const float y2) { CHECK_COORDS_ARE_VALID (x1, y1); CHECK_COORDS_ARE_VALID (x2, y2); @@ -87765,7 +87883,7 @@ void Path::quadraticTo (const float x1, const float y1, void Path::cubicTo (const float x1, const float y1, const float x2, const float y2, - const float x3, const float y3) throw() + const float x3, const float y3) { CHECK_COORDS_ARE_VALID (x1, y1); CHECK_COORDS_ARE_VALID (x2, y2); @@ -87790,7 +87908,7 @@ void Path::cubicTo (const float x1, const float y1, pathYMax = jmax (pathYMax, y1, y2, y3); } -void Path::closeSubPath() throw() +void Path::closeSubPath() { if (numElements > 0 && data.elements [numElements - 1] != closeSubPathMarker) @@ -87825,7 +87943,7 @@ const Point Path::getCurrentPosition() const } void Path::addRectangle (const float x, const float y, - const float w, const float h) throw() + const float w, const float h) { float x1 = x, y1 = y, x2 = x + w, y2 = y + h; @@ -87867,7 +87985,7 @@ void Path::addRectangle (const float x, const float y, data.elements [numElements++] = closeSubPathMarker; } -void Path::addRectangle (const Rectangle& rectangle) throw() +void Path::addRectangle (const Rectangle& rectangle) { addRectangle ((float) rectangle.getX(), (float) rectangle.getY(), (float) rectangle.getWidth(), (float) rectangle.getHeight()); @@ -87876,7 +87994,7 @@ void Path::addRectangle (const Rectangle& rectangle) throw() void Path::addRoundedRectangle (const float x, const float y, const float w, const float h, float csx, - float csy) throw() + float csy) { csx = jmin (csx, w * 0.5f); csy = jmin (csy, h * 0.5f); @@ -87899,14 +88017,14 @@ void Path::addRoundedRectangle (const float x, const float y, void Path::addRoundedRectangle (const float x, const float y, const float w, const float h, - float cs) throw() + float cs) { addRoundedRectangle (x, y, w, h, cs, cs); } void Path::addTriangle (const float x1, const float y1, const float x2, const float y2, - const float x3, const float y3) throw() + const float x3, const float y3) { startNewSubPath (x1, y1); lineTo (x2, y2); @@ -87917,7 +88035,7 @@ void Path::addTriangle (const float x1, const float y1, void Path::addQuadrilateral (const float x1, const float y1, const float x2, const float y2, const float x3, const float y3, - const float x4, const float y4) throw() + const float x4, const float y4) { startNewSubPath (x1, y1); lineTo (x2, y2); @@ -87927,7 +88045,7 @@ void Path::addQuadrilateral (const float x1, const float y1, } void Path::addEllipse (const float x, const float y, - const float w, const float h) throw() + const float w, const float h) { const float hw = w * 0.5f; const float hw55 = hw * 0.55f; @@ -87948,7 +88066,7 @@ void Path::addArc (const float x, const float y, const float w, const float h, const float fromRadians, const float toRadians, - const bool startAsNewSubPath) throw() + const bool startAsNewSubPath) { const float radiusX = w / 2.0f; const float radiusY = h / 2.0f; @@ -87961,14 +88079,12 @@ void Path::addArc (const float x, const float y, startAsNewSubPath); } -static const float ellipseAngularIncrement = 0.05f; - void Path::addCentredArc (const float centreX, const float centreY, const float radiusX, const float radiusY, const float rotationOfEllipse, const float fromRadians, const float toRadians, - const bool startAsNewSubPath) throw() + const bool startAsNewSubPath) { if (radiusX > 0.0f && radiusY > 0.0f) { @@ -87989,7 +88105,7 @@ void Path::addCentredArc (const float centreX, const float centreY, if (fromRadians < toRadians) { if (startAsNewSubPath) - angle += ellipseAngularIncrement; + angle += PathHelpers::ellipseAngularIncrement; while (angle < toRadians) { @@ -88001,13 +88117,13 @@ void Path::addCentredArc (const float centreX, const float centreY, lineTo (x, y); - angle += ellipseAngularIncrement; + angle += PathHelpers::ellipseAngularIncrement; } } else { if (startAsNewSubPath) - angle -= ellipseAngularIncrement; + angle -= PathHelpers::ellipseAngularIncrement; while (angle > toRadians) { @@ -88019,7 +88135,7 @@ void Path::addCentredArc (const float centreX, const float centreY, lineTo (x, y); - angle -= ellipseAngularIncrement; + angle -= PathHelpers::ellipseAngularIncrement; } } @@ -88084,49 +88200,28 @@ void Path::addPieSegment (const float x, const float y, closeSubPath(); } -static void perpendicularOffset (const float x1, const float y1, - const float x2, const float y2, - const float offsetX, const float offsetY, - float& resultX, float& resultY) throw() -{ - const float dx = x2 - x1; - const float dy = y2 - y1; - const float len = juce_hypotf (dx, dy); - - if (len == 0) - { - resultX = x1; - resultY = y1; - } - else - { - resultX = x1 + ((dx * offsetX) - (dy * offsetY)) / len; - resultY = y1 + ((dy * offsetX) + (dx * offsetY)) / len; - } -} - void Path::addLineSegment (const float startX, const float startY, const float endX, const float endY, - float lineThickness) throw() + float lineThickness) { lineThickness *= 0.5f; float x, y; - perpendicularOffset (startX, startY, endX, endY, - 0, lineThickness, x, y); + PathHelpers::perpendicularOffset (startX, startY, endX, endY, + 0, lineThickness, x, y); startNewSubPath (x, y); - perpendicularOffset (startX, startY, endX, endY, - 0, -lineThickness, x, y); + PathHelpers::perpendicularOffset (startX, startY, endX, endY, + 0, -lineThickness, x, y); lineTo (x, y); - perpendicularOffset (endX, endY, startX, startY, - 0, lineThickness, x, y); + PathHelpers::perpendicularOffset (endX, endY, startX, startY, + 0, lineThickness, x, y); lineTo (x, y); - perpendicularOffset (endX, endY, startX, startY, - 0, -lineThickness, x, y); + PathHelpers::perpendicularOffset (endX, endY, startX, startY, + 0, -lineThickness, x, y); lineTo (x, y); closeSubPath(); @@ -88136,7 +88231,7 @@ void Path::addArrow (const float startX, const float startY, const float endX, const float endY, float lineThickness, float arrowheadWidth, - float arrowheadLength) throw() + float arrowheadLength) { lineThickness *= 0.5f; arrowheadWidth *= 0.5f; @@ -88145,32 +88240,32 @@ void Path::addArrow (const float startX, const float startY, float x, y; - perpendicularOffset (startX, startY, endX, endY, - 0, lineThickness, x, y); + PathHelpers::perpendicularOffset (startX, startY, endX, endY, + 0, lineThickness, x, y); startNewSubPath (x, y); - perpendicularOffset (startX, startY, endX, endY, - 0, -lineThickness, x, y); + PathHelpers::perpendicularOffset (startX, startY, endX, endY, + 0, -lineThickness, x, y); lineTo (x, y); - perpendicularOffset (endX, endY, startX, startY, - arrowheadLength, lineThickness, x, y); + PathHelpers::perpendicularOffset (endX, endY, startX, startY, + arrowheadLength, lineThickness, x, y); lineTo (x, y); - perpendicularOffset (endX, endY, startX, startY, - arrowheadLength, arrowheadWidth, x, y); + PathHelpers::perpendicularOffset (endX, endY, startX, startY, + arrowheadLength, arrowheadWidth, x, y); lineTo (x, y); - perpendicularOffset (endX, endY, startX, startY, - 0, 0, x, y); + PathHelpers::perpendicularOffset (endX, endY, startX, startY, + 0, 0, x, y); lineTo (x, y); - perpendicularOffset (endX, endY, startX, startY, - arrowheadLength, -arrowheadWidth, x, y); + PathHelpers::perpendicularOffset (endX, endY, startX, startY, + arrowheadLength, -arrowheadWidth, x, y); lineTo (x, y); - perpendicularOffset (endX, endY, startX, startY, - arrowheadLength, -lineThickness, x, y); + PathHelpers::perpendicularOffset (endX, endY, startX, startY, + arrowheadLength, -lineThickness, x, y); lineTo (x, y); closeSubPath(); @@ -88281,15 +88376,15 @@ void Path::addBubble (float x, float y, lineTo (x, y + cs); if (cs > 0.0f) - addArc (x, y, cs2, cs2, float_Pi * 1.5f, float_Pi * 2.0f - ellipseAngularIncrement); + addArc (x, y, cs2, cs2, float_Pi * 1.5f, float_Pi * 2.0f - PathHelpers::ellipseAngularIncrement); closeSubPath(); } } -void Path::addPath (const Path& other) throw() +void Path::addPath (const Path& other) { - int i = 0; + size_t i = 0; while (i < other.numElements) { @@ -88341,9 +88436,9 @@ void Path::addPath (const Path& other) throw() } void Path::addPath (const Path& other, - const AffineTransform& transformToApply) throw() + const AffineTransform& transformToApply) { - int i = 0; + size_t i = 0; while (i < other.numElements) { @@ -88397,7 +88492,7 @@ void Path::addPath (const Path& other, void Path::applyTransform (const AffineTransform& transform) throw() { - int i = 0; + size_t i = 0; pathYMin = pathXMin = 0; pathYMax = pathXMax = 0; bool setMaxMin = false; @@ -88478,7 +88573,7 @@ void Path::applyTransform (const AffineTransform& transform) throw() const AffineTransform Path::getTransformToScaleToFit (const float x, const float y, const float w, const float h, const bool preserveProportions, - const Justification& justification) const throw() + const Justification& justification) const { Rectangle bounds (getBounds()); @@ -88531,7 +88626,7 @@ const AffineTransform Path::getTransformToScaleToFit (const float x, const float } } -bool Path::contains (const float x, const float y, const float tolerence) const throw() +bool Path::contains (const float x, const float y, const float tolerence) const { if (x <= pathXMin || x >= pathXMax || y <= pathYMin || y >= pathYMax) @@ -88565,7 +88660,7 @@ bool Path::contains (const float x, const float y, const float tolerence) const bool Path::intersectsLine (const float x1, const float y1, const float x2, const float y2, - const float tolerence) throw() + const float tolerence) { PathFlatteningIterator i (*this, AffineTransform::identity, tolerence); @@ -88583,13 +88678,13 @@ bool Path::intersectsLine (const float x1, const float y1, return false; } -const Path Path::createPathWithRoundedCorners (const float cornerRadius) const throw() +const Path Path::createPathWithRoundedCorners (const float cornerRadius) const { if (cornerRadius <= 0.01f) return *this; int indexOfPathStart = 0, indexOfPathStartThis = 0; - int n = 0; + size_t n = 0; bool lastWasLine = false, firstWasLine = false; Path p; @@ -88804,18 +88899,17 @@ void Path::loadPathFromStream (InputStream& source) } } -void Path::loadPathFromData (const unsigned char* const data, - const int numberOfBytes) throw() +void Path::loadPathFromData (const void* const data, const int numberOfBytes) { - MemoryInputStream in ((const char*) data, numberOfBytes, false); + MemoryInputStream in (data, numberOfBytes, false); loadPathFromStream (in); } void Path::writePathToStream (OutputStream& dest) const { - dest.writeByte ((useNonZeroWinding) ? 'n' : 'z'); + dest.writeByte (useNonZeroWinding ? 'n' : 'z'); - int i = 0; + size_t i = 0; while (i < numElements) { const float type = data.elements [i++]; @@ -88865,7 +88959,7 @@ const String Path::toString() const if (! useNonZeroWinding) s << "a "; - int i = 0; + size_t i = 0; float lastMarker = 0.0f; while (i < numElements) @@ -88934,24 +89028,6 @@ const String Path::toString() const return String (result, len); } -static const String nextToken (const tchar*& t) -{ - while (CharacterFunctions::isWhitespace (*t)) - ++t; - - const tchar* const start = t; - - while (*t != 0 && ! CharacterFunctions::isWhitespace (*t)) - ++t; - - const int length = (int) (t - start); - - while (CharacterFunctions::isWhitespace (*t)) - ++t; - - return String (start, length); -} - void Path::restoreFromString (const String& stringVersion) { clear(); @@ -88964,7 +89040,7 @@ void Path::restoreFromString (const String& stringVersion) while (*t != 0) { - const String token (nextToken (t)); + const String token (PathHelpers::nextToken (t)); const tchar firstChar = token[0]; int startNum = 0; @@ -89000,7 +89076,7 @@ void Path::restoreFromString (const String& stringVersion) } for (int i = startNum; i < numValues; ++i) - values [i] = nextToken (t).getFloatValue(); + values [i] = PathHelpers::nextToken (t).getFloatValue(); switch (marker) { @@ -89106,7 +89182,7 @@ BEGIN_JUCE_NAMESPACE PathFlatteningIterator::PathFlatteningIterator (const Path& path_, const AffineTransform& transform_, - float tolerence_) throw() + float tolerence_) : x2 (0), y2 (0), closesSubPath (false), @@ -89117,19 +89193,19 @@ PathFlatteningIterator::PathFlatteningIterator (const Path& path_, tolerence (tolerence_ * tolerence_), subPathCloseX (0), subPathCloseY (0), + isIdentityTransform (transform_.isIdentity()), stackBase (32), index (0), stackSize (32) { - isIdentityTransform = transform.isIdentity(); stackPos = stackBase; } -PathFlatteningIterator::~PathFlatteningIterator() throw() +PathFlatteningIterator::~PathFlatteningIterator() { } -bool PathFlatteningIterator::next() throw() +bool PathFlatteningIterator::next() { x1 = x2; y1 = y2; @@ -89222,7 +89298,7 @@ bool PathFlatteningIterator::next() throw() } else if (type == Path::quadMarker) { - const int offset = (int) (stackPos - stackBase); + const size_t offset = (size_t) (stackPos - stackBase); if (offset >= stackSize - 10) { @@ -89272,7 +89348,7 @@ bool PathFlatteningIterator::next() throw() } else if (type == Path::cubicMarker) { - const int offset = (int) (stackPos - stackBase); + const size_t offset = (size_t) (stackPos - stackBase); if (offset >= stackSize - 16) { @@ -114769,7 +114845,7 @@ public: { if (ok) { - FLAC__stream_encoder_finish (encoder); + FlacNamespace::FLAC__stream_encoder_finish (encoder); output->flush(); } else @@ -114778,7 +114854,7 @@ public: // to the caller of createWriter() } - FLAC__stream_encoder_delete (encoder); + FlacNamespace::FLAC__stream_encoder_delete (encoder); } bool write (const int** samplesToWrite, int numSamples) @@ -171304,7 +171380,7 @@ public: ~OggReader() { - ov_clear (&ovFile); + OggVorbisNamespace::ov_clear (&ovFile); } bool readSamples (int** destSamples, int numDestChannels, int startOffsetInDestBuffer, @@ -171343,8 +171419,8 @@ public: reservoirStart = jmax (0, (int) startSampleInFile); samplesInReservoir = reservoir.getNumSamples(); - if (reservoirStart != (int) ov_pcm_tell (&ovFile)) - ov_pcm_seek (&ovFile, reservoirStart); + if (reservoirStart != (int) OggVorbisNamespace::ov_pcm_tell (&ovFile)) + OggVorbisNamespace::ov_pcm_seek (&ovFile, reservoirStart); int offset = 0; int numToRead = samplesInReservoir; @@ -171353,7 +171429,7 @@ public: { float** dataIn = 0; - const int samps = ov_read_float (&ovFile, &dataIn, numToRead, &bitStream); + const int samps = OggVorbisNamespace::ov_read_float (&ovFile, &dataIn, numToRead, &bitStream); if (samps <= 0) break; @@ -171485,6 +171561,7 @@ public: ~OggWriter() { + using namespace OggVorbisNamespace; if (ok) { // write a zero-length packet to show ogg that we're finished.. @@ -171508,6 +171585,7 @@ public: bool write (const int** samplesToWrite, int numSamples) { + using namespace OggVorbisNamespace; if (! ok) return false; @@ -227886,91 +227964,115 @@ void CriticalSection::exit() const throw() pthread_mutex_unlock (&internal); } -struct EventStruct +class WaitableEventImpl { +public: + WaitableEventImpl() + : triggered (false) + { + pthread_cond_init (&condition, 0); + pthread_mutex_init (&mutex, 0); + } + + ~WaitableEventImpl() + { + pthread_cond_destroy (&condition); + pthread_mutex_destroy (&mutex); + } + + bool wait (const int timeOutMillisecs) throw() + { + pthread_mutex_lock (&mutex); + + if (! triggered) + { + if (timeOutMillisecs < 0) + { + do + { + pthread_cond_wait (&condition, &mutex); + } + while (! triggered); + } + else + { + struct timeval now; + gettimeofday (&now, 0); + + struct timespec time; + time.tv_sec = now.tv_sec + (timeOutMillisecs / 1000); + time.tv_nsec = (now.tv_usec + ((timeOutMillisecs % 1000) * 1000)) * 1000; + + if (time.tv_nsec >= 1000000000) + { + time.tv_nsec -= 1000000000; + time.tv_sec++; + } + + do + { + if (pthread_cond_timedwait (&condition, &mutex, &time) == ETIMEDOUT) + { + pthread_mutex_unlock (&mutex); + return false; + } + } + while (! triggered); + } + } + + triggered = false; + pthread_mutex_unlock (&mutex); + return true; + } + + void signal() throw() + { + pthread_mutex_lock (&mutex); + triggered = true; + pthread_cond_broadcast (&condition); + pthread_mutex_unlock (&mutex); + } + + void reset() throw() + { + pthread_mutex_lock (&mutex); + triggered = false; + pthread_mutex_unlock (&mutex); + } + +private: pthread_cond_t condition; pthread_mutex_t mutex; bool triggered; + + WaitableEventImpl (const WaitableEventImpl&); + WaitableEventImpl& operator= (const WaitableEventImpl&); }; WaitableEvent::WaitableEvent() throw() + : internal (new WaitableEventImpl()) { - EventStruct* const es = new EventStruct(); - es->triggered = false; - - pthread_cond_init (&es->condition, 0); - pthread_mutex_init (&es->mutex, 0); - - internal = es; } WaitableEvent::~WaitableEvent() throw() { - EventStruct* const es = (EventStruct*) internal; - - pthread_cond_destroy (&es->condition); - pthread_mutex_destroy (&es->mutex); - - delete es; + delete static_cast (internal); } bool WaitableEvent::wait (const int timeOutMillisecs) const throw() { - EventStruct* const es = (EventStruct*) internal; - pthread_mutex_lock (&es->mutex); - - if (timeOutMillisecs < 0) - { - while (! es->triggered) - pthread_cond_wait (&es->condition, &es->mutex); - } - else - { - while (! es->triggered) - { - struct timeval t; - gettimeofday (&t, 0); - - struct timespec time; - time.tv_sec = t.tv_sec + (timeOutMillisecs / 1000); - time.tv_nsec = (t.tv_usec + ((timeOutMillisecs % 1000) * 1000)) * 1000; - - if (time.tv_nsec >= 1000000000) - { - time.tv_nsec -= 1000000000; - time.tv_sec++; - } - - if (pthread_cond_timedwait (&es->condition, &es->mutex, &time) == ETIMEDOUT) - { - pthread_mutex_unlock (&es->mutex); - return false; - } - } - } - - es->triggered = false; - pthread_mutex_unlock (&es->mutex); - return true; + return static_cast (internal)->wait (timeOutMillisecs); } void WaitableEvent::signal() const throw() { - EventStruct* const es = (EventStruct*) internal; - - pthread_mutex_lock (&es->mutex); - es->triggered = true; - pthread_cond_broadcast (&es->condition); - pthread_mutex_unlock (&es->mutex); + static_cast (internal)->signal(); } void WaitableEvent::reset() const throw() { - EventStruct* const es = (EventStruct*) internal; - - pthread_mutex_lock (&es->mutex); - es->triggered = false; - pthread_mutex_unlock (&es->mutex); + static_cast (internal)->reset(); } void JUCE_CALLTYPE Thread::sleep (int millisecs) @@ -228058,9 +228160,9 @@ bool juce_canWriteToFile (const String& fileName) bool juce_deleteFile (const String& fileName) { if (juce_isDirectory (fileName)) - return rmdir ((const char*) fileName.toUTF8()) == 0; + return rmdir (fileName.toUTF8()) == 0; else - return remove ((const char*) fileName.toUTF8()) == 0; + return remove (fileName.toUTF8()) == 0; } bool juce_moveFile (const String& source, const String& dest) @@ -228093,7 +228195,7 @@ void* juce_fileOpen (const String& fileName, bool forWriting) { if (juce_fileExists (fileName, false)) { - const int f = open ((const char*) fileName.toUTF8(), O_RDWR, 00644); + const int f = open (fileName.toUTF8(), O_RDWR, 00644); if (f != -1) lseek (f, 0, SEEK_END); @@ -228106,7 +228208,7 @@ void* juce_fileOpen (const String& fileName, bool forWriting) } } - return (void*) open ((const char*) fileName.toUTF8(), flags, 00644); + return (void*) open (fileName.toUTF8(), flags, 00644); } void juce_fileClose (void* handle) @@ -228216,7 +228318,7 @@ const String juce_getVolumeLabel (const String& filenameOnVolume, for (;;) { - if (getattrlist ((const char*) f.getFullPathName().toUTF8(), + if (getattrlist (f.getFullPathName().toUTF8(), &attrList, &attrBuf, sizeof(attrBuf), 0) == 0) { return String::fromUTF8 (((const char*) &attrBuf.mountPointRef) + attrBuf.mountPointRef.attr_dataoffset, @@ -228237,7 +228339,7 @@ const String juce_getVolumeLabel (const String& filenameOnVolume, void juce_runSystemCommand (const String& command) { - int result = system ((const char*) command.toUTF8()); + int result = system (command.toUTF8()); (void) result; } @@ -228728,7 +228830,7 @@ bool juce_launchFile (const String& fileName, cmdString = cmdLines.joinIntoString (T(" || ")); } - const char* const argv[4] = { "/bin/sh", "-c", (const char*) cmdString.toUTF8(), 0 }; + const char* const argv[4] = { "/bin/sh", "-c", cmdString.toUTF8(), 0 }; const int cpid = fork(); @@ -229054,12 +229156,12 @@ public: if (! decomposeURL (proxyURL, proxyName, proxyPath, proxyPort)) return false; - host = gethostbyname ((const char*) proxyName.toUTF8()); + host = gethostbyname (proxyName.toUTF8()); port = proxyPort; } else { - host = gethostbyname ((const char*) hostName.toUTF8()); + host = gethostbyname (hostName.toUTF8()); port = hostPort; } @@ -229793,7 +229895,7 @@ void Process::lowerPrivilege() void* PlatformUtilities::loadDynamicLibrary (const String& name) { - return dlopen ((const char*) name.toUTF8(), RTLD_LOCAL | RTLD_NOW); + return dlopen (name.toUTF8(), RTLD_LOCAL | RTLD_NOW); } void PlatformUtilities::freeDynamicLibrary (void* handle) @@ -236557,7 +236659,7 @@ void FileChooser::showPlatformDialog (Array& results, MemoryOutputStream result; int status = -1; - FILE* stream = popen ((const char*) command.toUTF8(), "r"); + FILE* stream = popen (command.toUTF8(), "r"); if (stream != 0) { @@ -237844,91 +237946,115 @@ void CriticalSection::exit() const throw() pthread_mutex_unlock (&internal); } -struct EventStruct +class WaitableEventImpl { +public: + WaitableEventImpl() + : triggered (false) + { + pthread_cond_init (&condition, 0); + pthread_mutex_init (&mutex, 0); + } + + ~WaitableEventImpl() + { + pthread_cond_destroy (&condition); + pthread_mutex_destroy (&mutex); + } + + bool wait (const int timeOutMillisecs) throw() + { + pthread_mutex_lock (&mutex); + + if (! triggered) + { + if (timeOutMillisecs < 0) + { + do + { + pthread_cond_wait (&condition, &mutex); + } + while (! triggered); + } + else + { + struct timeval now; + gettimeofday (&now, 0); + + struct timespec time; + time.tv_sec = now.tv_sec + (timeOutMillisecs / 1000); + time.tv_nsec = (now.tv_usec + ((timeOutMillisecs % 1000) * 1000)) * 1000; + + if (time.tv_nsec >= 1000000000) + { + time.tv_nsec -= 1000000000; + time.tv_sec++; + } + + do + { + if (pthread_cond_timedwait (&condition, &mutex, &time) == ETIMEDOUT) + { + pthread_mutex_unlock (&mutex); + return false; + } + } + while (! triggered); + } + } + + triggered = false; + pthread_mutex_unlock (&mutex); + return true; + } + + void signal() throw() + { + pthread_mutex_lock (&mutex); + triggered = true; + pthread_cond_broadcast (&condition); + pthread_mutex_unlock (&mutex); + } + + void reset() throw() + { + pthread_mutex_lock (&mutex); + triggered = false; + pthread_mutex_unlock (&mutex); + } + +private: pthread_cond_t condition; pthread_mutex_t mutex; bool triggered; + + WaitableEventImpl (const WaitableEventImpl&); + WaitableEventImpl& operator= (const WaitableEventImpl&); }; WaitableEvent::WaitableEvent() throw() + : internal (new WaitableEventImpl()) { - EventStruct* const es = new EventStruct(); - es->triggered = false; - - pthread_cond_init (&es->condition, 0); - pthread_mutex_init (&es->mutex, 0); - - internal = es; } WaitableEvent::~WaitableEvent() throw() { - EventStruct* const es = (EventStruct*) internal; - - pthread_cond_destroy (&es->condition); - pthread_mutex_destroy (&es->mutex); - - delete es; + delete static_cast (internal); } bool WaitableEvent::wait (const int timeOutMillisecs) const throw() { - EventStruct* const es = (EventStruct*) internal; - pthread_mutex_lock (&es->mutex); - - if (timeOutMillisecs < 0) - { - while (! es->triggered) - pthread_cond_wait (&es->condition, &es->mutex); - } - else - { - while (! es->triggered) - { - struct timeval t; - gettimeofday (&t, 0); - - struct timespec time; - time.tv_sec = t.tv_sec + (timeOutMillisecs / 1000); - time.tv_nsec = (t.tv_usec + ((timeOutMillisecs % 1000) * 1000)) * 1000; - - if (time.tv_nsec >= 1000000000) - { - time.tv_nsec -= 1000000000; - time.tv_sec++; - } - - if (pthread_cond_timedwait (&es->condition, &es->mutex, &time) == ETIMEDOUT) - { - pthread_mutex_unlock (&es->mutex); - return false; - } - } - } - - es->triggered = false; - pthread_mutex_unlock (&es->mutex); - return true; + return static_cast (internal)->wait (timeOutMillisecs); } void WaitableEvent::signal() const throw() { - EventStruct* const es = (EventStruct*) internal; - - pthread_mutex_lock (&es->mutex); - es->triggered = true; - pthread_cond_broadcast (&es->condition); - pthread_mutex_unlock (&es->mutex); + static_cast (internal)->signal(); } void WaitableEvent::reset() const throw() { - EventStruct* const es = (EventStruct*) internal; - - pthread_mutex_lock (&es->mutex); - es->triggered = false; - pthread_mutex_unlock (&es->mutex); + static_cast (internal)->reset(); } void JUCE_CALLTYPE Thread::sleep (int millisecs) @@ -238016,9 +238142,9 @@ bool juce_canWriteToFile (const String& fileName) bool juce_deleteFile (const String& fileName) { if (juce_isDirectory (fileName)) - return rmdir ((const char*) fileName.toUTF8()) == 0; + return rmdir (fileName.toUTF8()) == 0; else - return remove ((const char*) fileName.toUTF8()) == 0; + return remove (fileName.toUTF8()) == 0; } bool juce_moveFile (const String& source, const String& dest) @@ -238051,7 +238177,7 @@ void* juce_fileOpen (const String& fileName, bool forWriting) { if (juce_fileExists (fileName, false)) { - const int f = open ((const char*) fileName.toUTF8(), O_RDWR, 00644); + const int f = open (fileName.toUTF8(), O_RDWR, 00644); if (f != -1) lseek (f, 0, SEEK_END); @@ -238064,7 +238190,7 @@ void* juce_fileOpen (const String& fileName, bool forWriting) } } - return (void*) open ((const char*) fileName.toUTF8(), flags, 00644); + return (void*) open (fileName.toUTF8(), flags, 00644); } void juce_fileClose (void* handle) @@ -238174,7 +238300,7 @@ const String juce_getVolumeLabel (const String& filenameOnVolume, for (;;) { - if (getattrlist ((const char*) f.getFullPathName().toUTF8(), + if (getattrlist (f.getFullPathName().toUTF8(), &attrList, &attrBuf, sizeof(attrBuf), 0) == 0) { return String::fromUTF8 (((const char*) &attrBuf.mountPointRef) + attrBuf.mountPointRef.attr_dataoffset, @@ -238195,7 +238321,7 @@ const String juce_getVolumeLabel (const String& filenameOnVolume, void juce_runSystemCommand (const String& command) { - int result = system ((const char*) command.toUTF8()); + int result = system (command.toUTF8()); (void) result; } @@ -251844,7 +251970,6 @@ END_JUCE_NAMESPACE fromConnection: (QTCaptureConnection*) connection { const Time now (Time::getCurrentTime()); - int64 presentationTime = ([sampleBuffer presentationTime].timeValue * 1000) / [sampleBuffer presentationTime].timeScale; #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 NSNumber* hosttime = (NSNumber*) [sampleBuffer attributeForKey: QTSampleBufferHostTimeAttribute]; @@ -251852,10 +251977,11 @@ END_JUCE_NAMESPACE NSNumber* hosttime = (NSNumber*) [sampleBuffer attributeForKey: @"hostTime"]; #endif - if (hosttime != nil) - presentationTime = (int64) AudioConvertHostTimeToNanos ([hosttime unsignedLongLongValue]) / 1000000; + int64 presentationTime = (hosttime != nil) + ? ((int64) AudioConvertHostTimeToNanos ([hosttime unsignedLongLongValue]) / 1000000 + 40) + : (([sampleBuffer presentationTime].timeValue * 1000) / [sampleBuffer presentationTime].timeScale + 50); - const int64 timeDiff = now.toMilliseconds() - presentationTime - 50; + const int64 timeDiff = now.toMilliseconds() - presentationTime; if (firstPresentationTime == 0) { @@ -251898,20 +252024,19 @@ CameraDevice::CameraDevice (const String& name_, int index) : name (name_) { isRecording = false; - QTCameraDeviceInteral* d = new QTCameraDeviceInteral (this, index); - internal = d; + internal = new QTCameraDeviceInteral (this, index); } CameraDevice::~CameraDevice() { stopRecording(); - delete (QTCameraDeviceInteral*) internal; + delete static_cast (internal); internal = 0; } Component* CameraDevice::createViewerComponent() { - return new QTCaptureViewerComp (this, (QTCameraDeviceInteral*) internal); + return new QTCaptureViewerComp (this, static_cast (internal)); } const String CameraDevice::getFileExtension() @@ -251923,7 +252048,7 @@ void CameraDevice::startRecordingToFile (const File& file, int quality) { stopRecording(); - QTCameraDeviceInteral* const d = (QTCameraDeviceInteral*) internal; + QTCameraDeviceInteral* const d = static_cast (internal); d->callbackDelegate->firstPresentationTime = 0; file.deleteFile(); @@ -251960,7 +252085,7 @@ void CameraDevice::startRecordingToFile (const File& file, int quality) const Time CameraDevice::getTimeOfFirstRecordedFrame() const { - QTCameraDeviceInteral* const d = (QTCameraDeviceInteral*) internal; + QTCameraDeviceInteral* const d = static_cast (internal); if (d->callbackDelegate->firstPresentationTime != 0) return Time (d->callbackDelegate->firstPresentationTime + d->callbackDelegate->averageTimeOffset); @@ -251971,26 +252096,21 @@ void CameraDevice::stopRecording() { if (isRecording) { - QTCameraDeviceInteral* const d = (QTCameraDeviceInteral*) internal; - d->resetFile(); + static_cast (internal)->resetFile(); isRecording = false; } } void CameraDevice::addListener (CameraImageListener* listenerToAdd) { - QTCameraDeviceInteral* const d = (QTCameraDeviceInteral*) internal; - if (listenerToAdd != 0) - d->addListener (listenerToAdd); + static_cast (internal)->addListener (listenerToAdd); } void CameraDevice::removeListener (CameraImageListener* listenerToRemove) { - QTCameraDeviceInteral* const d = (QTCameraDeviceInteral*) internal; - if (listenerToRemove != 0) - d->removeListener (listenerToRemove); + static_cast (internal)->removeListener (listenerToRemove); } const StringArray CameraDevice::getAvailableDevices() @@ -252015,7 +252135,7 @@ CameraDevice* CameraDevice::openDevice (int index, { ScopedPointer d (new CameraDevice (getAvailableDevices() [index], index)); - if (((QTCameraDeviceInteral*) (d->internal))->openingError.isEmpty()) + if (static_cast (d->internal)->openingError.isEmpty()) return d.release(); return 0; diff --git a/juce_amalgamated.h b/juce_amalgamated.h index d1eca81e93..c4c9518c42 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -197,7 +197,7 @@ #endif #ifndef JUCE_ASIO - #define JUCE_ASIO 1 + #define JUCE_ASIO 0 #endif #ifndef JUCE_WASAPI @@ -217,7 +217,7 @@ #endif #if ! (defined (JUCE_QUICKTIME) || JUCE_LINUX || JUCE_IPHONE || (JUCE_WINDOWS && ! JUCE_MSVC)) - #define JUCE_QUICKTIME 1 + #define JUCE_QUICKTIME 0 #endif #ifndef JUCE_OPENGL @@ -233,7 +233,7 @@ #endif #if (! defined (JUCE_USE_CDBURNER)) && ! (JUCE_WINDOWS && ! JUCE_MSVC) - #define JUCE_USE_CDBURNER 1 + #define JUCE_USE_CDBURNER 0 #endif #ifndef JUCE_USE_CDREADER @@ -273,7 +273,7 @@ #endif #ifndef JUCE_WEB_BROWSER - #define JUCE_WEB_BROWSER 1 + #define JUCE_WEB_BROWSER 0 #endif #ifndef JUCE_SUPPORT_CARBON @@ -6314,6 +6314,8 @@ private: Value& operator= (const Value& other); }; +OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const Value& value); + #endif // __JUCE_VALUE_JUCEHEADER__ /*** End of inlined file: juce_Value.h ***/ @@ -6709,7 +6711,8 @@ private: ReferenceCountedObjectPtr object; ListenerList listeners; - ValueTree (SharedObject* const object_); +public: + ValueTree (SharedObject* const object_); // (can be made private when VC6 support is finally dropped) }; #endif // __JUCE_VALUETREE_JUCEHEADER__ @@ -9884,6 +9887,11 @@ public: return Rectangle (x + deltaX, y + deltaY, w, h); } + const Rectangle operator+ (const Point& deltaPosition) const throw() + { + return Rectangle (x + deltaPosition.getX(), y + deltaPosition.getY(), w, h); + } + void expand (const ValueType deltaX, const ValueType deltaY) throw() { @@ -9929,7 +9937,7 @@ public: return xCoord >= x && yCoord >= y && xCoord < x + w && yCoord < y + h; } - bool contains (const Point point) const throw() + bool contains (const Point& point) const throw() { return point.getX() >= x && point.getY() >= y && point.getX() < x + w && point.getY() < y + h; } @@ -10341,13 +10349,13 @@ class JUCE_API Path { public: - Path() throw(); + Path(); - Path (const Path& other) throw(); + Path (const Path& other); - ~Path() throw(); + ~Path(); - Path& operator= (const Path& other) throw(); + Path& operator= (const Path& other); bool isEmpty() const throw(); @@ -10355,99 +10363,91 @@ public: const Rectangle getBoundsTransformed (const AffineTransform& transform) const throw(); - bool contains (const float x, - const float y, - const float tolerence = 10.0f) const throw(); + bool contains (float x, float y, + float tolerence = 10.0f) const; - bool intersectsLine (const float x1, const float y1, - const float x2, const float y2, - const float tolerence = 10.0f) throw(); + bool intersectsLine (float x1, float y1, + float x2, float y2, + float tolerence = 10.0f); void clear() throw(); - void startNewSubPath (const float startX, - const float startY) throw(); + void startNewSubPath (float startX, float startY); - void closeSubPath() throw(); + void closeSubPath(); - void lineTo (const float endX, - const float endY) throw(); + void lineTo (float endX, float endY); - void quadraticTo (const float controlPointX, - const float controlPointY, - const float endPointX, - const float endPointY) throw(); + void quadraticTo (float controlPointX, + float controlPointY, + float endPointX, + float endPointY); - void cubicTo (const float controlPoint1X, - const float controlPoint1Y, - const float controlPoint2X, - const float controlPoint2Y, - const float endPointX, - const float endPointY) throw(); + void cubicTo (float controlPoint1X, + float controlPoint1Y, + float controlPoint2X, + float controlPoint2Y, + float endPointX, + float endPointY); const Point getCurrentPosition() const; - void addRectangle (const float x, const float y, - const float w, const float h) throw(); + void addRectangle (float x, float y, float width, float height); - void addRectangle (const Rectangle& rectangle) throw(); + void addRectangle (const Rectangle& rectangle); - void addRoundedRectangle (const float x, const float y, - const float w, const float h, - float cornerSize) throw(); + void addRoundedRectangle (float x, float y, float width, float height, + float cornerSize); - void addRoundedRectangle (const float x, const float y, - const float w, const float h, + void addRoundedRectangle (float x, float y, float width, float height, float cornerSizeX, - float cornerSizeY) throw(); + float cornerSizeY); - void addTriangle (const float x1, const float y1, - const float x2, const float y2, - const float x3, const float y3) throw(); + void addTriangle (float x1, float y1, + float x2, float y2, + float x3, float y3); - void addQuadrilateral (const float x1, const float y1, - const float x2, const float y2, - const float x3, const float y3, - const float x4, const float y4) throw(); + void addQuadrilateral (float x1, float y1, + float x2, float y2, + float x3, float y3, + float x4, float y4); - void addEllipse (const float x, const float y, - const float width, const float height) throw(); + void addEllipse (float x, float y, float width, float height); - void addArc (const float x, const float y, - const float width, const float height, - const float fromRadians, - const float toRadians, - const bool startAsNewSubPath = false) throw(); + void addArc (float x, float y, float width, float height, + float fromRadians, + float toRadians, + bool startAsNewSubPath = false); - void addCentredArc (const float centreX, const float centreY, - const float radiusX, const float radiusY, - const float rotationOfEllipse, - const float fromRadians, - const float toRadians, - const bool startAsNewSubPath = false) throw(); + void addCentredArc (float centreX, float centreY, + float radiusX, float radiusY, + float rotationOfEllipse, + float fromRadians, + float toRadians, + bool startAsNewSubPath = false); - void addPieSegment (const float x, const float y, - const float width, const float height, - const float fromRadians, - const float toRadians, - const float innerCircleProportionalSize); + void addPieSegment (float x, float y, + float width, float height, + float fromRadians, + float toRadians, + float innerCircleProportionalSize); - void addLineSegment (const float startX, const float startY, - const float endX, const float endY, - float lineThickness) throw(); + void addLineSegment (float startX, float startY, + float endX, float endY, + float lineThickness); - void addArrow (const float startX, const float startY, - const float endX, const float endY, + void addArrow (float startX, float startY, + float endX, float endY, float lineThickness, float arrowheadWidth, - float arrowheadLength) throw(); + float arrowheadLength); - void addStar (const float centreX, - const float centreY, - const int numberOfPoints, - const float innerRadius, - const float outerRadius, - const float startAngle = 0.0f); + void addStar (float centreX, + float centreY, + int numberOfPoints, + float innerRadius, + float outerRadius, + float startAngle = 0.0f); void addBubble (float bodyX, float bodyY, float bodyW, float bodyH, @@ -10458,27 +10458,25 @@ public: float arrowPositionAlongEdgeProportional, float arrowWidth); - void addPath (const Path& pathToAppend) throw(); + void addPath (const Path& pathToAppend); void addPath (const Path& pathToAppend, - const AffineTransform& transformToApply) throw(); + const AffineTransform& transformToApply); void swapWithPath (Path& other); void applyTransform (const AffineTransform& transform) throw(); - void scaleToFit (const float x, const float y, - const float width, const float height, - const bool preserveProportions) throw(); + void scaleToFit (float x, float y, float width, float height, + bool preserveProportions) throw(); - const AffineTransform getTransformToScaleToFit (const float x, const float y, - const float width, const float height, - const bool preserveProportions, - const Justification& justificationType = Justification::centred) const throw(); + const AffineTransform getTransformToScaleToFit (float x, float y, float width, float height, + bool preserveProportions, + const Justification& justificationType = Justification::centred) const; - const Path createPathWithRoundedCorners (const float cornerRadius) const throw(); + const Path createPathWithRoundedCorners (float cornerRadius) const; - void setUsingNonZeroWinding (const bool isNonZeroWinding) throw(); + void setUsingNonZeroWinding (bool isNonZeroWinding) throw(); bool isUsingNonZeroWinding() const { return useNonZeroWinding; } @@ -10506,7 +10504,7 @@ public: private: const Path& path; - int index; + size_t index; Iterator (const Iterator&); Iterator& operator= (const Iterator&); @@ -10514,8 +10512,7 @@ public: void loadPathFromStream (InputStream& source); - void loadPathFromData (const unsigned char* const data, - const int numberOfBytes) throw(); + void loadPathFromData (const void* data, int numberOfBytes); void writePathToStream (OutputStream& destination) const; @@ -10529,7 +10526,7 @@ private: friend class PathFlatteningIterator; friend class Path::Iterator; ArrayAllocationBase data; - int numElements; + size_t numElements; float pathXMin, pathXMax, pathYMin, pathYMax; bool useNonZeroWinding; @@ -13359,30 +13356,34 @@ public: }; PropertiesFile (const File& file, - const int millisecondsBeforeSaving, - const int options); + int millisecondsBeforeSaving, + int optionFlags); ~PropertiesFile(); + bool isValidFile() const throw() { return loadedOk; } + bool saveIfNeeded(); bool save(); bool needsToBeSaved() const; + void setNeedsToBeSaved (bool needsToBeSaved); + const File getFile() const { return file; } static PropertiesFile* createDefaultAppPropertiesFile (const String& applicationName, const String& fileNameSuffix, const String& folderName, - const bool commonToAllUsers, - const int millisecondsBeforeSaving, - const int propertiesFileOptions); + bool commonToAllUsers, + int millisecondsBeforeSaving, + int propertiesFileOptions); static const File getDefaultAppSettingsFile (const String& applicationName, const String& fileNameSuffix, const String& folderName, - const bool commonToAllUsers); + bool commonToAllUsers); juce_UseDebuggingNewOperator @@ -13394,7 +13395,7 @@ private: File file; int timerInterval; const int options; - bool needsWriting; + bool loadedOk, needsWriting; void timerCallback(); @@ -26668,7 +26669,11 @@ public: OpenGLPixelFormat (const int bitsPerRGBComponent = 8, const int alphaBits = 8, const int depthBufferBits = 16, - const int stencilBufferBits = 0) throw(); + const int stencilBufferBits = 0); + + OpenGLPixelFormat (const OpenGLPixelFormat&); + OpenGLPixelFormat& operator= (const OpenGLPixelFormat&); + bool operator== (const OpenGLPixelFormat&) const; int redBits; /**< The number of bits per pixel to use for the red channel. */ int greenBits; /**< The number of bits per pixel to use for the green channel. */ @@ -26688,8 +26693,6 @@ public: static void getAvailablePixelFormats (Component* component, OwnedArray & results); - bool operator== (const OpenGLPixelFormat&) const throw(); - juce_UseDebuggingNewOperator }; @@ -27959,11 +27962,11 @@ public: PathFlatteningIterator (const Path& path, const AffineTransform& transform = AffineTransform::identity, - float tolerence = 6.0f) throw(); + float tolerence = 6.0f); - ~PathFlatteningIterator() throw(); + ~PathFlatteningIterator(); - bool next() throw(); + bool next(); float x1; float y1; @@ -27985,11 +27988,11 @@ private: const AffineTransform transform; float* points; float tolerence, subPathCloseX, subPathCloseY; - bool isIdentityTransform; + const bool isIdentityTransform; HeapBlock stackBase; float* stackPos; - int index, stackSize; + size_t index, stackSize; PathFlatteningIterator (const PathFlatteningIterator&); PathFlatteningIterator& operator= (const PathFlatteningIterator&); diff --git a/src/containers/juce_Value.cpp b/src/containers/juce_Value.cpp index cb7f1557b7..cd3a9c184a 100644 --- a/src/containers/juce_Value.cpp +++ b/src/containers/juce_Value.cpp @@ -217,5 +217,9 @@ void Value::callListeners() listeners.call (&Listener::valueChanged, v); } +OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const Value& value) +{ + return stream << value.toString(); +} END_JUCE_NAMESPACE diff --git a/src/containers/juce_Value.h b/src/containers/juce_Value.h index a5ddd23a90..4527103218 100644 --- a/src/containers/juce_Value.h +++ b/src/containers/juce_Value.h @@ -227,5 +227,8 @@ private: Value& operator= (const Value& other); }; +/** Writes a Value to an OutputStream as a UTF8 string. */ +OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const Value& value); + #endif // __JUCE_VALUE_JUCEHEADER__ diff --git a/src/containers/juce_ValueTree.h b/src/containers/juce_ValueTree.h index 0c0902ac80..63dcf349cd 100644 --- a/src/containers/juce_ValueTree.h +++ b/src/containers/juce_ValueTree.h @@ -443,7 +443,9 @@ private: ReferenceCountedObjectPtr object; ListenerList listeners; - ValueTree (SharedObject* const object_); +public: + /** @internal */ + ValueTree (SharedObject* const object_); // (can be made private when VC6 support is finally dropped) }; diff --git a/src/gui/components/special/juce_OpenGLComponent.cpp b/src/gui/components/special/juce_OpenGLComponent.cpp index a8fda1cba6..be13fa0d16 100644 --- a/src/gui/components/special/juce_OpenGLComponent.cpp +++ b/src/gui/components/special/juce_OpenGLComponent.cpp @@ -43,7 +43,7 @@ extern void juce_glViewport (const int w, const int h); OpenGLPixelFormat::OpenGLPixelFormat (const int bitsPerRGBComponent, const int alphaBits_, const int depthBufferBits_, - const int stencilBufferBits_) throw() + const int stencilBufferBits_) : redBits (bitsPerRGBComponent), greenBits (bitsPerRGBComponent), blueBits (bitsPerRGBComponent), @@ -58,9 +58,50 @@ OpenGLPixelFormat::OpenGLPixelFormat (const int bitsPerRGBComponent, { } -bool OpenGLPixelFormat::operator== (const OpenGLPixelFormat& other) const throw() +OpenGLPixelFormat::OpenGLPixelFormat (const OpenGLPixelFormat& other) + : redBits (other.redBits), + greenBits (other.greenBits), + blueBits (other.blueBits), + alphaBits (other.alphaBits), + depthBufferBits (other.depthBufferBits), + stencilBufferBits (other.stencilBufferBits), + accumulationBufferRedBits (other.accumulationBufferRedBits), + accumulationBufferGreenBits (other.accumulationBufferGreenBits), + accumulationBufferBlueBits (other.accumulationBufferBlueBits), + accumulationBufferAlphaBits (other.accumulationBufferAlphaBits), + fullSceneAntiAliasingNumSamples (other.fullSceneAntiAliasingNumSamples) { - return memcmp (this, &other, sizeof (other)) == 0; +} + +OpenGLPixelFormat& OpenGLPixelFormat::operator= (const OpenGLPixelFormat& other) +{ + redBits = other.redBits; + greenBits = other.greenBits; + blueBits = other.blueBits; + alphaBits = other.alphaBits; + depthBufferBits = other.depthBufferBits; + stencilBufferBits = other.stencilBufferBits; + accumulationBufferRedBits = other.accumulationBufferRedBits; + accumulationBufferGreenBits = other.accumulationBufferGreenBits; + accumulationBufferBlueBits = other.accumulationBufferBlueBits; + accumulationBufferAlphaBits = other.accumulationBufferAlphaBits; + fullSceneAntiAliasingNumSamples = other.fullSceneAntiAliasingNumSamples; + return *this; +} + +bool OpenGLPixelFormat::operator== (const OpenGLPixelFormat& other) const +{ + return redBits == other.redBits + && greenBits == other.greenBits + && blueBits == other.blueBits + && alphaBits == other.alphaBits + && depthBufferBits == other.depthBufferBits + && stencilBufferBits == other.stencilBufferBits + && accumulationBufferRedBits == other.accumulationBufferRedBits + && accumulationBufferGreenBits == other.accumulationBufferGreenBits + && accumulationBufferBlueBits == other.accumulationBufferBlueBits + && accumulationBufferAlphaBits == other.accumulationBufferAlphaBits + && fullSceneAntiAliasingNumSamples == other.fullSceneAntiAliasingNumSamples; } //============================================================================== diff --git a/src/gui/components/special/juce_OpenGLComponent.h b/src/gui/components/special/juce_OpenGLComponent.h index cf8f4e10c2..6f8ad9ec1e 100644 --- a/src/gui/components/special/juce_OpenGLComponent.h +++ b/src/gui/components/special/juce_OpenGLComponent.h @@ -50,7 +50,11 @@ public: OpenGLPixelFormat (const int bitsPerRGBComponent = 8, const int alphaBits = 8, const int depthBufferBits = 16, - const int stencilBufferBits = 0) throw(); + const int stencilBufferBits = 0); + + OpenGLPixelFormat (const OpenGLPixelFormat&); + OpenGLPixelFormat& operator= (const OpenGLPixelFormat&); + bool operator== (const OpenGLPixelFormat&) const; //============================================================================== int redBits; /**< The number of bits per pixel to use for the red channel. */ @@ -78,8 +82,6 @@ public: OwnedArray & results); //============================================================================== - bool operator== (const OpenGLPixelFormat&) const throw(); - juce_UseDebuggingNewOperator }; diff --git a/src/text/juce_String.cpp b/src/text/juce_String.cpp index 3b0cb57a9a..356b039011 100644 --- a/src/text/juce_String.cpp +++ b/src/text/juce_String.cpp @@ -53,6 +53,12 @@ BEGIN_JUCE_NAMESPACE class StringHolder { public: + StringHolder() + : refCount (0x3fffffff), allocatedNumChars (0) + { + text[0] = 0; + } + //============================================================================== static juce_wchar* create (const size_t numChars) { @@ -134,11 +140,13 @@ public: private: static inline StringHolder* bufferFromText (juce_wchar* const text) throw() { - return reinterpret_cast (reinterpret_cast (text) - offsetof (StringHolder, StringHolder::text)); + // (Can't use offsetof() here because of warnings about this not being a POD) + return reinterpret_cast (reinterpret_cast (text) + - (reinterpret_cast (reinterpret_cast (1)->text) - 1)); } }; -StringHolder StringHolder::empty = { 0x3fffffff, 0, { 0 } }; +StringHolder StringHolder::empty; const String String::empty; //============================================================================== @@ -353,7 +361,11 @@ namespace NumberToStringConverters static juce_wchar getDecimalPoint() { +#if JUCE_WINDOWS && _MSC_VER < 1400 + static juce_wchar dp = std::_USE (std::locale(), std::numpunct ).decimal_point(); +#else static juce_wchar dp = std::use_facet > (std::locale()).decimal_point(); +#endif return dp; } @@ -1092,6 +1104,7 @@ const String String::repeatedString (const juce_wchar* const stringToRepeat, int const int len = CharacterFunctions::length (stringToRepeat); String result ((size_t) (len * numberOfTimesToRepeat + 1), (int) 0); juce_wchar* n = result.text; + *n = 0; while (--numberOfTimesToRepeat >= 0) { diff --git a/src/utilities/juce_PropertiesFile.cpp b/src/utilities/juce_PropertiesFile.cpp index ded019f7f4..cd9af0ad06 100644 --- a/src/utilities/juce_PropertiesFile.cpp +++ b/src/utilities/juce_PropertiesFile.cpp @@ -187,7 +187,7 @@ bool PropertiesFile::save() if (childElement != 0) e->addChildElement (childElement); else - e->setAttribute (PropertyFileConstants::valueAttribute, + e->setAttribute (PropertyFileConstants::valueAttribute, getAllProperties().getAllValues() [i]); } diff --git a/src/utilities/juce_PropertiesFile.h b/src/utilities/juce_PropertiesFile.h index dea6b86106..a59e3aafe4 100644 --- a/src/utilities/juce_PropertiesFile.h +++ b/src/utilities/juce_PropertiesFile.h @@ -120,7 +120,7 @@ public: explicitly set this flag with setNeedsToBeSaved(). */ bool needsToBeSaved() const; - + /** Explicitly sets the flag to indicate whether the file needs saving or not. @see needsToBeSaved */