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

Function ToFloatTuple

trinity/Sprite2d/Tr2Sprite2dLineTrace_Blue.cpp:15–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13{
14
15bool 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

Callers 2

PyAppendVerticesMethod · 0.70
PySetVerticesMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected