예제 #1
0
static BOOL __RSErrorClassEqual(RSTypeRef obj1, RSTypeRef obj2)
{
    if (obj1 == obj2) return YES;
    RSErrorRef err1 = (RSErrorRef)obj1;
    RSErrorRef err2 = (RSErrorRef)obj2;
    if (err1->_code != err2->_code) return NO;
    if (RSEqual(err1->_domain, err2->_domain) == NO) return NO;
    if (RSEqual(err1->_userInfo, err2->_userInfo) == NO) return NO;
    return YES;
}
예제 #2
0
/*
 typedef RSTypeRef (*RSErrorUserInfoKeyCallBack)(RSErrorRef err, RSStringRef key)
 */
static RSTypeRef __RSErrorPOSIXCallBack(RSErrorRef err, RSStringRef key)
{
    if (!RSEqual(key, RSErrorDescriptionKey) && !RSEqual(key, RSErrorLocalizedFailureReasonKey)) return nil;
    
    const char *errStr = strerror((int)RSErrorGetCode(err));
    if (errStr && strlen(errStr)) return RSStringCreateWithCString(RSAllocatorSystemDefault, errStr, RSStringEncodingUTF8);
    #if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED
    /*RSBundle*/
    #endif
    
    return nil;
}
예제 #3
0
static RSTypeRef __RSErrorRSCoreFoundationCallBack(RSErrorRef err, RSStringRef key)
{
    if (!RSEqual(key, RSErrorDescriptionKey) && !RSEqual(key, RSErrorLocalizedFailureReasonKey)) return nil;
    RSStringRef errStr = nil;
    struct __RSErrorPrivateFormatTable cFormat = __RSErrorDomainRSCoreFoundationGetCStringWithCode(RSErrorGetCode(err));
    if (cFormat.argsCnt)
    {
        RSStringRef format = RSStringCreateWithCString(RSAllocatorSystemDefault, cFormat.format, RSStringEncodingUTF8);
        RSArrayRef objects = RSDictionaryGetValue(__RSErrorGetUserInfo(err), RSErrorTargetKey);
        RSTypeRef object[3] = {nil};
        RSIndex minCnt = 0;
        if (objects)
        {
            minCnt = min(cFormat.argsCnt, RSArrayGetCount(objects));
            switch (minCnt)
            {
                case 1:
                    object[0] = RSArrayObjectAtIndex(objects, 0);
                    errStr = RSStringCreateWithFormat(RSAllocatorSystemDefault, format, object[0]);
                    break;
                case 2:
                    object[0] = RSArrayObjectAtIndex(objects, 0);
                    object[1] = RSArrayObjectAtIndex(objects, 1);
                    errStr = RSStringCreateWithFormat(RSAllocatorSystemDefault, format, object[0], object[1]);
                    break;
                case 3:
                    object[0] = RSArrayObjectAtIndex(objects, 0);
                    object[1] = RSArrayObjectAtIndex(objects, 1);
                    object[2] = RSArrayObjectAtIndex(objects, 2);
                    errStr = RSStringCreateWithFormat(RSAllocatorSystemDefault, format, object[0], object[1], object[2]);
                    break;
                default:
                    HALTWithError(RSInvalidArgumentException, "the formate is too long to support");
                    break;
            }
        }
        for (RSIndex idx = 0; idx < minCnt; idx++)
        {
            RSRelease(object[idx]);
        }
        RSRelease(format);
    }
    else
    {
        errStr = RSStringCreateWithCString(RSAllocatorSystemDefault, cFormat.format, RSStringEncodingUTF8);
    }

    return errStr;
}
예제 #4
0
static RSTypeRef __RSErrorMachCallBack(RSErrorRef err, RSStringRef key)
{
    if (RSEqual(key, RSErrorDescriptionKey))
    {
        const char *errStr = mach_error_string((mach_error_t)RSErrorGetCode(err));
        if (errStr && strlen(errStr)) return RSStringCreateWithCString(RSAllocatorSystemDefault, errStr, RSStringEncodingUTF8);
    }
    return nil;
}
예제 #5
0
static BOOL __RSProcessInfoClassEqual(RSTypeRef rs1, RSTypeRef rs2) {
    RSProcessInfoRef RSProcessInfo1 = (RSProcessInfoRef)rs1;
    RSProcessInfoRef RSProcessInfo2 = (RSProcessInfoRef)rs2;
    BOOL result = NO;
    
    result = RSEqual(RSProcessInfo1->_info, RSProcessInfo2->_info);
    
    return result;
}
예제 #6
0
static BOOL __RSCoreUSBDeviceClassEqual(RSTypeRef rs1, RSTypeRef rs2) {
    RSCoreUSBDeviceRef RSCoreUSBDevice1 = (RSCoreUSBDeviceRef)rs1;
    RSCoreUSBDeviceRef RSCoreUSBDevice2 = (RSCoreUSBDeviceRef)rs2;
    BOOL result = NO;
    
    result = RSEqual(RSCoreUSBDevice1->_deviceName, RSCoreUSBDevice2->_deviceName);
    
    return result;
}
예제 #7
0
static BOOL __RSRenrenFriendClassEqual(RSTypeRef rs1, RSTypeRef rs2)
{
    RSRenrenFriendRef RSRenrenFriend1 = (RSRenrenFriendRef)rs1;
    RSRenrenFriendRef RSRenrenFriend2 = (RSRenrenFriendRef)rs2;
    BOOL result = NO;

    result = RSEqual(RSRenrenFriend1->_account, RSRenrenFriend2->_account);

    return result;
}
예제 #8
0
static BOOL __RSFileMonitorClassEqual(RSTypeRef rs1, RSTypeRef rs2)
{
    RSFileMonitorRef RSFileMonitor1 = (RSFileMonitorRef)rs1;
    RSFileMonitorRef RSFileMonitor2 = (RSFileMonitorRef)rs2;
    BOOL result = NO;
    
    result = RSEqual(RSFileMonitor1->_filePath, RSFileMonitor2->_filePath);
    
    return result;
}
예제 #9
0
static RSCalendarRef __RSCalendarCreateInstance(RSAllocatorRef allocator, RSStringRef identifier)
{
    if (identifier != RSGregorianCalendar &&
        identifier != RSBuddhistCalendar &&
        identifier != RSJapaneseCalendar &&
        identifier != RSIslamicCalendar &&
        identifier != RSIslamicCivilCalendar &&
        identifier != RSHebrewCalendar)
    {
        //    if (identifier != RSGregorianCalendar && identifier != RSBuddhistCalendar && identifier != RSJapaneseCalendar && identifier != RSIslamicCalendar && identifier != RSIslamicCivilCalendar && identifier != RSHebrewCalendar && identifier != RSChineseCalendar) {
        if (RSEqual(RSGregorianCalendar, identifier)) identifier = RSGregorianCalendar;
        else if (RSEqual(RSBuddhistCalendar, identifier)) identifier = RSBuddhistCalendar;
        else if (RSEqual(RSJapaneseCalendar, identifier)) identifier = RSJapaneseCalendar;
        else if (RSEqual(RSIslamicCalendar, identifier)) identifier = RSIslamicCalendar;
        else if (RSEqual(RSIslamicCivilCalendar, identifier)) identifier = RSIslamicCivilCalendar;
        else if (RSEqual(RSHebrewCalendar, identifier)) identifier = RSHebrewCalendar;
        //	else if (RSEqual(RSChineseCalendar, identifier)) identifier = RSChineseCalendar;
        else return nil;
    }
    RSCalendarRef calendar = (RSCalendarRef)__RSRuntimeCreateInstance(allocator, RSCalendarGetTypeID(), sizeof(struct __RSCalendar) - sizeof(struct __RSRuntimeBase));
    __RSCalendarSetIndentifier(calendar, identifier);
    return calendar;
}
예제 #10
0
static BOOL __RSQueueClassEqual(RSTypeRef rs1, RSTypeRef rs2)
{
    return RSEqual(((RSQueueRef)rs1)->_queueCore, ((RSQueueRef)rs2)->_queueCore);
}
예제 #11
0
RSExport RSIndex RSErrorRSCoreFoundationDomainGetNeedTargetCount(RSErrorRef err)
{
    __RSAssertIsError(err);
    if (!RSEqual(err, RSErrorDomainRSCoreFoundation)) return 0;
    return __RSErrorDomainRSCoreFoundationGetCStringWithCode(RSErrorGetCode(err)).argsCnt;
}
예제 #12
0
static BOOL __RSCalendarEqual(RSTypeRef obj1, RSTypeRef obj2)
{
    RSCalendarRef calendar1 = (RSCalendarRef)obj1;
    RSCalendarRef calendar2 = (RSCalendarRef)obj2;
    return RSEqual(calendar1->_identifier, calendar2->_identifier);
}