コード例 #1
0
static void __RSFileMonitorClassDeallocate(RSTypeRef rs)
{
    RSFileMonitorRef monitor = (RSFileMonitorRef)rs;
    __RSFileMonitorLock(monitor);
    if (monitor->_filePath) RSRelease(monitor->_filePath);
    if (monitor->_source) {
        dispatch_source_cancel(monitor->_source);
        close(monitor->_fd);
        monitor->_fd = 0;
        dispatch_release(monitor->_source);
        monitor->_source = nil;
    }
    __RSFileMonitorUnlock(monitor);
}
コード例 #2
0
static RSVersion ___RSCFPVersionCacheGetVersionWithID(___RSCFPVersionIndex idx) {
    if (idx < 0 || idx >= ___RSCFPVersionCount) return 0;
    if (likely(___RSCFPVersionListCache[idx])) return ___RSCFPVersionListCache[idx];
    RSDictionaryRef _contents = RSDictionaryCreateWithContentOfPath(RSAllocatorDefault, ___RSCoreOperatingSystemVersion);
    RSVersion productVersion = 0, buildVersion = 0;
    if (___RSCFPreferenceGetCFVersion(&productVersion, &buildVersion)) {
        ___RSCFPVersionListCache[___RSCFPVersionSelfBuild] = buildVersion;
        ___RSCFPVersionListCache[___RSCFPVersionSelf] = productVersion;
    }
    ___RSCFPVersionListCache[___RSCFPVersionOSBuild] = RSStringUnsignedLongValue(RSDictionaryGetValue(_contents, RSSTR("ProductBuildVersion")));
    ___RSCFPVersionListCache[___RSCFPVersionOSProduct] = RSStringUnsignedLongValue(RSDictionaryGetValue(_contents, RSSTR("ProductVersion")));
    ___RSCFPVersionListCache[___RSCFPVersionOSProductUserVisible] = RSStringUnsignedLongValue(RSDictionaryGetValue(_contents, RSSTR("ProductUserVisibleVersion")));
    if (_contents) RSRelease(_contents);
    return ___RSCFPVersionListCache[idx];
}
コード例 #3
0
static void __RSDistributedModuleClassDeallocate(RSTypeRef rs)
{
    RSDistributedModuleRef dm = (RSDistributedModuleRef)rs;
    dm->_callback.RSDistributedModuleWillDeallocate(dm);
    
    RSRelease(dm->_requestSendQueue);
    RSRelease(dm->_requestRecvQueue);
    RSRelease(dm->_dataSendQueue);
    RSRelease(dm->_dataRecvQueue);
    
    RSRelease(dm->_token);
    RSRelease(dm->_clientID);
    RSRelease(dm->_client);
}
コード例 #4
0
static void __RSProcessInfoClassDeallocate(RSTypeRef rs) {
    RSProcessInfoRef pi = (RSProcessInfoRef)rs;
    if (pi->_info)
    {
        __RSRuntimeSetInstanceSpecial(RSDictionaryGetValue(pi->_info, __RSProcessInfoEnvironment), NO);
        __RSRuntimeSetInstanceSpecial(RSDictionaryGetValue(pi->_info, __RSProcessInfoMachine), NO);
        __RSRuntimeSetInstanceSpecial(RSDictionaryGetValue(pi->_info, __RSProcessInfoOperatingSystemVersion), NO);
        __RSRuntimeSetInstanceSpecial(RSDictionaryGetValue(pi->_info, __RSProcessInfoKernel), NO);
        __RSRuntimeSetInstanceSpecial(RSDictionaryGetValue(pi->_info, __RSProcessInfoProcessor), NO);
        __RSRuntimeSetInstanceSpecial(RSDictionaryGetValue(pi->_info, __RSProcessInfoMemory), NO);
        __RSRuntimeSetInstanceSpecial(RSDictionaryGetValue(pi->_info, __RSProcessInfoProgramName), NO);
        __RSRuntimeSetInstanceSpecial(pi->_info, NO);
        RSRelease(pi->_info);
    }
    _RSCloseHandle(pi->_core);
}
コード例 #5
0
RSInline RSHandle __RSProcessInfoLoadLibForSerinalNumber() {
    RSHandle handle = nil;
#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_IPHONEOS
    RSBundleRef framework = RSBundleGetWithIdentifier(RSSTR("com.RetVal.RSCoreFoundation"));
    if (framework) {
        RSStringRef path = RSBundleCreatePathForResource(framework, RSSTR("RSProcessInfo"), RSSTR("dylib"));
        handle = _RSLoadLibrary(path);
        RSRelease(path);
    }
#elif DEPLOYMENT_TARGET_LINUX
    handle = _RSLoadLibrary(RSSTR("RSProcessInfo.so"));
#elif DEPLOYMENT_TARGET_WINDOWS
    handle = _RSLoadLibrary(RSSTR("RSProcessInfo.dll"));
#endif
    return handle;
}
コード例 #6
0
RSExport RSStringRef RSErrorCopyDescription(RSErrorRef err)
{
    __RSAssertIsError(err);
    RSStringRef result = __RSErrorCopyUserInfoKey(err, RSErrorLocalizedDescriptionKey), reason = nil;
    if (result == nil)
    {
        reason = __RSErrorCopyUserInfoKey(err, RSErrorLocalizedFailureReasonKey);
        if (reason)
            result = RSStringCreateWithFormat(RSAllocatorSystemDefault, RSSTR("The operation couldn't be completed. %R"), reason);
        else if ((reason = __RSErrorCopyUserInfoKey(err, RSErrorDescriptionKey)))
            result = RSStringCreateWithFormat(RSAllocatorSystemDefault, RSSTR("The operation couldn't be completed.(%R error %ld - %R)"), RSErrorGetDomain(err), RSErrorGetCode(err), reason);
        else
            result = RSStringCreateWithFormat(RSAllocatorSystemDefault, RSSTR("The operation couldn't be completed.(%R error %ld)"), RSErrorGetDomain(err), RSErrorGetCode(err));
    }
    if (reason) RSRelease(reason);
    return result;
}
コード例 #7
0
static BOOL __RSProcessInfoUpdateKeys(RSProcessInfoRef processInfo, RSArrayRef lookupKeys, RSArrayRef description, RSStringRef key) {
    if (key == nil || lookupKeys == nil) return NO;
    if (description == nil) description = lookupKeys;
    const RSUInteger keyCount = RSArrayGetCount(lookupKeys);
    if (keyCount > RSArrayGetCount(description)) return NO;
    RSUInteger successCount = 0;
    RSMutableDictionaryRef dict = RSDictionaryCreateMutable(RSAllocatorSystemDefault, 0, RSDictionaryRSTypeContext);
    if (dict)
    {
        for (RSUInteger idx = 0; idx < keyCount; idx++)
        {
            successCount += __RSProcessInfoUpdate(dict, RSArrayObjectAtIndex(lookupKeys, idx), RSArrayObjectAtIndex(description, idx));
        }
        __RSProcessInfoSetObjectForKey(processInfo, key, dict);
        RSRelease(dict);
    }
    return successCount == keyCount;
}
コード例 #8
0
static void __RSTimerClassDeallocate(RSTypeRef rs)
{
    RSTimerRef timer = (RSTimerRef)rs;
    struct __RSTimer *_timer = (struct __RSTimer *)timer;
    if (__RSTimerIsTimer(timer))
    {
        if (timer->_dps_timer)
        {
//            __dps_timer_invalid(timer->_dps_timer);
            if (__RSTimerIsSuspend(timer))
            {
                RSExceptionCreateAndRaise(RSAllocatorSystemDefault, RSGenericException, RSSTR("BUG: RSTimer want to invalidate a suspend timer"), RSAutorelease(RSDictionaryCreateWithObjectsAndOKeys(RSAllocatorSystemDefault, timer, RSExceptionObject, nil)));
                return;
            }
            __dps_timer_release(timer->_dps_timer);
        }
        _timer->_dps_timer = nil;
    }
    memset(&_timer->_descriptor, 0, sizeof(struct __RSTimerDescriptor));
    if (timer->_userInfo) RSRelease(timer->_userInfo);
}
コード例 #9
0
static BOOL ___RSCFPreferenceGetCFVersion(RSVersion* productVersion, RSVersion* buildVersion) {
    if (likely(___RSCFPVersionListCache[___RSCFPVersionSelfBuild])) return ___RSCFPVersionListCache[___RSCFPVersionSelfBuild];
    RSDictionaryRef _contents = RSDictionaryCreateWithContentOfPath(RSAllocatorDefault, RSFileManagerStandardizingPath(___RSCoreFoundationLoadPath));
    RSVersion _version1 = 0, _version2 = 0;
    RSStringRef version = RSDictionaryGetValue(_contents, RSSTR("RSProductVersion"));
    if (version)
    {
        _version1 = RSStringFloatValue(version);
        ___RSCFPVersionListCache[___RSCFPVersionSelfBuild] = _version1;
        if (*productVersion) *productVersion = _version1;
    }
    
    version = RSDictionaryGetValue(_contents, RSSTR("RSBundleVersion"));
    if (version)
    {
        _version2 = RSStringFloatValue(version);
        if (*buildVersion) *buildVersion = _version2;
    }
    RSRelease(_contents);
    return (_version1 || _version2) ? YES : NO;
}
コード例 #10
0
RSExport void RSDictionarySetValueForKeys(RSMutableDictionaryRef dictionary, RSArrayRef keys, RSTypeRef value) {
    if (nil == dictionary || nil == keys || !RSArrayGetCount(keys)) return;
    RSClassRef dictClass = RSClassGetWithUTF8String("RSDictionary");
    RSUInteger cnt = RSArrayGetCount(keys);
    if (cnt < 2) {
        return RSDictionarySetValue(dictionary, RSArrayObjectAtIndex(keys, 0), value);
    }
    cnt --;
    RSMutableDictionaryRef tmp = dictionary, tmp1 = tmp;
    for (RSUInteger idx = 0; idx < cnt; idx++) {
        if (RSInstanceIsMemberOfClass(tmp, dictClass)) {
            tmp1 = (RSMutableDictionaryRef)RSDictionaryGetValue(tmp, RSArrayObjectAtIndex(keys, idx));
            if (!tmp1) {
                tmp1 = RSDictionaryCreateMutable(RSAllocatorSystemDefault, 0, RSDictionaryRSTypeContext);
                RSDictionarySetValue(tmp, RSArrayObjectAtIndex(keys, idx), tmp1);
                RSRelease(tmp1);
            }
            tmp = tmp1;
        } else {
            return ;
        }
    }
    return RSDictionarySetValue(tmp, RSArrayLastObject(keys), value);
}
コード例 #11
0
RSInline void __RSTimeZoneSetName(RSTimeZoneRef timeZone, RSStringRef zoneName)
{
    if (timeZone->_zoneName != nil) RSRelease(timeZone->_zoneName);
    if (zoneName) ((struct __RSTimeZone*)timeZone)->_zoneName = RSRetain(zoneName);
    else ((struct __RSTimeZone*)timeZone)->_zoneName = nil;
}
コード例 #12
0
RSExport RSTimeZoneRef RSTimeZoneCopySystem()
{
    RSTimeZoneLockSystem;
    if (likely(__RSTimeZoneSystem))
    {
        RSTimeZoneUnlockSystem;
        return __RSTimeZoneSystem;
    }
    RSTimeZoneUnlockSystem;

    RSTimeZoneRef result = nil;
    RSCBuffer tzenv = __RSRuntimeGetEnvironment("TZFILE");
    if (unlikely(tzenv))
    {
        RSStringRef name = RSStringCreateWithCString(RSAllocatorSystemDefault, tzenv, RSStringEncodingASCII);
        result = RSTimeZoneCreateWithName(RSAllocatorSystemDefault, name);
        RSRelease(name);
        RSTimeZoneLockSystem;
        if (likely(__RSTimeZoneSystem == nil))
        {
            __RSTimeZoneSystem = result;
            __RSRuntimeSetInstanceSpecial(__RSTimeZoneSystem, YES);
        }
        RSTimeZoneUnlockSystem;
        return result;
    }
    tzenv = __RSRuntimeGetEnvironment("TZ");
    if (unlikely(tzenv))
    {
        RSStringRef name = RSStringCreateWithCString(RSAllocatorSystemDefault, tzenv, RSStringEncodingASCII);
        result = RSTimeZoneCreateWithName(RSAllocatorSystemDefault, name);
        RSRelease(name);
        RSTimeZoneLockSystem;
        if (likely(__RSTimeZoneSystem == nil))
        {
            __RSTimeZoneSystem = result;
            __RSRuntimeSetInstanceSpecial(__RSTimeZoneSystem, YES);
        }
        RSTimeZoneUnlockSystem;

        return result;
    }
    char linkbuf[RSMaxPathSize];
    size_t ret = readlink(TZZONELINK, linkbuf, sizeof(linkbuf));
    if (likely(0 < ret))
    {
        RSStringRef name = nil;
        linkbuf[ret] = '\0';
        if (strncmp(linkbuf, TZZONEINFO, sizeof(TZZONEINFO) - 1) == 0)
        {
            //linkbuf[strlen(linkbuf) - sizeof(TZZONEINFO) + 1] = 0;

            name = RSStringCreateWithCString(RSAllocatorSystemDefault, linkbuf + sizeof(TZZONEINFO) - 1, RSStringEncodingUTF8);
        }
        else
        {
            name = RSStringCreateWithCString(RSAllocatorSystemDefault, linkbuf, RSStringEncodingUTF8);//RSStringCreateWithBytes(RSAllocatorSystemDefault, (uint8_t *)linkbuf, strlen(linkbuf), RSStringEncodingUTF8, NO);
        }
        result = RSTimeZoneCreateWithName(RSAllocatorSystemDefault, name);
        RSRelease(name);
        if (result)
        {
            RSTimeZoneLockSystem;
            if (likely(__RSTimeZoneSystem == nil))
            {
                __RSTimeZoneSystem = result;
                __RSRuntimeSetInstanceSpecial(__RSTimeZoneSystem, YES);
            }
            RSTimeZoneUnlockSystem;
        }
        return result;
    }
    return result;
}
コード例 #13
0
static void __RSCoreUSBDeviceClassDeallocate(RSTypeRef rs) {
    RSCoreUSBDeviceRef device = (RSCoreUSBDeviceRef)rs;
    RSRelease(device->_deviceName);
}
コード例 #14
0
ファイル: RSCalendar.c プロジェクト: RetVal/RSCoreFoundation
static void __RSCalendarSetIndentifier(RSCalendarRef calendar, RSStringRef identifier)
{
    if (calendar->_identifier) RSRelease(calendar->_identifier);
    if (identifier) calendar->_identifier = RSRetain(identifier);
    else calendar->_identifier = nil;
}
コード例 #15
0
ファイル: RSCalendar.c プロジェクト: RetVal/RSCoreFoundation
static void __RSCalendarSetTimeZone(RSCalendarRef calendar, RSTimeZoneRef tz)
{
    if (calendar->_tz) RSRelease(calendar->_tz);
    if (tz) calendar->_tz = RSRetain(tz);
    else calendar->_tz = RSTimeZoneCopySystem();
}