Blender  V3.3
BPy_UnaryFunction0DViewShape.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
8 
9 #include "../BPy_Convert.h"
10 #include "../Iterator/BPy_Interface0DIterator.h"
11 
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 using namespace Freestyle;
20 
22 
23 //-------------------MODULE INITIALIZATION--------------------------------
24 
26 {
27  if (module == nullptr) {
28  return -1;
29  }
30 
31  if (PyType_Ready(&UnaryFunction0DViewShape_Type) < 0) {
32  return -1;
33  }
35  PyModule_AddObject(
36  module, "UnaryFunction0DViewShape", (PyObject *)&UnaryFunction0DViewShape_Type);
37 
38  if (PyType_Ready(&GetOccludeeF0D_Type) < 0) {
39  return -1;
40  }
41  Py_INCREF(&GetOccludeeF0D_Type);
42  PyModule_AddObject(module, "GetOccludeeF0D", (PyObject *)&GetOccludeeF0D_Type);
43 
44  if (PyType_Ready(&GetShapeF0D_Type) < 0) {
45  return -1;
46  }
47  Py_INCREF(&GetShapeF0D_Type);
48  PyModule_AddObject(module, "GetShapeF0D", (PyObject *)&GetShapeF0D_Type);
49 
50  return 0;
51 }
52 
53 //------------------------INSTANCE METHODS ----------------------------------
54 
56  "Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DViewShape`\n"
57  "\n"
58  "Base class for unary functions (functors) that work on\n"
59  ":class:`Interface0DIterator` and return a :class:`ViewShape` object.\n"
60  "\n"
61  ".. method:: __init__()\n"
62  "\n"
63  " Default constructor.\n";
64 
66  PyObject *args,
67  PyObject *kwds)
68 {
69  static const char *kwlist[] = {nullptr};
70 
71  if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
72  return -1;
73  }
74  self->uf0D_viewshape = new UnaryFunction0D<ViewShape *>();
75  self->uf0D_viewshape->py_uf0D = (PyObject *)self;
76  return 0;
77 }
78 
80 {
81  delete self->uf0D_viewshape;
82  UnaryFunction0D_Type.tp_dealloc((PyObject *)self);
83 }
84 
86 {
87  return PyUnicode_FromFormat(
88  "type: %s - address: %p", Py_TYPE(self)->tp_name, self->uf0D_viewshape);
89 }
90 
92  PyObject *args,
93  PyObject *kwds)
94 {
95  static const char *kwlist[] = {"it", nullptr};
96  PyObject *obj;
97 
98  if (!PyArg_ParseTupleAndKeywords(
99  args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj)) {
100  return nullptr;
101  }
102 
103  if (typeid(*(self->uf0D_viewshape)) == typeid(UnaryFunction0D<ViewShape *>)) {
104  PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
105  return nullptr;
106  }
107  if (self->uf0D_viewshape->operator()(*(((BPy_Interface0DIterator *)obj)->if0D_it)) < 0) {
108  if (!PyErr_Occurred()) {
109  string class_name(Py_TYPE(self)->tp_name);
110  PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
111  }
112  return nullptr;
113  }
114  return BPy_ViewShape_from_ViewShape(*(self->uf0D_viewshape->result));
115 }
116 
117 /*-----------------------BPy_UnaryFunction0DViewShape type definition ---------------------------*/
118 
120  PyVarObject_HEAD_INIT(nullptr, 0) "UnaryFunction0DViewShape", /* tp_name */
121  sizeof(BPy_UnaryFunction0DViewShape), /* tp_basicsize */
122  0, /* tp_itemsize */
123  (destructor)UnaryFunction0DViewShape___dealloc__, /* tp_dealloc */
124  0, /* tp_vectorcall_offset */
125  nullptr, /* tp_getattr */
126  nullptr, /* tp_setattr */
127  nullptr, /* tp_reserved */
128  (reprfunc)UnaryFunction0DViewShape___repr__, /* tp_repr */
129  nullptr, /* tp_as_number */
130  nullptr, /* tp_as_sequence */
131  nullptr, /* tp_as_mapping */
132  nullptr, /* tp_hash */
133  (ternaryfunc)UnaryFunction0DViewShape___call__, /* tp_call */
134  nullptr, /* tp_str */
135  nullptr, /* tp_getattro */
136  nullptr, /* tp_setattro */
137  nullptr, /* tp_as_buffer */
138  Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
140  nullptr, /* tp_traverse */
141  nullptr, /* tp_clear */
142  nullptr, /* tp_richcompare */
143  0, /* tp_weaklistoffset */
144  nullptr, /* tp_iter */
145  nullptr, /* tp_iternext */
146  nullptr, /* tp_methods */
147  nullptr, /* tp_members */
148  nullptr, /* tp_getset */
149  &UnaryFunction0D_Type, /* tp_base */
150  nullptr, /* tp_dict */
151  nullptr, /* tp_descr_get */
152  nullptr, /* tp_descr_set */
153  0, /* tp_dictoffset */
154  (initproc)UnaryFunction0DViewShape___init__, /* tp_init */
155  nullptr, /* tp_alloc */
156  nullptr, /* tp_new */
157 };
158 
160 
161 #ifdef __cplusplus
162 }
163 #endif
PyObject * BPy_ViewShape_from_ViewShape(ViewShape &vs)
PyTypeObject GetOccludeeF0D_Type
PyTypeObject GetShapeF0D_Type
PyTypeObject Interface0DIterator_Type
static int UnaryFunction0DViewShape___init__(BPy_UnaryFunction0DViewShape *self, PyObject *args, PyObject *kwds)
static void UnaryFunction0DViewShape___dealloc__(BPy_UnaryFunction0DViewShape *self)
static PyObject * UnaryFunction0DViewShape___repr__(BPy_UnaryFunction0DViewShape *self)
int UnaryFunction0DViewShape_Init(PyObject *module)
static char UnaryFunction0DViewShape___doc__[]
PyTypeObject UnaryFunction0DViewShape_Type
static PyObject * UnaryFunction0DViewShape___call__(BPy_UnaryFunction0DViewShape *self, PyObject *args, PyObject *kwds)
PyTypeObject UnaryFunction0D_Type
PyObject * self
Definition: bpy_driver.c:165
inherits from class Rep
Definition: AppCanvas.cpp:18
static struct PyModuleDef module
Definition: python.cpp:972