static CFType typeFromCFTypeRef(CFTypeRef type)
{
    ASSERT(type);

    if (type == tokenNullTypeRef())
        return Null;

    CFTypeID typeID = CFGetTypeID(type);
    if (typeID == CFArrayGetTypeID())
        return CFArray;
    if (typeID == CFBooleanGetTypeID())
        return CFBoolean;
    if (typeID == CFDataGetTypeID())
        return CFData;
    if (typeID == CFDictionaryGetTypeID())
        return CFDictionary;
    if (typeID == CFNullGetTypeID())
        return CFNull;
    if (typeID == CFNumberGetTypeID())
        return CFNumber;
    if (typeID == CFStringGetTypeID())
        return CFString;
    if (typeID == CFURLGetTypeID())
        return CFURL;
#if PLATFORM(MAC)
    if (typeID == SecCertificateGetTypeID())
        return SecCertificate;
#endif

    ASSERT_NOT_REACHED();
    return Unknown;
}
Пример #2
0
__attribute__((constructor)) void Init_TSICTString(void)
{
    kCFDataTypeID        = CFDataGetTypeID();
    kCFStringTypeID      = CFStringGetTypeID();
    kCFNumberTypeID      = CFNumberGetTypeID();
    kCFBooleanTypeID     = CFBooleanGetTypeID();
    kCFNullTypeID        = CFNullGetTypeID();
    kCFArrayTypeID       = CFArrayGetTypeID();
    kCFDictionaryTypeID  = CFDictionaryGetTypeID();
}
Пример #3
0
//--------------------------------------------------------------------------
// JSObjectKJSValue
//--------------------------------------------------------------------------
JSValue JSObjectKJSValue(JSUserObject* ptr)
{
    JSGlueAPIEntry entry;

    JSValue result = jsUndefined();
    if (ptr)
    {
        bool handled = false;

        switch (ptr->DataType())
        {
            case kJSUserObjectDataTypeJSValueWrapper:
            {
                JSValueWrapper* wrapper = (JSValueWrapper*)ptr->GetData();
                if (wrapper)
                {
                    result = wrapper->GetValue();
                    handled = true;
                }
                break;
            }

            case kJSUserObjectDataTypeCFType:
            {
                CFTypeRef cfType = (CFTypeRef*)ptr->GetData();
                if (cfType)
                {
                    CFTypeID typeID = CFGetTypeID(cfType);
                    if (typeID == CFStringGetTypeID())
                    {
                        result = jsString(getThreadGlobalExecState(), CFStringToUString((CFStringRef)cfType));
                        handled = true;
                    }
                    else if (typeID == CFNumberGetTypeID())
                    {
                        double num;
                        CFNumberGetValue((CFNumberRef)cfType, kCFNumberDoubleType, &num);
                        result = jsNumber(num);
                        handled = true;
                    }
                    else if (typeID == CFBooleanGetTypeID())
                    {
                        result = jsBoolean(CFBooleanGetValue((CFBooleanRef)cfType));
                        handled = true;
                    }
                    else if (typeID == CFNullGetTypeID())
                    {
                        result = jsNull();
                        handled = true;
                    }
                }
                break;
            }
        }
        if (!handled)
        {
            ExecState* exec = getThreadGlobalExecState();
            result = new (exec) UserObjectImp(getThreadGlobalObject()->userObjectStructure(), ptr);
        }
    }
    return result;
}
Пример #4
0
// the pathBuffer will contain the path to the profile for the
// primary monitor
Boolean get_screen_profile(char* pathBuffer, size_t maxPathSize)
{
    CFUUIDRef displayUUID = CGDisplayCreateUUIDFromDisplayID(
        kCGDirectMainDisplay);


    if (CFGetTypeID(displayUUID) == CFNullGetTypeID())
    {
        printf("Cannot get display UUID.\n");
        return false;
    }

    CFDictionaryRef displayInfo = ColorSyncDeviceCopyDeviceInfo(
        kColorSyncDisplayDeviceClass,
        displayUUID);

    if (!displayInfo)
    {
        printf("Cannot get display info.\n");
        CFRelease(displayUUID);
        return false;
    }
    CFRelease(displayUUID);

    //  CFDictionaryApplyFunction(displayInfo,printKeys,NULL);

    CFDictionaryRef customProfileInfo = CFDictionaryGetValue(displayInfo,
            kColorSyncFactoryProfiles);// kColorSyncCustomProfiles);

    if (!customProfileInfo)
    {
        printf("Cannot get display profile info.\n");
        CFRelease(displayInfo);
        return false;
    }

    CFTypeRef* profileDict =
        (CFTypeRef*)malloc(CFDictionaryGetCount(customProfileInfo) *
            sizeof(CFTypeRef));
    CFDictionaryGetKeysAndValues(customProfileInfo,
        NULL,
        (const void**)profileDict);

    if ((void*)profileDict[0] == kCFNull)
    {
        printf("Cannot get display profile Dictionary.\n");
        CFRelease(displayInfo);
        free(profileDict);
        return false;
    }

   // CFDictionaryApplyFunction(profileDict[0], printKeys, NULL);

    CFTypeRef* profileDictValues = (CFTypeRef*)malloc(CFDictionaryGetCount(
                profileDict[0]) * sizeof(CFTypeRef));
    CFDictionaryGetKeysAndValues(profileDict[0],
        NULL,
        (const void**)profileDictValues);

    if ((void*)profileDictValues[0] == kCFNull)
    {
        printf("Cannot get display profile Url.\n");
        CFRelease(displayInfo);
        free(profileDict);
        free(profileDictValues);
        return false;
    }

    Boolean result = CFURLGetFileSystemRepresentation((CFURLRef)profileDictValues[0],
            true,
            (UInt8*)pathBuffer,
            maxPathSize);
    free(profileDict);
    free(profileDictValues);
    CFRelease(displayInfo);

    if (!result)
        printf("Cannot get display profile path.\n");

    return result;
}