Blender V5.0
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");
62 PyObject *args,
63 PyObject *kwds)
64{
65 static const char *kwlist[] = {nullptr};
66
67 if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
68 return -1;
69 }
70 self->uf0D_viewshape = new UnaryFunction0D<ViewShape *>();
71 self->uf0D_viewshape->py_uf0D = (PyObject *)self;
72 return 0;
73}
74
76{
77 delete self->uf0D_viewshape;
78 UnaryFunction0D_Type.tp_dealloc((PyObject *)self);
79}
80
82{
83 return PyUnicode_FromFormat(
84 "type: %s - address: %p", Py_TYPE(self)->tp_name, self->uf0D_viewshape);
85}
86
88 PyObject *args,
89 PyObject *kwds)
90{
91 static const char *kwlist[] = {"it", nullptr};
92 PyObject *obj;
93
94 if (!PyArg_ParseTupleAndKeywords(
95 args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj))
96 {
97 return nullptr;
98 }
99
100 if (typeid(*(self->uf0D_viewshape)) == typeid(UnaryFunction0D<ViewShape *>)) {
101 PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
102 return nullptr;
103 }
104 if (self->uf0D_viewshape->operator()(*(((BPy_Interface0DIterator *)obj)->if0D_it)) < 0) {
105 if (!PyErr_Occurred()) {
106 string class_name(Py_TYPE(self)->tp_name);
107 PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
108 }
109 return nullptr;
110 }
111 return BPy_ViewShape_from_ViewShape(*(self->uf0D_viewshape->result));
112}
113
114/*-----------------------BPy_UnaryFunction0DViewShape type definition ---------------------------*/
115
117 /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
118 /*tp_name*/ "UnaryFunction0DViewShape",
119 /*tp_basicsize*/ sizeof(BPy_UnaryFunction0DViewShape),
120 /*tp_itemsize*/ 0,
121 /*tp_dealloc*/ (destructor)UnaryFunction0DViewShape___dealloc__,
122 /*tp_vectorcall_offset*/ 0,
123 /*tp_getattr*/ nullptr,
124 /*tp_setattr*/ nullptr,
125 /*tp_as_async*/ nullptr,
126 /*tp_repr*/ (reprfunc)UnaryFunction0DViewShape___repr__,
127 /*tp_as_number*/ nullptr,
128 /*tp_as_sequence*/ nullptr,
129 /*tp_as_mapping*/ nullptr,
130 /*tp_hash*/ nullptr,
131 /*tp_call*/ (ternaryfunc)UnaryFunction0DViewShape___call__,
132 /*tp_str*/ nullptr,
133 /*tp_getattro*/ nullptr,
134 /*tp_setattro*/ nullptr,
135 /*tp_as_buffer*/ nullptr,
136 /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
137 /*tp_doc*/ UnaryFunction0DViewShape___doc__,
138 /*tp_traverse*/ nullptr,
139 /*tp_clear*/ nullptr,
140 /*tp_richcompare*/ nullptr,
141 /*tp_weaklistoffset*/ 0,
142 /*tp_iter*/ nullptr,
143 /*tp_iternext*/ nullptr,
144 /*tp_methods*/ nullptr,
145 /*tp_members*/ nullptr,
146 /*tp_getset*/ nullptr,
147 /*tp_base*/ &UnaryFunction0D_Type,
148 /*tp_dict*/ nullptr,
149 /*tp_descr_get*/ nullptr,
150 /*tp_descr_set*/ nullptr,
151 /*tp_dictoffset*/ 0,
152 /*tp_init*/ (initproc)UnaryFunction0DViewShape___init__,
153 /*tp_alloc*/ nullptr,
154 /*tp_new*/ nullptr,
155};
156
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