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