22#include "CarlaMacUtils.hpp"
23#include "CarlaString.hpp"
28# define Component CocoaComponent
29# define MemoryBlock CocoaMemoryBlock
30# define Point CocoaPoint
33#import <Cocoa/Cocoa.h>
34#import <Foundation/Foundation.h>
40CARLA_BACKEND_START_NAMESPACE
44void initStandaloneApplication()
46 [[NSApplication sharedApplication] retain];
47 [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
48 [NSApp activateIgnoringOtherApps:YES];
51const char* findBinaryInBundle(
const char*
const bundleDir)
53 const CFURLRef urlRef = CFURLCreateFromFileSystemRepresentation(0, (
const UInt8*)bundleDir, (CFIndex)strlen(bundleDir),
true);
56 const CFBundleRef bundleRef = CFBundleCreate(kCFAllocatorDefault, urlRef);
59 const CFURLRef exeRef = CFBundleCopyExecutableURL(bundleRef);
62 const CFURLRef absoluteURL = CFURLCopyAbsoluteURL(exeRef);
65 const NSString* strRef = (NSString*)CFURLCopyFileSystemPath(absoluteURL, kCFURLPOSIXPathStyle);
68 static CarlaString ret;
69 ret = [strRef UTF8String];
71 CFRelease(absoluteURL);
79bool removeFileFromQuarantine(
const char*
const filename)
81 return removexattr(
filename,
"com.apple.quarantine", 0) == 0;
86AutoNSAutoreleasePool::AutoNSAutoreleasePool()
87 :
pool([NSAutoreleasePool new]) {}
89AutoNSAutoreleasePool::~AutoNSAutoreleasePool()
91 NSAutoreleasePool* rpool = (NSAutoreleasePool*)
pool;
97struct BundleLoader::PrivateData {
99 CFBundleRefNum refNum;
110 #pragma clang diagnostic push
111 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
112 CFBundleCloseBundleResourceMap(ref, refNum);
113 #pragma clang diagnostic pop
115 if (CFGetRetainCount(ref) == 1)
116 CFBundleUnloadExecutable(ref);
118 if (CFGetRetainCount(ref) > 0)
122 bool load(
const char*
const filename)
124 const CFURLRef urlRef = CFURLCreateFromFileSystemRepresentation(0, (
const UInt8*)
filename, (CFIndex)std::strlen(
filename),
true);
127 ref = CFBundleCreate(kCFAllocatorDefault, urlRef);
131 if (! CFBundleLoadExecutable(ref))
138 #pragma clang diagnostic push
139 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
140 refNum = CFBundleOpenBundleResourceMap(ref);
141 #pragma clang diagnostic pop
146BundleLoader::BundleLoader()
147 : pData(new PrivateData){}
149BundleLoader::~BundleLoader()
154bool BundleLoader::load(
const char*
const filename)
166CARLA_BACKEND_END_NAMESPACE
#define CARLA_SAFE_ASSERT_RETURN(cond, ret)
Definition CarlaDefines.h:190
#define noexcept
Definition DistrhoDefines.h:72
pool_t pool
Definition Util.cpp:167
static char filename[]
Definition features.c:5
#define const
Definition zconf.h:137