Blender V4.3
BPy_UnaryFunction1DVoid.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2008-2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10
11#include "../BPy_Convert.h"
13#include "../BPy_Interface1D.h"
14
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23using namespace Freestyle;
24
26
27//-------------------MODULE INITIALIZATION--------------------------------
28
30{
31 if (module == nullptr) {
32 return -1;
33 }
34
35 if (PyType_Ready(&UnaryFunction1DVoid_Type) < 0) {
36 return -1;
37 }
38 PyModule_AddObjectRef(module, "UnaryFunction1DVoid", (PyObject *)&UnaryFunction1DVoid_Type);
39
40 if (PyType_Ready(&ChainingTimeStampF1D_Type) < 0) {
41 return -1;
42 }
43 PyModule_AddObjectRef(module, "ChainingTimeStampF1D", (PyObject *)&ChainingTimeStampF1D_Type);
44
45 if (PyType_Ready(&IncrementChainingTimeStampF1D_Type) < 0) {
46 return -1;
47 }
48 PyModule_AddObjectRef(
49 module, "IncrementChainingTimeStampF1D", (PyObject *)&IncrementChainingTimeStampF1D_Type);
50
51 if (PyType_Ready(&TimeStampF1D_Type) < 0) {
52 return -1;
53 }
54 PyModule_AddObjectRef(module, "TimeStampF1D", (PyObject *)&TimeStampF1D_Type);
55
56 return 0;
57}
58
59//------------------------INSTANCE METHODS ----------------------------------
60
62 /* Wrap. */
63 UnaryFunction1DVoid___doc__,
64 "Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DVoid`\n"
65 "\n"
66 "Base class for unary functions (functors) working on\n"
67 ":class:`Interface1D`.\n"
68 "\n"
69 ".. method:: __init__()\n"
70 " __init__(integration_type)\n"
71 "\n"
72 " Builds a unary 1D function using either a default constructor\n"
73 " or the integration method given as an argument.\n"
74 "\n"
75 " :arg integration_type: An integration method.\n"
76 " :type integration_type: :class:`IntegrationType`\n");
77
79 PyObject *args,
80 PyObject *kwds)
81{
82 static const char *kwlist[] = {"integration", nullptr};
83 PyObject *obj = nullptr;
84
85 if (!PyArg_ParseTupleAndKeywords(
86 args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj))
87 {
88 return -1;
89 }
90
91 if (!obj) {
92 self->uf1D_void = new UnaryFunction1D_void();
93 }
94 else {
96 }
97
98 self->uf1D_void->py_uf1D = (PyObject *)self;
99
100 return 0;
101}
102
104{
105 delete self->uf1D_void;
106 UnaryFunction1D_Type.tp_dealloc((PyObject *)self);
107}
108
110{
111 return PyUnicode_FromFormat("type: %s - address: %p", Py_TYPE(self)->tp_name, self->uf1D_void);
112}
113
115 PyObject *args,
116 PyObject *kwds)
117{
118 static const char *kwlist[] = {"inter", nullptr};
119 PyObject *obj = nullptr;
120
121 if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &Interface1D_Type, &obj)) {
122 return nullptr;
123 }
124
125 if (typeid(*(self->uf1D_void)) == typeid(UnaryFunction1D_void)) {
126 PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
127 return nullptr;
128 }
129 if (self->uf1D_void->operator()(*(((BPy_Interface1D *)obj)->if1D)) < 0) {
130 if (!PyErr_Occurred()) {
131 string class_name(Py_TYPE(self)->tp_name);
132 PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
133 }
134 return nullptr;
135 }
136 Py_RETURN_NONE;
137}
138
139/*----------------------UnaryFunction1DVoid get/setters ----------------------------*/
140
142 /* Wrap. */
143 integration_type_doc,
144 "The integration method.\n"
145 "\n"
146 ":type: :class:`IntegrationType`");
147
148static PyObject *integration_type_get(BPy_UnaryFunction1DVoid *self, void * /*closure*/)
149{
150 return BPy_IntegrationType_from_IntegrationType(self->uf1D_void->getIntegrationType());
151}
152
153static int integration_type_set(BPy_UnaryFunction1DVoid *self, PyObject *value, void * /*closure*/)
154{
155 if (!BPy_IntegrationType_Check(value)) {
156 PyErr_SetString(PyExc_TypeError, "value must be an IntegrationType");
157 return -1;
158 }
159 self->uf1D_void->setIntegrationType(IntegrationType_from_BPy_IntegrationType(value));
160 return 0;
161}
162
163static PyGetSetDef BPy_UnaryFunction1DVoid_getseters[] = {
164 {"integration_type",
165 (getter)integration_type_get,
166 (setter)integration_type_set,
167 integration_type_doc,
168 nullptr},
169 {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
170};
171
172/*-----------------------BPy_UnaryFunction1DVoid type definition ------------------------------*/
173
175 /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
176 /*tp_name*/ "UnaryFunction1DVoid",
177 /*tp_basicsize*/ sizeof(BPy_UnaryFunction1DVoid),
178 /*tp_itemsize*/ 0,
179 /*tp_dealloc*/ (destructor)UnaryFunction1DVoid___dealloc__,
180 /*tp_vectorcall_offset*/ 0,
181 /*tp_getattr*/ nullptr,
182 /*tp_setattr*/ nullptr,
183 /*tp_as_async*/ nullptr,
184 /*tp_repr*/ (reprfunc)UnaryFunction1DVoid___repr__,
185 /*tp_as_number*/ nullptr,
186 /*tp_as_sequence*/ nullptr,
187 /*tp_as_mapping*/ nullptr,
188 /*tp_hash*/ nullptr,
189 /*tp_call*/ (ternaryfunc)UnaryFunction1DVoid___call__,
190 /*tp_str*/ nullptr,
191 /*tp_getattro*/ nullptr,
192 /*tp_setattro*/ nullptr,
193 /*tp_as_buffer*/ nullptr,
194 /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
195 /*tp_doc*/ UnaryFunction1DVoid___doc__,
196 /*tp_traverse*/ nullptr,
197 /*tp_clear*/ nullptr,
198 /*tp_richcompare*/ nullptr,
199 /*tp_weaklistoffset*/ 0,
200 /*tp_iter*/ nullptr,
201 /*tp_iternext*/ nullptr,
202 /*tp_methods*/ nullptr,
203 /*tp_members*/ nullptr,
205 /*tp_base*/ &UnaryFunction1D_Type,
206 /*tp_dict*/ nullptr,
207 /*tp_descr_get*/ nullptr,
208 /*tp_descr_set*/ nullptr,
209 /*tp_dictoffset*/ 0,
210 /*tp_init*/ (initproc)UnaryFunction1DVoid___init__,
211 /*tp_alloc*/ nullptr,
212 /*tp_new*/ nullptr,
213};
214
216
217#ifdef __cplusplus
218}
219#endif
PyTypeObject ChainingTimeStampF1D_Type
IntegrationType IntegrationType_from_BPy_IntegrationType(PyObject *obj)
PyObject * BPy_IntegrationType_from_IntegrationType(IntegrationType i)
PyTypeObject IncrementChainingTimeStampF1D_Type
PyTypeObject IntegrationType_Type
#define BPy_IntegrationType_Check(v)
PyTypeObject Interface1D_Type
PyTypeObject TimeStampF1D_Type
static int integration_type_set(BPy_UnaryFunction1DVoid *self, PyObject *value, void *)
static PyObject * UnaryFunction1DVoid___call__(BPy_UnaryFunction1DVoid *self, PyObject *args, PyObject *kwds)
int UnaryFunction1DVoid_Init(PyObject *module)
PyDoc_STRVAR(UnaryFunction1DVoid___doc__, "Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DVoid`\n" "\n" "Base class for unary functions (functors) working on\n" ":class:`Interface1D`.\n" "\n" ".. method:: __init__()\n" " __init__(integration_type)\n" "\n" " Builds a unary 1D function using either a default constructor\n" " or the integration method given as an argument.\n" "\n" " :arg integration_type: An integration method.\n" " :type integration_type: :class:`IntegrationType`\n")
PyTypeObject UnaryFunction1DVoid_Type
static PyObject * integration_type_get(BPy_UnaryFunction1DVoid *self, void *)
static int UnaryFunction1DVoid___init__(BPy_UnaryFunction1DVoid *self, PyObject *args, PyObject *kwds)
static void UnaryFunction1DVoid___dealloc__(BPy_UnaryFunction1DVoid *self)
static PyGetSetDef BPy_UnaryFunction1DVoid_getseters[]
static PyObject * UnaryFunction1DVoid___repr__(BPy_UnaryFunction1DVoid *self)
PyTypeObject UnaryFunction1D_Type
PyObject * self
inherits from class Rep
Definition AppCanvas.cpp:20
static struct PyModuleDef module
Definition python.cpp:991