1 /* Copyright (C) 2013-2020 Roland Lutz
3 AUTOMATICALLY GENERATED FROM data_line.m4 -- DO NOT EDIT
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software Foundation,
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
20 #include <structmember.h>
23 PyObject
*construct_line(const struct xornsch_line
*data
)
25 PyObject
*no_args
= PyTuple_New(0);
26 Line
*self
= (Line
*)PyObject_CallObject(
27 (PyObject
*)&LineType
, no_args
);
34 ((LineAttr
*)self
->line
)->data
= data
->line
;
35 return (PyObject
*)self
;
38 void prepare_line(Line
*self
,
39 xorn_obtype_t
*type_return
, const void **data_return
)
41 self
->data
.line
= ((LineAttr
*)self
->line
)->data
;
42 *type_return
= xornsch_obtype_line
;
43 *data_return
= &self
->data
;
46 static PyObject
*Line_new(
47 PyTypeObject
*type
, PyObject
*args
, PyObject
*kwds
)
49 Line
*self
= (Line
*)type
->tp_alloc(type
, 0);
53 PyObject
*no_args
= PyTuple_New(0);
54 self
->line
= PyObject_CallObject((PyObject
*)&LineAttrType
, no_args
);
57 if (self
->line
== NULL
) {
61 return (PyObject
*)self
;
64 static int Line_init(Line
*self
, PyObject
*args
, PyObject
*kwds
)
66 double x_arg
= 0., y_arg
= 0.;
67 double width_arg
= 0., height_arg
= 0.;
69 PyObject
*line_arg
= NULL
;
71 static char *kwlist
[] = {
79 if (!PyArg_ParseTupleAndKeywords(
80 args
, kwds
, "|ddddiO:Line", kwlist
,
82 &width_arg
, &height_arg
,
87 if (line_arg
!= NULL
&& !PyObject_TypeCheck(line_arg
, &LineAttrType
)) {
90 "line attribute must be %.50s, not %.50s",
91 LineAttrType
.tp_name
, line_arg
->ob_type
->tp_name
);
92 PyErr_SetString(PyExc_TypeError
, buf
);
96 self
->data
.pos
.x
= x_arg
;
97 self
->data
.pos
.y
= y_arg
;
98 self
->data
.size
.x
= width_arg
;
99 self
->data
.size
.y
= height_arg
;
100 self
->data
.color
= color_arg
;
101 if (line_arg
!= NULL
) {
103 Py_DECREF(self
->line
);
104 self
->line
= line_arg
;
110 static int Line_traverse(Line
*self
, visitproc visit
, void *arg
)
112 Py_VISIT(self
->line
);
116 static int Line_clear(Line
*self
)
118 Py_CLEAR(self
->line
);
122 static void Line_dealloc(Line
*self
)
125 self
->ob_type
->tp_free((PyObject
*)self
);
128 static PyMemberDef Line_members
[] = {
129 { "x", T_DOUBLE
, offsetof(Line
, data
.pos
.x
), 0,
131 { "y", T_DOUBLE
, offsetof(Line
, data
.pos
.y
), 0,
133 { "width", T_DOUBLE
, offsetof(Line
, data
.size
.x
), 0,
135 { "height", T_DOUBLE
, offsetof(Line
, data
.size
.y
), 0,
137 { "color", T_INT
, offsetof(Line
, data
.color
), 0,
139 { NULL
, 0, 0, 0, NULL
} /* Sentinel */
142 static PyObject
*Line_getline(Line
*self
, void *closure
)
144 Py_INCREF(self
->line
);
148 static int Line_setline(Line
*self
, PyObject
*value
, void *closure
)
151 PyErr_SetString(PyExc_TypeError
,
152 "line attribute cannot be deleted");
156 if (!PyObject_TypeCheck(value
, &LineAttrType
)) {
158 snprintf(buf
, BUFSIZ
,
159 "line attribute must be %.50s, not %.50s",
160 LineAttrType
.tp_name
, value
->ob_type
->tp_name
);
161 PyErr_SetString(PyExc_TypeError
, buf
);
166 Py_DECREF(self
->line
);
171 static PyGetSetDef Line_getset
[] = {
172 { "line", (getter
)Line_getline
, (setter
)Line_setline
,
173 PyDoc_STR(""), NULL
},
174 { NULL
, NULL
, NULL
, NULL
, NULL
} /* Sentinel */
177 PyTypeObject LineType
= {
178 PyObject_HEAD_INIT(NULL
)
181 /* For printing, in format "<module>.<name>" */
182 "xorn.storage.Line", /* const char *tp_name */
185 sizeof(Line
), /* Py_ssize_t tp_basicsize */
186 0, /* Py_ssize_t tp_itemsize */
188 /* Methods to implement standard operations */
189 (destructor
)Line_dealloc
, /* destructor tp_dealloc */
190 NULL
, /* printfunc tp_print */
191 NULL
, /* getattrfunc tp_getattr */
192 NULL
, /* setattrfunc tp_setattr */
193 NULL
, /* cmpfunc tp_compare */
194 NULL
, /* reprfunc tp_repr */
196 /* Method suites for standard classes */
197 NULL
, /* PyNumberMethods *tp_as_number */
198 NULL
, /* PySequenceMethods *tp_as_sequence */
199 NULL
, /* PyMappingMethods *tp_as_mapping */
201 /* More standard operations (here for binary compatibility) */
202 NULL
, /* hashfunc tp_hash */
203 NULL
, /* ternaryfunc tp_call */
204 NULL
, /* reprfunc tp_str */
205 NULL
, /* getattrofunc tp_getattro */
206 NULL
, /* setattrofunc tp_setattro */
208 /* Functions to access object as input/output buffer */
209 NULL
, /* PyBufferProcs *tp_as_buffer */
211 /* Flags to define presence of optional/expanded features */
212 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
| Py_TPFLAGS_HAVE_GC
,
215 /* Documentation string */
216 PyDoc_STR("Schematic line."),
217 /* const char *tp_doc */
219 /* Assigned meaning in release 2.0 */
220 /* call function for all accessible objects */
221 (traverseproc
)Line_traverse
,/* traverseproc tp_traverse */
223 /* delete references to contained objects */
224 (inquiry
)Line_clear
, /* inquiry tp_clear */
226 /* Assigned meaning in release 2.1 */
227 /* rich comparisons */
228 NULL
, /* richcmpfunc tp_richcompare */
230 /* weak reference enabler */
231 0, /* Py_ssize_t tp_weaklistoffset */
233 /* Added in release 2.2 */
235 NULL
, /* getiterfunc tp_iter */
236 NULL
, /* iternextfunc tp_iternext */
238 /* Attribute descriptor and subclassing stuff */
239 NULL
, /* struct PyMethodDef *tp_methods */
240 Line_members
, /* struct PyMemberDef *tp_members */
241 Line_getset
, /* struct PyGetSetDef *tp_getset */
242 NULL
, /* struct _typeobject *tp_base */
243 NULL
, /* PyObject *tp_dict */
244 NULL
, /* descrgetfunc tp_descr_get */
245 NULL
, /* descrsetfunc tp_descr_set */
246 0, /* Py_ssize_t tp_dictoffset */
247 (initproc
)Line_init
, /* initproc tp_init */
248 NULL
, /* allocfunc tp_alloc */
249 Line_new
, /* newfunc tp_new */
250 NULL
, /* freefunc tp_free--Low-level free-memory routine */
251 NULL
, /* inquiry tp_is_gc--For PyObject_IS_GC */
252 NULL
, /* PyObject *tp_bases */
253 NULL
, /* PyObject *tp_mro--method resolution order */
254 NULL
, /* PyObject *tp_cache */
255 NULL
, /* PyObject *tp_subclasses */
256 NULL
, /* PyObject *tp_weaklist */
257 NULL
, /* destructor tp_del */
259 /* Type attribute cache version tag. Added in version 2.6 */
260 0, /* unsigned int tp_version_tag */