python_c_extension/_disptools.c
/*!
 * Read a tuple of 3 floats and return an array of FLOATING.
 */
Read a tuple of 3 floats and return an array of FLOATING.
Read a tuple of 3 floats and return an array of FLOATING .
bool read_triplet(PyObject *tuple, FLOATING *result, const int expected_length, const char *parameter_name) {
    int len = PyTuple_Size(tuple);
    if (expected_length != len) {
        PyErr_Format(PyExc_ValueError, "Wrong number of components (%d) for %s.", len, parameter_name);
        return true;
    }
    for (int i = 0; i < len; ++i) {
        result[i] = (FLOATING) PyFloat_AsDouble(PyTuple_GetItem(tuple, i));
        if (PyErr_Occurred()) {
            PyErr_Format(PyExc_ValueError, "%s must be a tuple of floats.", parameter_name);
            return true;
        }
    }
    return false;
}
bool read_triplet ( PyObject * tuple , FLOATING * result , const int expected_length , const char * parameter_name ) { int len = PyTuple_Size ( tuple ) ; if ( expected_length != len ) { PyErr_Format ( PyExc_ValueError , " " , len , parameter_name ) ; return true ; } for ( int i = 0 ; i < len ; ++ i ) { result [ i ] = ( FLOATING ) PyFloat_AsDouble ( PyTuple_GetItem ( tuple , i ) ) ; if ( PyErr_Occurred ( ) ) { PyErr_Format ( PyExc_ValueError , " " , parameter_name ) ; return true ; } } return false ; }
Read a tuple of 3 floats and return an array of FLOATING.
Read a tuple of 3 floats and return an array of FLOATING .