void HeadlessView::loadExtensions() { if (extensionsLoaded) { return; } #ifdef MBGL_USE_CGL gl::InitializeExtensions([](const char * name) { static CFBundleRef framework = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengl")); if (!framework) { throw std::runtime_error("Failed to load OpenGL framework."); } CFStringRef str = CFStringCreateWithCString(kCFAllocatorDefault, name, kCFStringEncodingASCII); void* symbol = CFBundleGetFunctionPointerForName(framework, str); CFRelease(str); return reinterpret_cast<gl::glProc>(symbol); }); #endif #ifdef MBGL_USE_GLX gl::InitializeExtensions([](const char * name) { return glXGetProcAddress(reinterpret_cast<const GLubyte *>(name)); }); #endif extensionsLoaded = true; }
long GetHIToolboxVersion(void) { CFBundleRef bundle; CFStringRef versStr = nil; static unsigned long version = 0; if (version != 0) return version; bundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.HIToolbox")); if (bundle) versStr = (CFStringRef) CFBundleGetValueForInfoDictionaryKey(bundle, CFSTR("CFBundleShortVersionString")); if (versStr && (CFGetTypeID(versStr) == CFStringGetTypeID())) { int major = 0, minor = 0, bugfix = 0; char sz[20]; CFStringGetCString(versStr, sz, sizeof(sz), kCFStringEncodingUTF8); sscanf(sz, "%d.%d.%d", &major, &minor, &bugfix); version = (major << 8) + (minor << 4) + bugfix; } return version; }
static_inline const char * _intlize(const char *msg, int base, char *str, size_t len) { char domain[12 +20]; CFStringRef cfstring = CFStringCreateWithCString(kCFAllocatorSystemDefault, msg, kCFStringEncodingUTF8); CFStringRef cfdomain; CFBundleRef OpenAFSBundle = CFBundleGetBundleWithIdentifier(CFSTR("org.openafs.filesystems.afs")); if (!str) { CFRelease(cfstring); return msg; } snprintf(domain, sizeof(domain), "heim_com_err%d", base); cfdomain = CFStringCreateWithCString(kCFAllocatorSystemDefault, domain, kCFStringEncodingUTF8); if (OpenAFSBundle != NULL) { CFStringRef cflocal; cflocal = CFBundleCopyLocalizedString(OpenAFSBundle, cfstring, cfstring, cfdomain); CFStringGetCString(cflocal, str, len, kCFStringEncodingUTF8); CFRelease(cflocal); } else { CFStringGetCString(cfstring, str, len, kCFStringEncodingUTF8); } CFRelease(cfstring); CFRelease(cfdomain); return str; }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ÇPROJECTNAMEÈ::GetProperty //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ComponentResult ÇPROJECTNAMEÈ::GetProperty( AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement, void * outData ) { if (inScope == kAudioUnitScope_Global) { switch (inID) { case kAudioUnitProperty_CocoaUI: { // Look for a resource in the main bundle by name and type. CFBundleRef bundle = CFBundleGetBundleWithIdentifier( CFSTR("com.Demo.audiounit.ÇPROJECTNAMEÈ") ); if (bundle == NULL) return fnfErr; CFURLRef bundleURL = CFBundleCopyResourceURL( bundle, CFSTR("CocoaViewFactory"), CFSTR("bundle"), NULL); if (bundleURL == NULL) return fnfErr; CFStringRef className = CFSTR("CocoaViewFactory"); AudioUnitCocoaViewInfo cocoaInfo = { bundleURL, className }; *((AudioUnitCocoaViewInfo *)outData) = cocoaInfo; return noErr; } } } return AUEffectBase::GetProperty (inID, inScope, inElement, outData); }
//_____________________________________________________________________________ // AUPannerBase::AUPannerBase(AudioComponentInstance inAudioUnit) : AUBase(inAudioUnit, 1, 1), mBypassEffect(false) { { CABundleLocker lock; if (!sLocalized) { CFBundleRef bundle = CFBundleGetBundleWithIdentifier( CFSTR("com.apple.audio.units.Components") ); if (bundle != NULL) { kPanner_Azimuth_Name = CFCopyLocalizedStringFromTableInBundle(kPanner_Azimuth_Name, CFSTR("AudioUnits"), bundle, CFSTR("")); kPanner_Elevation_Name = CFCopyLocalizedStringFromTableInBundle(kPanner_Elevation_Name, CFSTR("AudioUnits"), bundle, CFSTR("")); kPanner_Distance_Name = CFCopyLocalizedStringFromTableInBundle(kPanner_Distance_Name, CFSTR("AudioUnits"), bundle, CFSTR("")); kPanner_CoordScale_Name = CFCopyLocalizedStringFromTableInBundle(kPanner_CoordScale_Name, CFSTR("AudioUnits"), bundle, CFSTR("")); kPanner_RefDistance_Name = CFCopyLocalizedStringFromTableInBundle(kPanner_RefDistance_Name, CFSTR("AudioUnits"), bundle, CFSTR("")); kPanner_Gain_Name = CFCopyLocalizedStringFromTableInBundle(kPanner_Gain_Name, CFSTR("AudioUnits"), bundle, CFSTR("")); } sLocalized = true; } } CreateElements(); SetParameter(kPannerParam_Azimuth, kPannerParamDefault_Azimuth); SetParameter(kPannerParam_Elevation, kPannerParamDefault_Elevation); SetParameter(kPannerParam_Distance, kPannerParamDefault_Distance); SetParameter(kPannerParam_CoordScale, kPannerParamDefault_CoordScale); SetParameter(kPannerParam_RefDistance, kPannerParamDefault_RefDistance); SetParameter(kPannerParam_Gain, kPannerParamDefault_Gain); }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // RadioEffectUnit::RadioEffectUnit // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ RadioEffectUnit::RadioEffectUnit(AudioUnit Component) : AUEffectBase(Component) { CreateElements(); if (!bGLocalized) { // Because we are in a component, we need to load our bundle by identifier so we can access our localized strings // It is important that the string passed here exactly matches that in the Info.plist Identifier string CFBundleRef bundle = CFBundleGetBundleWithIdentifier( CFSTR("com.epicgames.audiounit.radio") ); if (bundle != NULL) { kChebyshevPowerMultiplierName = CFCopyLocalizedStringFromTableInBundle(kChebyshevPowerMultiplierName, CFSTR("Localizable"), bundle, CFSTR("")); kChebyshevPowerName = CFCopyLocalizedStringFromTableInBundle(kChebyshevPowerName, CFSTR("Localizable"), bundle, CFSTR("")); kChebyshevMultiplierName = CFCopyLocalizedStringFromTableInBundle(kChebyshevMultiplierName, CFSTR("Localizable"), bundle, CFSTR("")); kChebyshevCubedMultiplierName = CFCopyLocalizedStringFromTableInBundle(kChebyshevCubedMultiplierName, CFSTR("Localizable"), bundle, CFSTR("")); } bGLocalized = TRUE; //so never pass the test again... } GFinalBandPassFilter.Initialize( 2000.0f, 400.0f, GetSampleRate() ); SetParameter(RadioParam_ChebyshevPowerMultiplier, kDefaultValue_ChebyshevPowerMultiplier ); SetParameter(RadioParam_ChebyshevPower, kDefaultValue_ChebyshevPower ); SetParameter(RadioParam_ChebyshevMultiplier, kDefaultValue_ChebyshevMultiplier ); SetParameter(RadioParam_ChebyshevCubedMultiplier, kDefaultValue_ChebyshevCubedMultiplier ); }
static string getFrameworkFromBundle() { // Attempt to locate the Firebird.framework bundle CFBundleRef fbFramework = CFBundleGetBundleWithIdentifier(CFSTR(DARWIN_FRAMEWORK_ID)); if (fbFramework) { CFURLRef msgFileUrl = CFBundleCopyResourceURL(fbFramework, CFSTR(DARWIN_GEN_DIR), NULL, NULL); if (msgFileUrl) { CFStringRef msgFilePath = CFURLCopyFileSystemPath(msgFileUrl, kCFURLPOSIXPathStyle); if (msgFilePath) { char file_buff[MAXPATHLEN]; if (CFStringGetCString(msgFilePath, file_buff, MAXPATHLEN, kCFStringEncodingMacRoman)) { string dir = file_buff; dir += PathUtils::dir_sep; return dir; } } } } // No luck return ""; }
void CAUGuiGraphic::loadImagePNG ( char* pngFileName ) { CFBundleRef bundleRef = CFBundleGetBundleWithIdentifier(CFSTR( AU_BUNDLE_IDENTIFIER )); CGDataProviderRef provider; if ( bundleRef ) { SInt16 tmp = CurResFile(); CFStringRef fileName = ::CFStringCreateWithCString( NULL, pngFileName, kCFStringEncodingASCII ); if ( fileName != NULL ) { CFURLRef url = ::CFBundleCopyResourceURL( bundleRef, fileName, NULL, NULL ); provider = CGDataProviderCreateWithURL( url ); Image = CGImageCreateWithPNGDataProvider( provider, NULL, false, kCGRenderingIntentDefault ); CGDataProviderRelease( provider ); CFRelease( url ); CFRelease( fileName ); } else { Image = NULL; } UseResFile(tmp); } }
/************************************************************************* * * hu_XMLLoad( inResourceName, inResourceExtension ) * * Purpose: Load a resource( XML ) file into a CFPropertyListRef * * Inputs: inResourceName - name of the resource file * inResourceExtension - extension of the resource file * * Returns: CFPropertyListRef - the data */ static CFPropertyListRef hu_XMLLoad(CFStringRef inResourceName, CFStringRef inResourceExtension) { CFURLRef resFileCFURLRef; CFPropertyListRef tCFPropertyListRef = NULL; // check the main (application) bundle resFileCFURLRef = CFBundleCopyResourceURL(CFBundleGetMainBundle(), inResourceName, inResourceExtension, NULL); if ( !resFileCFURLRef ) { // check this specific (HID_Utilities framework) bundle CFBundleRef tCFBundleRef = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.HID_Utilities")); if ( tCFBundleRef ) { resFileCFURLRef = CFBundleCopyResourceURL( tCFBundleRef, inResourceName, inResourceExtension, NULL ); } } if ( !resFileCFURLRef ) { // check bundles already loaded or otherwise known to the current process CFArrayRef tCFArrayRef = CFBundleGetAllBundles(); CFIndex idx, cnt = CFArrayGetCount(tCFArrayRef); for ( idx = 0; idx < cnt; idx++ ) { CFBundleRef tCFBundleRef = (CFBundleRef) CFArrayGetValueAtIndex(tCFArrayRef, idx) ; if ( tCFBundleRef ) { resFileCFURLRef = CFBundleCopyResourceURL( tCFBundleRef, inResourceName, inResourceExtension, NULL ); if ( resFileCFURLRef ) { break; } } } } if ( resFileCFURLRef ) { tCFPropertyListRef = hu_LoadFromXMLFile(resFileCFURLRef); CFRelease(resFileCFURLRef); } return (tCFPropertyListRef); } // hu_XMLLoad
int uv__set_process_title(const char* title) { #if TARGET_OS_IPHONE return -1; #else typedef CFTypeRef (*LSGetCurrentApplicationASNType)(void); typedef OSStatus (*LSSetApplicationInformationItemType)(int, CFTypeRef, CFStringRef, CFStringRef, CFDictionaryRef*); CFBundleRef launch_services_bundle; LSGetCurrentApplicationASNType ls_get_current_application_asn; LSSetApplicationInformationItemType ls_set_application_information_item; CFStringRef* display_name_key; ProcessSerialNumber psn; CFTypeRef asn; CFStringRef display_name; OSStatus err; launch_services_bundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.LaunchServices")); if (launch_services_bundle == NULL) return -1; ls_get_current_application_asn = (LSGetCurrentApplicationASNType) CFBundleGetFunctionPointerForName(launch_services_bundle, CFSTR("_LSGetCurrentApplicationASN")); if (ls_get_current_application_asn == NULL) return -1; ls_set_application_information_item = (LSSetApplicationInformationItemType) CFBundleGetFunctionPointerForName(launch_services_bundle, CFSTR("_LSSetApplicationInformationItem")); if (ls_set_application_information_item == NULL) return -1; display_name_key = CFBundleGetDataPointerForName(launch_services_bundle, CFSTR("_kLSDisplayNameKey")); if (display_name_key == NULL || *display_name_key == NULL) return -1; /* Force the process manager to initialize. */ GetCurrentProcess(&psn); display_name = CFStringCreateWithCString(NULL, title, kCFStringEncodingUTF8); asn = ls_get_current_application_asn(); err = ls_set_application_information_item(-2, /* Magic value. */ asn, *display_name_key, display_name, NULL); return (err == noErr) ? 0 : -1; #endif /* !TARGET_OS_IPHONE */ }
CFBundleRef GetCodecBundle() { static CFBundleRef sAudioCodecBundle = 0; if (!sAudioCodecBundle) { #if TARGET_OS_WIN32 sAudioCodecBundle = CFBundleGetBundleWithIdentifier(CFSTR(kCodecBundleID)); #else sAudioCodecBundle = CFBundleGetBundleWithIdentifier(kCodecBundleID); #endif if (sAudioCodecBundle) { CFRetain(sAudioCodecBundle); } } return sAudioCodecBundle; }
String WebInspectorProxy::inspectorPageURL() const { RetainPtr<CFURLRef> htmlURLRef(AdoptCF, CFBundleCopyResourceURL(CFBundleGetBundleWithIdentifier(CFSTR("com.apple.WebKit")), CFSTR("inspector"), CFSTR("html"), CFSTR("inspector"))); if (!htmlURLRef) return String(); return String(CFURLGetString(htmlURLRef.get())); }
static void open_libgl(void) { bundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengles")); // we are always linked to OpenGLES.framework statically, so it is already loaded and could be found by id assert(bundle != NULL); CFRetain(bundle); bundleURL = CFBundleCopyBundleURL(bundle); }
CFBundleRef GetCodecBundle() { static CFBundleRef sAudioCodecBundle = 0; if (!sAudioCodecBundle) { #ifdef _MSC_VER // QuickTime 6.4 and before is broken sAudioCodecBundle = CFBundleGetBundleWithIdentifier(CFSTR(kCodecBundleID)); #else sAudioCodecBundle = CFBundleGetBundleWithIdentifier(kCodecBundleID); #endif if (sAudioCodecBundle) { CFRetain(sAudioCodecBundle); } } return sAudioCodecBundle; }
int _glfwPlatformInit( void ) { struct timeval tv; UInt32 nullDummy = 0; _glfwWin.MacWindow = NULL; _glfwWin.AGLContext = NULL; _glfwWin.WindowFunctions = NULL; _glfwWin.MouseUPP = NULL; _glfwWin.CommandUPP = NULL; _glfwWin.KeyboardUPP = NULL; _glfwWin.WindowUPP = NULL; _glfwInput.Modifiers = 0; _glfwLibs.OpenGLFramework = CFBundleGetBundleWithIdentifier( CFSTR( "com.apple.opengl" ) ); if( _glfwLibs.OpenGLFramework == NULL ) { return GL_FALSE; } _glfwDesktopVideoMode = CGDisplayCurrentMode( kCGDirectMainDisplay ); if( _glfwDesktopVideoMode == NULL ) { return GL_FALSE; } _glfwInitThreads(); if( !_glfwChangeToResourcesDirectory() ) { return GL_FALSE; } if( !_glfwInstallEventHandlers() ) { _glfwPlatformTerminate(); return GL_FALSE; } // Ugly hack to reduce the nasty jump that occurs at the first non- // sys keypress, caused by OS X loading certain meta scripts used // for lexical- and raw keycode translation - instead of letting // this happen while our application is running, we do some blunt // function calls in advance just to get the script caching out of // the way, BEFORE our window/screen is opened. These calls might // generate err return codes, but we don't care in this case. // NOTE: KCHRPtr is declared globally, because we need it later on. KCHRPtr = (void *)GetScriptVariable( smCurrentScript, smKCHRCache ); KeyTranslate( KCHRPtr, 0, &nullDummy ); UppercaseText( (char *)&nullDummy, 0, smSystemScript ); gettimeofday( &tv, NULL ); _glfwTimer.t0 = tv.tv_sec + (double) tv.tv_usec / 1000000.0; return GL_TRUE; }
/* The real guts of the description creation functionality. See the header file for the steps this function goes through to compute the description. This function can take a CF or NSError. It's called by NSError for the localizedDescription computation. */ CFStringRef _CFErrorCreateLocalizedDescription(CFErrorRef err) { // First look for kCFErrorLocalizedDescriptionKey; if non-NULL, return that as-is. CFStringRef localizedDesc = _CFErrorCopyUserInfoKey(err, kCFErrorLocalizedDescriptionKey); if (localizedDesc) return localizedDesc; #if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_WINDOWS // Cache the CF bundle since we will be using it for localized strings. CFBundleRef cfBundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.CoreFoundation")); if (!cfBundle) { // This should be rare, but has been observed in the wild, due to running out of file descriptors. Normally we might not go to such extremes, but since we want to be able to present reasonable errors even in the case of errors such as running out of file descriptors, why not. This is CFError after all. !!! Be sure to have the same logic here as below for going through various options for fetching the strings. #endif CFStringRef result = NULL, reasonOrDesc; if ((reasonOrDesc = _CFErrorCopyUserInfoKey(err, kCFErrorLocalizedFailureReasonKey))) { // First look for kCFErrorLocalizedFailureReasonKey result = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("The operation couldn\\U2019t be completed. %@"), reasonOrDesc); } else if ((reasonOrDesc = _CFErrorCopyUserInfoKey(err, kCFErrorDescriptionKey))) { // Then try kCFErrorDescriptionKey result = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("The operation couldn\\U2019t be completed. (%@ error %ld - %@)"), CFErrorGetDomain(err), (long)CFErrorGetCode(err), reasonOrDesc); } else { // Last resort, just the domain and code result = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("The operation couldn\\U2019t be completed. (%@ error %ld.)"), CFErrorGetDomain(err), (long)CFErrorGetCode(err)); } if (reasonOrDesc) CFRelease(reasonOrDesc); return result; #if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_WINDOWS } #endif #if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_WINDOWS // Then look for kCFErrorLocalizedFailureReasonKey; if there, create a full sentence from that. CFStringRef reason = _CFErrorCopyUserInfoKey(err, kCFErrorLocalizedFailureReasonKey); if (reason) { CFStringRef operationFailedStr = CFCopyLocalizedStringFromTableInBundle(CFSTR("The operation couldn\\U2019t be completed. %@"), CFSTR("Error"), cfBundle, "A generic error string indicating there was a problem. The %@ will be replaced by a second sentence which indicates why the operation failed."); CFStringRef result = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, operationFailedStr, reason); CFRelease(operationFailedStr); CFRelease(reason); return result; } // Otherwise, generate a semi-user presentable string from the domain, code, and if available, the presumably non-localized kCFErrorDescriptionKey. CFStringRef result; CFStringRef desc = _CFErrorCopyUserInfoKey(err, kCFErrorDescriptionKey); CFStringRef localizedDomain = CFCopyLocalizedStringFromTableInBundle(CFErrorGetDomain(err), CFSTR("Error"), cfBundle, "These are localized in the comment above"); if (desc) { // We have kCFErrorDescriptionKey, so include that with the error domain and code CFStringRef operationFailedStr = CFCopyLocalizedStringFromTableInBundle(CFSTR("The operation couldn\\U2019t be completed. (%@ error %ld - %@)"), CFSTR("Error"), cfBundle, "A generic error string indicating there was a problem, followed by a parenthetical sentence which indicates error domain, code, and a description when there is no other way to present an error to the user. The first %@ indicates the error domain, %ld indicates the error code, and the second %@ indicates the description; so this might become '(Mach error 42 - Server error.)' for instance."); result = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, operationFailedStr, localizedDomain, (long)CFErrorGetCode(err), desc); CFRelease(operationFailedStr); CFRelease(desc); } else { // We don't have kCFErrorDescriptionKey, so just use error domain and code CFStringRef operationFailedStr = CFCopyLocalizedStringFromTableInBundle(CFSTR("The operation couldn\\U2019t be completed. (%@ error %ld.)"), CFSTR("Error"), cfBundle, "A generic error string indicating there was a problem, followed by a parenthetical sentence which indicates error domain and code when there is no other way to present an error to the user. The %@ indicates the error domain while %ld indicates the error code; so this might become '(Mach error 42.)' for instance."); result = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, operationFailedStr, localizedDomain, (long)CFErrorGetCode(err)); CFRelease(operationFailedStr); } CFRelease(localizedDomain); return result; #endif }
kim_error kim_os_string_create_localized (kim_string *out_string, kim_string in_string) { kim_error lock_err = kim_os_library_lock_for_bundle_lookup (); kim_error err = lock_err; kim_string string = NULL; CFStringRef cfkey = NULL; if (!err && !out_string) { err = check_error (KIM_NULL_PARAMETER_ERR); } if (!err && !in_string ) { err = check_error (KIM_NULL_PARAMETER_ERR); } if (!err) { err = kim_os_string_get_cfstring (in_string, &cfkey); } if (!err && kim_library_allow_home_directory_access ()) { CFStringRef cfstring = NULL; CFBundleRef framework = CFBundleGetBundleWithIdentifier (CFSTR ("edu.mit.Kerberos")); CFBundleRef main_bundle = CFBundleGetMainBundle (); if (framework) { cfstring = CFCopyLocalizedStringFromTableInBundle (cfkey, CFSTR ("InfoPlist"), framework, ""); } if (main_bundle && !cfstring) { cfstring = CFCopyLocalizedStringFromTableInBundle (cfkey, CFSTR ("InfoPlist"), main_bundle, ""); } if (!err && cfstring) { err = kim_os_string_create_from_cfstring (&string, cfstring); } if (cfstring) { CFRelease (cfstring); } } if (!err && !string) { err = kim_string_copy (&string, in_string); } if (!err) { *out_string = string; string = NULL; } if (cfkey) { CFRelease (cfkey); } kim_string_free (&string); if (!lock_err) { kim_os_library_unlock_for_bundle_lookup (); } return check_error (err); }
kim_boolean kim_os_library_caller_uses_gui (void) { kim_boolean caller_uses_gui = 0; /* Check for the HIToolbox (Carbon) or AppKit (Cocoa). * If either is loaded, we are a GUI app! */ CFBundleRef appKitBundle = CFBundleGetBundleWithIdentifier (CFSTR ("com.apple.AppKit")); CFBundleRef hiToolBoxBundle = CFBundleGetBundleWithIdentifier (CFSTR ("com.apple.HIToolbox")); if (hiToolBoxBundle && CFBundleIsExecutableLoaded (hiToolBoxBundle)) { caller_uses_gui = 1; /* Using Carbon */ } if (appKitBundle && CFBundleIsExecutableLoaded (appKitBundle)) { caller_uses_gui = 1; /* Using Cocoa */ } return caller_uses_gui; }
static CFStringRef MapCodeToReason(uint32_t code) { static dispatch_once_t once; static CFBundleRef bundle; CFStringRef reason; dispatch_once(&once, ^{ bundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.CFOpenDirectory")); });
static void CopyUTF8toUTF16NFC(const nsACString& aSrc, nsAString& aResult) { static PRBool sChecked = PR_FALSE; static UnicodeNormalizer sUnicodeNormalizer = NULL; // CFStringNormalize was not introduced until Mac OS 10.2 if (!sChecked) { CFBundleRef carbonBundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.Carbon")); if (carbonBundle) sUnicodeNormalizer = (UnicodeNormalizer) ::CFBundleGetFunctionPointerForName(carbonBundle, CFSTR("CFStringNormalize")); sChecked = PR_TRUE; } if (!sUnicodeNormalizer) { // OS X 10.1 or earlier CopyUTF8toUTF16(aSrc, aResult); return; } const nsAFlatCString &inFlatSrc = PromiseFlatCString(aSrc); // The number of 16bit code units in a UTF-16 string will never be // larger than the number of bytes in the corresponding UTF-8 string. CFMutableStringRef inStr = ::CFStringCreateMutable(NULL, inFlatSrc.Length()); if (!inStr) { CopyUTF8toUTF16(aSrc, aResult); return; } ::CFStringAppendCString(inStr, inFlatSrc.get(), kCFStringEncodingUTF8); sUnicodeNormalizer(inStr, kCFStringNormalizationFormC); CFIndex length = CFStringGetLength(inStr); const UniChar* chars = CFStringGetCharactersPtr(inStr); if (chars) aResult.Assign(chars, length); else { nsAutoTArray<UniChar, 512> buffer; if (buffer.SetLength(length)) { CFStringGetCharacters(inStr, CFRangeMake(0, length), buffer.Elements()); aResult.Assign(buffer.Elements(), length); } else CopyUTF8toUTF16(aSrc, aResult); } CFRelease(inStr); }
gl::glProc HeadlessBackend::initializeExtension(const char* name) { static CFBundleRef framework = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengl")); if (!framework) { throw std::runtime_error("Failed to load OpenGL framework."); } CFStringRef str = CFStringCreateWithCString(kCFAllocatorDefault, name, kCFStringEncodingASCII); void* symbol = CFBundleGetFunctionPointerForName(framework, str); CFRelease(str); return reinterpret_cast<gl::glProc>(symbol); }
CFBundleRef GetCodecBundle() { static CFBundleRef sAudioCodecBundle = 0; if (!sAudioCodecBundle) { sAudioCodecBundle = CFBundleGetBundleWithIdentifier(kCodecBundleID); if (sAudioCodecBundle) { CFRetain(sAudioCodecBundle); } } return sAudioCodecBundle; }
// --------------------------------------------------------------------------- // // ----------- void strget(const char* msg_id, char* string){ CFBundleRef bndl=CFBundleGetBundleWithIdentifier(CFSTR("com.cbconseil.macmapsuite.framework")); CFStringRef cfid=CFStringCreateWithCString(kCFAllocatorDefault,msg_id,kCFStringEncodingMacRoman); CFStringRef msg=CFBundleCopyLocalizedString(bndl,cfid,CFSTR("MESSAGES"),NULL); string[0]=0; CFRelease(cfid); if(!msg){ return; } CFStringGetCString(msg,string,256,kCFStringEncodingMacRoman); CFRelease(msg); }
void mac_get_resource_path(const char *_path,MyString& _resPath) { CFURLRef resourceURL; _resPath.Empty(); // Look for the resource in the main bundle by name and type. #ifdef ACTIVEGSPLUGIN CFBundleRef bundle = CFBundleGetBundleWithIdentifier(__CFStringMakeConstantString("com.freetoolsassociation.activegs")); #else CFBundleRef bundle = CFBundleGetMainBundle(); #endif CFStringRef ce = CFStringCreateWithCString( NULL, _path, kCFStringEncodingASCII); resourceURL = CFBundleCopyResourceURL( bundle, ce, NULL, NULL ); if(!resourceURL) { printf("Failed to locate a file in the loaded bundle! (%s)",_path); return; } char fileurl[1024]; if(!CFURLGetFileSystemRepresentation( resourceURL, true, (UInt8*) fileurl, 1024)) { printf("Failed to turn a bundle resource URL into a filesystem path representation!"); return; } _resPath = fileurl; }
CFStringRef Resources::getResourcesPathFromBundleId() { //@@TODO char buffer[PATH_MAX]; CFBundleRef bundle = CFBundleGetBundleWithIdentifier(CFSTR("SuperColldierAU") ); if (bundle == NULL) return NULL; CFURLRef bundleURL = CFBundleCopyBundleURL(bundle); CFURLGetFileSystemRepresentation(bundleURL, TRUE, (UInt8*)buffer,PATH_MAX); CFStringRef bundlePath = CFStringCreateWithCString(NULL,buffer, kCFStringEncodingUTF8); CFURLRef bundleResourcesURL = CFBundleCopyResourcesDirectoryURL(bundle); CFStringRef resourcesRelativePath = CFURLGetString(bundleResourcesURL); CFMutableStringRef resourcesPath = CFStringCreateMutable(NULL,0); CFStringAppend(resourcesPath,bundlePath); CFStringAppend(resourcesPath,resourcesRelativePath); return resourcesPath; }
int _glfwPlatformInit( void ) { struct timeval tv; UInt32 nullDummy = 0; _glfwWin.window = NULL; _glfwWin.aglContext = NULL; _glfwWin.cglContext = NULL; _glfwWin.windowUPP = NULL; _glfwInput.Modifiers = 0; _glfwLibrary.Unbundled = 0; _glfwLibrary.Libs.OpenGLFramework = CFBundleGetBundleWithIdentifier( CFSTR( "com.apple.opengl" ) ); if( _glfwLibrary.Libs.OpenGLFramework == NULL ) { fprintf( stderr, "glfwInit failing because you aren't linked to OpenGL\n" ); return GL_FALSE; } _glfwPlatformGetDesktopMode( &_glfwLibrary.desktopMode ); // Install atexit routine atexit( glfw_atexit ); _glfwInitThreads(); _glfwChangeToResourcesDirectory(); // Ugly hack to reduce the nasty jump that occurs at the first non- // sys keypress, caused by OS X loading certain meta scripts used // for lexical- and raw keycode translation - instead of letting // this happen while our application is running, we do some blunt // function calls in advance just to get the script caching out of // the way BEFORE our window/screen is opened. These calls might // generate err return codes, but we don't care in this case. // NOTE: KCHRPtr is declared globally, because we need it later on. KCHRPtr = (void *)GetScriptVariable( smCurrentScript, smKCHRCache ); KeyTranslate( KCHRPtr, 0, &nullDummy ); UppercaseText( (char *)&nullDummy, 0, smSystemScript ); gettimeofday( &tv, NULL ); _glfwLibrary.Timer.t0 = tv.tv_sec + (double) tv.tv_usec / 1000000.0; return GL_TRUE; }
CFBundleRef mac_loadExeBundle(const char *name) { CFBundleRef baseBundle = CFBundleGetBundleWithIdentifier(CFSTR("org.demi3d.Demi")); CFBundleRef mainBundle = CFBundleGetMainBundle(); CFStringRef nameRef = CFStringCreateWithCString(NULL, name, kCFStringEncodingASCII); CFURLRef bundleURL = 0; //URL of bundle to load CFBundleRef bundle = 0; //bundle to load //cut off .bundle if present if (CFStringHasSuffix(nameRef, CFSTR(".bundle"))) { CFStringRef nameTempRef = nameRef; int end = CFStringGetLength(nameTempRef) - CFStringGetLength(CFSTR(".bundle")); nameRef = CFStringCreateWithSubstring(NULL, nameTempRef, CFRangeMake(0, end)); CFRelease(nameTempRef); } //assume relative to Resources/ directory of Main bundle bundleURL = CFBundleCopyResourceURL(mainBundle, nameRef, CFSTR("bundle"), NULL); if (bundleURL) { bundle = CFBundleCreate(NULL, bundleURL); CFRelease(bundleURL); } //otherwise, try Resources/ directory of Ogre Framework bundle if (!bundle) { bundleURL = CFBundleCopyResourceURL(baseBundle, nameRef, CFSTR("bundle"), NULL); if (bundleURL) { bundle = CFBundleCreate(NULL, bundleURL); CFRelease(bundleURL); } } CFRelease(nameRef); if (bundle) { if (CFBundleLoadExecutable(bundle)) return bundle; else CFRelease(bundle); } return 0; }
OSStatus AKSampler_Plugin::GetProperty( AudioUnitPropertyID inPropertyID, AudioUnitScope inScope, AudioUnitElement inElement, void* outData) { if (inScope == kAudioUnitScope_Global) { switch (inPropertyID) { case kAudioUnitProperty_CocoaUI: { // Look for a resource in the main bundle by name and type. CFBundleRef bundle = CFBundleGetBundleWithIdentifier( CFSTR("io.audiokit.AKSampler") ); if (bundle == NULL) { printf("Could not find bundle specified for GUI resources\n"); return fnfErr; } CFURLRef bundleURL = CFBundleCopyResourceURL( bundle, CFSTR("AKSamplerUI"), CFSTR("bundle"), NULL); if (bundleURL == NULL) { printf("Could not create resource URL for GUI\n"); return fnfErr; } CFStringRef className = CFSTR("AKSampler_ViewFactory"); AudioUnitCocoaViewInfo cocoaInfo = { bundleURL, { className } }; *((AudioUnitCocoaViewInfo *)outData) = cocoaInfo; return noErr; } case kPresetFolderPathProperty: outData = (void*)presetFolderPath; return noErr; case kPresetNameProperty: outData = (void*)presetName; return noErr; } } return AUInstrumentBase::GetProperty (inPropertyID, inScope, inElement, outData); }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // WaveformViewDemo::GetProperty //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ComponentResult WaveformViewDemo::GetProperty( AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement, void * outData ) { if (inScope == kAudioUnitScope_Global) { switch (inID) { case kAudioUnitProperty_CocoaUI: { // Look for a resource in the main bundle by name and type. CFBundleRef bundle = CFBundleGetBundleWithIdentifier( CFSTR("com.apple.demo.audiounit.WaveformViewDemo") ); if (bundle == NULL) return fnfErr; CFURLRef bundleURL = CFBundleCopyResourceURL( bundle, CFSTR("WaveformViewDemoViewFactory"), CFSTR("bundle"), NULL); if (bundleURL == NULL) return fnfErr; CFStringRef className = CFSTR("WaveformViewDemoViewFactory"); AudioUnitCocoaViewInfo cocoaInfo = { bundleURL, className }; *((AudioUnitCocoaViewInfo *)outData) = cocoaInfo; return noErr; } case kAudioUnitProperty_WaveformOverview: { WaveformOverview *overview = (WaveformOverview*)outData; GetWaveformOverview(overview); return noErr; } case kAudioUnitProperty_SampleTimeStamp: { *(static_cast<Float64*>(outData)) =mRenderStamp.mSampleTime; return noErr; } } //end switch }//end global if return AUEffectBase::GetProperty (inID, inScope, inElement, outData); }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // AUDiskStreamingCheckbox::AUDiskStreamingCheckbox // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ AUDiskStreamingCheckbox::AUDiskStreamingCheckbox (AUCarbonViewBase *inBase, Point inLocation, ControlFontStyleRec & inFontStyle) : AUPropertyControl (inBase) { Rect r; r.top = inLocation.v; r.bottom = r.top; r.left = inLocation.h; r.right = r.left; // localize as necessary if (!sLocalized) { sLocalized = true; CFBundleRef mainBundle = CFBundleGetBundleWithIdentifier(kLocalizedStringBundle_AUView); if (mainBundle) { kStringStreamFromDisk = CFCopyLocalizedStringFromTableInBundle( kAUViewLocalizedStringKey_StreamFromDisk, kLocalizedStringTable_AUView, mainBundle, CFSTR("'Stream From Disk' checkbox title string")); } } verify_noerr(CreateCheckBoxControl( GetCarbonWindow(), &r, kStringStreamFromDisk, 0, true, &mControl)); verify_noerr (SetControlFontStyle (mControl, &inFontStyle)); ControlSize smallSize = kControlSizeSmall; verify_noerr (SetControlData (mControl, kControlEntireControl, kControlSizeTag, sizeof (ControlSize), &smallSize)); AUCarbonViewControl::SizeControlToFit(mControl, NULL, &mHeight); if (mHeight < 0) mHeight = 0; EmbedControl(mControl); UInt32 value = 0; UInt32 size = sizeof(value); verify_noerr (AudioUnitGetProperty (mView->GetEditAudioUnit(), kMusicDeviceProperty_StreamFromDisk, kAudioUnitScope_Global, 0, &value, &size)); HandlePropertyChange (value); RegisterEvents(); }