static RSCoreUSBDeviceRef __RSCoreUSBDeviceCreateInstance(RSAllocatorRef allocator, RSStringRef uuid) { RSCoreUSBDeviceRef instance = (RSCoreUSBDeviceRef)__RSRuntimeCreateInstance(allocator, _RSCoreUSBDeviceTypeID /*RSCoreUSBDeviceGetTypeID()*/, sizeof(struct __RSCoreUSBDevice) - sizeof(RSRuntimeBase)); return instance; }
static RSQueueRef __RSQueueCreateInstance(RSAllocatorRef allocator, RSIndex capacity, RSQueueAtomType atom) { RSQueueRef queue = (RSQueueRef)__RSRuntimeCreateInstance(allocator, _RSQueueTypeID, sizeof(struct __RSQueue) - sizeof(RSRuntimeBase)); queue->_lock = RSSpinLockInit; if (atom == RSQueueAtom) setAtom(queue); queue->_capacity = capacity; queue->_queueCore = RSArrayCreateMutable(allocator, capacity); return queue; }
RSExport RSErrorRef RSErrorCreate(RSAllocatorRef allocator, RSStringRef domain, RSIndex code, RSDictionaryRef userInfo) { RSErrorRef err = (RSErrorRef)__RSRuntimeCreateInstance(allocator, RSErrorGetTypeID(), sizeof(struct __RSError) - sizeof(RSRuntimeBase)); err->_code = code; if (domain) err->_domain = RSRetain(domain); else HALTWithError(RSInvalidArgumentException, "the domain is nil."); if (userInfo) err->_userInfo = RSRetain(userInfo); return err; }
static RSTimerRef __RSTimerCreateInstance(RSAllocatorRef allocator, RSAbsoluteTime start, RSTimeInterval timeInterval, BOOL repeats, RSDictionaryRef userInfo) { RSTimerRef timer = (RSTimerRef)__RSRuntimeCreateInstance(allocator, RSTimerGetTypeID(), sizeof(struct __RSTimer) - sizeof(struct __RSRuntimeBase)); struct __RSTimer *_timer = (struct __RSTimer *)timer; if (userInfo) _timer->_userInfo = RSRetain(userInfo); RSBitU64 _start = __dps_convert_absolute(start); __RSTimerDescriptorInit(timer, _start, timeInterval); if (repeats) __RSTimerSetRepeat(timer); return timer; }
static RSProcessInfoRef __RSProcessInfoCreateInstance(RSAllocatorRef allocator, RSDictionaryRef content) { RSProcessInfoRef instance = (RSProcessInfoRef)__RSRuntimeCreateInstance(allocator, _RSProcessInfoTypeID, sizeof(struct __RSProcessInfo) - sizeof(RSRuntimeBase)); if (content) { instance->_info = RSMutableCopy(allocator, content); } else { instance->_info = RSDictionaryCreateMutable(RSAllocatorDefault, 0, RSDictionaryRSTypeContext); } __RSRuntimeSetInstanceSpecial(instance->_info, YES); return instance; }
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; }
static RSTimeZoneRef __RSTimeZoneCreateInstance(RSAllocatorRef allocator, RSStringRef zoneName) { RSTimeZoneRef tz = __RSRuntimeCreateInstance(RSAllocatorSystemDefault, _RSTimeZoneTypeID, sizeof(struct __RSTimeZone) - sizeof(struct __RSRuntimeBase)); __RSTimeZoneSetName(tz, zoneName); return tz; }
static RSDateRef __RSDateCreateInstance(RSAllocatorRef allocator, RSAbsoluteTime time) { RSDateRef date = (RSDateRef)__RSRuntimeCreateInstance(allocator, RSDateGetTypeID(), sizeof(struct __RSDate) - sizeof(struct __RSRuntimeBase)); ((struct __RSDate*)date)->_time = time; return date; }