From f316faaa04e21b1a38e6b46abf65e3cce3ea6a0b Mon Sep 17 00:00:00 2001 From: Julian Storer Date: Mon, 22 Mar 2010 21:05:42 +0000 Subject: [PATCH] Change posix juce_readFile to always return >= 0. Sorted out a casting error in carbon AU plugins. Tidied up a bunch of win32 warnings. --- .../Source/ui/jucer_DocumentEditorComponent.h | 2 +- .../Source/ui/jucer_MainWindow.h | 2 +- .../Source/ui/jucer_ProjectContentComponent.h | 2 +- extras/juce demo/Source/MainDemoWindow.cpp | 2 +- extras/juce demo/Source/demos/TableDemo.cpp | 2 +- extras/juce demo/Source/demos/WidgetsDemo.cpp | 4 +- juce_amalgamated.cpp | 302 +++++++----------- juce_amalgamated.h | 47 ++- .../juce_ApplicationCommandTarget.h | 3 +- .../formats/juce_AudioUnitPluginFormat.mm | 6 +- .../plugins/formats/juce_VSTPluginFormat.cpp | 2 +- src/gui/components/buttons/juce_Button.h | 2 +- .../components/controls/juce_TableListBox.cpp | 4 +- src/gui/components/juce_Component.cpp | 21 +- .../juce_KeyMappingEditorComponent.cpp | 2 +- .../lookandfeel/juce_OldSchoolLookAndFeel.h | 12 +- .../special/juce_MagnifierComponent.cpp | 2 +- .../special/juce_MidiKeyboardComponent.h | 2 +- .../juce_LowLevelGraphicsPostScriptRenderer.h | 16 +- .../juce_LowLevelGraphicsSoftwareRenderer.h | 8 +- src/io/files/juce_File.h | 4 +- src/native/common/juce_posix_SharedCode.h | 6 +- src/native/linux/juce_linux_Fonts.cpp | 2 +- src/native/linux/juce_linux_Windowing.cpp | 2 +- .../mac/juce_iphone_UIViewComponentPeer.mm | 2 +- .../mac/juce_mac_NSViewComponentPeer.mm | 2 +- src/native/windows/juce_win32_Files.cpp | 215 +++++-------- src/native/windows/juce_win32_Fonts.cpp | 2 +- src/native/windows/juce_win32_Threads.cpp | 28 +- src/native/windows/juce_win32_Windowing.cpp | 2 +- 30 files changed, 270 insertions(+), 438 deletions(-) diff --git a/extras/Jucer (experimental)/Source/ui/jucer_DocumentEditorComponent.h b/extras/Jucer (experimental)/Source/ui/jucer_DocumentEditorComponent.h index 061ca9a3fe..1c24eb8255 100644 --- a/extras/Jucer (experimental)/Source/ui/jucer_DocumentEditorComponent.h +++ b/extras/Jucer (experimental)/Source/ui/jucer_DocumentEditorComponent.h @@ -46,7 +46,7 @@ public: //============================================================================== ApplicationCommandTarget* getNextCommandTarget(); void getAllCommands (Array & commands); - void getCommandInfo (const CommandID commandID, ApplicationCommandInfo& result); + void getCommandInfo (CommandID commandID, ApplicationCommandInfo& result); bool perform (const InvocationInfo& info); //============================================================================== diff --git a/extras/Jucer (experimental)/Source/ui/jucer_MainWindow.h b/extras/Jucer (experimental)/Source/ui/jucer_MainWindow.h index 6094a30648..bb26facf17 100644 --- a/extras/Jucer (experimental)/Source/ui/jucer_MainWindow.h +++ b/extras/Jucer (experimental)/Source/ui/jucer_MainWindow.h @@ -74,7 +74,7 @@ public: //============================================================================== ApplicationCommandTarget* getNextCommandTarget(); void getAllCommands (Array & commands); - void getCommandInfo (const CommandID commandID, ApplicationCommandInfo& result); + void getCommandInfo (CommandID commandID, ApplicationCommandInfo& result); bool perform (const InvocationInfo& info); //============================================================================== diff --git a/extras/Jucer (experimental)/Source/ui/jucer_ProjectContentComponent.h b/extras/Jucer (experimental)/Source/ui/jucer_ProjectContentComponent.h index f41cf3c8f3..69049a04d2 100644 --- a/extras/Jucer (experimental)/Source/ui/jucer_ProjectContentComponent.h +++ b/extras/Jucer (experimental)/Source/ui/jucer_ProjectContentComponent.h @@ -61,7 +61,7 @@ public: //============================================================================== ApplicationCommandTarget* getNextCommandTarget(); void getAllCommands (Array & commands); - void getCommandInfo (const CommandID commandID, ApplicationCommandInfo& result); + void getCommandInfo (CommandID commandID, ApplicationCommandInfo& result); bool isCommandActive (const CommandID commandID); bool perform (const InvocationInfo& info); diff --git a/extras/juce demo/Source/MainDemoWindow.cpp b/extras/juce demo/Source/MainDemoWindow.cpp index cc28980a3e..9253ac547d 100644 --- a/extras/juce demo/Source/MainDemoWindow.cpp +++ b/extras/juce demo/Source/MainDemoWindow.cpp @@ -224,7 +224,7 @@ public: // This method is used when something needs to find out the details about one of the commands // that this object can perform.. - void getCommandInfo (const CommandID commandID, ApplicationCommandInfo& result) + void getCommandInfo (CommandID commandID, ApplicationCommandInfo& result) { const String generalCategory (T("General")); const String demosCategory (T("Demos")); diff --git a/extras/juce demo/Source/demos/TableDemo.cpp b/extras/juce demo/Source/demos/TableDemo.cpp index 7b127f4b2b..e21ff5eadb 100644 --- a/extras/juce demo/Source/demos/TableDemo.cpp +++ b/extras/juce demo/Source/demos/TableDemo.cpp @@ -116,7 +116,7 @@ public: // This is overloaded from TableListBoxModel, and tells us that the user has clicked a table header // to change the sort order. - void sortOrderChanged (int newSortColumnId, const bool isForwards) + void sortOrderChanged (int newSortColumnId, bool isForwards) { if (newSortColumnId != 0) { diff --git a/extras/juce demo/Source/demos/WidgetsDemo.cpp b/extras/juce demo/Source/demos/WidgetsDemo.cpp index b49d1e527c..1b659317c1 100644 --- a/extras/juce demo/Source/demos/WidgetsDemo.cpp +++ b/extras/juce demo/Source/demos/WidgetsDemo.cpp @@ -224,7 +224,7 @@ public: { } - double snapValue (double attemptedValue, const bool userIsDragging) + double snapValue (double attemptedValue, bool userIsDragging) { if (! userIsDragging) return attemptedValue; // if they're entering the value in the text-box, don't mess with it. @@ -809,7 +809,7 @@ private: ids.add (juceLogoButton); } - ToolbarItemComponent* createItem (const int itemId) + ToolbarItemComponent* createItem (int itemId) { switch (itemId) { diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 7d5addbdb4..aa118de493 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -30648,7 +30648,7 @@ public: innerWrapper->setSize (getWidth(), getHeight()); } - bool keyStateChanged (const bool) + bool keyStateChanged (bool) { return false; } @@ -30747,7 +30747,7 @@ private: AudioProcessorEditor* AudioUnitPluginInstance::createEditor() { - ScopedPointer w (new AudioUnitPluginWindowCocoa (*this, false)); + ScopedPointer w (new AudioUnitPluginWindowCocoa (*this, false)); if (! static_cast (static_cast (w))->isValid()) w = 0; @@ -30757,7 +30757,7 @@ AudioProcessorEditor* AudioUnitPluginInstance::createEditor() { w = new AudioUnitPluginWindowCarbon (*this); - if (! static_cast (static_cast (w))->isValid()) + if (! static_cast (static_cast (w))->isValid()) w = 0; } #endif @@ -32500,7 +32500,7 @@ public: } #endif - bool keyStateChanged (const bool) + bool keyStateChanged (bool) { return pluginWantsKeys; } @@ -38364,17 +38364,20 @@ void Component::setVisible (bool shouldBeVisible) } } - sendVisibilityChangeMessage(); - - if (safePointer != 0 && flags.hasHeavyweightPeerFlag) + if (safePointer != 0) { - ComponentPeer* const peer = getPeer(); + sendVisibilityChangeMessage(); - jassert (peer != 0); - if (peer != 0) + if (safePointer != 0 && flags.hasHeavyweightPeerFlag) { - peer->setVisible (shouldBeVisible); - internalHierarchyChanged(); + ComponentPeer* const peer = getPeer(); + + jassert (peer != 0); + if (peer != 0) + { + peer->setVisible (shouldBeVisible); + internalHierarchyChanged(); + } } } } @@ -40178,13 +40181,13 @@ void Component::parentSizeChanged() void Component::addComponentListener (ComponentListener* const newListener) { + jassert (isValidComponent()); componentListeners.add (newListener); } void Component::removeComponentListener (ComponentListener* const listenerToRemove) { jassert (isValidComponent()); - componentListeners.remove (listenerToRemove); } @@ -50430,7 +50433,7 @@ public: { } - void addMenuItems (PopupMenu& menu, const int columnIdClicked) + void addMenuItems (PopupMenu& menu, int columnIdClicked) { if (owner.isAutoSizeMenuOptionShown()) { @@ -50442,7 +50445,7 @@ public: TableHeaderComponent::addMenuItems (menu, columnIdClicked); } - void reactToMenuItem (const int menuReturnId, const int columnIdClicked) + void reactToMenuItem (int menuReturnId, int columnIdClicked) { if (menuReturnId == 0xf836743) { @@ -58964,7 +58967,7 @@ public: return true; } - bool keyStateChanged (const bool) + bool keyStateChanged (bool) { return true; } @@ -73522,7 +73525,7 @@ public: void setTitle (const String&) {} void setPosition (int, int) {} void setSize (int, int) {} - void setBounds (int, int, int, int, const bool) {} + void setBounds (int, int, int, int, bool) {} void setMinimised (bool) {} bool isMinimised() const { return false; } void setFullScreen (bool) {} @@ -211746,11 +211749,9 @@ void juce_setCurrentThreadName (const String& name) info.dwThreadID = GetCurrentThreadId(); info.dwFlags = 0; - #define MS_VC_EXCEPTION 0x406d1388 - __try { - RaiseException (MS_VC_EXCEPTION, 0, sizeof (info) / sizeof (ULONG_PTR), (ULONG_PTR*) &info); + RaiseException (0x406d1388 /*MS_VC_EXCEPTION*/, 0, sizeof (info) / sizeof (ULONG_PTR), (ULONG_PTR*) &info); } __except (EXCEPTION_CONTINUE_EXECUTION) {} @@ -211839,25 +211840,11 @@ void juce_repeatLastProcessPriority() switch (lastProcessPriority) { - case Process::LowPriority: - p = IDLE_PRIORITY_CLASS; - break; - - case Process::NormalPriority: - p = NORMAL_PRIORITY_CLASS; - break; - - case Process::HighPriority: - p = HIGH_PRIORITY_CLASS; - break; - - case Process::RealtimePriority: - p = REALTIME_PRIORITY_CLASS; - break; - - default: - jassertfalse // bad priority value - return; + case Process::LowPriority: p = IDLE_PRIORITY_CLASS; break; + case Process::NormalPriority: p = NORMAL_PRIORITY_CLASS; break; + case Process::HighPriority: p = HIGH_PRIORITY_CLASS; break; + case Process::RealtimePriority: p = REALTIME_PRIORITY_CLASS; break; + default: jassertfalse; return; // bad priority value } SetPriorityClass (GetCurrentProcess(), p); @@ -211992,8 +211979,12 @@ void InterProcessLock::exit() #define CSIDL_MYVIDEO 0x000e #endif -const tchar File::separator = T('\\'); -const tchar* File::separatorString = T("\\"); +#ifndef INVALID_FILE_ATTRIBUTES + #define INVALID_FILE_ATTRIBUTES ((DWORD) -1) +#endif + +const juce_wchar File::separator = T('\\'); +const juce_wchar* File::separatorString = T("\\"); bool juce_fileExists (const String& fileName, const bool dontCountDirectories) { @@ -212001,31 +211992,27 @@ bool juce_fileExists (const String& fileName, const bool dontCountDirectories) return false; const DWORD attr = GetFileAttributes (fileName); - return dontCountDirectories ? ((attr & FILE_ATTRIBUTE_DIRECTORY) == 0) - : (attr != 0xffffffff); + : (attr != INVALID_FILE_ATTRIBUTES); } bool juce_isDirectory (const String& fileName) { const DWORD attr = GetFileAttributes (fileName); - - return (attr != 0xffffffff) - && ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0); + return ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) && (attr != INVALID_FILE_ATTRIBUTES); } bool juce_canWriteToFile (const String& fileName) { const DWORD attr = GetFileAttributes (fileName); - - return ((attr & FILE_ATTRIBUTE_READONLY) == 0); + return (attr & FILE_ATTRIBUTE_READONLY) == 0; } bool juce_setFileReadOnly (const String& fileName, bool isReadOnly) { DWORD attr = GetFileAttributes (fileName); - if (attr == 0xffffffff) + if (attr == INVALID_FILE_ATTRIBUTES) return false; if (isReadOnly != juce_canWriteToFile (fileName)) @@ -212062,13 +212049,11 @@ bool File::moveToTrash() const // The string we pass in must be double null terminated.. String doubleNullTermPath (getFullPathName() + " "); - TCHAR* p = (TCHAR*) (const TCHAR*) doubleNullTermPath; + TCHAR* const p = const_cast (static_cast (doubleNullTermPath)); p [getFullPathName().length()] = 0; fos.wFunc = FO_DELETE; - fos.hwnd = (HWND) 0; fos.pFrom = p; - fos.pTo = NULL; fos.fFlags = FOF_ALLOWUNDO | FOF_NOERRORUI | FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR | FOF_RENAMEONCOLLISION; @@ -212088,9 +212073,7 @@ bool juce_copyFile (const String& source, const String& dest) void juce_createDirectory (const String& fileName) { if (! juce_fileExists (fileName, true)) - { CreateDirectory (fileName, 0); - } } // return 0 if not possible @@ -212129,29 +212112,21 @@ int juce_fileRead (void* handle, void* buffer, int size) { DWORD num = 0; ReadFile ((HANDLE) handle, buffer, size, &num, 0); - return num; + return (int) num; } int juce_fileWrite (void* handle, const void* buffer, int size) { DWORD num; - - WriteFile ((HANDLE) handle, - buffer, size, - &num, 0); - - return num; + WriteFile ((HANDLE) handle, buffer, size, &num, 0); + return (int) num; } int64 juce_fileSetPosition (void* handle, int64 pos) { LARGE_INTEGER li; li.QuadPart = pos; - li.LowPart = SetFilePointer ((HANDLE) handle, - li.LowPart, - &li.HighPart, - FILE_BEGIN); // (returns -1 if it fails) - + li.LowPart = SetFilePointer ((HANDLE) handle, li.LowPart, &li.HighPart, FILE_BEGIN); // (returns -1 if it fails) return li.QuadPart; } @@ -212159,10 +212134,7 @@ int64 juce_fileGetPosition (void* handle) { LARGE_INTEGER li; li.QuadPart = 0; - li.LowPart = SetFilePointer ((HANDLE) handle, - 0, &li.HighPart, - FILE_CURRENT); // (returns -1 if it fails) - + li.LowPart = SetFilePointer ((HANDLE) handle, 0, &li.HighPart, FILE_CURRENT); // (returns -1 if it fails) return jmax ((int64) 0, li.QuadPart); } @@ -212176,33 +212148,21 @@ int64 juce_getFileSize (const String& fileName) WIN32_FILE_ATTRIBUTE_DATA attributes; if (GetFileAttributesEx (fileName, GetFileExInfoStandard, &attributes)) - { - return (((int64) attributes.nFileSizeHigh) << 32) - | attributes.nFileSizeLow; - } + return (((int64) attributes.nFileSizeHigh) << 32) | attributes.nFileSizeLow; return 0; } static int64 fileTimeToTime (const FILETIME* const ft) { - // tell me if this fails! - static_jassert (sizeof (ULARGE_INTEGER) == sizeof (FILETIME)); + static_jassert (sizeof (ULARGE_INTEGER) == sizeof (FILETIME)); // tell me if this fails! -#if JUCE_GCC - return (((const ULARGE_INTEGER*) ft)->QuadPart - 116444736000000000LL) / 10000; -#else - return (((const ULARGE_INTEGER*) ft)->QuadPart - 116444736000000000) / 10000; -#endif + return (reinterpret_cast (ft)->QuadPart - literal64bit (116444736000000000)) / 10000; } static void timeToFileTime (const int64 time, FILETIME* const ft) { -#if JUCE_GCC - ((ULARGE_INTEGER*) ft)->QuadPart = time * 10000 + 116444736000000000LL; -#else - ((ULARGE_INTEGER*) ft)->QuadPart = time * 10000 + 116444736000000000; -#endif + reinterpret_cast (ft)->QuadPart = time * 10000 + literal64bit (116444736000000000); } void juce_getFileTimes (const String& fileName, @@ -212229,26 +212189,21 @@ bool juce_setFileTimes (const String& fileName, int64 accessTime, int64 creationTime) { - FILETIME m, a, c; - - if (modificationTime > 0) - timeToFileTime (modificationTime, &m); - - if (accessTime > 0) - timeToFileTime (accessTime, &a); - - if (creationTime > 0) - timeToFileTime (creationTime, &c); - void* const h = juce_fileOpen (fileName, true); bool ok = false; if (h != 0) { + FILETIME m, a, c; + timeToFileTime (modificationTime, &m); + timeToFileTime (accessTime, &a); + timeToFileTime (creationTime, &c); + ok = SetFileTime ((HANDLE) h, - (creationTime > 0) ? &c : 0, - (accessTime > 0) ? &a : 0, - (modificationTime > 0) ? &m : 0) != 0; + creationTime > 0 ? &c : 0, + accessTime > 0 ? &a : 0, + modificationTime > 0 ? &m : 0) != 0; + juce_fileClose (h); } @@ -212263,7 +212218,7 @@ const StringArray juce_getFileSystemRoots() buffer[1] = 0; GetLogicalDriveStrings (2048, buffer); - TCHAR* n = buffer; + const TCHAR* n = buffer; StringArray roots; while (*n != 0) @@ -212271,46 +212226,45 @@ const StringArray juce_getFileSystemRoots() roots.add (String (n)); while (*n++ != 0) - { - } + {} } roots.sort (true); return roots; } +static const String getDriveFromPath (const String& path) +{ + if (path.isNotEmpty() && path[1] == T(':')) + return path.substring (0, 2) + T("\\"); + + return path; +} + const String juce_getVolumeLabel (const String& filenameOnVolume, int& volumeSerialNumber) { - TCHAR n [4]; - n[0] = *(const TCHAR*) filenameOnVolume; - n[1] = L':'; - n[2] = L'\\'; - n[3] = 0; - - TCHAR dest [64]; + TCHAR dest[64]; DWORD serialNum; - if (! GetVolumeInformation (n, dest, 64, (DWORD*) &serialNum, 0, 0, 0, 0)) + if (! GetVolumeInformation (getDriveFromPath (filenameOnVolume), dest, + numElementsInArray (dest), &serialNum, 0, 0, 0, 0)) { dest[0] = 0; serialNum = 0; } volumeSerialNumber = serialNum; - return String (dest); + return dest; } -static int64 getDiskSpaceInfo (String fn, const bool total) +static int64 getDiskSpaceInfo (const String& path, const bool total) { - if (fn[1] == T(':')) - fn = fn.substring (0, 2) + T("\\"); - ULARGE_INTEGER spc, tot, totFree; - if (GetDiskFreeSpaceEx (fn, &spc, &tot, &totFree)) - return (int64) (total ? tot.QuadPart - : spc.QuadPart); + if (GetDiskFreeSpaceEx (getDriveFromPath (path), &spc, &tot, &totFree)) + return total ? (int64) tot.QuadPart + : (int64) spc.QuadPart; return 0; } @@ -212325,15 +212279,9 @@ int64 File::getVolumeTotalSize() const return getDiskSpaceInfo (getFullPathName(), true); } -static unsigned int getWindowsDriveType (const String& fileName) +static unsigned int getWindowsDriveType (const String& path) { - TCHAR n[4]; - n[0] = *(const TCHAR*) fileName; - n[1] = L':'; - n[2] = L'\\'; - n[3] = 0; - - return GetDriveType (n); + return GetDriveType (getDriveFromPath (path)); } bool File::isOnCDRomDrive() const @@ -212348,15 +212296,10 @@ bool File::isOnHardDisk() const const unsigned int n = getWindowsDriveType (getFullPathName()); - if (fullPath.toLowerCase()[0] <= 'b' - && fullPath[1] == T(':')) - { + if (fullPath.toLowerCase()[0] <= 'b' && fullPath[1] == T(':')) return n != DRIVE_REMOVABLE; - } else - { return n != DRIVE_CDROM && n != DRIVE_REMOTE; - } } bool File::isOnRemovableDrive() const @@ -212376,7 +212319,7 @@ static const File juce_getSpecialFolderPath (int type) { WCHAR path [MAX_PATH + 256]; - if (SHGetSpecialFolderPath (0, path, type, 0)) + if (SHGetSpecialFolderPath (0, path, type, FALSE)) return File (String (path)); return File::nonexistent; @@ -212388,49 +212331,26 @@ const File JUCE_CALLTYPE File::getSpecialLocation (const SpecialLocationType typ switch (type) { - case userHomeDirectory: - csidlType = CSIDL_PROFILE; - break; + case userHomeDirectory: csidlType = CSIDL_PROFILE; break; + case userDocumentsDirectory: csidlType = CSIDL_PERSONAL; break; + case userDesktopDirectory: csidlType = CSIDL_DESKTOP; break; + case userApplicationDataDirectory: csidlType = CSIDL_APPDATA; break; + case commonApplicationDataDirectory: csidlType = CSIDL_COMMON_APPDATA; break; + case globalApplicationsDirectory: csidlType = CSIDL_PROGRAM_FILES; break; + case userMusicDirectory: csidlType = CSIDL_MYMUSIC; break; + case userMoviesDirectory: csidlType = CSIDL_MYVIDEO; break; - case userDocumentsDirectory: - csidlType = CSIDL_PERSONAL; - break; - - case userDesktopDirectory: - csidlType = CSIDL_DESKTOP; - break; - - case userApplicationDataDirectory: - csidlType = CSIDL_APPDATA; - break; - - case commonApplicationDataDirectory: - csidlType = CSIDL_COMMON_APPDATA; - break; - - case globalApplicationsDirectory: - csidlType = CSIDL_PROGRAM_FILES; - break; - - case userMusicDirectory: - csidlType = CSIDL_MYMUSIC; - break; - - case userMoviesDirectory: - csidlType = CSIDL_MYVIDEO; - break; - - case tempDirectory: + case tempDirectory: { WCHAR dest [2048]; dest[0] = 0; - GetTempPath (2048, dest); + GetTempPath (numElementsInArray (dest), dest); return File (String (dest)); } - case invokedExecutableFile: - case currentExecutableFile: - case currentApplicationFile: + case invokedExecutableFile: + case currentExecutableFile: + case currentApplicationFile: { HINSTANCE moduleHandle = (HINSTANCE) PlatformUtilities::getCurrentModuleInstanceHandle(); @@ -212441,9 +212361,9 @@ const File JUCE_CALLTYPE File::getSpecialLocation (const SpecialLocationType typ } break; - default: - jassertfalse // unknown type? - return File::nonexistent; + default: + jassertfalse // unknown type? + return File::nonexistent; } return juce_getSpecialFolderPath (csidlType); @@ -212468,7 +212388,7 @@ const String File::getVersion() const DWORD handle = 0; DWORD bufferSize = GetFileVersionInfoSize (getFullPathName(), &handle); - HeapBlock buffer; + HeapBlock buffer; buffer.calloc (bufferSize); if (GetFileVersionInfo (getFullPathName(), 0, bufferSize, buffer)) @@ -212478,9 +212398,9 @@ const String File::getVersion() const if (VerQueryValue (buffer, (LPTSTR) _T("\\"), (LPVOID*) &vffi, &len)) { - result << (int) HIWORD (vffi->dwFileVersionMS) << "." - << (int) LOWORD (vffi->dwFileVersionMS) << "." - << (int) HIWORD (vffi->dwFileVersionLS) << "." + result << (int) HIWORD (vffi->dwFileVersionMS) << '.' + << (int) LOWORD (vffi->dwFileVersionMS) << '.' + << (int) HIWORD (vffi->dwFileVersionLS) << '.' << (int) LOWORD (vffi->dwFileVersionLS); } } @@ -212544,7 +212464,6 @@ static void getFindFileInfo (FindDataType& findData, if (isReadOnly != 0) *isReadOnly = ((findData.dwFileAttributes & FILE_ATTRIBUTE_READONLY) != 0); - } void* juce_findFileStart (const String& directory, const String& wildCard, String& firstResult, @@ -212594,8 +212513,7 @@ void juce_findFileClose (void* handle) FindClose (handle); } -bool juce_launchFile (const String& fileName, - const String& parameters) +bool juce_launchFile (const String& fileName, const String& parameters) { HINSTANCE hInstance = 0; @@ -214227,7 +214145,7 @@ public: repaintNowIfTransparent(); } - void setBounds (int x, int y, int w, int h, const bool isNowFullScreen) + void setBounds (int x, int y, int w, int h, bool isNowFullScreen) { fullScreen = isNowFullScreen; offsetWithinParent (x, y); @@ -216935,7 +216853,7 @@ public: tm.tmDefaultChar); } - bool loadGlyphIfPossible (const juce_wchar character) + bool loadGlyphIfPossible (juce_wchar character) { HDC dc = FontDCHolder::getInstance()->loadFont (name, isBold, isItalic, 0); @@ -228038,7 +227956,7 @@ void juce_fileClose (void* handle) int juce_fileRead (void* handle, void* buffer, int size) { if (handle != 0) - return (int) read ((int) (pointer_sized_int) handle, buffer, size); + return jmax (0, (int) read ((int) (pointer_sized_int) handle, buffer, size)); return 0; } @@ -228063,8 +227981,8 @@ int64 juce_fileGetPosition (void* handle) { if (handle != 0) return lseek ((int) (pointer_sized_int) handle, 0, SEEK_CUR); - else - return -1; + + return -1; } void juce_fileFlush (void* handle) @@ -230895,7 +230813,7 @@ public: } } - bool loadGlyphIfPossible (const juce_wchar character) + bool loadGlyphIfPossible (juce_wchar character) { return FreeTypeInterface::getInstance() ->addGlyphToFont (character, name, isBold, isItalic, *this); @@ -231723,7 +231641,7 @@ public: setBounds (wx, wy, w, h, false); } - void setBounds (int x, int y, int w, int h, const bool isNowFullScreen) + void setBounds (int x, int y, int w, int h, bool isNowFullScreen) { fullScreen = isNowFullScreen; @@ -238007,7 +237925,7 @@ void juce_fileClose (void* handle) int juce_fileRead (void* handle, void* buffer, int size) { if (handle != 0) - return (int) read ((int) (pointer_sized_int) handle, buffer, size); + return jmax (0, (int) read ((int) (pointer_sized_int) handle, buffer, size)); return 0; } @@ -238032,8 +237950,8 @@ int64 juce_fileGetPosition (void* handle) { if (handle != 0) return lseek ((int) (pointer_sized_int) handle, 0, SEEK_CUR); - else - return -1; + + return -1; } void juce_fileFlush (void* handle) @@ -240465,7 +240383,7 @@ public: void setTitle (const String& title); void setPosition (int x, int y); void setSize (int w, int h); - void setBounds (int x, int y, int w, int h, const bool isNowFullScreen); + void setBounds (int x, int y, int w, int h, bool isNowFullScreen); const Rectangle getBounds() const; const Rectangle getBounds (const bool global) const; @@ -245989,7 +245907,7 @@ void NSViewComponentPeer::setSize (int w, int h) setBounds (component->getX(), component->getY(), w, h, false); } -void NSViewComponentPeer::setBounds (int x, int y, int w, int h, const bool isNowFullScreen) +void NSViewComponentPeer::setBounds (int x, int y, int w, int h, bool isNowFullScreen) { fullScreen = isNowFullScreen; w = jmax (0, w); diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 27707a430c..71bd821d7b 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -4426,9 +4426,9 @@ public: bool setAsCurrentWorkingDirectory() const; - static const tchar separator; + static const juce_wchar separator; - static const tchar* separatorString; + static const juce_wchar* separatorString; static const String createLegalFileName (const String& fileNameToFix); @@ -12858,8 +12858,7 @@ public: virtual void getAllCommands (Array & commands) = 0; - virtual void getCommandInfo (const CommandID commandID, - ApplicationCommandInfo& result) = 0; + virtual void getCommandInfo (CommandID commandID, ApplicationCommandInfo& result) = 0; virtual bool perform (const InvocationInfo& info) = 0; @@ -15930,7 +15929,7 @@ protected: void mouseUp (const MouseEvent& e); bool keyPressed (const KeyPress& key); bool keyPressed (const KeyPress& key, Component* originatingComponent); - bool keyStateChanged (const bool isKeyDown, Component* originatingComponent); + bool keyStateChanged (bool isKeyDown, Component* originatingComponent); void paint (Graphics& g); void parentHierarchyChanged(); void focusGained (FocusChangeType cause); @@ -25182,10 +25181,10 @@ public: virtual void drawTickBox (Graphics& g, Component& component, float x, float y, float w, float h, - const bool ticked, - const bool isEnabled, - const bool isMouseOverButton, - const bool isButtonDown); + bool ticked, + bool isEnabled, + bool isMouseOverButton, + bool isButtonDown); virtual void drawProgressBar (Graphics& g, ProgressBar& progressBar, int width, int height, @@ -25222,7 +25221,7 @@ public: MenuBarComponent& menuBar); virtual void drawComboBox (Graphics& g, int width, int height, - const bool isButtonDown, + bool isButtonDown, int buttonX, int buttonY, int buttonW, int buttonH, ComboBox& box); @@ -25240,7 +25239,7 @@ public: virtual int getSliderThumbRadius (Slider& slider); - virtual Button* createSliderButton (const bool isIncrement); + virtual Button* createSliderButton (bool isIncrement); virtual ImageEffectFilter* getSliderEffect(); @@ -26473,7 +26472,7 @@ public: void mouseExit (const MouseEvent& e); void mouseWheelMove (const MouseEvent& e, float wheelIncrementX, float wheelIncrementY); void timerCallback(); - bool keyStateChanged (const bool isKeyDown); + bool keyStateChanged (bool isKeyDown); void focusLost (FocusChangeType cause); void handleNoteOn (MidiKeyboardState* source, int midiChannel, int midiNoteNumber, float velocity); void handleNoteOff (MidiKeyboardState* source, int midiChannel, int midiNoteNumber); @@ -27439,8 +27438,8 @@ public: LowLevelGraphicsPostScriptRenderer (OutputStream& resultingPostScript, const String& documentTitle, - const int totalWidth, - const int totalHeight); + int totalWidth, + int totalHeight); ~LowLevelGraphicsPostScriptRenderer(); @@ -27464,16 +27463,16 @@ public: void setOpacity (float opacity); void setInterpolationQuality (Graphics::ResamplingQuality quality); - void fillRect (const Rectangle& r, const bool replaceExistingContents); + void fillRect (const Rectangle& r, bool replaceExistingContents); void fillPath (const Path& path, const AffineTransform& transform); void drawImage (const Image& sourceImage, const Rectangle& srcClip, - const AffineTransform& transform, const bool fillEntireClipAsTiles); + const AffineTransform& transform, bool fillEntireClipAsTiles); void drawLine (double x1, double y1, double x2, double y2); - void drawVerticalLine (const int x, double top, double bottom); - void drawHorizontalLine (const int x, double top, double bottom); + void drawVerticalLine (int x, double top, double bottom); + void drawHorizontalLine (int x, double top, double bottom); const Font getFont(); void setFont (const Font& newFont); @@ -27507,9 +27506,9 @@ protected: void writeClip(); void writeColour (const Colour& colour); void writePath (const Path& path) const; - void writeXY (const float x, const float y) const; + void writeXY (float x, float y) const; void writeTransform (const AffineTransform& trans) const; - void writeImage (const Image& im, const int sx, const int sy, const int maxW, const int maxH) const; + void writeImage (const Image& im, int sx, int sy, int maxW, int maxH) const; LowLevelGraphicsPostScriptRenderer (const LowLevelGraphicsPostScriptRenderer& other); LowLevelGraphicsPostScriptRenderer& operator= (const LowLevelGraphicsPostScriptRenderer&); @@ -27556,16 +27555,16 @@ public: void setOpacity (float opacity); void setInterpolationQuality (Graphics::ResamplingQuality quality); - void fillRect (const Rectangle& r, const bool replaceExistingContents); + void fillRect (const Rectangle& r, bool replaceExistingContents); void fillPath (const Path& path, const AffineTransform& transform); void drawImage (const Image& sourceImage, const Rectangle& srcClip, - const AffineTransform& transform, const bool fillEntireClipAsTiles); + const AffineTransform& transform, bool fillEntireClipAsTiles); void drawLine (double x1, double y1, double x2, double y2); - void drawVerticalLine (const int x, double top, double bottom); - void drawHorizontalLine (const int x, double top, double bottom); + void drawVerticalLine (int x, double top, double bottom); + void drawHorizontalLine (int x, double top, double bottom); void setFont (const Font& newFont); const Font getFont(); diff --git a/src/application/juce_ApplicationCommandTarget.h b/src/application/juce_ApplicationCommandTarget.h index 4819fe5b1e..35f5a422c9 100644 --- a/src/application/juce_ApplicationCommandTarget.h +++ b/src/application/juce_ApplicationCommandTarget.h @@ -164,8 +164,7 @@ public: active or inactive), you should call ApplicationCommandManager::commandStatusChanged() to cause the manager to refresh its status. */ - virtual void getCommandInfo (const CommandID commandID, - ApplicationCommandInfo& result) = 0; + virtual void getCommandInfo (CommandID commandID, ApplicationCommandInfo& result) = 0; /** This must actually perform the specified command. diff --git a/src/audio/plugins/formats/juce_AudioUnitPluginFormat.mm b/src/audio/plugins/formats/juce_AudioUnitPluginFormat.mm index f870d07e53..c2e593e60b 100644 --- a/src/audio/plugins/formats/juce_AudioUnitPluginFormat.mm +++ b/src/audio/plugins/formats/juce_AudioUnitPluginFormat.mm @@ -983,7 +983,7 @@ public: } //============================================================================== - bool keyStateChanged (const bool) + bool keyStateChanged (bool) { return false; } @@ -1087,7 +1087,7 @@ private: //============================================================================== AudioProcessorEditor* AudioUnitPluginInstance::createEditor() { - ScopedPointer w (new AudioUnitPluginWindowCocoa (*this, false)); + ScopedPointer w (new AudioUnitPluginWindowCocoa (*this, false)); if (! static_cast (static_cast (w))->isValid()) w = 0; @@ -1097,7 +1097,7 @@ AudioProcessorEditor* AudioUnitPluginInstance::createEditor() { w = new AudioUnitPluginWindowCarbon (*this); - if (! static_cast (static_cast (w))->isValid()) + if (! static_cast (static_cast (w))->isValid()) w = 0; } #endif diff --git a/src/audio/plugins/formats/juce_VSTPluginFormat.cpp b/src/audio/plugins/formats/juce_VSTPluginFormat.cpp index 5c58c7352c..4cb77cdc6a 100644 --- a/src/audio/plugins/formats/juce_VSTPluginFormat.cpp +++ b/src/audio/plugins/formats/juce_VSTPluginFormat.cpp @@ -1263,7 +1263,7 @@ public: #endif //============================================================================== - bool keyStateChanged (const bool) + bool keyStateChanged (bool) { return pluginWantsKeys; } diff --git a/src/gui/components/buttons/juce_Button.h b/src/gui/components/buttons/juce_Button.h index 6ff2e26262..3875421ea7 100644 --- a/src/gui/components/buttons/juce_Button.h +++ b/src/gui/components/buttons/juce_Button.h @@ -448,7 +448,7 @@ protected: /** @internal */ bool keyPressed (const KeyPress& key, Component* originatingComponent); /** @internal */ - bool keyStateChanged (const bool isKeyDown, Component* originatingComponent); + bool keyStateChanged (bool isKeyDown, Component* originatingComponent); /** @internal */ void paint (Graphics& g); /** @internal */ diff --git a/src/gui/components/controls/juce_TableListBox.cpp b/src/gui/components/controls/juce_TableListBox.cpp index 05b920fe68..e46d881c4c 100644 --- a/src/gui/components/controls/juce_TableListBox.cpp +++ b/src/gui/components/controls/juce_TableListBox.cpp @@ -276,7 +276,7 @@ public: { } - void addMenuItems (PopupMenu& menu, const int columnIdClicked) + void addMenuItems (PopupMenu& menu, int columnIdClicked) { if (owner.isAutoSizeMenuOptionShown()) { @@ -288,7 +288,7 @@ public: TableHeaderComponent::addMenuItems (menu, columnIdClicked); } - void reactToMenuItem (const int menuReturnId, const int columnIdClicked) + void reactToMenuItem (int menuReturnId, int columnIdClicked) { if (menuReturnId == 0xf836743) { diff --git a/src/gui/components/juce_Component.cpp b/src/gui/components/juce_Component.cpp index bedab607ea..b805de63a4 100644 --- a/src/gui/components/juce_Component.cpp +++ b/src/gui/components/juce_Component.cpp @@ -169,17 +169,20 @@ void Component::setVisible (bool shouldBeVisible) } } - sendVisibilityChangeMessage(); - - if (safePointer != 0 && flags.hasHeavyweightPeerFlag) + if (safePointer != 0) { - ComponentPeer* const peer = getPeer(); + sendVisibilityChangeMessage(); - jassert (peer != 0); - if (peer != 0) + if (safePointer != 0 && flags.hasHeavyweightPeerFlag) { - peer->setVisible (shouldBeVisible); - internalHierarchyChanged(); + ComponentPeer* const peer = getPeer(); + + jassert (peer != 0); + if (peer != 0) + { + peer->setVisible (shouldBeVisible); + internalHierarchyChanged(); + } } } } @@ -2009,13 +2012,13 @@ void Component::parentSizeChanged() void Component::addComponentListener (ComponentListener* const newListener) { + jassert (isValidComponent()); componentListeners.add (newListener); } void Component::removeComponentListener (ComponentListener* const listenerToRemove) { jassert (isValidComponent()); - componentListeners.remove (listenerToRemove); } diff --git a/src/gui/components/keyboard/juce_KeyMappingEditorComponent.cpp b/src/gui/components/keyboard/juce_KeyMappingEditorComponent.cpp index 9127fef16a..09a69bab65 100644 --- a/src/gui/components/keyboard/juce_KeyMappingEditorComponent.cpp +++ b/src/gui/components/keyboard/juce_KeyMappingEditorComponent.cpp @@ -449,7 +449,7 @@ public: return true; } - bool keyStateChanged (const bool) + bool keyStateChanged (bool) { return true; } diff --git a/src/gui/components/lookandfeel/juce_OldSchoolLookAndFeel.h b/src/gui/components/lookandfeel/juce_OldSchoolLookAndFeel.h index d55df2d203..25586de864 100644 --- a/src/gui/components/lookandfeel/juce_OldSchoolLookAndFeel.h +++ b/src/gui/components/lookandfeel/juce_OldSchoolLookAndFeel.h @@ -62,10 +62,10 @@ public: virtual void drawTickBox (Graphics& g, Component& component, float x, float y, float w, float h, - const bool ticked, - const bool isEnabled, - const bool isMouseOverButton, - const bool isButtonDown); + bool ticked, + bool isEnabled, + bool isMouseOverButton, + bool isButtonDown); //============================================================================== virtual void drawProgressBar (Graphics& g, ProgressBar& progressBar, @@ -108,7 +108,7 @@ public: //============================================================================== virtual void drawComboBox (Graphics& g, int width, int height, - const bool isButtonDown, + bool isButtonDown, int buttonX, int buttonY, int buttonW, int buttonH, ComboBox& box); @@ -127,7 +127,7 @@ public: virtual int getSliderThumbRadius (Slider& slider); - virtual Button* createSliderButton (const bool isIncrement); + virtual Button* createSliderButton (bool isIncrement); virtual ImageEffectFilter* getSliderEffect(); diff --git a/src/gui/components/special/juce_MagnifierComponent.cpp b/src/gui/components/special/juce_MagnifierComponent.cpp index 52d52284b7..e47fce3986 100644 --- a/src/gui/components/special/juce_MagnifierComponent.cpp +++ b/src/gui/components/special/juce_MagnifierComponent.cpp @@ -54,7 +54,7 @@ public: void setTitle (const String&) {} void setPosition (int, int) {} void setSize (int, int) {} - void setBounds (int, int, int, int, const bool) {} + void setBounds (int, int, int, int, bool) {} void setMinimised (bool) {} bool isMinimised() const { return false; } void setFullScreen (bool) {} diff --git a/src/gui/components/special/juce_MidiKeyboardComponent.h b/src/gui/components/special/juce_MidiKeyboardComponent.h index caecb3ef08..6777eddc56 100644 --- a/src/gui/components/special/juce_MidiKeyboardComponent.h +++ b/src/gui/components/special/juce_MidiKeyboardComponent.h @@ -292,7 +292,7 @@ public: /** @internal */ void timerCallback(); /** @internal */ - bool keyStateChanged (const bool isKeyDown); + bool keyStateChanged (bool isKeyDown); /** @internal */ void focusLost (FocusChangeType cause); /** @internal */ diff --git a/src/gui/graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.h b/src/gui/graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.h index 7785a2c686..4a5a72abc3 100644 --- a/src/gui/graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.h +++ b/src/gui/graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.h @@ -41,8 +41,8 @@ public: //============================================================================== LowLevelGraphicsPostScriptRenderer (OutputStream& resultingPostScript, const String& documentTitle, - const int totalWidth, - const int totalHeight); + int totalWidth, + int totalHeight); ~LowLevelGraphicsPostScriptRenderer(); @@ -69,16 +69,16 @@ public: void setInterpolationQuality (Graphics::ResamplingQuality quality); //============================================================================== - void fillRect (const Rectangle& r, const bool replaceExistingContents); + void fillRect (const Rectangle& r, bool replaceExistingContents); void fillPath (const Path& path, const AffineTransform& transform); void drawImage (const Image& sourceImage, const Rectangle& srcClip, - const AffineTransform& transform, const bool fillEntireClipAsTiles); + const AffineTransform& transform, bool fillEntireClipAsTiles); void drawLine (double x1, double y1, double x2, double y2); - void drawVerticalLine (const int x, double top, double bottom); - void drawHorizontalLine (const int x, double top, double bottom); + void drawVerticalLine (int x, double top, double bottom); + void drawHorizontalLine (int x, double top, double bottom); //============================================================================== const Font getFont(); @@ -114,9 +114,9 @@ protected: void writeClip(); void writeColour (const Colour& colour); void writePath (const Path& path) const; - void writeXY (const float x, const float y) const; + void writeXY (float x, float y) const; void writeTransform (const AffineTransform& trans) const; - void writeImage (const Image& im, const int sx, const int sy, const int maxW, const int maxH) const; + void writeImage (const Image& im, int sx, int sy, int maxW, int maxH) const; LowLevelGraphicsPostScriptRenderer (const LowLevelGraphicsPostScriptRenderer& other); LowLevelGraphicsPostScriptRenderer& operator= (const LowLevelGraphicsPostScriptRenderer&); diff --git a/src/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.h b/src/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.h index 30c3f270b8..a8fb24c081 100644 --- a/src/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.h +++ b/src/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.h @@ -68,16 +68,16 @@ public: void setInterpolationQuality (Graphics::ResamplingQuality quality); //============================================================================== - void fillRect (const Rectangle& r, const bool replaceExistingContents); + void fillRect (const Rectangle& r, bool replaceExistingContents); void fillPath (const Path& path, const AffineTransform& transform); void drawImage (const Image& sourceImage, const Rectangle& srcClip, - const AffineTransform& transform, const bool fillEntireClipAsTiles); + const AffineTransform& transform, bool fillEntireClipAsTiles); void drawLine (double x1, double y1, double x2, double y2); - void drawVerticalLine (const int x, double top, double bottom); - void drawHorizontalLine (const int x, double top, double bottom); + void drawVerticalLine (int x, double top, double bottom); + void drawHorizontalLine (int x, double top, double bottom); //============================================================================== void setFont (const Font& newFont); diff --git a/src/io/files/juce_File.h b/src/io/files/juce_File.h index 0c62bf293b..8f70ac8251 100644 --- a/src/io/files/juce_File.h +++ b/src/io/files/juce_File.h @@ -858,13 +858,13 @@ public: On Windows, this will be '\', on Mac/Linux, it'll be '/' */ - static const tchar separator; + static const juce_wchar separator; /** The system-specific file separator character, as a string. On Windows, this will be '\', on Mac/Linux, it'll be '/' */ - static const tchar* separatorString; + static const juce_wchar* separatorString; //============================================================================== /** Removes illegal characters from a filename. diff --git a/src/native/common/juce_posix_SharedCode.h b/src/native/common/juce_posix_SharedCode.h index 37197faafb..e69d69063e 100644 --- a/src/native/common/juce_posix_SharedCode.h +++ b/src/native/common/juce_posix_SharedCode.h @@ -323,7 +323,7 @@ void juce_fileClose (void* handle) int juce_fileRead (void* handle, void* buffer, int size) { if (handle != 0) - return (int) read ((int) (pointer_sized_int) handle, buffer, size); + return jmax (0, (int) read ((int) (pointer_sized_int) handle, buffer, size)); return 0; } @@ -348,8 +348,8 @@ int64 juce_fileGetPosition (void* handle) { if (handle != 0) return lseek ((int) (pointer_sized_int) handle, 0, SEEK_CUR); - else - return -1; + + return -1; } void juce_fileFlush (void* handle) diff --git a/src/native/linux/juce_linux_Fonts.cpp b/src/native/linux/juce_linux_Fonts.cpp index d4c2f8a7c1..979819e006 100644 --- a/src/native/linux/juce_linux_Fonts.cpp +++ b/src/native/linux/juce_linux_Fonts.cpp @@ -496,7 +496,7 @@ public: } } - bool loadGlyphIfPossible (const juce_wchar character) + bool loadGlyphIfPossible (juce_wchar character) { return FreeTypeInterface::getInstance() ->addGlyphToFont (character, name, isBold, isItalic, *this); diff --git a/src/native/linux/juce_linux_Windowing.cpp b/src/native/linux/juce_linux_Windowing.cpp index b638ce673b..5ce15f49fb 100644 --- a/src/native/linux/juce_linux_Windowing.cpp +++ b/src/native/linux/juce_linux_Windowing.cpp @@ -785,7 +785,7 @@ public: setBounds (wx, wy, w, h, false); } - void setBounds (int x, int y, int w, int h, const bool isNowFullScreen) + void setBounds (int x, int y, int w, int h, bool isNowFullScreen) { fullScreen = isNowFullScreen; diff --git a/src/native/mac/juce_iphone_UIViewComponentPeer.mm b/src/native/mac/juce_iphone_UIViewComponentPeer.mm index 3474f6f153..2c56adc26e 100644 --- a/src/native/mac/juce_iphone_UIViewComponentPeer.mm +++ b/src/native/mac/juce_iphone_UIViewComponentPeer.mm @@ -96,7 +96,7 @@ public: void setTitle (const String& title); void setPosition (int x, int y); void setSize (int w, int h); - void setBounds (int x, int y, int w, int h, const bool isNowFullScreen); + void setBounds (int x, int y, int w, int h, bool isNowFullScreen); const Rectangle getBounds() const; const Rectangle getBounds (const bool global) const; diff --git a/src/native/mac/juce_mac_NSViewComponentPeer.mm b/src/native/mac/juce_mac_NSViewComponentPeer.mm index 4482f424af..8fc09fcb8c 100644 --- a/src/native/mac/juce_mac_NSViewComponentPeer.mm +++ b/src/native/mac/juce_mac_NSViewComponentPeer.mm @@ -952,7 +952,7 @@ void NSViewComponentPeer::setSize (int w, int h) setBounds (component->getX(), component->getY(), w, h, false); } -void NSViewComponentPeer::setBounds (int x, int y, int w, int h, const bool isNowFullScreen) +void NSViewComponentPeer::setBounds (int x, int y, int w, int h, bool isNowFullScreen) { fullScreen = isNowFullScreen; w = jmax (0, w); diff --git a/src/native/windows/juce_win32_Files.cpp b/src/native/windows/juce_win32_Files.cpp index dfc086e63a..c6ded02ad5 100644 --- a/src/native/windows/juce_win32_Files.cpp +++ b/src/native/windows/juce_win32_Files.cpp @@ -37,9 +37,13 @@ #define CSIDL_MYVIDEO 0x000e #endif +#ifndef INVALID_FILE_ATTRIBUTES + #define INVALID_FILE_ATTRIBUTES ((DWORD) -1) +#endif + //============================================================================== -const tchar File::separator = T('\\'); -const tchar* File::separatorString = T("\\"); +const juce_wchar File::separator = T('\\'); +const juce_wchar* File::separatorString = T("\\"); //============================================================================== @@ -49,31 +53,27 @@ bool juce_fileExists (const String& fileName, const bool dontCountDirectories) return false; const DWORD attr = GetFileAttributes (fileName); - return dontCountDirectories ? ((attr & FILE_ATTRIBUTE_DIRECTORY) == 0) - : (attr != 0xffffffff); + : (attr != INVALID_FILE_ATTRIBUTES); } bool juce_isDirectory (const String& fileName) { const DWORD attr = GetFileAttributes (fileName); - - return (attr != 0xffffffff) - && ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0); + return ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) && (attr != INVALID_FILE_ATTRIBUTES); } bool juce_canWriteToFile (const String& fileName) { const DWORD attr = GetFileAttributes (fileName); - - return ((attr & FILE_ATTRIBUTE_READONLY) == 0); + return (attr & FILE_ATTRIBUTE_READONLY) == 0; } bool juce_setFileReadOnly (const String& fileName, bool isReadOnly) { DWORD attr = GetFileAttributes (fileName); - if (attr == 0xffffffff) + if (attr == INVALID_FILE_ATTRIBUTES) return false; if (isReadOnly != juce_canWriteToFile (fileName)) @@ -111,13 +111,11 @@ bool File::moveToTrash() const // The string we pass in must be double null terminated.. String doubleNullTermPath (getFullPathName() + " "); - TCHAR* p = (TCHAR*) (const TCHAR*) doubleNullTermPath; + TCHAR* const p = const_cast (static_cast (doubleNullTermPath)); p [getFullPathName().length()] = 0; fos.wFunc = FO_DELETE; - fos.hwnd = (HWND) 0; fos.pFrom = p; - fos.pTo = NULL; fos.fFlags = FOF_ALLOWUNDO | FOF_NOERRORUI | FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR | FOF_RENAMEONCOLLISION; @@ -137,9 +135,7 @@ bool juce_copyFile (const String& source, const String& dest) void juce_createDirectory (const String& fileName) { if (! juce_fileExists (fileName, true)) - { CreateDirectory (fileName, 0); - } } //============================================================================== @@ -180,29 +176,21 @@ int juce_fileRead (void* handle, void* buffer, int size) { DWORD num = 0; ReadFile ((HANDLE) handle, buffer, size, &num, 0); - return num; + return (int) num; } int juce_fileWrite (void* handle, const void* buffer, int size) { DWORD num; - - WriteFile ((HANDLE) handle, - buffer, size, - &num, 0); - - return num; + WriteFile ((HANDLE) handle, buffer, size, &num, 0); + return (int) num; } int64 juce_fileSetPosition (void* handle, int64 pos) { LARGE_INTEGER li; li.QuadPart = pos; - li.LowPart = SetFilePointer ((HANDLE) handle, - li.LowPart, - &li.HighPart, - FILE_BEGIN); // (returns -1 if it fails) - + li.LowPart = SetFilePointer ((HANDLE) handle, li.LowPart, &li.HighPart, FILE_BEGIN); // (returns -1 if it fails) return li.QuadPart; } @@ -210,10 +198,7 @@ int64 juce_fileGetPosition (void* handle) { LARGE_INTEGER li; li.QuadPart = 0; - li.LowPart = SetFilePointer ((HANDLE) handle, - 0, &li.HighPart, - FILE_CURRENT); // (returns -1 if it fails) - + li.LowPart = SetFilePointer ((HANDLE) handle, 0, &li.HighPart, FILE_CURRENT); // (returns -1 if it fails) return jmax ((int64) 0, li.QuadPart); } @@ -227,10 +212,7 @@ int64 juce_getFileSize (const String& fileName) WIN32_FILE_ATTRIBUTE_DATA attributes; if (GetFileAttributesEx (fileName, GetFileExInfoStandard, &attributes)) - { - return (((int64) attributes.nFileSizeHigh) << 32) - | attributes.nFileSizeLow; - } + return (((int64) attributes.nFileSizeHigh) << 32) | attributes.nFileSizeLow; return 0; } @@ -238,23 +220,14 @@ int64 juce_getFileSize (const String& fileName) //============================================================================== static int64 fileTimeToTime (const FILETIME* const ft) { - // tell me if this fails! - static_jassert (sizeof (ULARGE_INTEGER) == sizeof (FILETIME)); + static_jassert (sizeof (ULARGE_INTEGER) == sizeof (FILETIME)); // tell me if this fails! -#if JUCE_GCC - return (((const ULARGE_INTEGER*) ft)->QuadPart - 116444736000000000LL) / 10000; -#else - return (((const ULARGE_INTEGER*) ft)->QuadPart - 116444736000000000) / 10000; -#endif + return (reinterpret_cast (ft)->QuadPart - literal64bit (116444736000000000)) / 10000; } static void timeToFileTime (const int64 time, FILETIME* const ft) { -#if JUCE_GCC - ((ULARGE_INTEGER*) ft)->QuadPart = time * 10000 + 116444736000000000LL; -#else - ((ULARGE_INTEGER*) ft)->QuadPart = time * 10000 + 116444736000000000; -#endif + reinterpret_cast (ft)->QuadPart = time * 10000 + literal64bit (116444736000000000); } void juce_getFileTimes (const String& fileName, @@ -264,7 +237,6 @@ void juce_getFileTimes (const String& fileName, { WIN32_FILE_ATTRIBUTE_DATA attributes; - if (GetFileAttributesEx (fileName, GetFileExInfoStandard, &attributes)) { modificationTime = fileTimeToTime (&attributes.ftLastWriteTime); @@ -282,26 +254,21 @@ bool juce_setFileTimes (const String& fileName, int64 accessTime, int64 creationTime) { - FILETIME m, a, c; - - if (modificationTime > 0) - timeToFileTime (modificationTime, &m); - - if (accessTime > 0) - timeToFileTime (accessTime, &a); - - if (creationTime > 0) - timeToFileTime (creationTime, &c); - void* const h = juce_fileOpen (fileName, true); bool ok = false; if (h != 0) { + FILETIME m, a, c; + timeToFileTime (modificationTime, &m); + timeToFileTime (accessTime, &a); + timeToFileTime (creationTime, &c); + ok = SetFileTime ((HANDLE) h, - (creationTime > 0) ? &c : 0, - (accessTime > 0) ? &a : 0, - (modificationTime > 0) ? &m : 0) != 0; + creationTime > 0 ? &c : 0, + accessTime > 0 ? &a : 0, + modificationTime > 0 ? &m : 0) != 0; + juce_fileClose (h); } @@ -317,7 +284,7 @@ const StringArray juce_getFileSystemRoots() buffer[1] = 0; GetLogicalDriveStrings (2048, buffer); - TCHAR* n = buffer; + const TCHAR* n = buffer; StringArray roots; while (*n != 0) @@ -325,8 +292,7 @@ const StringArray juce_getFileSystemRoots() roots.add (String (n)); while (*n++ != 0) - { - } + {} } roots.sort (true); @@ -334,38 +300,38 @@ const StringArray juce_getFileSystemRoots() } //============================================================================== +static const String getDriveFromPath (const String& path) +{ + if (path.isNotEmpty() && path[1] == T(':')) + return path.substring (0, 2) + T("\\"); + + return path; +} + const String juce_getVolumeLabel (const String& filenameOnVolume, int& volumeSerialNumber) { - TCHAR n [4]; - n[0] = *(const TCHAR*) filenameOnVolume; - n[1] = L':'; - n[2] = L'\\'; - n[3] = 0; - - TCHAR dest [64]; + TCHAR dest[64]; DWORD serialNum; - if (! GetVolumeInformation (n, dest, 64, (DWORD*) &serialNum, 0, 0, 0, 0)) + if (! GetVolumeInformation (getDriveFromPath (filenameOnVolume), dest, + numElementsInArray (dest), &serialNum, 0, 0, 0, 0)) { dest[0] = 0; serialNum = 0; } volumeSerialNumber = serialNum; - return String (dest); + return dest; } -static int64 getDiskSpaceInfo (String fn, const bool total) +static int64 getDiskSpaceInfo (const String& path, const bool total) { - if (fn[1] == T(':')) - fn = fn.substring (0, 2) + T("\\"); - ULARGE_INTEGER spc, tot, totFree; - if (GetDiskFreeSpaceEx (fn, &spc, &tot, &totFree)) - return (int64) (total ? tot.QuadPart - : spc.QuadPart); + if (GetDiskFreeSpaceEx (getDriveFromPath (path), &spc, &tot, &totFree)) + return total ? (int64) tot.QuadPart + : (int64) spc.QuadPart; return 0; } @@ -381,15 +347,9 @@ int64 File::getVolumeTotalSize() const } //============================================================================== -static unsigned int getWindowsDriveType (const String& fileName) +static unsigned int getWindowsDriveType (const String& path) { - TCHAR n[4]; - n[0] = *(const TCHAR*) fileName; - n[1] = L':'; - n[2] = L'\\'; - n[3] = 0; - - return GetDriveType (n); + return GetDriveType (getDriveFromPath (path)); } bool File::isOnCDRomDrive() const @@ -404,15 +364,10 @@ bool File::isOnHardDisk() const const unsigned int n = getWindowsDriveType (getFullPathName()); - if (fullPath.toLowerCase()[0] <= 'b' - && fullPath[1] == T(':')) - { + if (fullPath.toLowerCase()[0] <= 'b' && fullPath[1] == T(':')) return n != DRIVE_REMOVABLE; - } else - { return n != DRIVE_CDROM && n != DRIVE_REMOTE; - } } bool File::isOnRemovableDrive() const @@ -433,7 +388,7 @@ static const File juce_getSpecialFolderPath (int type) { WCHAR path [MAX_PATH + 256]; - if (SHGetSpecialFolderPath (0, path, type, 0)) + if (SHGetSpecialFolderPath (0, path, type, FALSE)) return File (String (path)); return File::nonexistent; @@ -445,49 +400,26 @@ const File JUCE_CALLTYPE File::getSpecialLocation (const SpecialLocationType typ switch (type) { - case userHomeDirectory: - csidlType = CSIDL_PROFILE; - break; + case userHomeDirectory: csidlType = CSIDL_PROFILE; break; + case userDocumentsDirectory: csidlType = CSIDL_PERSONAL; break; + case userDesktopDirectory: csidlType = CSIDL_DESKTOP; break; + case userApplicationDataDirectory: csidlType = CSIDL_APPDATA; break; + case commonApplicationDataDirectory: csidlType = CSIDL_COMMON_APPDATA; break; + case globalApplicationsDirectory: csidlType = CSIDL_PROGRAM_FILES; break; + case userMusicDirectory: csidlType = CSIDL_MYMUSIC; break; + case userMoviesDirectory: csidlType = CSIDL_MYVIDEO; break; - case userDocumentsDirectory: - csidlType = CSIDL_PERSONAL; - break; - - case userDesktopDirectory: - csidlType = CSIDL_DESKTOP; - break; - - case userApplicationDataDirectory: - csidlType = CSIDL_APPDATA; - break; - - case commonApplicationDataDirectory: - csidlType = CSIDL_COMMON_APPDATA; - break; - - case globalApplicationsDirectory: - csidlType = CSIDL_PROGRAM_FILES; - break; - - case userMusicDirectory: - csidlType = CSIDL_MYMUSIC; - break; - - case userMoviesDirectory: - csidlType = CSIDL_MYVIDEO; - break; - - case tempDirectory: + case tempDirectory: { WCHAR dest [2048]; dest[0] = 0; - GetTempPath (2048, dest); + GetTempPath (numElementsInArray (dest), dest); return File (String (dest)); } - case invokedExecutableFile: - case currentExecutableFile: - case currentApplicationFile: + case invokedExecutableFile: + case currentExecutableFile: + case currentApplicationFile: { HINSTANCE moduleHandle = (HINSTANCE) PlatformUtilities::getCurrentModuleInstanceHandle(); @@ -498,9 +430,9 @@ const File JUCE_CALLTYPE File::getSpecialLocation (const SpecialLocationType typ } break; - default: - jassertfalse // unknown type? - return File::nonexistent; + default: + jassertfalse // unknown type? + return File::nonexistent; } return juce_getSpecialFolderPath (csidlType); @@ -520,7 +452,6 @@ bool File::setAsCurrentWorkingDirectory() const return SetCurrentDirectory (getFullPathName()) != FALSE; } - //============================================================================== const String File::getVersion() const { @@ -528,7 +459,7 @@ const String File::getVersion() const DWORD handle = 0; DWORD bufferSize = GetFileVersionInfoSize (getFullPathName(), &handle); - HeapBlock buffer; + HeapBlock buffer; buffer.calloc (bufferSize); if (GetFileVersionInfo (getFullPathName(), 0, bufferSize, buffer)) @@ -538,9 +469,9 @@ const String File::getVersion() const if (VerQueryValue (buffer, (LPTSTR) _T("\\"), (LPVOID*) &vffi, &len)) { - result << (int) HIWORD (vffi->dwFileVersionMS) << "." - << (int) LOWORD (vffi->dwFileVersionMS) << "." - << (int) HIWORD (vffi->dwFileVersionLS) << "." + result << (int) HIWORD (vffi->dwFileVersionMS) << '.' + << (int) LOWORD (vffi->dwFileVersionMS) << '.' + << (int) HIWORD (vffi->dwFileVersionLS) << '.' << (int) LOWORD (vffi->dwFileVersionLS); } } @@ -607,7 +538,6 @@ static void getFindFileInfo (FindDataType& findData, if (isReadOnly != 0) *isReadOnly = ((findData.dwFileAttributes & FILE_ATTRIBUTE_READONLY) != 0); - } void* juce_findFileStart (const String& directory, const String& wildCard, String& firstResult, @@ -658,8 +588,7 @@ void juce_findFileClose (void* handle) } //============================================================================== -bool juce_launchFile (const String& fileName, - const String& parameters) +bool juce_launchFile (const String& fileName, const String& parameters) { HINSTANCE hInstance = 0; diff --git a/src/native/windows/juce_win32_Fonts.cpp b/src/native/windows/juce_win32_Fonts.cpp index c1a6212174..144d5b899b 100644 --- a/src/native/windows/juce_win32_Fonts.cpp +++ b/src/native/windows/juce_win32_Fonts.cpp @@ -268,7 +268,7 @@ public: tm.tmDefaultChar); } - bool loadGlyphIfPossible (const juce_wchar character) + bool loadGlyphIfPossible (juce_wchar character) { HDC dc = FontDCHolder::getInstance()->loadFont (name, isBold, isItalic, 0); diff --git a/src/native/windows/juce_win32_Threads.cpp b/src/native/windows/juce_win32_Threads.cpp index f53154edd9..85c974163e 100644 --- a/src/native/windows/juce_win32_Threads.cpp +++ b/src/native/windows/juce_win32_Threads.cpp @@ -162,11 +162,9 @@ void juce_setCurrentThreadName (const String& name) info.dwThreadID = GetCurrentThreadId(); info.dwFlags = 0; - #define MS_VC_EXCEPTION 0x406d1388 - __try { - RaiseException (MS_VC_EXCEPTION, 0, sizeof (info) / sizeof (ULONG_PTR), (ULONG_PTR*) &info); + RaiseException (0x406d1388 /*MS_VC_EXCEPTION*/, 0, sizeof (info) / sizeof (ULONG_PTR), (ULONG_PTR*) &info); } __except (EXCEPTION_CONTINUE_EXECUTION) {} @@ -256,25 +254,11 @@ void juce_repeatLastProcessPriority() switch (lastProcessPriority) { - case Process::LowPriority: - p = IDLE_PRIORITY_CLASS; - break; - - case Process::NormalPriority: - p = NORMAL_PRIORITY_CLASS; - break; - - case Process::HighPriority: - p = HIGH_PRIORITY_CLASS; - break; - - case Process::RealtimePriority: - p = REALTIME_PRIORITY_CLASS; - break; - - default: - jassertfalse // bad priority value - return; + case Process::LowPriority: p = IDLE_PRIORITY_CLASS; break; + case Process::NormalPriority: p = NORMAL_PRIORITY_CLASS; break; + case Process::HighPriority: p = HIGH_PRIORITY_CLASS; break; + case Process::RealtimePriority: p = REALTIME_PRIORITY_CLASS; break; + default: jassertfalse; return; // bad priority value } SetPriorityClass (GetCurrentProcess(), p); diff --git a/src/native/windows/juce_win32_Windowing.cpp b/src/native/windows/juce_win32_Windowing.cpp index c0f616ff88..65ae1d0954 100644 --- a/src/native/windows/juce_win32_Windowing.cpp +++ b/src/native/windows/juce_win32_Windowing.cpp @@ -483,7 +483,7 @@ public: repaintNowIfTransparent(); } - void setBounds (int x, int y, int w, int h, const bool isNowFullScreen) + void setBounds (int x, int y, int w, int h, bool isNowFullScreen) { fullScreen = isNowFullScreen; offsetWithinParent (x, y);