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