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