示例#1
0
文件: IoList.c 项目: doublec/io
int IoList_compare(IoList *self, IoList *otherList)
{
	if (!ISLIST(otherList))
	{
		return IoObject_defaultCompare(self, otherList);
	}
	else
	{
		size_t s1 =  List_size(DATA(self));
		size_t s2 =  List_size(DATA(otherList));
		size_t i;

		if (s1 != s2)
		{
			return s1 > s2 ? 1 : -1;
		}

		for (i = 0; i < s1; i ++)
		{
			IoObject *v1 = LIST_AT_(DATA(self), i);
			IoObject *v2 = LIST_AT_(DATA(otherList), i);
			int c = IoObject_compare(v1, v2);

			if (c)
			{
				return c;
			}
		}
	}
	return 0;
}
示例#2
0
IoMessage *IoMessage_deepCopyOf_(IoMessage *self)
{
	IoMessage *child = IoMessage_new(IOSTATE);
	int i;

	/*printf("deep copying: %s\n", UArray_asCString(IoMessage_description(self)));*/
	for (i = 0; i < IoMessage_argCount(self); i ++)
	{
		List_append_(DATA(child)->args,
					 IOREF(IoMessage_deepCopyOf_(LIST_AT_(DATA(self)->args, i))));
	}

	IoMessage_rawSetName_(child, DATA(self)->name);
	IoMessage_rawSetCachedResult_(child, (IoObject *)DATA(self)->cachedResult);

	if (DATA(self)->next)
	{
		IoMessage_rawSetNext_(child, IoMessage_deepCopyOf_(DATA(self)->next));
	}
	/*printf("deep copy result: %s\n", UArray_asCString(IoMessage_description(child)));*/
	return child;
}