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