Blender  V2.93
BPy_UnaryFunction1D.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_UnaryFunction1D.h"
22 
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 using namespace Freestyle;
37 
39 
40 //-------------------MODULE INITIALIZATION--------------------------------
42 {
43  if (module == nullptr) {
44  return -1;
45  }
46 
47  if (PyType_Ready(&UnaryFunction1D_Type) < 0) {
48  return -1;
49  }
50  Py_INCREF(&UnaryFunction1D_Type);
51  PyModule_AddObject(module, "UnaryFunction1D", (PyObject *)&UnaryFunction1D_Type);
52 
61 
62  return 0;
63 }
64 
65 //------------------------INSTANCE METHODS ----------------------------------
66 
67 static char UnaryFunction1D___doc__[] =
68  "Base class for Unary Functions (functors) working on\n"
69  ":class:`Interface1D`. A unary function will be used by invoking\n"
70  "__call__() on an Interface1D. In Python, several different subclasses\n"
71  "of UnaryFunction1D are used depending on the types of functors' return\n"
72  "values. For example, you would inherit from a\n"
73  ":class:`UnaryFunction1DDouble` if you wish to define a function that\n"
74  "returns a double value. Available UnaryFunction1D subclasses are:\n"
75  "\n"
76  "* :class:`UnaryFunction1DDouble`\n"
77  "* :class:`UnaryFunction1DEdgeNature`\n"
78  "* :class:`UnaryFunction1DFloat`\n"
79  "* :class:`UnaryFunction1DUnsigned`\n"
80  "* :class:`UnaryFunction1DVec2f`\n"
81  "* :class:`UnaryFunction1DVec3f`\n"
82  "* :class:`UnaryFunction1DVectorViewShape`\n"
83  "* :class:`UnaryFunction1DVoid`\n";
84 
86 {
87  Py_TYPE(self)->tp_free((PyObject *)self);
88 }
89 
90 static PyObject *UnaryFunction1D___repr__(BPy_UnaryFunction1D * /*self*/)
91 {
92  return PyUnicode_FromString("UnaryFunction1D");
93 }
94 
95 /*----------------------UnaryFunction1D get/setters ----------------------------*/
96 
97 PyDoc_STRVAR(UnaryFunction1D_name_doc,
98  "The name of the unary 1D function.\n"
99  "\n"
100  ":type: str");
101 
102 static PyObject *UnaryFunction1D_name_get(BPy_UnaryFunction1D *self, void *UNUSED(closure))
103 {
104  return PyUnicode_FromString(Py_TYPE(self)->tp_name);
105 }
106 
107 static PyGetSetDef BPy_UnaryFunction1D_getseters[] = {
108  {"name",
109  (getter)UnaryFunction1D_name_get,
110  (setter) nullptr,
111  UnaryFunction1D_name_doc,
112  nullptr},
113  {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
114 };
115 
116 /*-----------------------BPy_UnaryFunction1D type definition ------------------------------*/
117 
118 PyTypeObject UnaryFunction1D_Type = {
119  PyVarObject_HEAD_INIT(nullptr, 0) "UnaryFunction1D", /* tp_name */
120  sizeof(BPy_UnaryFunction1D), /* tp_basicsize */
121  0, /* tp_itemsize */
122  (destructor)UnaryFunction1D___dealloc__, /* tp_dealloc */
123  0, /* tp_vectorcall_offset */
124  nullptr, /* tp_getattr */
125  nullptr, /* tp_setattr */
126  nullptr, /* tp_reserved */
127  (reprfunc)UnaryFunction1D___repr__, /* tp_repr */
128  nullptr, /* tp_as_number */
129  nullptr, /* tp_as_sequence */
130  nullptr, /* tp_as_mapping */
131  nullptr, /* tp_hash */
132  nullptr, /* tp_call */
133  nullptr, /* tp_str */
134  nullptr, /* tp_getattro */
135  nullptr, /* tp_setattro */
136  nullptr, /* tp_as_buffer */
137  Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
138  UnaryFunction1D___doc__, /* tp_doc */
139  nullptr, /* tp_traverse */
140  nullptr, /* tp_clear */
141  nullptr, /* tp_richcompare */
142  0, /* tp_weaklistoffset */
143  nullptr, /* tp_iter */
144  nullptr, /* tp_iternext */
145  nullptr, /* tp_methods */
146  nullptr, /* tp_members */
147  BPy_UnaryFunction1D_getseters, /* tp_getset */
148  nullptr, /* tp_base */
149  nullptr, /* tp_dict */
150  nullptr, /* tp_descr_get */
151  nullptr, /* tp_descr_set */
152  0, /* tp_dictoffset */
153  nullptr, /* tp_init */
154  nullptr, /* tp_alloc */
155  PyType_GenericNew, /* tp_new */
156 };
157 
159 
160 #ifdef __cplusplus
161 }
162 #endif
#define UNUSED(x)
int UnaryFunction1DDouble_Init(PyObject *module)
int UnaryFunction1DEdgeNature_Init(PyObject *module)
int UnaryFunction1DFloat_Init(PyObject *module)
int UnaryFunction1DUnsigned_Init(PyObject *module)
int UnaryFunction1DVec2f_Init(PyObject *module)
int UnaryFunction1DVec3f_Init(PyObject *module)
int UnaryFunction1DVectorViewShape_Init(PyObject *module)
int UnaryFunction1DVoid_Init(PyObject *module)
static PyObject * UnaryFunction1D___repr__(BPy_UnaryFunction1D *)
static void UnaryFunction1D___dealloc__(BPy_UnaryFunction1D *self)
PyTypeObject UnaryFunction1D_Type
int UnaryFunction1D_Init(PyObject *module)
static PyGetSetDef BPy_UnaryFunction1D_getseters[]
static char UnaryFunction1D___doc__[]
static PyObject * UnaryFunction1D_name_get(BPy_UnaryFunction1D *self, void *UNUSED(closure))
PyDoc_STRVAR(UnaryFunction1D_name_doc, "The name of the unary 1D function.\n" "\n" ":type: str")
static struct PyModuleDef module
inherits from class Rep
Definition: AppCanvas.cpp:32