Blender  V3.3
BPy_UnaryFunction1D.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #include "BPy_UnaryFunction1D.h"
8 
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 using namespace Freestyle;
23 
25 
26 //-------------------MODULE INITIALIZATION--------------------------------
28 {
29  if (module == nullptr) {
30  return -1;
31  }
32 
33  if (PyType_Ready(&UnaryFunction1D_Type) < 0) {
34  return -1;
35  }
36  Py_INCREF(&UnaryFunction1D_Type);
37  PyModule_AddObject(module, "UnaryFunction1D", (PyObject *)&UnaryFunction1D_Type);
38 
47 
48  return 0;
49 }
50 
51 //------------------------INSTANCE METHODS ----------------------------------
52 
53 static char UnaryFunction1D___doc__[] =
54  "Base class for Unary Functions (functors) working on\n"
55  ":class:`Interface1D`. A unary function will be used by invoking\n"
56  "__call__() on an Interface1D. In Python, several different subclasses\n"
57  "of UnaryFunction1D are used depending on the types of functors' return\n"
58  "values. For example, you would inherit from a\n"
59  ":class:`UnaryFunction1DDouble` if you wish to define a function that\n"
60  "returns a double value. Available UnaryFunction1D subclasses are:\n"
61  "\n"
62  "* :class:`UnaryFunction1DDouble`\n"
63  "* :class:`UnaryFunction1DEdgeNature`\n"
64  "* :class:`UnaryFunction1DFloat`\n"
65  "* :class:`UnaryFunction1DUnsigned`\n"
66  "* :class:`UnaryFunction1DVec2f`\n"
67  "* :class:`UnaryFunction1DVec3f`\n"
68  "* :class:`UnaryFunction1DVectorViewShape`\n"
69  "* :class:`UnaryFunction1DVoid`\n";
70 
72 {
73  Py_TYPE(self)->tp_free((PyObject *)self);
74 }
75 
76 static PyObject *UnaryFunction1D___repr__(BPy_UnaryFunction1D * /*self*/)
77 {
78  return PyUnicode_FromString("UnaryFunction1D");
79 }
80 
81 /*----------------------UnaryFunction1D get/setters ----------------------------*/
82 
83 PyDoc_STRVAR(UnaryFunction1D_name_doc,
84  "The name of the unary 1D function.\n"
85  "\n"
86  ":type: str");
87 
88 static PyObject *UnaryFunction1D_name_get(BPy_UnaryFunction1D *self, void *UNUSED(closure))
89 {
90  return PyUnicode_FromString(Py_TYPE(self)->tp_name);
91 }
92 
93 static PyGetSetDef BPy_UnaryFunction1D_getseters[] = {
94  {"name",
96  (setter) nullptr,
97  UnaryFunction1D_name_doc,
98  nullptr},
99  {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
100 };
101 
102 /*-----------------------BPy_UnaryFunction1D type definition ------------------------------*/
103 
104 PyTypeObject UnaryFunction1D_Type = {
105  PyVarObject_HEAD_INIT(nullptr, 0) "UnaryFunction1D", /* tp_name */
106  sizeof(BPy_UnaryFunction1D), /* tp_basicsize */
107  0, /* tp_itemsize */
108  (destructor)UnaryFunction1D___dealloc__, /* tp_dealloc */
109  0, /* tp_vectorcall_offset */
110  nullptr, /* tp_getattr */
111  nullptr, /* tp_setattr */
112  nullptr, /* tp_reserved */
113  (reprfunc)UnaryFunction1D___repr__, /* tp_repr */
114  nullptr, /* tp_as_number */
115  nullptr, /* tp_as_sequence */
116  nullptr, /* tp_as_mapping */
117  nullptr, /* tp_hash */
118  nullptr, /* tp_call */
119  nullptr, /* tp_str */
120  nullptr, /* tp_getattro */
121  nullptr, /* tp_setattro */
122  nullptr, /* tp_as_buffer */
123  Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
124  UnaryFunction1D___doc__, /* tp_doc */
125  nullptr, /* tp_traverse */
126  nullptr, /* tp_clear */
127  nullptr, /* tp_richcompare */
128  0, /* tp_weaklistoffset */
129  nullptr, /* tp_iter */
130  nullptr, /* tp_iternext */
131  nullptr, /* tp_methods */
132  nullptr, /* tp_members */
133  BPy_UnaryFunction1D_getseters, /* tp_getset */
134  nullptr, /* tp_base */
135  nullptr, /* tp_dict */
136  nullptr, /* tp_descr_get */
137  nullptr, /* tp_descr_set */
138  0, /* tp_dictoffset */
139  nullptr, /* tp_init */
140  nullptr, /* tp_alloc */
141  PyType_GenericNew, /* tp_new */
142 };
143 
145 
146 #ifdef __cplusplus
147 }
148 #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")
inherits from class Rep
Definition: AppCanvas.cpp:18
static struct PyModuleDef module
Definition: python.cpp:972