1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-26 02:14:22 +00:00

Changed some obj-C literals to avoid cross-linkage problems in plugins. More introjucer work.

This commit is contained in:
Julian Storer 2011-07-07 22:16:51 +01:00
parent 0db8d0403b
commit cf4ecfacac
18 changed files with 236 additions and 215 deletions

View file

@ -254,7 +254,7 @@ END_JUCE_NAMESPACE
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
NSNumber* hosttime = (NSNumber*) [sampleBuffer attributeForKey: QTSampleBufferHostTimeAttribute];
#else
NSNumber* hosttime = (NSNumber*) [sampleBuffer attributeForKey: @"hostTime"];
NSNumber* hosttime = (NSNumber*) [sampleBuffer attributeForKey: nsStringLiteral ("hostTime")];
#endif
int64 presentationTime = (hosttime != nil)
@ -353,10 +353,10 @@ void CameraDevice::startRecordingToFile (const File& file, int quality)
if ([mediaType isEqualToString: QTMediaTypeVideo])
options = [QTCompressionOptions compressionOptionsWithIdentifier:
quality >= 1 ? @"QTCompressionOptionsSD480SizeH264Video"
: @"QTCompressionOptions240SizeH264Video"];
quality >= 1 ? nsStringLiteral ("QTCompressionOptionsSD480SizeH264Video")_
nsStringLiteral ("QTCompressionOptions240SizeH264Video")];
else if ([mediaType isEqualToString: QTMediaTypeSound])
options = [QTCompressionOptions compressionOptionsWithIdentifier: @"QTCompressionOptionsHighQualityAACAudio"];
options = [QTCompressionOptions compressionOptionsWithIdentifier: nsStringLiteral ("QTCompressionOptionsHighQualityAACAudio")];
[d->fileOutput setCompressionOptions: options forConnection: connection];
}

View file

@ -264,7 +264,7 @@ String File::getVersion() const
if (info != nil)
{
NSString* name = [info valueForKey: @"CFBundleShortVersionString"];
NSString* name = [info valueForKey: nsStringLiteral ("CFBundleShortVersionString")];
if (name != nil)
result = nsStringToJuce (name);
@ -307,7 +307,7 @@ bool File::moveToTrash() const
return [[NSWorkspace sharedWorkspace]
performFileOperation: NSWorkspaceRecycleOperation
source: [p stringByDeletingLastPathComponent]
destination: @""
destination: nsEmptyString()
files: [NSArray arrayWithObject: [p lastPathComponent]]
tag: nil ];
#endif
@ -433,7 +433,7 @@ void File::revealToUser() const
{
#if ! JUCE_IOS
if (exists())
[[NSWorkspace sharedWorkspace] selectFile: juceStringToNS (getFullPathName()) inFileViewerRootedAtPath: @""];
[[NSWorkspace sharedWorkspace] selectFile: juceStringToNS (getFullPathName()) inFileViewerRootedAtPath: nsEmptyString()];
else if (getParentDirectory().exists())
getParentDirectory().revealToUser();
#endif

View file

@ -96,7 +96,7 @@ public:
{
NSMenuItem* item = [parent addItemWithTitle: juceStringToNS (name)
action: nil
keyEquivalent: @""];
keyEquivalent: nsEmptyString()];
[item setTag: tag];
NSMenu* sub = createMenu (child, name, menuId, tag);
@ -200,7 +200,7 @@ public:
NSString* text = juceStringToNS (iter.itemName.upToFirstOccurrenceOf ("<end>", false, true));
if (text == nil)
text = @"";
text = nsEmptyString();
if (iter.isSeparator)
{
@ -210,7 +210,7 @@ public:
{
NSMenuItem* item = [menuToAddTo addItemWithTitle: text
action: nil
keyEquivalent: @""];
keyEquivalent: nsEmptyString()];
[item setEnabled: false];
}
@ -218,7 +218,7 @@ public:
{
NSMenuItem* item = [menuToAddTo addItemWithTitle: text
action: nil
keyEquivalent: @""];
keyEquivalent: nsEmptyString()];
[item setTag: iter.itemId];
[item setEnabled: iter.isEnabled];
@ -232,7 +232,7 @@ public:
{
NSMenuItem* item = [menuToAddTo addItemWithTitle: text
action: @selector (menuItemInvoked:)
keyEquivalent: @""];
keyEquivalent: nsEmptyString()];
[item setTag: iter.itemId];
[item setEnabled: iter.isEnabled];
@ -315,7 +315,7 @@ private:
static void flashMenuBar (NSMenu* menu)
{
if ([[menu title] isEqualToString: @"Apple"])
if ([[menu title] isEqualToString: nsStringLiteral ("Apple")])
return;
[menu retain];
@ -323,7 +323,7 @@ private:
const unichar f35Key = NSF35FunctionKey;
NSString* f35String = [NSString stringWithCharacters: &f35Key length: 1];
NSMenuItem* item = [[NSMenuItem alloc] initWithTitle: @"x"
NSMenuItem* item = [[NSMenuItem alloc] initWithTitle: nsStringLiteral ("x")
action: nil
keyEquivalent: f35String];
[item setTarget: nil];
@ -480,11 +480,11 @@ namespace MainMenuHelpers
NSMenuItem* item;
// Services...
item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString (@"Services", nil)
action: nil keyEquivalent: @""];
item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString (nsStringLiteral ("Services"), nil)
action: nil keyEquivalent: nsEmptyString()];
[menu addItem: item];
[item release];
NSMenu* servicesMenu = [[NSMenu alloc] initWithTitle: @"Services"];
NSMenu* servicesMenu = [[NSMenu alloc] initWithTitle: nsStringLiteral ("Services")];
[menu setSubmenu: servicesMenu forItem: item];
[NSApp setServicesMenu: servicesMenu];
[servicesMenu release];
@ -492,20 +492,20 @@ namespace MainMenuHelpers
// Hide + Show stuff...
item = [[NSMenuItem alloc] initWithTitle: juceStringToNS ("Hide " + appName)
action: @selector (hide:) keyEquivalent: @"h"];
action: @selector (hide:) keyEquivalent: nsStringLiteral ("h")];
[item setTarget: NSApp];
[menu addItem: item];
[item release];
item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString (@"Hide Others", nil)
action: @selector (hideOtherApplications:) keyEquivalent: @"h"];
item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString (nsStringLiteral ("Hide Others"), nil)
action: @selector (hideOtherApplications:) keyEquivalent: nsStringLiteral ("h")];
[item setKeyEquivalentModifierMask: NSCommandKeyMask | NSAlternateKeyMask];
[item setTarget: NSApp];
[menu addItem: item];
[item release];
item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString (@"Show All", nil)
action: @selector (unhideAllApplications:) keyEquivalent: @""];
item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString (nsStringLiteral ("Show All"), nil)
action: @selector (unhideAllApplications:) keyEquivalent: nsEmptyString()];
[item setTarget: NSApp];
[menu addItem: item];
[item release];
@ -514,7 +514,7 @@ namespace MainMenuHelpers
// Quit item....
item = [[NSMenuItem alloc] initWithTitle: juceStringToNS ("Quit " + appName)
action: @selector (terminate:) keyEquivalent: @"q"];
action: @selector (terminate:) keyEquivalent: nsStringLiteral ("q")];
[item setTarget: NSApp];
[menu addItem: item];
@ -533,10 +533,10 @@ namespace MainMenuHelpers
{
JUCE_AUTORELEASEPOOL
NSMenu* mainMenu = [[NSMenu alloc] initWithTitle: @"MainMenu"];
NSMenuItem* item = [mainMenu addItemWithTitle: @"Apple" action: nil keyEquivalent: @""];
NSMenu* mainMenu = [[NSMenu alloc] initWithTitle: nsStringLiteral ("MainMenu")];
NSMenuItem* item = [mainMenu addItemWithTitle: nsStringLiteral ("Apple") action: nil keyEquivalent: nsEmptyString()];
NSMenu* appMenu = [[NSMenu alloc] initWithTitle: @"Apple"];
NSMenu* appMenu = [[NSMenu alloc] initWithTitle: nsStringLiteral ("Apple")];
[NSApp performSelector: @selector (setAppleMenu:) withObject: appMenu];
[mainMenu setSubmenu: appMenu forItem: item];

View file

@ -285,7 +285,7 @@ using namespace JUCE_NAMESPACE;
- (void) broadcastMessageCallback: (NSNotification*) n
{
NSDictionary* dict = (NSDictionary*) [n userInfo];
const String messageString (nsStringToJuce ((NSString*) [dict valueForKey: @"message"]));
const String messageString (nsStringToJuce ((NSString*) [dict valueForKey: nsStringLiteral ("message")]));
MessageManager::getInstance()->deliverBroadcastMessage (messageString);
}
@ -406,7 +406,7 @@ bool MessageManager::postMessageToSystemQueue (Message* message)
void MessageManager::broadcastMessage (const String& message)
{
NSDictionary* info = [NSDictionary dictionaryWithObject: juceStringToNS (message)
forKey: @"message"];
forKey: nsStringLiteral ("message")];
[[NSDistributedNotificationCenter defaultCenter] postNotificationName: AppDelegateRedirector::getBroacastEventName()
object: nil

View file

@ -1543,7 +1543,7 @@ BOOL NSViewComponentPeer::sendDragCallback (const int type, id <NSDraggingInfo>
NSPasteboard* pasteBoard = [sender draggingPasteboard];
StringArray files;
NSString* iTunesPasteboardType = @"CorePasteboardFlavorType 0x6974756E"; // 'itun'
NSString* iTunesPasteboardType = nsStringLiteral ("CorePasteboardFlavorType 0x6974756E"); // 'itun'
if (bestType == NSFilesPromisePboardType
&& [[pasteBoard types] containsObject: iTunesPasteboardType])
@ -1553,13 +1553,13 @@ BOOL NSViewComponentPeer::sendDragCallback (const int type, id <NSDraggingInfo>
if ([list isKindOfClass: [NSDictionary class]])
{
NSDictionary* iTunesDictionary = (NSDictionary*) list;
NSArray* tracks = [iTunesDictionary valueForKey: @"Tracks"];
NSArray* tracks = [iTunesDictionary valueForKey: nsStringLiteral ("Tracks")];
NSEnumerator* enumerator = [tracks objectEnumerator];
NSDictionary* track;
while ((track = [enumerator nextObject]) != nil)
{
NSURL* url = [NSURL URLWithString: [track valueForKey: @"Location"]];
NSURL* url = [NSURL URLWithString: [track valueForKey: nsStringLiteral ("Location")]];
if ([url isFileURL])
files.add (nsStringToJuce ([url path]));

View file

@ -429,7 +429,7 @@ private:
if (req == nil)
return nil;
[req setHTTPMethod: isPost ? @"POST" : @"GET"];
[req setHTTPMethod: nsStringLiteral (isPost ? "POST" : "GET")];
//[req setCachePolicy: NSURLRequestReloadIgnoringLocalAndRemoteCacheData];
StringArray headerLines;

View file

@ -123,7 +123,7 @@ static QTMovie* openMovieFromStream (InputStream* movieStream, File& movieFile)
movie = [QTMovie movieWithDataReference: [QTDataReference dataReferenceWithReferenceToData: [NSData dataWithBytes: temp.getData()
length: temp.getSize()]
name: [NSString stringWithUTF8String: suffixesToTry[i]]
MIMEType: @""]
MIMEType: nsEmptyString()]
error: nil];
if (movie != 0)

View file

@ -67,7 +67,7 @@ END_JUCE_NAMESPACE
(void) request;
(void) frame;
NSURL* url = [actionInformation valueForKey: @"WebActionOriginalURLKey"];
NSURL* url = [actionInformation valueForKey: nsStringLiteral ("WebActionOriginalURLKey")];
if (ownerComponent->pageAboutToLoad (nsStringToJuce ([url absoluteString])))
[listener use];
@ -86,8 +86,8 @@ public:
WebBrowserComponentInternal (WebBrowserComponent* owner)
{
webView = [[WebView alloc] initWithFrame: NSMakeRect (0, 0, 100.0f, 100.0f)
frameName: @""
groupName: @""];
frameName: nsEmptyString()
groupName: nsEmptyString()];
setView (webView);
clickListener = [[DownloadClickDetector alloc] initWithWebBrowserOwner: owner];
@ -112,7 +112,7 @@ public:
if (postData != nullptr && postData->getSize() > 0)
{
[r setHTTPMethod: @"POST"];
[r setHTTPMethod: nsStringLiteral ("POST")];
[r setHTTPBody: [NSData dataWithBytes: postData->getData()
length: postData->getSize()]];
}

View file

@ -104,7 +104,7 @@ void JUCE_CALLTYPE NativeMessageBox::showMessageBox (AlertWindow::AlertIconType
const String& title, const String& message,
Component* associatedComponent)
{
OSXMessageBox box (iconType, title, message, @"OK", nil, nil, 0, false);
OSXMessageBox box (iconType, title, message, nsStringLiteral ("OK"), nil, nil, 0, false);
(void) box.getResult();
}
@ -112,7 +112,7 @@ void JUCE_CALLTYPE NativeMessageBox::showMessageBoxAsync (AlertWindow::AlertIcon
const String& title, const String& message,
Component* associatedComponent)
{
new OSXMessageBox (iconType, title, message, @"OK", nil, nil, 0, true);
new OSXMessageBox (iconType, title, message, nsStringLiteral ("OK"), nil, nil, 0, true);
}
bool JUCE_CALLTYPE NativeMessageBox::showOkCancelBox (AlertWindow::AlertIconType iconType,
@ -121,7 +121,9 @@ bool JUCE_CALLTYPE NativeMessageBox::showOkCancelBox (AlertWindow::AlertIconType
ModalComponentManager::Callback* callback)
{
ScopedPointer<OSXMessageBox> mb (new OSXMessageBox (iconType, title, message,
@"OK", @"Cancel", nil, callback, callback != nullptr));
nsStringLiteral ("OK"),
nsStringLiteral ("Cancel"),
nil, callback, callback != nullptr));
if (callback == nullptr)
return mb->getResult() == 1;
@ -135,7 +137,10 @@ int JUCE_CALLTYPE NativeMessageBox::showYesNoCancelBox (AlertWindow::AlertIconTy
ModalComponentManager::Callback* callback)
{
ScopedPointer<OSXMessageBox> mb (new OSXMessageBox (iconType, title, message,
@"Yes", @"Cancel", @"No", callback, callback != nullptr));
nsStringLiteral ("Yes"),
nsStringLiteral ("Cancel"),
nsStringLiteral ("No"),
callback, callback != nullptr));
if (callback == nullptr)
return mb->getResult();

View file

@ -42,6 +42,16 @@ namespace
{
return [NSString stringWithUTF8String: s.toUTF8()];
}
NSString* nsStringLiteral (const char* const s) noexcept
{
return [NSString stringWithUTF8String: s];
}
NSString* nsEmptyString() noexcept
{
return [NSString string];
}
}