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