| 399 | } |
| 400 | |
| 401 | PyObject* Tr2Sprite2dPolygon::PyAppendTriangles( PyObject* self, PyObject* args ) |
| 402 | { |
| 403 | auto pThis = BluePythonCast<Tr2Sprite2dPolygon*>( self ); |
| 404 | PyObject* pyTriangles = nullptr; |
| 405 | |
| 406 | if( !PyArg_ParseTuple( args, "O", &pyTriangles ) ) |
| 407 | { |
| 408 | return nullptr; |
| 409 | } |
| 410 | |
| 411 | if( !PySequence_Check( pyTriangles ) ) |
| 412 | { |
| 413 | PyErr_SetString( PyExc_TypeError, "triangles parameter must be a sequence of 3-tuples" ); |
| 414 | return nullptr; |
| 415 | } |
| 416 | |
| 417 | for( ssize_t index = 0;; ++index ) |
| 418 | { |
| 419 | auto item = PySequence_GetItem( pyTriangles, index ); |
| 420 | if( !item ) |
| 421 | { |
| 422 | PyErr_Clear(); |
| 423 | break; |
| 424 | } |
| 425 | if( !PyTuple_Check( item ) || PyTuple_GET_SIZE( item ) != 3 || |
| 426 | !PyVerCompat::IsPyInt( PyTuple_GET_ITEM( item, 0 ) ) || !PyVerCompat::IsPyInt( PyTuple_GET_ITEM( item, 1 ) ) || !PyVerCompat::IsPyInt( PyTuple_GET_ITEM( item, 2 ) ) ) |
| 427 | { |
| 428 | Py_DECREF( item ); |
| 429 | PyErr_SetString( PyExc_TypeError, "triangles parameter must be a sequence of 3-tuples" ); |
| 430 | return nullptr; |
| 431 | } |
| 432 | Tr2Sprite2dTrianglePtr triangle; |
| 433 | triangle.CreateInstance(); |
| 434 | |
| 435 | triangle->m_index[0] = uint16_t( FromPython<int32_t>( PyTuple_GET_ITEM( item, 0 ) ) ); |
| 436 | triangle->m_index[1] = uint16_t( FromPython<int32_t>( PyTuple_GET_ITEM( item, 1 ) ) ); |
| 437 | triangle->m_index[2] = uint16_t( FromPython<int32_t>( PyTuple_GET_ITEM( item, 2 ) ) ); |
| 438 | |
| 439 | pThis->m_triangles.Append( triangle ); |
| 440 | |
| 441 | Py_DECREF( item ); |
| 442 | } |
| 443 | pThis->SetDirty(); |
| 444 | Py_RETURN_NONE; |
| 445 | } |
| 446 | |
| 447 | #endif |
| 448 |
nothing calls this directly
no test coverage detected