Skip to content
Permalink
Browse files

macOS: Fixed some deprecation warnings and silenced some others for t…

…he time being
  • Loading branch information...
ed95 committed Jun 24, 2019
1 parent e88228a commit bdeaeaf36832d07ab4632a6e6a3803f677bdc280
@@ -32,14 +32,6 @@ namespace juce
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnonnull" // aovid some spurious 10.11 SDK warnings

// The AudioHardwareService stuff was deprecated in 10.11 but there's no replacement yet,
// so we'll have to silence the warnings here and revisit it in a future OS version..
#if ((defined (MAC_OS_X_VERSION_10_13) && MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_13) \
|| (defined (MAC_OS_X_VERSION_10_12) && MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_12) \
|| (defined (MAC_OS_X_VERSION_10_11) && MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_11))
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif
#endif

//==============================================================================
@@ -52,19 +44,18 @@ struct SystemVol
addr.mElement = kAudioObjectPropertyElementMaster;
addr.mSelector = kAudioHardwarePropertyDefaultOutputDevice;

if (AudioHardwareServiceHasProperty (kAudioObjectSystemObject, &addr))
if (AudioObjectHasProperty (kAudioObjectSystemObject, &addr))
{
UInt32 deviceIDSize = sizeof (outputDeviceID);
OSStatus status = AudioHardwareServiceGetPropertyData (kAudioObjectSystemObject, &addr, 0,
nullptr, &deviceIDSize, &outputDeviceID);
OSStatus status = AudioObjectGetPropertyData (kAudioObjectSystemObject, &addr, 0, nullptr, &deviceIDSize, &outputDeviceID);

if (status == noErr)
{
addr.mElement = kAudioObjectPropertyElementMaster;
addr.mSelector = selector;
addr.mScope = kAudioDevicePropertyScopeOutput;

if (! AudioHardwareServiceHasProperty (outputDeviceID, &addr))
if (! AudioObjectHasProperty (outputDeviceID, &addr))
outputDeviceID = kAudioObjectUnknown;
}
}
@@ -77,8 +68,7 @@ struct SystemVol
if (outputDeviceID != kAudioObjectUnknown)
{
UInt32 size = sizeof (gain);
AudioHardwareServiceGetPropertyData (outputDeviceID, &addr,
0, nullptr, &size, &gain);
AudioObjectGetPropertyData (outputDeviceID, &addr, 0, nullptr, &size, &gain);
}

return (float) gain;
@@ -91,8 +81,7 @@ struct SystemVol
Float32 newVolume = gain;
UInt32 size = sizeof (newVolume);

return AudioHardwareServiceSetPropertyData (outputDeviceID, &addr, 0, nullptr,
size, &newVolume) == noErr;
return AudioObjectSetPropertyData (outputDeviceID, &addr, 0, nullptr, size, &newVolume) == noErr;
}

return false;
@@ -105,8 +94,7 @@ struct SystemVol
if (outputDeviceID != kAudioObjectUnknown)
{
UInt32 size = sizeof (muted);
AudioHardwareServiceGetPropertyData (outputDeviceID, &addr,
0, nullptr, &size, &muted);
AudioObjectGetPropertyData (outputDeviceID, &addr, 0, nullptr, &size, &muted);
}

return muted != 0;
@@ -119,8 +107,7 @@ struct SystemVol
UInt32 newMute = mute ? 1 : 0;
UInt32 size = sizeof (newMute);

return AudioHardwareServiceSetPropertyData (outputDeviceID, &addr, 0, nullptr,
size, &newMute) == noErr;
return AudioObjectSetPropertyData (outputDeviceID, &addr, 0, nullptr, size, &newMute) == noErr;
}

return false;
@@ -133,8 +120,7 @@ struct SystemVol
bool canSetVolume() const noexcept
{
Boolean isSettable = NO;
return AudioHardwareServiceIsPropertySettable (outputDeviceID, &addr, &isSettable) == noErr
&& isSettable;
return AudioObjectIsPropertySettable (outputDeviceID, &addr, &isSettable) == noErr && isSettable;
}
};

@@ -47,6 +47,7 @@
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#pragma clang diagnostic ignored "-Wextra-semi"
#pragma clang diagnostic ignored "-Wmissing-braces"
#pragma clang diagnostic ignored "-Wshadow-field"
#if __has_warning("-Wpragma-pack")
#pragma clang diagnostic ignored "-Wpragma-pack"
#endif
@@ -28,12 +28,20 @@
#if JUCE_MAC || JUCE_IOS

#if JUCE_IOS
#if JUCE_MODULE_AVAILABLE_juce_opengl && defined (__IPHONE_12_0) && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_12_0
#define GLES_SILENCE_DEPRECATION 1
#endif

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <CoreData/CoreData.h>
#import <MobileCoreServices/MobileCoreServices.h>
#include <sys/fcntl.h>
#else
#if JUCE_MODULE_AVAILABLE_juce_opengl && defined (MAC_OS_X_VERSION_10_14) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14
#define GL_SILENCE_DEPRECATION 1
#endif

#import <Cocoa/Cocoa.h>
#if (! defined MAC_OS_X_VERSION_10_12) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12
#define NSEventModifierFlagCommand NSCommandKeyMask
@@ -657,7 +657,7 @@ struct SIMDNativeOps<int64_t>

static forcedinline __m128i JUCE_VECTOR_CALLTYPE greaterThan (__m128i a, __m128i b) noexcept
{
#if defined(__SSE4_1__)
#if defined(__SSE4_2__)
return _mm_cmpgt_epi64 (a, b);
#else
return SIMDFallbackOps<int64_t, __m128i>::greaterThan (a, b);
@@ -717,7 +717,7 @@ struct SIMDNativeOps<uint64_t>

static forcedinline __m128i JUCE_VECTOR_CALLTYPE greaterThan (__m128i a, __m128i b) noexcept
{
#if defined(__SSE4_1__)
#if defined(__SSE4_2__)
return _mm_cmpgt_epi64 (ssign (a), ssign (b));
#else
return SIMDFallbackOps<uint64_t, __m128i>::greaterThan (a, b);
@@ -639,9 +639,10 @@ static CGBitmapInfo getCGImageFlags (const Image::PixelFormat& format)
{
if (state->fontRef != nullptr && state->fillType.isColour())
{
#if JUCE_CLANG
#if JUCE_CLANG && ! (defined (MAC_OS_X_VERSION_10_16) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_16)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#define JUCE_DEPRECATION_IGNORED 1
#endif

if (transform.isOnlyTranslation())
@@ -668,8 +669,9 @@ static CGBitmapInfo getCGImageFlags (const Image::PixelFormat& format)
CGContextRestoreGState (context);
}

#if JUCE_CLANG
#if JUCE_DEPRECATION_IGNORED
#pragma clang diagnostic pop
#undef JUCE_DEPRECATION_IGNORED
#endif
}
else
@@ -1086,7 +1086,7 @@ static UIKeyboardType getUIKeyboardType (TextInputTarget::VirtualKeyboardType ty
jassert (i < n);
i = jmin (n - 1, i);

NSNumber *value = [NSNumber numberWithInt:Orientations::convertFromJuce (orientations[i])];
NSNumber *value = [NSNumber numberWithInt: (int) Orientations::convertFromJuce (orientations[i])];
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
[value release];
}
@@ -121,7 +121,6 @@ static NSRect flippedScreenRect (NSRect r) noexcept
setAlwaysOnTop (true);

[window setContentView: view];
[window setAutodisplay: YES];
[window setAcceptsMouseMovedEvents: YES];

// We'll both retain and also release this on closing because plugin hosts can unexpectedly
@@ -808,7 +807,7 @@ void drawRect (NSRect r)
if (r.size.width < 1.0f || r.size.height < 1.0f)
return;

auto cg = (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort];
auto cg = (CGContextRef) [[NSGraphicsContext currentContext] CGContext];

if (! component.isOpaque())
CGContextClearRect (cg, CGContextGetClipBoundingBox (cg));
@@ -1245,7 +1244,7 @@ static unsigned int getNSWindowStyleMask (const int flags) noexcept

static NSArray* getSupportedDragTypes()
{
return [NSArray arrayWithObjects: NSFilenamesPboardType, NSFilesPromisePboardType, NSStringPboardType, nil];
return [NSArray arrayWithObjects: (NSString*) kUTTypeFileURL, (NSString*) kPasteboardTypeFileURLPromise, NSPasteboardTypeString, nil];
}

BOOL sendDragCallback (const int type, id <NSDraggingInfo> sender)
@@ -1260,8 +1259,8 @@ BOOL sendDragCallback (const int type, id <NSDraggingInfo> sender)
ComponentPeer::DragInfo dragInfo;
dragInfo.position.setXY ((int) p.x, (int) ([view frame].size.height - p.y));

if (contentType == NSStringPboardType)
dragInfo.text = nsStringToJuce ([pasteboard stringForType: NSStringPboardType]);
if (contentType == NSPasteboardTypeString)
dragInfo.text = nsStringToJuce ([pasteboard stringForType: NSPasteboardTypeString]);
else
dragInfo.files = getDroppedFiles (pasteboard, contentType);

@@ -1284,7 +1283,7 @@ StringArray getDroppedFiles (NSPasteboard* pasteboard, NSString* contentType)
StringArray files;
NSString* iTunesPasteboardType = nsStringLiteral ("CorePasteboardFlavorType 0x6974756E"); // 'itun'

if (contentType == NSFilesPromisePboardType
if ([contentType isEqualToString: (NSString*) kPasteboardTypeFileURLPromise]
&& [[pasteboard types] containsObject: iTunesPasteboardType])
{
id list = [pasteboard propertyListForType: iTunesPasteboardType];
@@ -1310,14 +1309,14 @@ StringArray getDroppedFiles (NSPasteboard* pasteboard, NSString* contentType)
}
else
{
id list = [pasteboard propertyListForType: NSFilenamesPboardType];
NSArray* items = [pasteboard readObjectsForClasses:@[[NSURL class]] options: nil];

if ([list isKindOfClass: [NSArray class]])
for (unsigned int i = 0; i < [items count]; ++i)
{
NSArray* items = (NSArray*) [pasteboard propertyListForType: NSFilenamesPboardType];
NSURL* url = [items objectAtIndex: i];

for (unsigned int i = 0; i < [items count]; ++i)
files.add (nsStringToJuce ((NSString*) [items objectAtIndex: i]));
if ([url isFileURL])
files.add (nsStringToJuce ([url path]));
}
}

@@ -518,8 +518,8 @@ bool juce_areThereAnyAlwaysOnTopWindows()
static void selectImageForDrawing (const Image& image)
{
[NSGraphicsContext saveGraphicsState];
[NSGraphicsContext setCurrentContext: [NSGraphicsContext graphicsContextWithGraphicsPort: juce_getImageContext (image)
flipped: false]];
[NSGraphicsContext setCurrentContext: [NSGraphicsContext graphicsContextWithCGContext: juce_getImageContext (image)
flipped: false]];
}

static void releaseImageAfterDrawing()
@@ -590,16 +590,16 @@ Image createSnapshotOfNativeWindow (void* nativeWindowHandle)
{
NSPasteboard* pb = [NSPasteboard generalPasteboard];

[pb declareTypes: [NSArray arrayWithObject: NSStringPboardType]
[pb declareTypes: [NSArray arrayWithObject: NSPasteboardTypeString]
owner: nil];

[pb setString: juceStringToNS (text)
forType: NSStringPboardType];
forType: NSPasteboardTypeString];
}

String SystemClipboard::getTextFromClipboard()
{
return nsStringToJuce ([[NSPasteboard generalPasteboard] stringForType: NSStringPboardType]);
return nsStringToJuce ([[NSPasteboard generalPasteboard] stringForType: NSPasteboardTypeString]);
}

void Process::setDockIconVisible (bool isVisible)
@@ -76,16 +76,17 @@ class SystemTrayIconComponent::Pimpl : private Timer
stopTimer();

// There's currently no good alternative to this...
#if defined __clang__ && defined (MAC_OS_X_VERSION_10_14) && MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_14
#define IGNORE_POPUP_DEPRECATION 1
#if JUCE_CLANG && ! (defined (MAC_OS_X_VERSION_10_16) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_16)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#define JUCE_DEPRECATION_IGNORED 1
#endif

[statusItem.get() popUpStatusItemMenu: m];

#if IGNORE_POPUP_DEPRECATION
#if JUCE_DEPRECATION_IGNORED
#pragma clang diagnostic pop
#undef JUCE_DEPRECATION_IGNORED
#endif

startTimer (1);
@@ -24,6 +24,12 @@
==============================================================================
*/

#if JUCE_CLANG && ! (defined (MAC_OS_X_VERSION_10_16) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_16)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#define JUCE_DEPRECATION_IGNORED 1
#endif

#if JUCE_MAC

namespace juce
@@ -359,6 +365,11 @@ void mouseMove (const MouseEvent&)
#endif
};

#if JUCE_DEPRECATION_IGNORED
#pragma clang diagnostic pop
#undef JUCE_DEPRECATION_IGNORED
#endif

//==============================================================================
WebBrowserComponent::WebBrowserComponent (bool unloadWhenHidden)
: unloadPageWhenBrowserIsHidden (unloadWhenHidden)
@@ -93,14 +93,20 @@
#undef KeyPress
#elif JUCE_IOS
#if defined (__IPHONE_7_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_7_0
#if defined (__IPHONE_12_0) && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_12_0
#define GLES_SILENCE_DEPRECATION 1
#endif
#include <OpenGLES/ES3/gl.h>
#else
#include <OpenGLES/ES2/gl.h>
#endif
#elif JUCE_MAC
#define JUCE_OPENGL3 1
#include <OpenGL/gl3.h>
#include <OpenGL/gl3ext.h>
#define JUCE_OPENGL3 1
#if defined (MAC_OS_X_VERSION_10_14) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14
#define GL_SILENCE_DEPRECATION 1
#endif
#include <OpenGL/gl3.h>
#include <OpenGL/gl3ext.h>
#elif JUCE_ANDROID
#include <android/native_window.h>
#include <android/native_window_jni.h>
@@ -27,6 +27,12 @@
namespace juce
{

#if JUCE_CLANG && ! (defined (MAC_OS_X_VERSION_10_16) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_16)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#define JUCE_DEPRECATION_IGNORED 1
#endif

class OpenGLContext::NativeContext
{
public:
@@ -205,15 +211,23 @@ class OpenGLContext::NativeContext
minSwapTimeMs = (numFramesPerSwap * 1000) / 60;

[renderContext setValues: (const GLint*) &numFramesPerSwap
#if defined (MAC_OS_X_VERSION_10_12) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12
forParameter: NSOpenGLContextParameterSwapInterval];
#else
forParameter: NSOpenGLCPSwapInterval];
#endif
return true;
}

int getSwapInterval() const
{
GLint numFrames = 0;
[renderContext getValues: &numFrames
#if defined (MAC_OS_X_VERSION_10_12) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12
forParameter: NSOpenGLContextParameterSwapInterval];
#else
forParameter: NSOpenGLCPSwapInterval];
#endif

return numFrames;
}
@@ -252,4 +266,9 @@ bool OpenGLHelpers::isContextActive()
return CGLGetCurrentContext() != CGLContextObj();
}

#if JUCE_DEPRECATION_IGNORED
#pragma clang diagnostic pop
#undef JUCE_DEPRECATION_IGNORED
#endif

} // namespace juce

0 comments on commit bdeaeaf

Please sign in to comment.
You can’t perform that action at this time.