Blender  V2.93
BPy_UnaryFunction0DEdgeNature.cpp
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
22 
23 #include "../BPy_Convert.h"
24 #include "../Iterator/BPy_Interface0DIterator.h"
25 
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 using namespace Freestyle;
33 
35 
36 //-------------------MODULE INITIALIZATION--------------------------------
37 
39 {
40  if (module == nullptr) {
41  return -1;
42  }
43 
44  if (PyType_Ready(&UnaryFunction0DEdgeNature_Type) < 0) {
45  return -1;
46  }
48  PyModule_AddObject(
49  module, "UnaryFunction0DEdgeNature", (PyObject *)&UnaryFunction0DEdgeNature_Type);
50 
51  if (PyType_Ready(&CurveNatureF0D_Type) < 0) {
52  return -1;
53  }
54  Py_INCREF(&CurveNatureF0D_Type);
55  PyModule_AddObject(module, "CurveNatureF0D", (PyObject *)&CurveNatureF0D_Type);
56 
57  return 0;
58 }
59 
60 //------------------------INSTANCE METHODS ----------------------------------
61 
63  "Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DEdgeNature`\n"
64  "\n"
65  "Base class for unary functions (functors) that work on\n"
66  ":class:`Interface0DIterator` and return a :class:`Nature` object.\n"
67  "\n"
68  ".. method:: __init__()\n"
69  "\n"
70  " Default constructor.\n";
71 
73  PyObject *args,
74  PyObject *kwds)
75 {
76  static const char *kwlist[] = {nullptr};
77 
78  if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
79  return -1;
80  }
81  self->uf0D_edgenature = new UnaryFunction0D<Nature::EdgeNature>();
82  self->uf0D_edgenature->py_uf0D = (PyObject *)self;
83  return 0;
84 }
85 
87 {
88  delete self->uf0D_edgenature;
89  UnaryFunction0D_Type.tp_dealloc((PyObject *)self);
90 }
91 
93 {
94  return PyUnicode_FromFormat(
95  "type: %s - address: %p", Py_TYPE(self)->tp_name, self->uf0D_edgenature);
96 }
97 
99  PyObject *args,
100  PyObject *kwds)
101 {
102  static const char *kwlist[] = {"it", nullptr};
103  PyObject *obj;
104 
105  if (!PyArg_ParseTupleAndKeywords(
106  args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj)) {
107  return nullptr;
108  }
109 
110  if (typeid(*(self->uf0D_edgenature)) == typeid(UnaryFunction0D<Nature::EdgeNature>)) {
111  PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
112  return nullptr;
113  }
114  if (self->uf0D_edgenature->operator()(*(((BPy_Interface0DIterator *)obj)->if0D_it)) < 0) {
115  if (!PyErr_Occurred()) {
116  string class_name(Py_TYPE(self)->tp_name);
117  PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
118  }
119  return nullptr;
120  }
121  return BPy_Nature_from_Nature(self->uf0D_edgenature->result);
122 }
123 
124 /*-----------------------BPy_UnaryFunction0DEdgeNature type definition --------------------------*/
125 
127  PyVarObject_HEAD_INIT(nullptr, 0) "UnaryFunction0DEdgeNature", /* tp_name */
128  sizeof(BPy_UnaryFunction0DEdgeNature), /* tp_basicsize */
129  0, /* tp_itemsize */
130  (destructor)UnaryFunction0DEdgeNature___dealloc__, /* tp_dealloc */
131  0, /* tp_vectorcall_offset */
132  nullptr, /* tp_getattr */
133  nullptr, /* tp_setattr */
134  nullptr, /* tp_reserved */
135  (reprfunc)UnaryFunction0DEdgeNature___repr__, /* tp_repr */
136  nullptr, /* tp_as_number */
137  nullptr, /* tp_as_sequence */
138  nullptr, /* tp_as_mapping */
139  nullptr, /* tp_hash */
140  (ternaryfunc)UnaryFunction0DEdgeNature___call__, /* tp_call */
141  nullptr, /* tp_str */
142  nullptr, /* tp_getattro */
143  nullptr, /* tp_setattro */
144  nullptr, /* tp_as_buffer */
145  Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
147  nullptr, /* tp_traverse */
148  nullptr, /* tp_clear */
149  nullptr, /* tp_richcompare */
150  0, /* tp_weaklistoffset */
151  nullptr, /* tp_iter */
152  nullptr, /* tp_iternext */
153  nullptr, /* tp_methods */
154  nullptr, /* tp_members */
155  nullptr, /* tp_getset */
156  &UnaryFunction0D_Type, /* tp_base */
157  nullptr, /* tp_dict */
158  nullptr, /* tp_descr_get */
159  nullptr, /* tp_descr_set */
160  0, /* tp_dictoffset */
161  (initproc)UnaryFunction0DEdgeNature___init__, /* tp_init */
162  nullptr, /* tp_alloc */
163  nullptr, /* tp_new */
164 };
165 
167 
168 #ifdef __cplusplus
169 }
170 #endif
PyObject * BPy_Nature_from_Nature(unsigned short n)
PyTypeObject CurveNatureF0D_Type
PyTypeObject Interface0DIterator_Type
static void UnaryFunction0DEdgeNature___dealloc__(BPy_UnaryFunction0DEdgeNature *self)
int UnaryFunction0DEdgeNature_Init(PyObject *module)
static PyObject * UnaryFunction0DEdgeNature___repr__(BPy_UnaryFunction0DEdgeNature *self)
static int UnaryFunction0DEdgeNature___init__(BPy_UnaryFunction0DEdgeNature *self, PyObject *args, PyObject *kwds)
PyTypeObject UnaryFunction0DEdgeNature_Type
static PyObject * UnaryFunction0DEdgeNature___call__(BPy_UnaryFunction0DEdgeNature *self, PyObject *args, PyObject *kwds)
static char UnaryFunction0DEdgeNature___doc__[]
PyTypeObject UnaryFunction0D_Type
static struct PyModuleDef module
PyObject * self
Definition: bpy_driver.c:185
inherits from class Rep
Definition: AppCanvas.cpp:32