From 646732530cfc3f5c33e9b60d61ec10ca91ee28e1 Mon Sep 17 00:00:00 2001 From: jules Date: Thu, 13 Aug 2009 19:37:19 +0000 Subject: [PATCH] Tidying up and removing some compiler warnings on the mac. --- .../platform_specific_code/juce_mac_Fonts.mm | 2 +- .../juce_mac_SystemStats.mm | 65 ++++------------- .../mac/PluginHost.xcodeproj/project.pbxproj | 4 +- .../src/juce_LibrarySource.mm | 8 +++ .../demo/src/juce_LibrarySource.mm | 32 +++++---- extras/juce demo/build/win32_vc6/jucedemo.dsp | 4 -- extras/juce demo/src/juce_LibrarySource.mm | 41 ++++++----- .../build/mac/Jucer.xcodeproj/project.pbxproj | 6 ++ extras/the jucer/src/juce_LibrarySource.mm | 8 +++ juce_amalgamated.cpp | 69 +++++-------------- .../image_file_formats/pnglib/pngconf.h | 2 + 11 files changed, 100 insertions(+), 141 deletions(-) diff --git a/build/macosx/platform_specific_code/juce_mac_Fonts.mm b/build/macosx/platform_specific_code/juce_mac_Fonts.mm index 020b6d0c12..c12913e4bd 100644 --- a/build/macosx/platform_specific_code/juce_mac_Fonts.mm +++ b/build/macosx/platform_specific_code/juce_mac_Fonts.mm @@ -342,7 +342,7 @@ const StringArray Font::findAllTypefaceNames() throw() const ScopedAutoReleasePool pool; NSArray* fonts = [[NSFontManager sharedFontManager] availableFontFamilies]; - for (int i = 0; i < [fonts count]; ++i) + for (unsigned int i = 0; i < [fonts count]; ++i) names.add (nsStringToJuce ((NSString*) [fonts objectAtIndex: i])); names.sort (true); diff --git a/build/macosx/platform_specific_code/juce_mac_SystemStats.mm b/build/macosx/platform_specific_code/juce_mac_SystemStats.mm index 4050215903..292f0feafc 100644 --- a/build/macosx/platform_specific_code/juce_mac_SystemStats.mm +++ b/build/macosx/platform_specific_code/juce_mac_SystemStats.mm @@ -89,7 +89,7 @@ void SystemStats::initialiseStats() throw() { initialised = true; - // etremely annoying: adding this line stops the apple menu items from working. Of + // extremely annoying: adding this line stops the apple menu items from working. Of // course, not adding it means that carbon windows (e.g. in plugins) won't get // any events. //NSApplicationLoad(); @@ -118,42 +118,6 @@ void SystemStats::initialiseStats() throw() } } -static const String getCpuInfo (const char* key, bool lastOne = false) throw() -{ - String info; - char buf [256]; - - FILE* f = fopen ("/proc/cpuinfo", "r"); - - while (f != 0 && fgets (buf, sizeof(buf), f)) - { - if (strncmp (buf, key, strlen (key)) == 0) - { - char* p = buf; - - while (*p && *p != '\n') - ++p; - - if (*p != 0) - *p = 0; - - p = buf; - - while (*p != 0 && *p != ':') - ++p; - - if (*p != 0 && *(p + 1) != 0) - info = p + 2; - - if (! lastOne) - break; - } - } - - fclose (f); - return info; -} - //============================================================================== SystemStats::OperatingSystemType SystemStats::getOperatingSystemType() throw() { @@ -177,15 +141,11 @@ bool SystemStats::isOperatingSystem64Bit() throw() int SystemStats::getMemorySizeInMegabytes() throw() { -#if MACOS_10_4_OR_EARLIER - long bytes; - if (Gestalt (gestaltPhysicalRAMSize, &bytes) == noErr) - return (int) (((unsigned long) bytes) / (1024 * 1024)); - - return 0; -#else - return (int) ([[NSProcessInfo processInfo] physicalMemory] / (1024 * 1024)); -#endif + uint64 mem = 0; + size_t memSize = sizeof (mem); + int mib[] = { CTL_HW, HW_MEMSIZE }; + sysctl (mib, 2, &mem, &memSize, 0, 0); + return mem / (1024 * 1024); } bool SystemStats::hasMMX() throw() @@ -237,11 +197,16 @@ const String SystemStats::getCpuVendor() throw() int SystemStats::getCpuSpeedInMegaherz() throw() { -#if MACOS_10_4_OR_EARLIER - return GetCPUSpeed(); -#else - return roundDoubleToInt (getCpuInfo ("cpu MHz").getDoubleValue()); + uint64 speedHz = 0; + size_t speedSize = sizeof (speedHz); + int mib[] = { CTL_HW, HW_CPU_FREQ }; + sysctl (mib, 2, &speedHz, &speedSize, 0, 0); + +#if JUCE_BIG_ENDIAN + if (speedSize == 4) + speedHz >>= 32; #endif + return speedHz / 1000000; } int SystemStats::getNumCpus() throw() diff --git a/extras/audio plugin host/build/mac/PluginHost.xcodeproj/project.pbxproj b/extras/audio plugin host/build/mac/PluginHost.xcodeproj/project.pbxproj index a017a5bc38..a4ddfe7e91 100644 --- a/extras/audio plugin host/build/mac/PluginHost.xcodeproj/project.pbxproj +++ b/extras/audio plugin host/build/mac/PluginHost.xcodeproj/project.pbxproj @@ -241,7 +241,7 @@ buildSettings = { GCC_ENABLE_FIX_AND_CONTINUE = YES; GCC_OPTIMIZATION_LEVEL = 0; - PRODUCT_NAME = "Juce Plugin Host"; + PRODUCT_NAME = PluginHost; USER_HEADER_SEARCH_PATHS = "~/SDKs/vstsdk2.4 $(inherited)"; ZERO_LINK = NO; }; @@ -251,7 +251,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 84FC4CD80CD8894600850651 /* juce.xcconfig */; buildSettings = { - PRODUCT_NAME = "Juce Plugin Host"; + PRODUCT_NAME = PluginHost; SEPARATE_STRIP = YES; USER_HEADER_SEARCH_PATHS = "~/SDKs/vstsdk2.4 $(inherited)"; ZERO_LINK = NO; diff --git a/extras/audio plugin host/src/juce_LibrarySource.mm b/extras/audio plugin host/src/juce_LibrarySource.mm index 8e2b658e82..429beb2475 100644 --- a/extras/audio plugin host/src/juce_LibrarySource.mm +++ b/extras/audio plugin host/src/juce_LibrarySource.mm @@ -9,4 +9,12 @@ */ #include "juce_AppConfig.h" + +// This is where all the juce code gets included, via this amalgamated file.. #include "../../../juce_amalgamated.mm" + +/* NB. A handy tip is that if you're doing a lot of debugging into the juce code, then stepping through + the amalgamated file can be slow or impossible for the debugger. But if you use the following line + instead of the one above, then it makes it a lot easier.. +*/ +//#include "../../../src/juce_amalgamated_template.cpp" diff --git a/extras/audio plugins/demo/src/juce_LibrarySource.mm b/extras/audio plugins/demo/src/juce_LibrarySource.mm index f6af73081b..6c9769b487 100644 --- a/extras/audio plugins/demo/src/juce_LibrarySource.mm +++ b/extras/audio plugins/demo/src/juce_LibrarySource.mm @@ -1,12 +1,20 @@ - -/* - This file includes the entire juce source tree via the amalgamated file. - - You could add the amalgamated file directly to your project, but doing it - like this allows you to put your app's config settings in the - juce_AppConfig.h file and have them applied to both the juce headers and - the source code. -*/ - -#include "juce_AppConfig.h" -#include "../../../../juce_amalgamated.mm" + +/* + This file includes the entire juce source tree via the amalgamated file. + + You could add the amalgamated file directly to your project, but doing it + like this allows you to put your app's config settings in the + juce_AppConfig.h file and have them applied to both the juce headers and + the source code. +*/ + +#include "juce_AppConfig.h" + +// This is where all the juce code gets included, via this amalgamated file.. +#include "../../../juce_amalgamated.mm" + +/* NB. A handy tip is that if you're doing a lot of debugging into the juce code, then stepping through + the amalgamated file can be slow or impossible for the debugger. But if you use the following line + instead of the one above, then it makes it a lot easier.. +*/ +//#include "../../../src/juce_amalgamated_template.cpp" \ No newline at end of file diff --git a/extras/juce demo/build/win32_vc6/jucedemo.dsp b/extras/juce demo/build/win32_vc6/jucedemo.dsp index 8bc5c9ea1b..99c1105812 100644 --- a/extras/juce demo/build/win32_vc6/jucedemo.dsp +++ b/extras/juce demo/build/win32_vc6/jucedemo.dsp @@ -149,10 +149,6 @@ SOURCE=..\..\src\BinaryData.cpp # End Source File # Begin Source File -SOURCE=..\..\src\juce_LibrarySource.cpp -# End Source File -# Begin Source File - SOURCE=..\..\src\jucedemo_headers.h # End Source File # Begin Source File diff --git a/extras/juce demo/src/juce_LibrarySource.mm b/extras/juce demo/src/juce_LibrarySource.mm index fac774c6cb..24dcc223c6 100644 --- a/extras/juce demo/src/juce_LibrarySource.mm +++ b/extras/juce demo/src/juce_LibrarySource.mm @@ -1,21 +1,20 @@ - -/* - This file includes the entire juce source tree via the amalgamated file. - - You could add the amalgamated file directly to your project, but doing it - like this allows you to put your app's config settings in the - juce_AppConfig.h file and have them applied to both the juce headers and - the source code. -*/ - -#include "juce_AppConfig.h" - -// This is where all the juce code gets included, via this amalgamated file.. -#include "../../../juce_amalgamated.mm" - - -/* NB. A handy tip is that if you're doing a lot of debugging into the juce code, then stepping through - the amalgamated file can be slow or impossible for the debugger. But if you use the following line - instead of the one above, then it makes it a lot easier.. -*/ -//#include "../../../src/juce_amalgamated_template.cpp" + +/* + This file includes the entire juce source tree via the amalgamated file. + + You could add the amalgamated file directly to your project, but doing it + like this allows you to put your app's config settings in the + juce_AppConfig.h file and have them applied to both the juce headers and + the source code. +*/ + +#include "juce_AppConfig.h" + +// This is where all the juce code gets included, via this amalgamated file.. +#include "../../../juce_amalgamated.mm" + +/* NB. A handy tip is that if you're doing a lot of debugging into the juce code, then stepping through + the amalgamated file can be slow or impossible for the debugger. But if you use the following line + instead of the one above, then it makes it a lot easier.. +*/ +//#include "../../../src/juce_amalgamated_template.cpp" diff --git a/extras/the jucer/build/mac/Jucer.xcodeproj/project.pbxproj b/extras/the jucer/build/mac/Jucer.xcodeproj/project.pbxproj index 19bdbbfe95..8c7b6ddb0a 100644 --- a/extras/the jucer/build/mac/Jucer.xcodeproj/project.pbxproj +++ b/extras/the jucer/build/mac/Jucer.xcodeproj/project.pbxproj @@ -550,6 +550,8 @@ C0E91AC608A95435008D54AB /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1)"; + ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1 = "ppc i386"; COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_FIX_AND_CONTINUE = YES; @@ -558,6 +560,7 @@ INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Applications"; PRODUCT_NAME = Jucer; + SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; WRAPPER_EXTENSION = app; }; name = Debug; @@ -565,6 +568,8 @@ C0E91AC708A95435008D54AB /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1)"; + ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1 = "ppc i386"; DEAD_CODE_STRIPPING = YES; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_MODEL_TUNING = G5; @@ -572,6 +577,7 @@ INSTALL_PATH = "$(HOME)/Applications"; ONLY_LINK_ESSENTIAL_SYMBOLS = YES; PRODUCT_NAME = Jucer; + SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; STRIP_INSTALLED_PRODUCT = YES; WRAPPER_EXTENSION = app; }; diff --git a/extras/the jucer/src/juce_LibrarySource.mm b/extras/the jucer/src/juce_LibrarySource.mm index 8e2b658e82..429beb2475 100644 --- a/extras/the jucer/src/juce_LibrarySource.mm +++ b/extras/the jucer/src/juce_LibrarySource.mm @@ -9,4 +9,12 @@ */ #include "juce_AppConfig.h" + +// This is where all the juce code gets included, via this amalgamated file.. #include "../../../juce_amalgamated.mm" + +/* NB. A handy tip is that if you're doing a lot of debugging into the juce code, then stepping through + the amalgamated file can be slow or impossible for the debugger. But if you use the following line + instead of the one above, then it makes it a lot easier.. +*/ +//#include "../../../src/juce_amalgamated_template.cpp" diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 3f3291090c..c5c5e73900 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -205996,7 +205996,9 @@ namespace pnglibNamespace #endif /* PNG_SETJMP_SUPPORTED */ #ifdef BSD +#if ! JUCE_MAC # include +#endif #else # include #endif @@ -254530,7 +254532,7 @@ void SystemStats::initialiseStats() throw() { initialised = true; - // etremely annoying: adding this line stops the apple menu items from working. Of + // extremely annoying: adding this line stops the apple menu items from working. Of // course, not adding it means that carbon windows (e.g. in plugins) won't get // any events. //NSApplicationLoad(); @@ -254559,42 +254561,6 @@ void SystemStats::initialiseStats() throw() } } -static const String getCpuInfo (const char* key, bool lastOne = false) throw() -{ - String info; - char buf [256]; - - FILE* f = fopen ("/proc/cpuinfo", "r"); - - while (f != 0 && fgets (buf, sizeof(buf), f)) - { - if (strncmp (buf, key, strlen (key)) == 0) - { - char* p = buf; - - while (*p && *p != '\n') - ++p; - - if (*p != 0) - *p = 0; - - p = buf; - - while (*p != 0 && *p != ':') - ++p; - - if (*p != 0 && *(p + 1) != 0) - info = p + 2; - - if (! lastOne) - break; - } - } - - fclose (f); - return info; -} - SystemStats::OperatingSystemType SystemStats::getOperatingSystemType() throw() { return MacOSX; @@ -254617,15 +254583,11 @@ bool SystemStats::isOperatingSystem64Bit() throw() int SystemStats::getMemorySizeInMegabytes() throw() { -#if MACOS_10_4_OR_EARLIER - long bytes; - if (Gestalt (gestaltPhysicalRAMSize, &bytes) == noErr) - return (int) (((unsigned long) bytes) / (1024 * 1024)); - - return 0; -#else - return (int) ([[NSProcessInfo processInfo] physicalMemory] / (1024 * 1024)); -#endif + uint64 mem = 0; + size_t memSize = sizeof (mem); + int mib[] = { CTL_HW, HW_MEMSIZE }; + sysctl (mib, 2, &mem, &memSize, 0, 0); + return mem / (1024 * 1024); } bool SystemStats::hasMMX() throw() @@ -254677,11 +254639,16 @@ const String SystemStats::getCpuVendor() throw() int SystemStats::getCpuSpeedInMegaherz() throw() { -#if MACOS_10_4_OR_EARLIER - return GetCPUSpeed(); -#else - return roundDoubleToInt (getCpuInfo ("cpu MHz").getDoubleValue()); + uint64 speedHz = 0; + size_t speedSize = sizeof (speedHz); + int mib[] = { CTL_HW, HW_CPU_FREQ }; + sysctl (mib, 2, &speedHz, &speedSize, 0, 0); + +#if JUCE_BIG_ENDIAN + if (speedSize == 4) + speedHz >>= 32; #endif + return speedHz / 1000000; } int SystemStats::getNumCpus() throw() @@ -260711,7 +260678,7 @@ const StringArray Font::findAllTypefaceNames() throw() const ScopedAutoReleasePool pool; NSArray* fonts = [[NSFontManager sharedFontManager] availableFontFamilies]; - for (int i = 0; i < [fonts count]; ++i) + for (unsigned int i = 0; i < [fonts count]; ++i) names.add (nsStringToJuce ((NSString*) [fonts objectAtIndex: i])); names.sort (true); diff --git a/src/juce_appframework/gui/graphics/imaging/image_file_formats/pnglib/pngconf.h b/src/juce_appframework/gui/graphics/imaging/image_file_formats/pnglib/pngconf.h index 51629ee653..c379da888a 100644 --- a/src/juce_appframework/gui/graphics/imaging/image_file_formats/pnglib/pngconf.h +++ b/src/juce_appframework/gui/graphics/imaging/image_file_formats/pnglib/pngconf.h @@ -360,7 +360,9 @@ #endif /* PNG_SETJMP_SUPPORTED */ #ifdef BSD +#if ! JUCE_MAC # include +#endif #else # include #endif