Blender V4.3
BPy_UnaryFunction0DVectorViewShape.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#include "BLI_sys_types.h"
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22using namespace Freestyle;
23
25
26//-------------------MODULE INITIALIZATION--------------------------------
27
29{
30 if (module == nullptr) {
31 return -1;
32 }
33
34 if (PyType_Ready(&UnaryFunction0DVectorViewShape_Type) < 0) {
35 return -1;
36 }
37 PyModule_AddObjectRef(
38 module, "UnaryFunction0DVectorViewShape", (PyObject *)&UnaryFunction0DVectorViewShape_Type);
39
40 if (PyType_Ready(&GetOccludersF0D_Type) < 0) {
41 return -1;
42 }
43 PyModule_AddObjectRef(module, "GetOccludersF0D", (PyObject *)&GetOccludersF0D_Type);
44
45 return 0;
46}
47
48//------------------------INSTANCE METHODS ----------------------------------
49
51 /* Wrap. */
52 UnaryFunction0DVectorViewShape___doc__,
53 "Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DVectorViewShape`\n"
54 "\n"
55 "Base class for unary functions (functors) that work on\n"
56 ":class:`Interface0DIterator` and return a list of :class:`ViewShape`\n"
57 "objects.\n"
58 "\n"
59 ".. method:: __init__()\n"
60 "\n"
61 " Default constructor.\n");
62
64 PyObject *args,
65 PyObject *kwds)
66{
67 static const char *kwlist[] = {nullptr};
68
69 if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
70 return -1;
71 }
72 self->uf0D_vectorviewshape = new UnaryFunction0D<std::vector<ViewShape *>>();
73 self->uf0D_vectorviewshape->py_uf0D = (PyObject *)self;
74 return 0;
75}
76
78{
79 delete self->uf0D_vectorviewshape;
80 UnaryFunction0D_Type.tp_dealloc((PyObject *)self);
81}
82
84{
85 return PyUnicode_FromFormat(
86 "type: %s - address: %p", Py_TYPE(self)->tp_name, self->uf0D_vectorviewshape);
87}
88
90 PyObject *args,
91 PyObject *kwds)
92{
93 static const char *kwlist[] = {"it", nullptr};
94 PyObject *obj;
95
96 if (!PyArg_ParseTupleAndKeywords(
97 args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj))
98 {
99 return nullptr;
100 }
101
102 if (typeid(*(self->uf0D_vectorviewshape)) == typeid(UnaryFunction0D<std::vector<ViewShape *>>)) {
103 PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
104 return nullptr;
105 }
106 if (self->uf0D_vectorviewshape->operator()(*(((BPy_Interface0DIterator *)obj)->if0D_it)) < 0) {
107 if (!PyErr_Occurred()) {
108 string class_name(Py_TYPE(self)->tp_name);
109 PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
110 }
111 return nullptr;
112 }
113
114 const uint list_len = self->uf0D_vectorviewshape->result.size();
115 PyObject *list = PyList_New(list_len);
116 for (uint i = 0; i < list_len; i++) {
117 ViewShape *v = self->uf0D_vectorviewshape->result[i];
118 PyList_SET_ITEM(list, i, v ? BPy_ViewShape_from_ViewShape(*v) : (Py_INCREF(Py_None), Py_None));
119 }
120
121 return list;
122}
123
124/*-----------------------BPy_UnaryFunction0DVectorViewShape type definition ---------------------*/
125
127 /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
128 /*tp_name*/ "UnaryFunction0DVectorViewShape",
129 /*tp_basicsize*/ sizeof(BPy_UnaryFunction0DVectorViewShape),
130 /*tp_itemsize*/ 0,
131 /*tp_dealloc*/ (destructor)UnaryFunction0DVectorViewShape___dealloc__,
132 /*tp_vectorcall_offset*/ 0,
133 /*tp_getattr*/ nullptr,
134 /*tp_setattr*/ nullptr,
135 /*tp_as_async*/ nullptr,
136 /*tp_repr*/ (reprfunc)UnaryFunction0DVectorViewShape___repr__,
137 /*tp_as_number*/ nullptr,
138 /*tp_as_sequence*/ nullptr,
139 /*tp_as_mapping*/ nullptr,
140 /*tp_hash*/ nullptr,
141 /*tp_call*/ (ternaryfunc)UnaryFunction0DVectorViewShape___call__,
142 /*tp_str*/ nullptr,
143 /*tp_getattro*/ nullptr,
144 /*tp_setattro*/ nullptr,
145 /*tp_as_buffer*/ nullptr,
146 /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
147 /*tp_doc*/ UnaryFunction0DVectorViewShape___doc__,
148 /*tp_traverse*/ nullptr,
149 /*tp_clear*/ nullptr,
150 /*tp_richcompare*/ nullptr,
151 /*tp_weaklistoffset*/ 0,
152 /*tp_iter*/ nullptr,
153 /*tp_iternext*/ nullptr,
154 /*tp_methods*/ nullptr,
155 /*tp_members*/ nullptr,
156 /*tp_getset*/ nullptr,
157 /*tp_base*/ &UnaryFunction0D_Type,
158 /*tp_dict*/ nullptr,
159 /*tp_descr_get*/ nullptr,
160 /*tp_descr_set*/ nullptr,
161 /*tp_dictoffset*/ 0,
162 /*tp_init*/ (initproc)UnaryFunction0DVectorViewShape___init__,
163 /*tp_alloc*/ nullptr,
164 /*tp_new*/ nullptr,
165};
166
168
169#ifdef __cplusplus
170}
171#endif
unsigned int uint
PyObject * BPy_ViewShape_from_ViewShape(ViewShape &vs)
PyTypeObject GetOccludersF0D_Type
PyTypeObject Interface0DIterator_Type
PyDoc_STRVAR(UnaryFunction0DVectorViewShape___doc__, "Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DVectorViewShape`\n" "\n" "Base class for unary functions (functors) that work on\n" ":class:`Interface0DIterator` and return a list of :class:`ViewShape`\n" "objects.\n" "\n" ".. method:: __init__()\n" "\n" " Default constructor.\n")
PyTypeObject UnaryFunction0DVectorViewShape_Type
static PyObject * UnaryFunction0DVectorViewShape___call__(BPy_UnaryFunction0DVectorViewShape *self, PyObject *args, PyObject *kwds)
static PyObject * UnaryFunction0DVectorViewShape___repr__(BPy_UnaryFunction0DVectorViewShape *self)
int UnaryFunction0DVectorViewShape_Init(PyObject *module)
static void UnaryFunction0DVectorViewShape___dealloc__(BPy_UnaryFunction0DVectorViewShape *self)
static int UnaryFunction0DVectorViewShape___init__(BPy_UnaryFunction0DVectorViewShape *self, PyObject *args, PyObject *kwds)
PyTypeObject UnaryFunction0D_Type
ATTR_WARN_UNUSED_RESULT const BMVert * v
PyObject * self
inherits from class Rep
Definition AppCanvas.cpp:20
static struct PyModuleDef module
Definition python.cpp:991