27 #ifndef vtkPythonArgs_h
28 #define vtkPythonArgs_h
32 #include "PyVTKObject.h"
33 #include "PyVTKTemplate.h"
47 Args(args), MethodName(methodname) {
48 this->N = PyTuple_GET_SIZE(args);
49 this->
M = PyType_Check(
self);
57 Args(args), MethodName(methodname) {
58 this->N = PyTuple_GET_SIZE(args);
79 static void *GetSelfSpecialPointer(
PyObject *
self);
82 bool CheckArgCount(
int nmin,
int nmax);
85 bool CheckArgCount(
int n);
94 static bool ErrorOccurred();
102 int GetArgSize(
int i);
108 v = this->GetArgAsPythonObject(b);
124 v = (T *)this->GetArgAsVTKObject(classname, b);
139 v =
static_cast<T *
>(this->GetArgAsSpecialObject(classname, &o));
140 return (v != NULL); }
144 v =
static_cast<T *
>(
146 return (v != NULL); }
154 v =
static_cast<T *
>(this->GetArgAsSpecialObject(classname, NULL));
155 return (v != NULL); }
158 v =
static_cast<T *
>(
160 return (v != NULL); }
168 v =
static_cast<T
>(this->GetArgAsEnum(enumname, r));
182 v = (T *)this->GetArgAsSIPObject(classname, r);
196 v =
static_cast<T
>(this->GetArgAsSIPEnum(enumname, r));
213 bool GetBuffer(
void *&v,
Py_buffer *buf);
215 bool GetBuffer(
const void *&v,
Py_buffer *buf);
220 bool GetValue(
const char *&v);
221 static bool GetValue(
PyObject *o,
const char *&v);
222 bool GetValue(
char *&v);
223 static bool GetValue(
PyObject *o,
char *&v);
232 bool GetValue(
char &v);
233 static bool GetValue(
PyObject *o,
char &v);
238 bool GetValue(
float &v);
239 static bool GetValue(
PyObject *o,
float &v);
240 bool GetValue(
double &v);
241 static bool GetValue(
PyObject *o,
double &v);
242 bool GetValue(
bool &v);
243 static bool GetValue(
PyObject *o,
bool &v);
244 bool GetValue(
signed char &v);
245 static bool GetValue(
PyObject *o,
signed char &v);
246 bool GetValue(
unsigned char &v);
247 static bool GetValue(
PyObject *o,
unsigned char &v);
248 bool GetValue(
short &v);
249 static bool GetValue(
PyObject *o,
short &v);
250 bool GetValue(
unsigned short &v);
251 static bool GetValue(
PyObject *o,
unsigned short &v);
252 bool GetValue(
int &v);
253 static bool GetValue(
PyObject *o,
int &v);
254 bool GetValue(
unsigned int &v);
255 static bool GetValue(
PyObject *o,
unsigned int &v);
256 bool GetValue(
long &v);
257 static bool GetValue(
PyObject *o,
long &v);
258 bool GetValue(
unsigned long &v);
259 static bool GetValue(
PyObject *o,
unsigned long &v);
260 bool GetValue(
long long &v);
261 static bool GetValue(
PyObject *o,
long long &v);
262 bool GetValue(
unsigned long long &v);
263 static bool GetValue(
PyObject *o,
unsigned long long &v);
268 bool GetArray(
float *v,
int n);
269 bool GetArray(
double *v,
int n);
270 bool GetArray(
bool *v,
int n);
271 bool GetArray(
char *v,
int n);
272 bool GetArray(
signed char *v,
int n);
273 bool GetArray(
unsigned char *v,
int n);
274 bool GetArray(
short *v,
int n);
275 bool GetArray(
unsigned short *v,
int n);
276 bool GetArray(
int *v,
int n);
277 bool GetArray(
unsigned int *v,
int n);
278 bool GetArray(
long *v,
int n);
279 bool GetArray(
unsigned long *v,
int n);
280 bool GetArray(
long long *v,
int n);
281 bool GetArray(
unsigned long long *v,
int n);
286 bool GetNArray(
float *v,
int ndims,
const int *dims);
287 bool GetNArray(
double *v,
int ndims,
const int *dims);
288 bool GetNArray(
bool *v,
int ndims,
const int *dims);
289 bool GetNArray(
char *v,
int ndims,
const int *dims);
290 bool GetNArray(
signed char *v,
int ndims,
const int *dims);
291 bool GetNArray(
unsigned char *v,
int ndims,
const int *dims);
292 bool GetNArray(
short *v,
int ndims,
const int *dims);
293 bool GetNArray(
unsigned short *v,
int ndims,
const int *dims);
294 bool GetNArray(
int *v,
int ndims,
const int *dims);
295 bool GetNArray(
unsigned int *v,
int ndims,
const int *dims);
296 bool GetNArray(
long *v,
int ndims,
const int *dims);
297 bool GetNArray(
unsigned long *v,
int ndims,
const int *dims);
298 bool GetNArray(
long long *v,
int ndims,
const int *dims);
299 bool GetNArray(
unsigned long long *v,
int ndims,
const int *dims);
306 bool SetArgValue(
int i,
char v);
307 bool SetArgValue(
int i,
float v);
308 bool SetArgValue(
int i,
double v);
309 bool SetArgValue(
int i,
bool v);
310 bool SetArgValue(
int i,
signed char v);
311 bool SetArgValue(
int i,
unsigned char v);
312 bool SetArgValue(
int i,
short v);
313 bool SetArgValue(
int i,
unsigned short v);
314 bool SetArgValue(
int i,
int v);
315 bool SetArgValue(
int i,
unsigned int v);
316 bool SetArgValue(
int i,
long v);
317 bool SetArgValue(
int i,
unsigned long v);
318 bool SetArgValue(
int i,
long long v);
319 bool SetArgValue(
int i,
unsigned long long v);
324 bool SetArray(
int i,
const float *v,
int n);
325 bool SetArray(
int i,
const double *v,
int n);
326 bool SetArray(
int i,
const bool *v,
int n);
327 bool SetArray(
int i,
const char *v,
int n);
328 bool SetArray(
int i,
const signed char *v,
int n);
329 bool SetArray(
int i,
const unsigned char *v,
int n);
330 bool SetArray(
int i,
const short *v,
int n);
331 bool SetArray(
int i,
const unsigned short *v,
int n);
332 bool SetArray(
int i,
const int *v,
int n);
333 bool SetArray(
int i,
const unsigned int *v,
int n);
334 bool SetArray(
int i,
const long *v,
int n);
335 bool SetArray(
int i,
const unsigned long *v,
int n);
336 bool SetArray(
int i,
const long long *v,
int n);
337 bool SetArray(
int i,
const unsigned long long *v,
int n);
342 bool SetNArray(
int i,
const float *v,
int n,
const int *d);
343 bool SetNArray(
int i,
const double *v,
int n,
const int *d);
344 bool SetNArray(
int i,
const bool *v,
int n,
const int *d);
345 bool SetNArray(
int i,
const char *v,
int n,
const int *d);
346 bool SetNArray(
int i,
const signed char *v,
int n,
const int *d);
347 bool SetNArray(
int i,
const unsigned char *v,
int n,
const int *d);
348 bool SetNArray(
int i,
const short *v,
int n,
const int *d);
349 bool SetNArray(
int i,
const unsigned short *v,
int n,
const int *d);
350 bool SetNArray(
int i,
const int *v,
int n,
const int *d);
351 bool SetNArray(
int i,
const unsigned int *v,
int n,
const int *d);
352 bool SetNArray(
int i,
const long *v,
int n,
const int *d);
353 bool SetNArray(
int i,
const unsigned long *v,
int n,
const int *d);
354 bool SetNArray(
int i,
const long long *v,
int n,
const int *d);
355 bool SetNArray(
int i,
const unsigned long long *v,
int n,
const int *d);
363 static PyObject *BuildVTKObject(
const void *v);
366 static PyObject *BuildSpecialObject(
const void *v,
const char *classname);
369 static PyObject *BuildEnumValue(
int v,
const char *enumname);
375 const void *v,
const char *classname,
bool created);
379 static PyObject *BuildSIPEnumValue(
int v,
const char *classname);
382 static PyObject *BuildValue(
const void *v);
386 static PyObject *BuildValue(
const char *v,
size_t l);
387 static PyObject *BuildValue(
const char *v);
393 static PyObject *BuildValue(
char v);
397 static PyObject *BuildValue(
double v);
398 static PyObject *BuildValue(
bool v);
400 static PyObject *BuildValue(
unsigned int v);
401 static PyObject *BuildValue(
long v);
402 static PyObject *BuildValue(
unsigned long v);
403 static PyObject *BuildValue(
long long v);
404 static PyObject *BuildValue(
unsigned long long v);
408 static PyObject *BuildBytes(
const char *v,
int n);
412 static PyObject *BuildTuple(
const float *v,
int n);
413 static PyObject *BuildTuple(
const double *v,
int n);
414 static PyObject *BuildTuple(
const bool *v,
int n);
415 static PyObject *BuildTuple(
const signed char *v,
int n);
416 static PyObject *BuildTuple(
const unsigned char *v,
int n);
417 static PyObject *BuildTuple(
const short *v,
int n);
418 static PyObject *BuildTuple(
const unsigned short *v,
int n);
419 static PyObject *BuildTuple(
const int *v,
int n);
420 static PyObject *BuildTuple(
const unsigned int *v,
int n);
421 static PyObject *BuildTuple(
const long *v,
int n);
422 static PyObject *BuildTuple(
const unsigned long *v,
int n);
423 static PyObject *BuildTuple(
const long long *v,
int n);
424 static PyObject *BuildTuple(
const unsigned long long *v,
int n);
432 do { b[i] = a[i]; }
while (++i < n); }
440 do {
if (a[i] != b[i])
break; }
while (++i < n);
447 return static_cast<int>(PyTuple_GET_SIZE(args)); }
453 return (static_cast<int>(PyTuple_GET_SIZE(args)) -
454 PyType_Check(
self)); }
458 static bool ArgCountError(
int n,
const char *
name);
468 PyObject *GetArgAsPythonObject(
bool &valid);
469 static PyObject *GetArgAsPythonObject(
475 vtkObjectBase *GetArgAsVTKObject(
const char *classname,
bool &valid);
477 PyObject *o,
const char *classname,
bool &valid);
482 void *GetArgAsSpecialObject(
const char *classname,
PyObject **newobj);
483 static void *GetArgAsSpecialObject(
489 int GetArgAsEnum(
const char *enumname,
bool &valid);
490 static int GetArgAsEnum(
491 PyObject *o,
const char *enumname,
bool &valid);
496 void *GetArgAsSIPObject(
const char *classname,
bool &valid);
497 static void *GetArgAsSIPObject(
498 PyObject *o,
const char *classname,
bool &valid);
503 int GetArgAsSIPEnum(
const char *classname,
bool &valid);
504 static int GetArgAsSIPEnum(
505 PyObject *o,
const char *classname,
bool &valid);
509 bool PureVirtualError();
512 bool ArgCountError(
int m,
int n);
515 bool RefineArgTypeError(
int i);
520 const char *MethodName;
534 if (PyType_Check(
self))
538 return (
self ? ((PyVTKObject *)
self)->vtk_ptr : NULL);
545 if (PyType_Check(
self))
549 return (
self ? ((PyVTKSpecialObject *)
self)->vtk_ptr : NULL);
556 return ((PyVTKSpecialObject *)
self)->vtk_ptr;
566 int nargs = this->N - this->M;
567 if (nargs >= nmin && nargs <= nmax)
579 int nargs = this->N - this->M;
608 return (PyErr_Occurred() != NULL);
625 static_cast<vtkObjectBase *>(const_cast<void *>(v)));
630 const char *classname)
632 return PyVTKSpecialObject_CopyNew(classname, v);
644 const void *v,
const char *classname,
bool created)
662 return PyString_FromString(s);
671 #if PY_VERSION_HEX < 0x03000000
672 return PyString_FromStringAndSize(a, static_cast<Py_ssize_t>(l));
674 #if PY_VERSION_HEX >= 0x03030000
675 PyObject *o = PyUnicode_FromStringAndSize(a, static_cast<Py_ssize_t>(l));
677 PyObject *o = PyUnicode_Decode(a, static_cast<Py_ssize_t>(l), NULL, NULL);
710 #ifdef Py_USING_UNICODE
711 return PyUnicode_DecodeUTF8(s.c_str(),
static_cast<Py_ssize_t
>(s.size()), NULL);
713 return PyString_FromStringAndSize(s.c_str(),
static_cast<Py_ssize_t
>(s.size()));
723 return PyString_FromString(b);
729 return PyFloat_FromDouble(a);
735 return PyBool_FromLong((
long)a);
741 return PyInt_FromLong(a);
747 #if VTK_SIZEOF_INT < VTK_SIZEOF_LONG
748 return PyInt_FromLong(a);
752 return PyInt_FromLong((
long)(a));
754 return PyLong_FromUnsignedLong(a);
761 return PyInt_FromLong(a);
769 return PyInt_FromLong((
long)(a));
771 return PyLong_FromUnsignedLong(a);
777 return PyLong_FromLongLong(a);
783 return PyLong_FromUnsignedLongLong(a);
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)
int GetArgAsEnum(const char *enumname, bool &valid)
static vtkObjectBase * GetSelfPointer(PyObject *self, PyObject *args)
static bool GetSIPEnumValue(PyObject *o, T &v, const char *enumname)
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)
PyObject * GetArgAsPythonObject(bool &valid)
static int GetArgCount(PyObject *args)
static PyObject * BuildBytes(const char *v, int n)
static void * GetSelfSpecialPointer(PyObject *self, PyObject *args)
static bool ArgCountError(int n, const char *name)
const char * utf8_str() const
#define VTKWRAPPINGPYTHONCORE_EXPORT
static PyObject * GetSelfFromFirstArg(PyObject *self, PyObject *args)
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)
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)
#define PyBytes_FromStringAndSize
static PyObject * BuildNone()
bool CheckArgCount(int nmin, int nmax)
String class that stores Unicode text.
static PyObject * GetObjectFromPointer(vtkObjectBase *ptr)