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