27 #ifndef __vtkPythonArgs_h
28 #define __vtkPythonArgs_h
30 #include "vtkWrappingPythonCoreModule.h"
32 #include "PyVTKClass.h"
33 #include "PyVTKTemplate.h"
35 #include "vtkConfigure.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);
65 void Reset() { this->I = this->M; }
70 static vtkObjectBase *GetSelfPointer(PyObject *
self, PyObject *args);
74 static void *GetSelfPointer(PyObject *
self);
77 bool CheckArgCount(
int nmin,
int nmax);
80 bool CheckArgCount(
int n);
89 static bool ErrorOccurred();
102 v = (T *)this->GetArgAsVTKObject(classname, b);
117 v =
static_cast<T *
>(this->GetArgAsSpecialObject(classname, &o));
118 return (v != NULL); }
121 PyObject *arg, T *&v, PyObject *&o,
const char *classname) {
122 v =
static_cast<T *
>(
124 return (v != NULL); }
132 v =
static_cast<T *
>(this->GetArgAsSpecialObject(classname, NULL));
133 return (v != NULL); }
136 v =
static_cast<T *
>(
138 return (v != NULL); }
146 v =
static_cast<T
>(this->GetArgAsEnum(enumname, r));
160 v = (T *)this->GetArgAsSIPObject(classname, r);
174 v =
static_cast<T
>(this->GetArgAsSIPEnum(enumname, r));
186 bool GetFunction(PyObject *&o);
187 static bool GetFunction(PyObject *arg, PyObject *&o);
191 bool GetValue(
void *&v);
192 static bool GetValue(PyObject *o,
void *&v);
193 bool GetValue(
const void *&v);
194 static bool GetValue(PyObject *o,
const void *&v);
198 bool GetValue(
const char *&v);
199 static bool GetValue(PyObject *o,
const char *&v);
200 bool GetValue(
char *&v);
201 static bool GetValue(PyObject *o,
char *&v);
202 bool GetValue(std::string &v);
203 static bool GetValue(PyObject *o, std::string &v);
210 bool GetValue(
char &v);
211 static bool GetValue(PyObject *o,
char &v);
216 bool GetValue(
float &v);
217 static bool GetValue(PyObject *o,
float &v);
218 bool GetValue(
double &v);
219 static bool GetValue(PyObject *o,
double &v);
220 bool GetValue(
bool &v);
221 static bool GetValue(PyObject *o,
bool &v);
222 bool GetValue(
signed char &v);
223 static bool GetValue(PyObject *o,
signed char &v);
224 bool GetValue(
unsigned char &v);
225 static bool GetValue(PyObject *o,
unsigned char &v);
226 bool GetValue(
short &v);
227 static bool GetValue(PyObject *o,
short &v);
228 bool GetValue(
unsigned short &v);
229 static bool GetValue(PyObject *o,
unsigned short &v);
230 bool GetValue(
int &v);
231 static bool GetValue(PyObject *o,
int &v);
232 bool GetValue(
unsigned int &v);
233 static bool GetValue(PyObject *o,
unsigned int &v);
234 bool GetValue(
long &v);
235 static bool GetValue(PyObject *o,
long &v);
236 bool GetValue(
unsigned long &v);
237 static bool GetValue(PyObject *o,
unsigned long &v);
238 #ifdef VTK_TYPE_USE_LONG_LONG
239 bool GetValue(
long long &v);
240 static bool GetValue(PyObject *o,
long long &v);
241 bool GetValue(
unsigned long long &v);
242 static bool GetValue(PyObject *o,
unsigned long long &v);
244 #ifdef VTK_TYPE_USE___INT64
245 bool GetValue(__int64 &v);
246 static bool GetValue(PyObject *o, __int64 &v);
247 bool GetValue(
unsigned __int64 &v);
248 static bool GetValue(PyObject *o,
unsigned __int64 &v);
254 bool GetArray(
float *v,
int n);
255 bool GetArray(
double *v,
int n);
256 bool GetArray(
bool *v,
int n);
257 bool GetArray(
char *v,
int n);
258 bool GetArray(
signed char *v,
int n);
259 bool GetArray(
unsigned char *v,
int n);
260 bool GetArray(
short *v,
int n);
261 bool GetArray(
unsigned short *v,
int n);
262 bool GetArray(
int *v,
int n);
263 bool GetArray(
unsigned int *v,
int n);
264 bool GetArray(
long *v,
int n);
265 bool GetArray(
unsigned long *v,
int n);
266 #ifdef VTK_TYPE_USE_LONG_LONG
267 bool GetArray(
long long *v,
int n);
268 bool GetArray(
unsigned long long *v,
int n);
270 #ifdef VTK_TYPE_USE___INT64
271 bool GetArray(__int64 *v,
int n);
272 bool GetArray(
unsigned __int64 *v,
int n);
278 bool GetNArray(
float *v,
int ndims,
const int *dims);
279 bool GetNArray(
double *v,
int ndims,
const int *dims);
280 bool GetNArray(
bool *v,
int ndims,
const int *dims);
281 bool GetNArray(
char *v,
int ndims,
const int *dims);
282 bool GetNArray(
signed char *v,
int ndims,
const int *dims);
283 bool GetNArray(
unsigned char *v,
int ndims,
const int *dims);
284 bool GetNArray(
short *v,
int ndims,
const int *dims);
285 bool GetNArray(
unsigned short *v,
int ndims,
const int *dims);
286 bool GetNArray(
int *v,
int ndims,
const int *dims);
287 bool GetNArray(
unsigned int *v,
int ndims,
const int *dims);
288 bool GetNArray(
long *v,
int ndims,
const int *dims);
289 bool GetNArray(
unsigned long *v,
int ndims,
const int *dims);
290 #ifdef VTK_TYPE_USE_LONG_LONG
291 bool GetNArray(
long long *v,
int ndims,
const int *dims);
292 bool GetNArray(
unsigned long long *v,
int ndims,
const int *dims);
294 #ifdef VTK_TYPE_USE___INT64
295 bool GetNArray(__int64 *v,
int ndims,
const int *dims);
296 bool GetNArray(
unsigned __int64 *v,
int ndims,
const int *dims);
302 bool SetArgValue(
int i,
const std::string &v);
304 bool SetArgValue(
int i,
char v);
305 bool SetArgValue(
int i,
float v);
306 bool SetArgValue(
int i,
double v);
307 bool SetArgValue(
int i,
bool v);
308 bool SetArgValue(
int i,
signed char v);
309 bool SetArgValue(
int i,
unsigned char v);
310 bool SetArgValue(
int i,
short v);
311 bool SetArgValue(
int i,
unsigned short v);
312 bool SetArgValue(
int i,
int v);
313 bool SetArgValue(
int i,
unsigned int v);
314 bool SetArgValue(
int i,
long v);
315 bool SetArgValue(
int i,
unsigned long v);
316 #ifdef VTK_TYPE_USE_LONG_LONG
317 bool SetArgValue(
int i,
long long v);
318 bool SetArgValue(
int i,
unsigned long long v);
320 #ifdef VTK_TYPE_USE___INT64
321 bool SetArgValue(
int i, __int64 v);
322 bool SetArgValue(
int i,
unsigned __int64 v);
328 bool SetArray(
int i,
const float *v,
int n);
329 bool SetArray(
int i,
const double *v,
int n);
330 bool SetArray(
int i,
const bool *v,
int n);
331 bool SetArray(
int i,
const char *v,
int n);
332 bool SetArray(
int i,
const signed char *v,
int n);
333 bool SetArray(
int i,
const unsigned char *v,
int n);
334 bool SetArray(
int i,
const short *v,
int n);
335 bool SetArray(
int i,
const unsigned short *v,
int n);
336 bool SetArray(
int i,
const int *v,
int n);
337 bool SetArray(
int i,
const unsigned int *v,
int n);
338 bool SetArray(
int i,
const long *v,
int n);
339 bool SetArray(
int i,
const unsigned long *v,
int n);
340 #ifdef VTK_TYPE_USE_LONG_LONG
341 bool SetArray(
int i,
const long long *v,
int n);
342 bool SetArray(
int i,
const unsigned long long *v,
int n);
344 #ifdef VTK_TYPE_USE___INT64
345 bool SetArray(
int i,
const __int64 *v,
int n);
346 bool SetArray(
int i,
const unsigned __int64 *v,
int n);
352 bool SetNArray(
int i,
const float *v,
int n,
const int *d);
353 bool SetNArray(
int i,
const double *v,
int n,
const int *d);
354 bool SetNArray(
int i,
const bool *v,
int n,
const int *d);
355 bool SetNArray(
int i,
const char *v,
int n,
const int *d);
356 bool SetNArray(
int i,
const signed char *v,
int n,
const int *d);
357 bool SetNArray(
int i,
const unsigned char *v,
int n,
const int *d);
358 bool SetNArray(
int i,
const short *v,
int n,
const int *d);
359 bool SetNArray(
int i,
const unsigned short *v,
int n,
const int *d);
360 bool SetNArray(
int i,
const int *v,
int n,
const int *d);
361 bool SetNArray(
int i,
const unsigned int *v,
int n,
const int *d);
362 bool SetNArray(
int i,
const long *v,
int n,
const int *d);
363 bool SetNArray(
int i,
const unsigned long *v,
int n,
const int *d);
364 #ifdef VTK_TYPE_USE_LONG_LONG
365 bool SetNArray(
int i,
const long long *v,
int n,
const int *d);
366 bool SetNArray(
int i,
const unsigned long long *v,
int n,
const int *d);
368 #ifdef VTK_TYPE_USE___INT64
369 bool SetNArray(
int i,
const __int64 *v,
int n,
const int *d);
370 bool SetNArray(
int i,
const unsigned __int64 *v,
int n,
const int *d);
375 static PyObject *BuildNone();
379 static PyObject *BuildVTKObject(
const void *v);
382 static PyObject *BuildSpecialObject(
const void *v,
const char *classname);
385 static PyObject *BuildEnumValue(
int v,
const char *enumname);
390 static PyObject *BuildSIPObject(
391 const void *v,
const char *classname,
bool created);
395 static PyObject *BuildSIPEnumValue(
int v,
const char *classname);
398 static PyObject *BuildValue(
const void *v);
402 static PyObject *BuildValue(
const char *v);
403 static PyObject *BuildValue(
const std::string &v);
408 static PyObject *BuildValue(
char v);
412 static PyObject *BuildValue(
double v);
413 static PyObject *BuildValue(
bool v);
414 static PyObject *BuildValue(
int v);
415 static PyObject *BuildValue(
unsigned int v);
416 static PyObject *BuildValue(
long v);
417 static PyObject *BuildValue(
unsigned long v);
418 #ifdef VTK_TYPE_USE_LONG_LONG
419 static PyObject *BuildValue(
long long v);
420 static PyObject *BuildValue(
unsigned long long v);
422 #ifdef VTK_TYPE_USE___INT64
423 static PyObject *BuildValue(__int64 v);
424 static PyObject *BuildValue(
unsigned __int64 v);
429 static PyObject *BuildBytes(
const char *v,
int n);
433 static PyObject *BuildTuple(
const float *v,
int n);
434 static PyObject *BuildTuple(
const double *v,
int n);
435 static PyObject *BuildTuple(
const bool *v,
int n);
436 static PyObject *BuildTuple(
const signed char *v,
int n);
437 static PyObject *BuildTuple(
const unsigned char *v,
int n);
438 static PyObject *BuildTuple(
const short *v,
int n);
439 static PyObject *BuildTuple(
const unsigned short *v,
int n);
440 static PyObject *BuildTuple(
const int *v,
int n);
441 static PyObject *BuildTuple(
const unsigned int *v,
int n);
442 static PyObject *BuildTuple(
const long *v,
int n);
443 static PyObject *BuildTuple(
const unsigned long *v,
int n);
444 #ifdef VTK_TYPE_USE_LONG_LONG
445 static PyObject *BuildTuple(
const long long *v,
int n);
446 static PyObject *BuildTuple(
const unsigned long long *v,
int n);
448 #ifdef VTK_TYPE_USE___INT64
449 static PyObject *BuildTuple(
const __int64 *v,
int n);
450 static PyObject *BuildTuple(
const unsigned __int64 *v,
int n);
459 do { b[i] = a[i]; }
while (++i < n); }
467 do {
if (a[i] != b[i])
break; }
while (++i < n);
474 return static_cast<int>(PyTuple_GET_SIZE(args)); }
480 return (static_cast<int>(PyTuple_GET_SIZE(args)) -
481 PyVTKClass_Check(
self)); }
485 static bool ArgCountError(
int n,
const char *name);
491 static vtkObjectBase *GetSelfFromFirstArg(PyObject *
self, PyObject *args);
495 vtkObjectBase *GetArgAsVTKObject(
const char *classname,
bool &valid);
497 PyObject *o,
const char *classname,
bool &valid);
502 void *GetArgAsSpecialObject(
const char *classname, PyObject **newobj);
503 static void *GetArgAsSpecialObject(
504 PyObject *o,
const char *classname, PyObject **newobj);
509 int GetArgAsEnum(
const char *classname,
bool &valid);
510 static int GetArgAsEnum(
511 PyObject *o,
const char *classname,
bool &valid);
516 void *GetArgAsSIPObject(
const char *classname,
bool &valid);
517 static void *GetArgAsSIPObject(
518 PyObject *o,
const char *classname,
bool &valid);
523 int GetArgAsSIPEnum(
const char *classname,
bool &valid);
524 static int GetArgAsSIPEnum(
525 PyObject *o,
const char *classname,
bool &valid);
529 bool PureVirtualError();
532 bool ArgCountError(
int m,
int n);
535 bool RefineArgTypeError(
int i);
540 const char *MethodName;
554 if (PyVTKClass_Check(
self))
558 return ((PyVTKObject *)
self)->vtk_ptr;
565 return ((PyVTKSpecialObject *)
self)->vtk_ptr;
575 int nargs = this->N - this->M;
576 if (nargs >= nmin && nargs <= nmax)
588 int nargs = this->N - this->M;
617 return (PyErr_Occurred() != NULL);
634 static_cast<vtkObjectBase *>(const_cast<void *>(v)));
639 const char *classname)
641 return PyVTKSpecialObject_CopyNew(classname, v);
653 const void *v,
const char *classname,
bool created)
671 return PyString_FromString(s);
682 return PyString_FromString(a);
691 return PyString_FromStringAndSize(a.c_str(),
static_cast<Py_ssize_t>(a.size()));
699 #ifdef Py_USING_UNICODE
700 return PyUnicode_DecodeUTF8(s.c_str(),
static_cast<Py_ssize_t>(s.size()), NULL);
702 return PyString_FromStringAndSize(s.c_str(),
static_cast<Py_ssize_t>(s.size()));
712 return PyString_FromString(b);
718 return PyFloat_FromDouble(a);
724 #if PY_VERSION_HEX >= 0x02030000
725 return PyBool_FromLong((
long)a);
727 return PyInt_FromLong((
long)a);
734 return PyInt_FromLong(a);
740 #if VTK_SIZEOF_INT < VTK_SIZEOF_LONG
741 return PyInt_FromLong(a);
745 return PyInt_FromLong((
long)(a));
747 return PyLong_FromUnsignedLong(a);
754 return PyInt_FromLong(a);
762 return PyInt_FromLong((
long)(a));
764 return PyLong_FromUnsignedLong(a);
767 #if defined(VTK_TYPE_USE_LONG_LONG)
771 #if defined(PY_LONG_LONG)
772 return PyLong_FromLongLong(a);
774 return PyLong_FromLong((
long)(a));
781 #if defined(PY_LONG_LONG)
782 return PyLong_FromUnsignedLongLong(a);
784 return PyLong_FromUnsignedLong((
unsigned long)(a));
789 #if defined(VTK_TYPE_USE___INT64)
793 #if defined(PY_LONG_LONG)
794 return PyLong_FromLongLong(a);
796 return PyLong_FromLong((
long)(a));
803 #if defined(PY_LONG_LONG)
804 return PyLong_FromUnsignedLongLong(a);
806 return PyLong_FromUnsignedLong((
unsigned long)(a));
814 return PyString_FromStringAndSize(a, n);
int GetArgAsEnum(const char *classname, bool &valid)
bool GetSIPObject(T *&v, const char *classname)
static void SaveArray(const T *a, T *b, int n)
vtkPythonArgs(PyObject *args, const char *methodname)
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)
static int GetArgCount(PyObject *args)
static PyObject * BuildBytes(const char *v, int n)
static bool ArgCountError(int n, const char *name)
const char * utf8_str() const
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)
static bool GetEnumValue(PyObject *o, T &v, const char *enumname)
bool GetVTKObject(PyObject *o, T *&v, const char *classname)
bool GetEnumValue(T &v, const char *enumname)
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)
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)