27 #ifndef vtkPythonArgs_h
28 #define vtkPythonArgs_h
30 #include "vtkWrappingPythonCoreModule.h"
32 #include "PyVTKClass.h"
33 #include "PyVTKTemplate.h"
47 Args(args), MethodName(methodname) {
48 this->N = PyTuple_GET_SIZE(args);
49 this->
M = PyVTKClass_Check(
self);
57 Args(args), MethodName(methodname) {
58 this->N = PyTuple_GET_SIZE(args);
74 static void *GetSelfPointer(
PyObject *
self);
77 bool CheckArgCount(
int nmin,
int nmax);
80 bool CheckArgCount(
int n);
89 static bool ErrorOccurred();
97 int GetArgSize(
int i);
103 v = this->GetArgAsPythonObject(b);
119 v = (T *)this->GetArgAsVTKObject(classname, b);
134 v =
static_cast<T *
>(this->GetArgAsSpecialObject(classname, &o));
135 return (v != NULL); }
139 v =
static_cast<T *
>(
141 return (v != NULL); }
149 v =
static_cast<T *
>(this->GetArgAsSpecialObject(classname, NULL));
150 return (v != NULL); }
153 v =
static_cast<T *
>(
155 return (v != NULL); }
163 v =
static_cast<T
>(this->GetArgAsEnum(enumtype, r));
177 v = (T *)this->GetArgAsSIPObject(classname, r);
191 v =
static_cast<T
>(this->GetArgAsSIPEnum(enumname, r));
208 bool GetValue(
void *&v);
209 static bool GetValue(
PyObject *o,
void *&v);
210 bool GetValue(
const void *&v);
211 static bool GetValue(
PyObject *o,
const void *&v);
215 bool GetValue(
const char *&v);
216 static bool GetValue(
PyObject *o,
const char *&v);
217 bool GetValue(
char *&v);
218 static bool GetValue(
PyObject *o,
char *&v);
227 bool GetValue(
char &v);
228 static bool GetValue(
PyObject *o,
char &v);
233 bool GetValue(
float &v);
234 static bool GetValue(
PyObject *o,
float &v);
235 bool GetValue(
double &v);
236 static bool GetValue(
PyObject *o,
double &v);
237 bool GetValue(
bool &v);
238 static bool GetValue(
PyObject *o,
bool &v);
239 bool GetValue(
signed char &v);
240 static bool GetValue(
PyObject *o,
signed char &v);
241 bool GetValue(
unsigned char &v);
242 static bool GetValue(
PyObject *o,
unsigned char &v);
243 bool GetValue(
short &v);
244 static bool GetValue(
PyObject *o,
short &v);
245 bool GetValue(
unsigned short &v);
246 static bool GetValue(
PyObject *o,
unsigned short &v);
247 bool GetValue(
int &v);
248 static bool GetValue(
PyObject *o,
int &v);
249 bool GetValue(
unsigned int &v);
250 static bool GetValue(
PyObject *o,
unsigned int &v);
251 bool GetValue(
long &v);
252 static bool GetValue(
PyObject *o,
long &v);
253 bool GetValue(
unsigned long &v);
254 static bool GetValue(
PyObject *o,
unsigned long &v);
255 #ifdef VTK_TYPE_USE_LONG_LONG
256 bool GetValue(
long long &v);
257 static bool GetValue(
PyObject *o,
long long &v);
258 bool GetValue(
unsigned long long &v);
259 static bool GetValue(
PyObject *o,
unsigned long long &v);
261 #ifdef VTK_TYPE_USE___INT64
262 bool GetValue(__int64 &v);
263 static bool GetValue(
PyObject *o, __int64 &v);
264 bool GetValue(
unsigned __int64 &v);
265 static bool GetValue(
PyObject *o,
unsigned __int64 &v);
271 bool GetArray(
float *v,
int n);
272 bool GetArray(
double *v,
int n);
273 bool GetArray(
bool *v,
int n);
274 bool GetArray(
char *v,
int n);
275 bool GetArray(
signed char *v,
int n);
276 bool GetArray(
unsigned char *v,
int n);
277 bool GetArray(
short *v,
int n);
278 bool GetArray(
unsigned short *v,
int n);
279 bool GetArray(
int *v,
int n);
280 bool GetArray(
unsigned int *v,
int n);
281 bool GetArray(
long *v,
int n);
282 bool GetArray(
unsigned long *v,
int n);
283 #ifdef VTK_TYPE_USE_LONG_LONG
284 bool GetArray(
long long *v,
int n);
285 bool GetArray(
unsigned long long *v,
int n);
287 #ifdef VTK_TYPE_USE___INT64
288 bool GetArray(__int64 *v,
int n);
289 bool GetArray(
unsigned __int64 *v,
int n);
295 bool GetNArray(
float *v,
int ndims,
const int *dims);
296 bool GetNArray(
double *v,
int ndims,
const int *dims);
297 bool GetNArray(
bool *v,
int ndims,
const int *dims);
298 bool GetNArray(
char *v,
int ndims,
const int *dims);
299 bool GetNArray(
signed char *v,
int ndims,
const int *dims);
300 bool GetNArray(
unsigned char *v,
int ndims,
const int *dims);
301 bool GetNArray(
short *v,
int ndims,
const int *dims);
302 bool GetNArray(
unsigned short *v,
int ndims,
const int *dims);
303 bool GetNArray(
int *v,
int ndims,
const int *dims);
304 bool GetNArray(
unsigned int *v,
int ndims,
const int *dims);
305 bool GetNArray(
long *v,
int ndims,
const int *dims);
306 bool GetNArray(
unsigned long *v,
int ndims,
const int *dims);
307 #ifdef VTK_TYPE_USE_LONG_LONG
308 bool GetNArray(
long long *v,
int ndims,
const int *dims);
309 bool GetNArray(
unsigned long long *v,
int ndims,
const int *dims);
311 #ifdef VTK_TYPE_USE___INT64
312 bool GetNArray(__int64 *v,
int ndims,
const int *dims);
313 bool GetNArray(
unsigned __int64 *v,
int ndims,
const int *dims);
321 bool SetArgValue(
int i,
char v);
322 bool SetArgValue(
int i,
float v);
323 bool SetArgValue(
int i,
double v);
324 bool SetArgValue(
int i,
bool v);
325 bool SetArgValue(
int i,
signed char v);
326 bool SetArgValue(
int i,
unsigned char v);
327 bool SetArgValue(
int i,
short v);
328 bool SetArgValue(
int i,
unsigned short v);
329 bool SetArgValue(
int i,
int v);
330 bool SetArgValue(
int i,
unsigned int v);
331 bool SetArgValue(
int i,
long v);
332 bool SetArgValue(
int i,
unsigned long v);
333 #ifdef VTK_TYPE_USE_LONG_LONG
334 bool SetArgValue(
int i,
long long v);
335 bool SetArgValue(
int i,
unsigned long long v);
337 #ifdef VTK_TYPE_USE___INT64
338 bool SetArgValue(
int i, __int64 v);
339 bool SetArgValue(
int i,
unsigned __int64 v);
345 bool SetArray(
int i,
const float *v,
int n);
346 bool SetArray(
int i,
const double *v,
int n);
347 bool SetArray(
int i,
const bool *v,
int n);
348 bool SetArray(
int i,
const char *v,
int n);
349 bool SetArray(
int i,
const signed char *v,
int n);
350 bool SetArray(
int i,
const unsigned char *v,
int n);
351 bool SetArray(
int i,
const short *v,
int n);
352 bool SetArray(
int i,
const unsigned short *v,
int n);
353 bool SetArray(
int i,
const int *v,
int n);
354 bool SetArray(
int i,
const unsigned int *v,
int n);
355 bool SetArray(
int i,
const long *v,
int n);
356 bool SetArray(
int i,
const unsigned long *v,
int n);
357 #ifdef VTK_TYPE_USE_LONG_LONG
358 bool SetArray(
int i,
const long long *v,
int n);
359 bool SetArray(
int i,
const unsigned long long *v,
int n);
361 #ifdef VTK_TYPE_USE___INT64
362 bool SetArray(
int i,
const __int64 *v,
int n);
363 bool SetArray(
int i,
const unsigned __int64 *v,
int n);
369 bool SetNArray(
int i,
const float *v,
int n,
const int *d);
370 bool SetNArray(
int i,
const double *v,
int n,
const int *d);
371 bool SetNArray(
int i,
const bool *v,
int n,
const int *d);
372 bool SetNArray(
int i,
const char *v,
int n,
const int *d);
373 bool SetNArray(
int i,
const signed char *v,
int n,
const int *d);
374 bool SetNArray(
int i,
const unsigned char *v,
int n,
const int *d);
375 bool SetNArray(
int i,
const short *v,
int n,
const int *d);
376 bool SetNArray(
int i,
const unsigned short *v,
int n,
const int *d);
377 bool SetNArray(
int i,
const int *v,
int n,
const int *d);
378 bool SetNArray(
int i,
const unsigned int *v,
int n,
const int *d);
379 bool SetNArray(
int i,
const long *v,
int n,
const int *d);
380 bool SetNArray(
int i,
const unsigned long *v,
int n,
const int *d);
381 #ifdef VTK_TYPE_USE_LONG_LONG
382 bool SetNArray(
int i,
const long long *v,
int n,
const int *d);
383 bool SetNArray(
int i,
const unsigned long long *v,
int n,
const int *d);
385 #ifdef VTK_TYPE_USE___INT64
386 bool SetNArray(
int i,
const __int64 *v,
int n,
const int *d);
387 bool SetNArray(
int i,
const unsigned __int64 *v,
int n,
const int *d);
396 static PyObject *BuildVTKObject(
const void *v);
399 static PyObject *BuildSpecialObject(
const void *v,
const char *classname);
402 static PyObject *BuildEnumValue(
int v,
const char *enumname);
408 const void *v,
const char *classname,
bool created);
412 static PyObject *BuildSIPEnumValue(
int v,
const char *classname);
415 static PyObject *BuildValue(
const void *v);
419 static PyObject *BuildValue(
const char *v);
425 static PyObject *BuildValue(
char v);
429 static PyObject *BuildValue(
double v);
430 static PyObject *BuildValue(
bool v);
432 static PyObject *BuildValue(
unsigned int v);
433 static PyObject *BuildValue(
long v);
434 static PyObject *BuildValue(
unsigned long v);
435 #ifdef VTK_TYPE_USE_LONG_LONG
436 static PyObject *BuildValue(
long long v);
437 static PyObject *BuildValue(
unsigned long long v);
439 #ifdef VTK_TYPE_USE___INT64
440 static PyObject *BuildValue(__int64 v);
441 static PyObject *BuildValue(
unsigned __int64 v);
446 static PyObject *BuildBytes(
const char *v,
int n);
450 static PyObject *BuildTuple(
const float *v,
int n);
451 static PyObject *BuildTuple(
const double *v,
int n);
452 static PyObject *BuildTuple(
const bool *v,
int n);
453 static PyObject *BuildTuple(
const signed char *v,
int n);
454 static PyObject *BuildTuple(
const unsigned char *v,
int n);
455 static PyObject *BuildTuple(
const short *v,
int n);
456 static PyObject *BuildTuple(
const unsigned short *v,
int n);
457 static PyObject *BuildTuple(
const int *v,
int n);
458 static PyObject *BuildTuple(
const unsigned int *v,
int n);
459 static PyObject *BuildTuple(
const long *v,
int n);
460 static PyObject *BuildTuple(
const unsigned long *v,
int n);
461 #ifdef VTK_TYPE_USE_LONG_LONG
462 static PyObject *BuildTuple(
const long long *v,
int n);
463 static PyObject *BuildTuple(
const unsigned long long *v,
int n);
465 #ifdef VTK_TYPE_USE___INT64
466 static PyObject *BuildTuple(
const __int64 *v,
int n);
467 static PyObject *BuildTuple(
const unsigned __int64 *v,
int n);
476 do { b[i] = a[i]; }
while (++i < n); }
484 do {
if (a[i] != b[i])
break; }
while (++i < n);
491 return static_cast<int>(PyTuple_GET_SIZE(args)); }
497 return (static_cast<int>(PyTuple_GET_SIZE(args)) -
498 PyVTKClass_Check(
self)); }
502 static bool ArgCountError(
int n,
const char *
name);
512 PyObject *GetArgAsPythonObject(
bool &valid);
513 static PyObject *GetArgAsPythonObject(
519 vtkObjectBase *GetArgAsVTKObject(
const char *classname,
bool &valid);
521 PyObject *o,
const char *classname,
bool &valid);
526 void *GetArgAsSpecialObject(
const char *classname,
PyObject **newobj);
527 static void *GetArgAsSpecialObject(
533 int GetArgAsEnum(PyTypeObject *enumtype,
bool &valid);
534 static int GetArgAsEnum(
535 PyObject *o, PyTypeObject *enumtype,
bool &valid);
540 void *GetArgAsSIPObject(
const char *classname,
bool &valid);
541 static void *GetArgAsSIPObject(
542 PyObject *o,
const char *classname,
bool &valid);
547 int GetArgAsSIPEnum(
const char *classname,
bool &valid);
548 static int GetArgAsSIPEnum(
549 PyObject *o,
const char *classname,
bool &valid);
553 bool PureVirtualError();
556 bool ArgCountError(
int m,
int n);
559 bool RefineArgTypeError(
int i);
564 const char *MethodName;
578 if (PyVTKClass_Check(
self))
582 return ((PyVTKObject *)
self)->vtk_ptr;
589 return ((PyVTKSpecialObject *)
self)->vtk_ptr;
599 int nargs = this->N - this->M;
600 if (nargs >= nmin && nargs <= nmax)
612 int nargs = this->N - this->M;
641 return (PyErr_Occurred() != NULL);
658 static_cast<vtkObjectBase *>(const_cast<void *>(v)));
663 const char *classname)
665 return PyVTKSpecialObject_CopyNew(classname, v);
677 const void *v,
const char *classname,
bool created)
695 return PyString_FromString(s);
706 return PyString_FromString(a);
715 return PyString_FromStringAndSize(a.c_str(),
static_cast<Py_ssize_t>(a.size()));
723 #ifdef Py_USING_UNICODE
724 return PyUnicode_DecodeUTF8(s.c_str(),
static_cast<Py_ssize_t>(s.size()), NULL);
726 return PyString_FromStringAndSize(s.c_str(),
static_cast<Py_ssize_t>(s.size()));
736 return PyString_FromString(b);
742 return PyFloat_FromDouble(a);
748 #if PY_VERSION_HEX >= 0x02030000
749 return PyBool_FromLong((
long)a);
751 return PyInt_FromLong((
long)a);
758 return PyInt_FromLong(a);
764 #if VTK_SIZEOF_INT < VTK_SIZEOF_LONG
765 return PyInt_FromLong(a);
769 return PyInt_FromLong((
long)(a));
771 return PyLong_FromUnsignedLong(a);
778 return PyInt_FromLong(a);
786 return PyInt_FromLong((
long)(a));
788 return PyLong_FromUnsignedLong(a);
791 #if defined(VTK_TYPE_USE_LONG_LONG)
795 #if defined(PY_LONG_LONG)
796 return PyLong_FromLongLong(a);
798 return PyLong_FromLong((
long)(a));
805 #if defined(PY_LONG_LONG)
806 return PyLong_FromUnsignedLongLong(a);
808 return PyLong_FromUnsignedLong((
unsigned long)(a));
813 #if defined(VTK_TYPE_USE___INT64)
817 #if defined(PY_LONG_LONG)
818 return PyLong_FromLongLong(a);
820 return PyLong_FromLong((
long)(a));
827 #if defined(PY_LONG_LONG)
828 return PyLong_FromUnsignedLongLong(a);
830 return PyLong_FromUnsignedLong((
unsigned long)(a));
838 return PyString_FromStringAndSize(a, n);
bool GetSIPObject(T *&v, const char *classname)
static void SaveArray(const T *a, T *b, int n)
vtkPythonArgs(PyObject *args, const char *methodname)
bool GetPythonObject(PyObject *&v)
static PyObject * BuildVTKObject(const void *v)
bool GetSpecialObject(T *&v, PyObject *&o, const char *classname)
bool GetSIPEnumValue(T &v, const char *enumname)
static PyObject * BuildValue(const void *v)
static vtkObjectBase * GetSelfPointer(PyObject *self, PyObject *args)
static bool GetSIPEnumValue(PyObject *o, T &v, const char *enumname)
static vtkObjectBase * GetSelfFromFirstArg(PyObject *self, PyObject *args)
int GetArgAsSIPEnum(const char *classname, bool &valid)
static bool GetSpecialObject(PyObject *o, T *&v, const char *classname)
static PyObject * BuildSIPObject(const void *v, const char *classname, bool created)
vtkObjectBase * GetArgAsVTKObject(const char *classname, bool &valid)
static bool GetSIPObject(PyObject *o, T *&v, const char *classname)
static bool GetSpecialObject(PyObject *arg, T *&v, PyObject *&o, const char *classname)
void * GetArgAsSpecialObject(const char *classname, PyObject **newobj)
static PyObject * BuildSIPEnumValue(int v, const char *classname)
static bool ErrorOccurred()
vtkPythonArgs(PyObject *self, PyObject *args, const char *methodname)
int GetArgAsEnum(PyTypeObject *enumtype, bool &valid)
PyObject * GetArgAsPythonObject(bool &valid)
static int GetArgCount(PyObject *args)
static PyObject * BuildBytes(const char *v, int n)
static bool GetEnumValue(PyObject *o, T &v, PyTypeObject *enumtype)
static bool ArgCountError(int n, const char *name)
const char * utf8_str() const
bool GetEnumValue(T &v, PyTypeObject *enumtype)
abstract base class for most VTK objects
bool GetVTKObject(T *&v, const char *classname)
static char * ManglePointer(const void *ptr, const char *type)
static int GetArgCount(PyObject *self, PyObject *args)
bool GetVTKObject(PyObject *o, T *&v, const char *classname)
static bool ArrayHasChanged(const T *a, const T *b, int n)
void * GetArgAsSIPObject(const char *classname, bool &valid)
static PyObject * SIPGetObjectFromPointer(const void *ptr, const char *classname, bool is_new)
bool GetPythonObject(PyObject *o, PyObject *&v)
static PyObject * BuildSpecialObject(const void *v, const char *classname)
bool GetSpecialObject(T *&v, const char *classname)
static PyObject * BuildEnumValue(int v, const char *enumname)
static PyObject * BuildNone()
bool CheckArgCount(int nmin, int nmax)
String class that stores Unicode text.
static PyObject * GetObjectFromPointer(vtkObjectBase *ptr)