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