Blender V4.3
BPy_UnaryFunction0DEdgeNature.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2008-2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10
11#include "../BPy_Convert.h"
13
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20using namespace Freestyle;
21
23
24//-------------------MODULE INITIALIZATION--------------------------------
25
27{
28 if (module == nullptr) {
29 return -1;
30 }
31
32 if (PyType_Ready(&UnaryFunction0DEdgeNature_Type) < 0) {
33 return -1;
34 }
35 PyModule_AddObjectRef(
36 module, "UnaryFunction0DEdgeNature", (PyObject *)&UnaryFunction0DEdgeNature_Type);
37
38 if (PyType_Ready(&CurveNatureF0D_Type) < 0) {
39 return -1;
40 }
41 PyModule_AddObjectRef(module, "CurveNatureF0D", (PyObject *)&CurveNatureF0D_Type);
42
43 return 0;
44}
45
46//------------------------INSTANCE METHODS ----------------------------------
47
49 /* Wrap. */
50 UnaryFunction0DEdgeNature___doc__,
51 "Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DEdgeNature`\n"
52 "\n"
53 "Base class for unary functions (functors) that work on\n"
54 ":class:`Interface0DIterator` and return a :class:`Nature` object.\n"
55 "\n"
56 ".. method:: __init__()\n"
57 "\n"
58 " Default constructor.\n");
59
61 PyObject *args,
62 PyObject *kwds)
63{
64 static const char *kwlist[] = {nullptr};
65
66 if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
67 return -1;
68 }
69 self->uf0D_edgenature = new UnaryFunction0D<Nature::EdgeNature>();
70 self->uf0D_edgenature->py_uf0D = (PyObject *)self;
71 return 0;
72}
73
75{
76 delete self->uf0D_edgenature;
77 UnaryFunction0D_Type.tp_dealloc((PyObject *)self);
78}
79
81{
82 return PyUnicode_FromFormat(
83 "type: %s - address: %p", Py_TYPE(self)->tp_name, self->uf0D_edgenature);
84}
85
87 PyObject *args,
88 PyObject *kwds)
89{
90 static const char *kwlist[] = {"it", nullptr};
91 PyObject *obj;
92
93 if (!PyArg_ParseTupleAndKeywords(
94 args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj))
95 {
96 return nullptr;
97 }
98
99 if (typeid(*(self->uf0D_edgenature)) == typeid(UnaryFunction0D<Nature::EdgeNature>)) {
100 PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
101 return nullptr;
102 }
103 if (self->uf0D_edgenature->operator()(*(((BPy_Interface0DIterator *)obj)->if0D_it)) < 0) {
104 if (!PyErr_Occurred()) {
105 string class_name(Py_TYPE(self)->tp_name);
106 PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
107 }
108 return nullptr;
109 }
110 return BPy_Nature_from_Nature(self->uf0D_edgenature->result);
111}
112
113/*-----------------------BPy_UnaryFunction0DEdgeNature type definition --------------------------*/
114
116 /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
117 /*tp_name*/ "UnaryFunction0DEdgeNature",
118 /*tp_basicsize*/ sizeof(BPy_UnaryFunction0DEdgeNature),
119 /*tp_itemsize*/ 0,
120 /*tp_dealloc*/ (destructor)UnaryFunction0DEdgeNature___dealloc__,
121 /*tp_vectorcall_offset*/ 0,
122 /*tp_getattr*/ nullptr,
123 /*tp_setattr*/ nullptr,
124 /*tp_as_async*/ nullptr,
125 /*tp_repr*/ (reprfunc)UnaryFunction0DEdgeNature___repr__,
126 /*tp_as_number*/ nullptr,
127 /*tp_as_sequence*/ nullptr,
128 /*tp_as_mapping*/ nullptr,
129 /*tp_hash*/ nullptr,
130 /*tp_call*/ (ternaryfunc)UnaryFunction0DEdgeNature___call__,
131 /*tp_str*/ nullptr,
132 /*tp_getattro*/ nullptr,
133 /*tp_setattro*/ nullptr,
134 /*tp_as_buffer*/ nullptr,
135 /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
136 /*tp_doc*/ UnaryFunction0DEdgeNature___doc__,
137 /*tp_traverse*/ nullptr,
138 /*tp_clear*/ nullptr,
139 /*tp_richcompare*/ nullptr,
140 /*tp_weaklistoffset*/ 0,
141 /*tp_iter*/ nullptr,
142 /*tp_iternext*/ nullptr,
143 /*tp_methods*/ nullptr,
144 /*tp_members*/ nullptr,
145 /*tp_getset*/ nullptr,
146 /*tp_base*/ &UnaryFunction0D_Type,
147 /*tp_dict*/ nullptr,
148 /*tp_descr_get*/ nullptr,
149 /*tp_descr_set*/ nullptr,
150 /*tp_dictoffset*/ 0,
151 /*tp_init*/ (initproc)UnaryFunction0DEdgeNature___init__,
152 /*tp_alloc*/ nullptr,
153 /*tp_new*/ nullptr,
154};
155
157
158#ifdef __cplusplus
159}
160#endif
PyObject * BPy_Nature_from_Nature(ushort n)
PyTypeObject CurveNatureF0D_Type
PyTypeObject Interface0DIterator_Type
static void UnaryFunction0DEdgeNature___dealloc__(BPy_UnaryFunction0DEdgeNature *self)
int UnaryFunction0DEdgeNature_Init(PyObject *module)
static int UnaryFunction0DEdgeNature___init__(BPy_UnaryFunction0DEdgeNature *self, PyObject *args, PyObject *kwds)
static PyObject * UnaryFunction0DEdgeNature___repr__(BPy_UnaryFunction0DEdgeNature *self)
PyTypeObject UnaryFunction0DEdgeNature_Type
PyDoc_STRVAR(UnaryFunction0DEdgeNature___doc__, "Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DEdgeNature`\n" "\n" "Base class for unary functions (functors) that work on\n" ":class:`Interface0DIterator` and return a :class:`Nature` object.\n" "\n" ".. method:: __init__()\n" "\n" " Default constructor.\n")
static PyObject * UnaryFunction0DEdgeNature___call__(BPy_UnaryFunction0DEdgeNature *self, PyObject *args, PyObject *kwds)
PyTypeObject UnaryFunction0D_Type
PyObject * self
inherits from class Rep
Definition AppCanvas.cpp:20
static struct PyModuleDef module
Definition python.cpp:991