| 13 | { |
| 14 | |
| 15 | bool ToFloatTuple( PyObject* value, ssize_t length, float* destination ) |
| 16 | { |
| 17 | if( PyTuple_Check( value ) && PyTuple_GET_SIZE( value ) == length ) |
| 18 | { |
| 19 | for( ssize_t i = 0; i < length; ++i ) |
| 20 | { |
| 21 | auto item = PyTuple_GET_ITEM( value, i ); |
| 22 | if( PyFloat_Check( item ) ) |
| 23 | { |
| 24 | destination[i] = float( PyFloat_AsDouble( item ) ); |
| 25 | } |
| 26 | #if PY_MAJOR_VERSION == 2 |
| 27 | else if( PyInt_Check( item ) ) |
| 28 | { |
| 29 | destination[i] = float( PyInt_AsLong( item ) ); |
| 30 | } |
| 31 | #endif |
| 32 | else if( PyLong_Check( item ) ) |
| 33 | { |
| 34 | destination[i] = float( PyLong_AsDouble( item ) ); |
| 35 | } |
| 36 | else |
| 37 | { |
| 38 | return false; |
| 39 | } |
| 40 | } |
| 41 | return true; |
| 42 | } |
| 43 | return false; |
| 44 | } |
| 45 | |
| 46 | } |
| 47 |
no outgoing calls
no test coverage detected