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