MCPcopy Create free account
hub / github.com/Kitware/VTK / vtkPythonGetArray

Function vtkPythonGetArray

Wrapping/PythonCore/vtkPythonArgs.cxx:466–524  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

464
465template <class T>
466inline bool vtkPythonGetArray(PyObject* o, T* a, size_t n)
467{
468 if (a)
469 {
470 Py_ssize_t m = static_cast<Py_ssize_t>(n);
471
472 if (PyTuple_Check(o))
473 {
474 m = PyTuple_Size(o);
475 if (m == static_cast<Py_ssize_t>(n))
476 {
477 bool r = true;
478 for (Py_ssize_t i = 0; i < m && r; i++)
479 {
480 PyObject* s = PyTuple_GetItem(o, i);
481 r = vtkPythonGetValue(s, a[i]);
482 }
483 return r;
484 }
485 }
486 else if (PyList_Check(o))
487 {
488 m = PyList_Size(o);
489 if (m == static_cast<Py_ssize_t>(n))
490 {
491 bool r = true;
492 for (Py_ssize_t i = 0; i < m && r; i++)
493 {
494 PyObject* s = PyList_GetItem(o, i);
495 r = vtkPythonGetValue(s, a[i]);
496 }
497 return r;
498 }
499 }
500 else if (PySequence_Check(o))
501 {
502 m = PySequence_Size(o);
503 if (m == static_cast<Py_ssize_t>(n))
504 {
505 bool r = true;
506 for (Py_ssize_t i = 0; i < m && r; i++)
507 {
508 r = false;
509 PyObject* s = PySequence_GetItem(o, i);
510 if (s && vtkPythonGetValue(s, a[i]))
511 {
512 Py_DECREF(s);
513 r = true;
514 }
515 }
516 return r;
517 }
518 }
519
520 return vtkPythonSequenceError(o, n, m);
521 }
522
523 return true;

Callers

nothing calls this directly

Calls 4

vtkPythonGetValueFunction · 0.85
vtkPythonSequenceErrorFunction · 0.85
vtkPythonGetStringValueFunction · 0.85
vtkPythonGetStringSizeFunction · 0.85

Tested by

no test coverage detected