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