Blender V5.0
BPy_UnaryFunction0DId.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
15
16using namespace Freestyle;
17
19
20//-------------------MODULE INITIALIZATION--------------------------------
21
23{
24 if (module == nullptr) {
25 return -1;
26 }
27
28 if (PyType_Ready(&UnaryFunction0DId_Type) < 0) {
29 return -1;
30 }
31 PyModule_AddObjectRef(module, "UnaryFunction0DId", (PyObject *)&UnaryFunction0DId_Type);
32
33 if (PyType_Ready(&ShapeIdF0D_Type) < 0) {
34 return -1;
35 }
36 PyModule_AddObjectRef(module, "ShapeIdF0D", (PyObject *)&ShapeIdF0D_Type);
37
38 return 0;
39}
40
41//------------------------INSTANCE METHODS ----------------------------------
42
44 /* Wrap. */
45 UnaryFunction0DId___doc__,
46 "Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DId`\n"
47 "\n"
48 "Base class for unary functions (functors) that work on\n"
49 ":class:`Interface0DIterator` and return an :class:`Id` object.\n"
50 "\n"
51 ".. method:: __init__()\n"
52 "\n"
53 " Default constructor.\n");
54static int UnaryFunction0DId___init__(BPy_UnaryFunction0DId *self, PyObject *args, PyObject *kwds)
55{
56 static const char *kwlist[] = {nullptr};
57
58 if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
59 return -1;
60 }
61 self->uf0D_id = new UnaryFunction0D<Id>();
62 self->uf0D_id->py_uf0D = (PyObject *)self;
63 return 0;
64}
65
67{
68 delete self->uf0D_id;
69 UnaryFunction0D_Type.tp_dealloc((PyObject *)self);
70}
71
73{
74 return PyUnicode_FromFormat("type: %s - address: %p", Py_TYPE(self)->tp_name, self->uf0D_id);
75}
76
78 PyObject *args,
79 PyObject *kwds)
80{
81 static const char *kwlist[] = {"it", nullptr};
82 PyObject *obj;
83
84 if (!PyArg_ParseTupleAndKeywords(
85 args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj))
86 {
87 return nullptr;
88 }
89
90 if (typeid(*(self->uf0D_id)) == typeid(UnaryFunction0D<Id>)) {
91 PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
92 return nullptr;
93 }
94 if (self->uf0D_id->operator()(*(((BPy_Interface0DIterator *)obj)->if0D_it)) < 0) {
95 if (!PyErr_Occurred()) {
96 string class_name(Py_TYPE(self)->tp_name);
97 PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
98 }
99 return nullptr;
100 }
101 return BPy_Id_from_Id(self->uf0D_id->result);
102}
103
104/*-----------------------BPy_UnaryFunction0DId type definition ------------------------------*/
105
107 /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
108 /*tp_name*/ "UnaryFunction0DId",
109 /*tp_basicsize*/ sizeof(BPy_UnaryFunction0DId),
110 /*tp_itemsize*/ 0,
111 /*tp_dealloc*/ (destructor)UnaryFunction0DId___dealloc__,
112 /*tp_vectorcall_offset*/ 0,
113 /*tp_getattr*/ nullptr,
114 /*tp_setattr*/ nullptr,
115 /*tp_as_async*/ nullptr,
116 /*tp_repr*/ (reprfunc)UnaryFunction0DId___repr__,
117 /*tp_as_number*/ nullptr,
118 /*tp_as_sequence*/ nullptr,
119 /*tp_as_mapping*/ nullptr,
120 /*tp_hash*/ nullptr,
121 /*tp_call*/ (ternaryfunc)UnaryFunction0DId___call__,
122 /*tp_str*/ nullptr,
123 /*tp_getattro*/ nullptr,
124 /*tp_setattro*/ nullptr,
125 /*tp_as_buffer*/ nullptr,
126 /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
127 /*tp_doc*/ UnaryFunction0DId___doc__,
128 /*tp_traverse*/ nullptr,
129 /*tp_clear*/ nullptr,
130 /*tp_richcompare*/ nullptr,
131 /*tp_weaklistoffset*/ 0,
132 /*tp_iter*/ nullptr,
133 /*tp_iternext*/ nullptr,
134 /*tp_methods*/ nullptr,
135 /*tp_members*/ nullptr,
136 /*tp_getset*/ nullptr,
137 /*tp_base*/ &UnaryFunction0D_Type,
138 /*tp_dict*/ nullptr,
139 /*tp_descr_get*/ nullptr,
140 /*tp_descr_set*/ nullptr,
141 /*tp_dictoffset*/ 0,
142 /*tp_init*/ (initproc)UnaryFunction0DId___init__,
143 /*tp_alloc*/ nullptr,
144 /*tp_new*/ nullptr,
145};
146
PyObject * BPy_Id_from_Id(Id &id)
PyTypeObject Interface0DIterator_Type
PyTypeObject ShapeIdF0D_Type
static void UnaryFunction0DId___dealloc__(BPy_UnaryFunction0DId *self)
static int UnaryFunction0DId___init__(BPy_UnaryFunction0DId *self, PyObject *args, PyObject *kwds)
static PyObject * UnaryFunction0DId___repr__(BPy_UnaryFunction0DId *self)
int UnaryFunction0DId_Init(PyObject *module)
PyDoc_STRVAR(UnaryFunction0DId___doc__, "Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DId`\n" "\n" "Base class for unary functions (functors) that work on\n" ":class:`Interface0DIterator` and return an :class:`Id` object.\n" "\n" ".. method:: __init__()\n" "\n" " Default constructor.\n")
PyTypeObject UnaryFunction0DId_Type
static PyObject * UnaryFunction0DId___call__(BPy_UnaryFunction0DId *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:796