Blender V5.3
BPy_UnaryFunction0DId.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
22int UnaryFunction0DId_Init(PyObject *module)
23{
24 if (module == nullptr) {
25 return -1;
26 }
27
28 if (PyType_Ready(&UnaryFunction0DId_Type) < 0) {
29 return -1;
30 }
31 PyModule_AddObjectRef(module, "UnaryFunction0DId", (PyObject *)&UnaryFunction0DId_Type);
32
33 if (PyType_Ready(&ShapeIdF0D_Type) < 0) {
34 return -1;
35 }
36 PyModule_AddObjectRef(module, "ShapeIdF0D", (PyObject *)&ShapeIdF0D_Type);
37
38 return 0;
39}
40
41//------------------------INSTANCE METHODS ----------------------------------
42
44 /* Wrap. */
45 UnaryFunction0DId___doc__,
46 "Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DId`\n"
47 "\n"
48 "Base class for unary functions (functors) that work on\n"
49 ":class:`Interface0DIterator` and return an :class:`Id` object.\n"
50 "\n"
51 ".. method:: __init__()\n"
52 "\n"
53 " Default constructor.\n");
54static int UnaryFunction0DId___init__(BPy_UnaryFunction0DId *self, PyObject *args, PyObject *kwds)
55{
56 static const char *kwlist[] = {nullptr};
57
58 if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
59 return -1;
60 }
61 self->uf0D_id = new UnaryFunction0D<Id>();
62 self->uf0D_id->py_uf0D = (PyObject *)self;
63 return 0;
64}
65
67{
68 delete self->uf0D_id;
69 UnaryFunction0D_Type.tp_dealloc((PyObject *)self);
70}
71
73{
74 return PyUnicode_FromFormat("type: %s - address: %p", Py_TYPE(self)->tp_name, self->uf0D_id);
75}
76
78 PyObject *args,
79 PyObject *kwds)
80{
81 static const char *kwlist[] = {"it", nullptr};
82 PyObject *obj;
83
84 if (!PyArg_ParseTupleAndKeywords(args,
85 kwds,
86 "O!" /* `it` */
87 ":__call__",
88 (char **)kwlist,
90 &obj))
91 {
92 return nullptr;
93 }
94
95 if (typeid(*(self->uf0D_id)) == typeid(UnaryFunction0D<Id>)) {
96 PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
97 return nullptr;
98 }
99 if (self->uf0D_id->operator()(*(((BPy_Interface0DIterator *)obj)->if0D_it)) < 0) {
100 if (!PyErr_Occurred()) {
101 string class_name(Py_TYPE(self)->tp_name);
102 PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
103 }
104 return nullptr;
105 }
106 return BPy_Id_from_Id(self->uf0D_id->result);
107}
108
109/*-----------------------BPy_UnaryFunction0DId type definition ------------------------------*/
110
112 /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
113 /*tp_name*/ "UnaryFunction0DId",
114 /*tp_basicsize*/ sizeof(BPy_UnaryFunction0DId),
115 /*tp_itemsize*/ 0,
116 /*tp_dealloc*/ (destructor)UnaryFunction0DId___dealloc__,
117 /*tp_vectorcall_offset*/ 0,
118 /*tp_getattr*/ nullptr,
119 /*tp_setattr*/ nullptr,
120 /*tp_as_async*/ nullptr,
121 /*tp_repr*/ (reprfunc)UnaryFunction0DId___repr__,
122 /*tp_as_number*/ nullptr,
123 /*tp_as_sequence*/ nullptr,
124 /*tp_as_mapping*/ nullptr,
125 /*tp_hash*/ nullptr,
126 /*tp_call*/ (ternaryfunc)UnaryFunction0DId___call__,
127 /*tp_str*/ nullptr,
128 /*tp_getattro*/ nullptr,
129 /*tp_setattro*/ nullptr,
130 /*tp_as_buffer*/ nullptr,
131 /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
132 /*tp_doc*/ UnaryFunction0DId___doc__,
133 /*tp_traverse*/ nullptr,
134 /*tp_clear*/ nullptr,
135 /*tp_richcompare*/ nullptr,
136 /*tp_weaklistoffset*/ 0,
137 /*tp_iter*/ nullptr,
138 /*tp_iternext*/ nullptr,
139 /*tp_methods*/ nullptr,
140 /*tp_members*/ nullptr,
141 /*tp_getset*/ nullptr,
142 /*tp_base*/ &UnaryFunction0D_Type,
143 /*tp_dict*/ nullptr,
144 /*tp_descr_get*/ nullptr,
145 /*tp_descr_set*/ nullptr,
146 /*tp_dictoffset*/ 0,
147 /*tp_init*/ (initproc)UnaryFunction0DId___init__,
148 /*tp_alloc*/ nullptr,
149 /*tp_new*/ nullptr,
150};
151
PyObject * BPy_Id_from_Id(Id &id)
PyDoc_STRVAR(FalseBP1D___doc__, "Class hierarchy: :class:`freestyle.types.BinaryPredicate1D` > :class:`FalseBP1D`\n" "\n" ".. method:: __call__(inter1, inter2)\n" "\n" " Always returns false.\n" "\n" " :param inter1: The first Interface1D object.\n" " :type inter1: :class:`freestyle.types.Interface1D`\n" " :param inter2: The second Interface1D object.\n" " :type inter2: :class:`freestyle.types.Interface1D`\n" " :return: False.\n" " :rtype: bool\n")
PyTypeObject Interface0DIterator_Type
PyTypeObject ShapeIdF0D_Type
static void UnaryFunction0DId___dealloc__(BPy_UnaryFunction0DId *self)
static int UnaryFunction0DId___init__(BPy_UnaryFunction0DId *self, PyObject *args, PyObject *kwds)
static PyObject * UnaryFunction0DId___repr__(BPy_UnaryFunction0DId *self)
int UnaryFunction0DId_Init(PyObject *module)
PyTypeObject UnaryFunction0DId_Type
static PyObject * UnaryFunction0DId___call__(BPy_UnaryFunction0DId *self, PyObject *args, PyObject *kwds)
PyTypeObject UnaryFunction0D_Type
inherits from class Rep
Definition AppCanvas.cpp:20
Freestyle::UnaryFunction0D< Freestyle::Id > * uf0D_id