Blender  V2.93
BPy_UnaryFunction0D.cpp
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
21 #include "BPy_UnaryFunction0D.h"
22 
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 using namespace Freestyle;
39 
41 
42 //-------------------MODULE INITIALIZATION--------------------------------
44 {
45  if (module == nullptr) {
46  return -1;
47  }
48 
49  if (PyType_Ready(&UnaryFunction0D_Type) < 0) {
50  return -1;
51  }
52  Py_INCREF(&UnaryFunction0D_Type);
53  PyModule_AddObject(module, "UnaryFunction0D", (PyObject *)&UnaryFunction0D_Type);
54 
65 
66  return 0;
67 }
68 
69 //------------------------INSTANCE METHODS ----------------------------------
70 
71 static char UnaryFunction0D___doc__[] =
72  "Base class for Unary Functions (functors) working on\n"
73  ":class:`Interface0DIterator`. A unary function will be used by\n"
74  "invoking __call__() on an Interface0DIterator. In Python, several\n"
75  "different subclasses of UnaryFunction0D are used depending on the\n"
76  "types of functors' return values. For example, you would inherit from\n"
77  "a :class:`UnaryFunction0DDouble` if you wish to define a function that\n"
78  "returns a double value. Available UnaryFunction0D subclasses are:\n"
79  "\n"
80  "* :class:`UnaryFunction0DDouble`\n"
81  "* :class:`UnaryFunction0DEdgeNature`\n"
82  "* :class:`UnaryFunction0DFloat`\n"
83  "* :class:`UnaryFunction0DId`\n"
84  "* :class:`UnaryFunction0DMaterial`\n"
85  "* :class:`UnaryFunction0DUnsigned`\n"
86  "* :class:`UnaryFunction0DVec2f`\n"
87  "* :class:`UnaryFunction0DVec3f`\n"
88  "* :class:`UnaryFunction0DVectorViewShape`\n"
89  "* :class:`UnaryFunction0DViewShape`\n";
90 
92 {
93  Py_TYPE(self)->tp_free((PyObject *)self);
94 }
95 
96 static PyObject *UnaryFunction0D___repr__(BPy_UnaryFunction0D * /*self*/)
97 {
98  return PyUnicode_FromString("UnaryFunction0D");
99 }
100 
101 /*----------------------UnaryFunction0D get/setters ----------------------------*/
102 
103 PyDoc_STRVAR(UnaryFunction0D_name_doc,
104  "The name of the unary 0D function.\n"
105  "\n"
106  ":type: str");
107 
108 static PyObject *UnaryFunction0D_name_get(BPy_UnaryFunction0D *self, void *UNUSED(closure))
109 {
110  return PyUnicode_FromString(Py_TYPE(self)->tp_name);
111 }
112 
113 static PyGetSetDef BPy_UnaryFunction0D_getseters[] = {
114  {"name",
115  (getter)UnaryFunction0D_name_get,
116  (setter) nullptr,
117  UnaryFunction0D_name_doc,
118  nullptr},
119  {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
120 };
121 
122 /*-----------------------BPy_UnaryFunction0D type definition ------------------------------*/
123 
124 PyTypeObject UnaryFunction0D_Type = {
125  PyVarObject_HEAD_INIT(nullptr, 0) "UnaryFunction0D", /* tp_name */
126  sizeof(BPy_UnaryFunction0D), /* tp_basicsize */
127  0, /* tp_itemsize */
128  (destructor)UnaryFunction0D___dealloc__, /* tp_dealloc */
129  0, /* tp_vectorcall_offset */
130  nullptr, /* tp_getattr */
131  nullptr, /* tp_setattr */
132  nullptr, /* tp_reserved */
133  (reprfunc)UnaryFunction0D___repr__, /* tp_repr */
134  nullptr, /* tp_as_number */
135  nullptr, /* tp_as_sequence */
136  nullptr, /* tp_as_mapping */
137  nullptr, /* tp_hash */
138  nullptr, /* tp_call */
139  nullptr, /* tp_str */
140  nullptr, /* tp_getattro */
141  nullptr, /* tp_setattro */
142  nullptr, /* tp_as_buffer */
143  Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
144  UnaryFunction0D___doc__, /* tp_doc */
145  nullptr, /* tp_traverse */
146  nullptr, /* tp_clear */
147  nullptr, /* tp_richcompare */
148  0, /* tp_weaklistoffset */
149  nullptr, /* tp_iter */
150  nullptr, /* tp_iternext */
151  nullptr, /* tp_methods */
152  nullptr, /* tp_members */
153  BPy_UnaryFunction0D_getseters, /* tp_getset */
154  nullptr, /* tp_base */
155  nullptr, /* tp_dict */
156  nullptr, /* tp_descr_get */
157  nullptr, /* tp_descr_set */
158  0, /* tp_dictoffset */
159  nullptr, /* tp_init */
160  nullptr, /* tp_alloc */
161  PyType_GenericNew, /* tp_new */
162 };
163 
165 
166 #ifdef __cplusplus
167 }
168 #endif
#define UNUSED(x)
int UnaryFunction0DDouble_Init(PyObject *module)
int UnaryFunction0DEdgeNature_Init(PyObject *module)
int UnaryFunction0DFloat_Init(PyObject *module)
int UnaryFunction0DId_Init(PyObject *module)
int UnaryFunction0DMaterial_Init(PyObject *module)
int UnaryFunction0DUnsigned_Init(PyObject *module)
int UnaryFunction0DVec2f_Init(PyObject *module)
int UnaryFunction0DVec3f_Init(PyObject *module)
int UnaryFunction0DVectorViewShape_Init(PyObject *module)
int UnaryFunction0DViewShape_Init(PyObject *module)
PyDoc_STRVAR(UnaryFunction0D_name_doc, "The name of the unary 0D function.\n" "\n" ":type: str")
PyTypeObject UnaryFunction0D_Type
static PyObject * UnaryFunction0D___repr__(BPy_UnaryFunction0D *)
static PyGetSetDef BPy_UnaryFunction0D_getseters[]
static void UnaryFunction0D___dealloc__(BPy_UnaryFunction0D *self)
static PyObject * UnaryFunction0D_name_get(BPy_UnaryFunction0D *self, void *UNUSED(closure))
int UnaryFunction0D_Init(PyObject *module)
static char UnaryFunction0D___doc__[]
static struct PyModuleDef module
inherits from class Rep
Definition: AppCanvas.cpp:32