MCPcopy Create free account
hub / github.com/carbonengine/trinity / ToFloatTuple

Function ToFloatTuple

trinity/Sprite2d/Tr2Sprite2dPolygon_Blue.cpp:16–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

PyAppendVerticesMethod · 0.70
PySetVerticesMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected