Exemple #1
0
IO_METHOD(IoDate, setDay)
{
	/*doc Date setDay(aNumber)
	Sets the day of the receiver. Returns self.
	*/

	int v = IoMessage_locals_intArgAt_(m, locals, 0);
	int month = Date_month(DATA(self)) + 1;

	IOASSERT(v >= 1 && v <= 31, "day must be within range 1-31");

	if (month == 2)
	{
		if (Date_isLeapYear(DATA(self)))
		{
			IOASSERT(v >= 1 && v <= 29, "day must be within range 1-29");
		}
		else
		{
			IOASSERT(v >= 1 && v <= 28, "day must be within range 1-28");
		}
	}
	else if (month == 11)
	{
		IOASSERT(v >= 1 && v <= 30, "day must be within range 1-30");
	}
	else if (month == 12)
	{
		IOASSERT(v >= 1 && v <= 31, "day must be within range 1-31");
	}

	Date_setDay_(DATA(self), v);
	IoObject_isDirty_(self, 1);
	return self;
}
Exemple #2
0
IoObject *IoSeq_convertToFixedSizeType(IoSeq *self, IoObject *locals, IoMessage *m)
{
	IO_ASSERT_NOT_SYMBOL(self);
	UArray_convertToFixedSizeType(DATA(self));
	IoObject_isDirty_(self, 1);
	return self;
}
Exemple #3
0
IO_METHOD(IoSeq, convertToFixedSizeType)
{
	IO_ASSERT_NOT_SYMBOL(self);
	UArray_convertToFixedSizeType(DATA(self));
	IoObject_isDirty_(self, 1);
	return self;
}
Exemple #4
0
IoObject *IoObject_rawClonePrimitive(IoObject *proto)
{
	IoObject *self = IoObject_alloc(proto);
	IoObject_tag_(self, IoObject_tag(proto));
	IoObject_setProtoTo_(self, proto);
	IoObject_setDataPointer_(self, NULL);
	IoObject_isDirty_(self, 1);
	return self;
}
Exemple #5
0
IO_METHOD(IoDate, fromNumber)
{
	/*doc Date fromNumber(aNumber)
	Sets the receiver to be aNumber seconds since 1970.
	*/

	Date_fromSeconds_(DATA(self), IoMessage_locals_doubleArgAt_(m, locals, 0));
	IoObject_isDirty_(self, 1);
	return self;
}
Exemple #6
0
IO_METHOD(IoDate, addInPlace)
{
	/*doc Date +=(aDuration)
	Add aDuration to the receiver. Returns self. 
	*/

	IoDuration *d = IoMessage_locals_durationArgAt_(m, locals, 0);
	Date_addDuration_(DATA(self), IoDuration_duration(d));
	IoObject_isDirty_(self, 1);
	return self;
}
Exemple #7
0
IO_METHOD(IoDate, subtractInPlace)
{
	/*doc Date -=(aDuration)
	Subtract aDuration from the receiver. Returns self.
	*/

	IoDuration *d = IoMessage_locals_durationArgAt_(m, locals, 0);
	Date_subtractDuration_(DATA(self), IoDuration_duration(d));
	IoObject_isDirty_(self, 1);
	return self;
}
Exemple #8
0
IO_METHOD(IoDate, setGmtOffset)
{
	/*doc Date setGmtOffset
	Set the number of minutes west of GMT for this Date's zone
	*/

	struct timezone tz = Date_timeZone(DATA(self));
	tz.tz_minuteswest = IoMessage_locals_intArgAt_(m, locals, 0);
	Date_setTimeZone_(DATA(self), tz);
	IoObject_isDirty_(self, 1);
	return self;
}
Exemple #9
0
IO_METHOD(IoDate, setSecond)
{
	/*doc Date setSecond(aNumber)
	Sets the second of the receiver. Returns self.
	*/

	int v = IoMessage_locals_intArgAt_(m, locals, 0);
	IOASSERT(v >= 0 && v <= 59, "second must be within range 0-59");
	Date_setSecond_(DATA(self), v);
	IoObject_isDirty_(self, 1);
	return self;
}
Exemple #10
0
IO_METHOD(IoDate, setHour)
{
	/*doc Date setHour(aNumber)
	Sets the hour of the receiver. Returns self.
	*/

	int v = IoMessage_locals_intArgAt_(m, locals, 0);
	IOASSERT(v >= 0 && v <= 23, "hour must be within range 0-23");
	Date_setHour_(DATA(self), v);
	IoObject_isDirty_(self, 1);
	return self;
}
Exemple #11
0
IO_METHOD(IoDate, convertToUTC)
{
	/*doc Date convertToUTC
	Converts self from a local date to the equivalent UTC date
	*/

	struct timezone tz;
	tz.tz_minuteswest = 0;
	tz.tz_dsttime = 0;
	Date_convertToTimeZone_(DATA(self), tz);
	IoObject_isDirty_(self, 1);
	return self;
}
Exemple #12
0
IO_METHOD(IoDate, setToUTC)
{
	/*doc Date asUTC
	Changes the timezone of this date to utc
	*/

	struct timezone tz;
	tz.tz_minuteswest = 0;
	tz.tz_dsttime = 0;
	
	Date_setTimeZone_(DATA(self), tz);
	IoObject_isDirty_(self, 1);
	
	return self;
}
Exemple #13
0
IO_METHOD(IoDate, convertToLocal)
{
	/*doc Date convertToLocal
	Converts self date from a UTC date to the equivalent local date
	*/

	struct timeval tv;
	struct timezone tz;
	
	gettimeofday(&tv, &tz);
	
	Date_convertToTimeZone_(DATA(self), tz);
	IoObject_isDirty_(self, 1);
	return self;
}
Exemple #14
0
IO_METHOD(IoDate, fromString)
{
	/*doc Date fromString(aString, formatString)
	Sets the receiver to the date specified by aString as parsed according to the given formatString. See the Date asString method for formatting rules. Returns self. 
	*/

	IoMessage_assertArgCount_receiver_(m, 2, self);
	{
		IoSymbol *date_input = IoMessage_locals_seqArgAt_(m, locals, 0);
		IoSymbol *format = IoMessage_locals_seqArgAt_(m, locals, 1);
		Date_fromString_format_(DATA(self), CSTRING(date_input), CSTRING(format));
	}
	IoObject_isDirty_(self, 1);
	return self;
}
Exemple #15
0
IO_METHOD(IoDate, convertToZone)
{
	/*doc Date convertToZone(offset, isDST)
	Converts self to an equivalent data in a zone with offset (minutes west) and DST (true, false).
	*/

	struct timezone tz;
	
	int mw = IoMessage_locals_intArgAt_(m, locals, 0);
	int dst = IoMessage_locals_boolArgAt_(m, locals, 1);
	
	tz.tz_minuteswest = mw;
	tz.tz_dsttime = dst;
	Date_convertToTimeZone_(DATA(self), tz);
	IoObject_isDirty_(self, 1);
	return self;
}
Exemple #16
0
IoObject *IoObject_rawClone(IoObject *proto)
{
	IoObject *self = IoObject_alloc(proto);
	IoObject_tag_(self, IoObject_tag(proto));
	/*
	{
		IoObject **protos = IoObject_protos(self);
		protos[0] = proto;
	}
	*/
	IoObject_setProtoTo_(self, proto);

	//IoObject_protos(self)[0] = proto;
	//IoObject_setDataPointer_(self, IoObject_dataPointer(proto)); // is this right?
	IoObject_isDirty_(self, 1);
	return self;
}
Exemple #17
0
IO_METHOD(IoSeq, convertToItemType)
{
	/*doc Sequence convertToItemType(aTypeName)
	Converts the underlying machine type for the elements, expanding or contracting
	the size of the Sequence as needed. 
	Valid names are uint8, uint16, uint32, uint64, int8, int16, int32, 
	int64, float32, and float64. Note that 64 bit types are only available 
	on platforms that support such types. Returns self. 
	*/
	IoSymbol *typeName = IoMessage_locals_symbolArgAt_(m, locals, 0);
	CTYPE itemType = CTYPE_forName(CSTRING(typeName));

	IO_ASSERT_NOT_SYMBOL(self);

	IOASSERT(itemType != -1, "invalid item type name");

	UArray_convertToItemType_(DATA(self), itemType);
	IoObject_isDirty_(self, 1);
	return self;
}
Exemple #18
0
IO_METHOD(IoSeq, setItemType)
{
	/*doc Sequence setItemType(aTypeName)
	Sets the underlying machine type for the elements. 
	Valid names are uint8, uint16, uint32, uint64, int8, int16, int32, 
	int64, float32, and float64. Note that 64 bit types are only available 
	on platforms that support such types. Returns self. 
	*/

	CTYPE itemType;
	IoSeq *typeName;

	IO_ASSERT_NOT_SYMBOL(self);

	typeName = IoMessage_locals_symbolArgAt_(m, locals, 0);
	itemType = CTYPE_forName(CSTRING(typeName));

	IOASSERT(itemType != -1, "invalid item type name");

	UArray_setItemType_(DATA(self), itemType);
	IoObject_isDirty_(self, 1);
	return self;
}
Exemple #19
0
IO_METHOD(IoSeq, setEncoding)
{
	/*doc Sequence setEncoding(encodingName)
	Sets the encoding flag of the receiver (only the encoding flag, 
	itemSize and itemType will change, no conversion is done between UTF
	encodings - you can use convertToUTF8, etc methods for conversions). 
	Valid encodings are number, utf8, utf16, and utf32. Returns self. 
	*/

	CENCODING encoding;
	IoSeq *encodingName;

	IO_ASSERT_NOT_SYMBOL(self);

	encodingName = IoMessage_locals_symbolArgAt_(m, locals, 0);
	encoding = CENCODING_forName(CSTRING(encodingName));

	IOASSERT(encoding != -1, "invalid encoding name");

	UArray_setEncoding_(DATA(self), encoding);

	IoObject_isDirty_(self, 1);
	return self;
}
Exemple #20
0
void IoList_rawAt_put_(IoList *self, int i, IoObject *v)
{
	List_at_put_(DATA(self), i, IOREF(v));
	IoObject_isDirty_(self, 1);
}
Exemple #21
0
void IoList_rawRemove_(IoList *self, IoObject *v)
{
	List_remove_(DATA(self), IOREF(v));
	IoObject_isDirty_(self, 1);
}
Exemple #22
0
void IoList_rawAppend_(IoList *self, IoObject *v)
{
	List_append_(DATA(self), IOREF(v));
	IoObject_isDirty_(self, 1);
}