Example #1
0
static PyObject* PyPointlessVector_subscript_priv(PyPointlessVector* self, uint32_t i)
{
	i += self->slice_i;

	switch (self->v->type) {
		case POINTLESS_VECTOR_VALUE:
		case POINTLESS_VECTOR_VALUE_HASHABLE:
			return pypointless_value(self->pp, pointless_reader_vector_value(&self->pp->p, self->v) + i);
		case POINTLESS_VECTOR_I8:
			return pypointless_i32(self->pp, (int32_t)pointless_reader_vector_i8(&self->pp->p, self->v)[i]);
		case POINTLESS_VECTOR_U8:
			return pypointless_u32(self->pp, (uint32_t)pointless_reader_vector_u8(&self->pp->p, self->v)[i]);
		case POINTLESS_VECTOR_I16:
			return pypointless_i32(self->pp, (int32_t)pointless_reader_vector_i16(&self->pp->p, self->v)[i]);
		case POINTLESS_VECTOR_U16:
			return pypointless_u32(self->pp, (uint32_t)pointless_reader_vector_u16(&self->pp->p, self->v)[i]);
		case POINTLESS_VECTOR_I32:
			return pypointless_i32(self->pp, pointless_reader_vector_i32(&self->pp->p, self->v)[i]);
		case POINTLESS_VECTOR_U32:
			return pypointless_u32(self->pp, pointless_reader_vector_u32(&self->pp->p, self->v)[i]);
		case POINTLESS_VECTOR_I64:
			return pypointless_i64(self->pp, pointless_reader_vector_i64(&self->pp->p, self->v)[i]);
		case POINTLESS_VECTOR_U64:
			return pypointless_u64(self->pp, pointless_reader_vector_u64(&self->pp->p, self->v)[i]);
		case POINTLESS_VECTOR_FLOAT:
			return pypointless_float(self->pp, pointless_reader_vector_float(&self->pp->p, self->v)[i]);
	}

	PyErr_Format(PyExc_TypeError, "strange array type");
	return 0;
}
Example #2
0
static PyObject* PyPointlessSetIter_iternext(PyPointlessSetIter* iter)
{
	// iterator already reached end
	if (iter->set == 0)
		return 0;

	pointless_value_t* v = 0;

	if (pointless_reader_set_iter(&iter->set->pp->p, iter->set->v, &v, &iter->iter_state))
		return pypointless_value(iter->set->pp, v);

	Py_DECREF(iter->set);
	iter->set = 0;
	return 0;
}