static int PyUnitListProxy_setitem( PyUnitListProxy* self, Py_ssize_t index, PyObject* arg) { PyObject* value; PyObject* unicode_value; PyObject* bytes_value; if (index > self->size) { PyErr_SetString(PyExc_IndexError, "index out of range"); return -1; } value = _get_unit(self->unit_class, arg); if (value == NULL) { return -1; } unicode_value = PyObject_CallMethod(value, "to_string", "s", "fits"); if (unicode_value == NULL) { Py_DECREF(value); return -1; } Py_DECREF(value); if (PyUnicode_Check(unicode_value)) { bytes_value = PyUnicode_AsASCIIString(unicode_value); if (bytes_value == NULL) { Py_DECREF(unicode_value); return -1; } Py_DECREF(unicode_value); } else { bytes_value = unicode_value; } strncpy(self->array[index], PyBytes_AsString(bytes_value), MAXSIZE); Py_DECREF(bytes_value); return 0; }
/*@null@*/ static PyObject* PyUnitListProxy_getitem( PyUnitListProxy* self, Py_ssize_t index) { PyObject *value; PyObject *result; if (index >= self->size) { PyErr_SetString(PyExc_IndexError, "index out of range"); return NULL; } value = PyUnicode_FromString(self->array[index]); result = _get_unit(self->unit_class, value); Py_DECREF(value); return result; }
static const char * arv_gc_converter_get_float_unit (ArvGcFloat *gc_float, GError **error) { return _get_unit (ARV_GC_CONVERTER (gc_float), error); }
static const char * arv_gc_converter_get_integer_unit (ArvGcInteger *gc_integer, GError **error) { return _get_unit (ARV_GC_CONVERTER (gc_integer), error); }