Esempio n. 1
0
 //-----------------------------------------------------------------------
 bool StringConverter::parse(const String& val, uint32& ret)
 {
     char* end;
     ret = (uint32)strtoul_l(val.c_str(), &end, 0, _numLocale);
     return val.c_str() != end;
 }
Esempio n. 2
0
static
#elif DEPLOYMENT_TARGET_WINDOWS
CF_EXPORT
#endif
void __CFInitialize(void) {
    static int __done = 0;

    if (!__done) {
        __done = 1;

#if defined(DEBUG) || defined(ENABLE_ZOMBIES)
        const char *value = getenv("NSZombieEnabled");
        if (value && (*value == 'Y' || *value == 'y')) __CFZombieEnabled = 0xff;
        value = getenv("NSDeallocateZombies");
        if (value && (*value == 'Y' || *value == 'y')) __CFDeallocateZombies = 0xff;

        value = getenv("CFZombieLevel");
        if (NULL != value) {
#if DEPLOYMENT_TARGET_MACOSX
            __CFZombieLevel = (uint32_t)strtoul_l(value, NULL, 0, NULL);
#else
            __CFZombieLevel = (uint32_t)strtoul(value, NULL, 0);
#endif
        }
        if (0x0 == __CFZombieLevel) __CFZombieLevel = 0x0000FC00; // default
#endif

        __CFRuntimeClassTableSize = 1024;
        __CFRuntimeClassTable = (CFRuntimeClass **)calloc(__CFRuntimeClassTableSize, sizeof(CFRuntimeClass *));
        __CFBaseInitialize();

        /* Here so that two runtime classes get indices 0, 1. */
        __kCFNotATypeTypeID = _CFRuntimeRegisterClass(&__CFNotATypeClass);
        __kCFTypeTypeID = _CFRuntimeRegisterClass(&__CFTypeClass);

        /* Here so that __kCFAllocatorTypeID gets index 2. */
        __CFAllocatorInitialize();

#if DEPLOYMENT_TARGET_MACOSX
        {
            CFIndex idx, cnt;
            char **args = *_NSGetArgv();
            cnt = *_NSGetArgc();
            for (idx = 1; idx < cnt - 1; idx++) {
                if (NULL == args[idx]) continue;
                if (0 == strcmp(args[idx], "-AppleLanguages") && args[idx + 1]) {
                    CFIndex length = strlen(args[idx + 1]);
                    __CFAppleLanguages = malloc(length + 1);
                    memmove(__CFAppleLanguages, args[idx + 1], length + 1);
                    break;
                }
            }
        }
#endif


        /* CFBag needs to be up before CFString. */
        __CFBagInitialize();

#if !__LP64__
        // Creating this lazily in CFRetain causes recursive call to CFRetain
        __CFRuntimeExternRefCountTable = CFBagCreateMutable(kCFAllocatorSystemDefault, 0, NULL);
#endif

        /*** _CFRuntimeCreateInstance() can finally be called generally after this line. ***/

        __CFRuntimeClassTableCount = 7;
        __CFStringInitialize();		// CFString's TypeID must be 0x7, now and forever
        __CFRuntimeClassTableCount = 16;
        __CFDictionaryInitialize();
        __CFArrayInitialize();
        __CFDataInitialize();
        __CFSetInitialize();
        __CFNullInitialize();		// See above for hard-coding of this position
        __CFBooleanInitialize();	// See above for hard-coding of this position
        __CFNumberInitialize();		// See above for hard-coding of this position


        __CFDateInitialize();	// just initializes the time goo
//	_CFRuntimeBridgeClasses(CFDateGetTypeID(), objc_lookUpClass("NSCFDate") ? "NSCFDate" : "__NSCFDate");
        __CFTimeZoneInitialize();
//	_CFRuntimeBridgeClasses(CFTimeZoneGetTypeID(), "NSCFTimeZone");
        __CFBinaryHeapInitialize();
        __CFBitVectorInitialize();
        __CFCharacterSetInitialize();
#if DEPLOYMENT_TARGET_WINDOWS
        __CFLocaleInitialize();
#endif
        __CFStorageInitialize();
        __CFErrorInitialize();
        __CFTreeInitialize();
        __CFURLInitialize();
        __CFBundleInitialize();
#if DEPLOYMENT_TARGET_MACOSX
        __CFPlugInInitialize();
        __CFPlugInInstanceInitialize();
#endif //__MACH__
        __CFUUIDInitialize();
#if DEPLOYMENT_TARGET_MACOSX
        __CFMessagePortInitialize();
        __CFMachPortInitialize();
#endif
        __CFStreamInitialize();
        __CFPreferencesDomainInitialize();
#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
        __CFRunLoopInitialize();
        __CFRunLoopObserverInitialize();
        __CFRunLoopSourceInitialize();
        __CFRunLoopTimerInitialize();
        __CFSocketInitialize();
#endif
        __CFFileDescriptorInitialize();
        __CFNotificationCenterInitialize();

#if DEPLOYMENT_TARGET_MACOSX
        {
            CFIndex idx, cnt;
            char **args;
            args = *_NSGetArgv();
            cnt = *_NSGetArgc();
            CFIndex count;
            CFStringRef *list, buffer[256];
            list = (cnt <= 256) ? (CFStringRef*)buffer : (CFStringRef*)malloc(cnt * sizeof(CFStringRef));
            for (idx = 0, count = 0; idx < cnt; idx++) {
                if (NULL == args[idx]) continue;
                list[count] = CFStringCreateWithCString(kCFAllocatorSystemDefault, args[idx], kCFStringEncodingUTF8);
                if (NULL == list[count]) {
                    list[count] = CFStringCreateWithCString(kCFAllocatorSystemDefault, args[idx], kCFStringEncodingISOLatin1);
                    // We CANNOT use the string SystemEncoding here;
                    // Do not argue: it is not initialized yet, but these
                    // arguments MUST be initialized before it is.
                    // We should just ignore the argument if the UTF-8
                    // conversion fails, but out of charity we try once
                    // more with ISO Latin1, a standard unix encoding.
                }
                if (NULL != list[count]) count++;
            }
            __CFArgStuff = CFArrayCreate(kCFAllocatorSystemDefault, (const void **)list, count, &kCFTypeArrayCallBacks);
        }
#endif
        _CFProcessPath();	// cache this early

        if (__CFRuntimeClassTableCount < 256) __CFRuntimeClassTableCount = 256;

#if defined(DEBUG) && !DEPLOYMENT_TARGET_WINDOWS
        CFLog(kCFLogLevelWarning, CFSTR("Assertions enabled"));
#endif
    }
}