예제 #1
0
int
LDAPValueList_Extend(LDAPValueList *self, PyObject *b) {
	if (balancing(b, self->deleted) != 0) return -1;
	if (UniqueList_Extend(self->added, b) != 0) return -1;
	if (UniqueList_Extend((UniqueList *)self, b) != 0) return -1;
	return 0;
}
예제 #2
0
/*	Set the slice of LDAPValueList between `ilow` and `ihigh` to the contents of `itemlist`.
	The `itemlist` must be containing unique elements. New items are append to the added list,
	and removed items are append to the deleted list. The `itemlist` may be NULL, indicating
	the assignment of an empty list (slice deletion).
*/
int
LDAPValueList_SetSlice(LDAPValueList *self, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *itemlist) {
	PyObject *remove;

	/* Copying the removable items from LDAPValueList to deleted list.*/
	remove = PyList_GetSlice((PyObject *)self, ilow, ihigh);
	if (remove == NULL) return -1;
	if (balancing(remove, self->added) != 0) {
		Py_DECREF(remove);
		return -1;
	}
	if (UniqueList_Extend(self->deleted, remove) != 0) {
		Py_DECREF(remove);
		return -1;
	}
	Py_DECREF(remove);

	/* Copying new items to the added list.*/
	if (itemlist != NULL) {
		if (balancing(itemlist, self->deleted) != 0) return -1;
		if (UniqueList_Extend(self->added, itemlist) != 0) return -1;
	}

    return UniqueList_SetSlice((UniqueList *)self, ilow, ihigh, itemlist);
}
예제 #3
0
static PyObject *
UL_extend(UniqueList *self, PyObject *b) {
	if (UniqueList_Extend(self, b) == 0) {
		return Py_None;
	}
	return NULL;
}