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