Merge fixes from branch 'xorn'
[geda-gaf.git] / xorn / src / cpython / storage / data_net.c
blobe65e45921bdac0ad4e1cf096118b050f6a43c66e
1 /* Copyright (C) 2013-2020 Roland Lutz
3 AUTOMATICALLY GENERATED FROM data_net.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. */
19 #include "data.h"
20 #include <structmember.h>
23 PyObject *construct_net(const struct xornsch_net *data)
25 PyObject *no_args = PyTuple_New(0);
26 Net *self = (Net *)PyObject_CallObject(
27 (PyObject *)&NetType, no_args);
28 Py_DECREF(no_args);
30 if (self == NULL)
31 return NULL;
33 self->data = *data;
34 return (PyObject *)self;
37 void prepare_net(Net *self,
38 xorn_obtype_t *type_return, const void **data_return)
40 *type_return = xornsch_obtype_net;
41 *data_return = &self->data;
44 static PyObject *Net_new(
45 PyTypeObject *type, PyObject *args, PyObject *kwds)
47 Net *self = (Net *)type->tp_alloc(type, 0);
48 if (self == NULL)
49 return NULL;
50 return (PyObject *)self;
53 static int Net_init(Net *self, PyObject *args, PyObject *kwds)
55 double x_arg = 0., y_arg = 0.;
56 double width_arg = 0., height_arg = 0.;
57 int color_arg = 0;
58 PyObject *is_bus_arg = NULL;
59 PyObject *is_pin_arg = NULL;
60 PyObject *is_inverted_arg = NULL;
62 static char *kwlist[] = {
63 "x", "y",
64 "width", "height",
65 "color",
66 "is_bus",
67 "is_pin",
68 "is_inverted",
69 NULL
72 if (!PyArg_ParseTupleAndKeywords(
73 args, kwds, "|ddddiOOO:Net", kwlist,
74 &x_arg, &y_arg,
75 &width_arg, &height_arg,
76 &color_arg,
77 &is_bus_arg,
78 &is_pin_arg,
79 &is_inverted_arg))
80 return -1;
82 int is_bus = 0;
83 if (is_bus_arg != NULL) {
84 is_bus = PyObject_IsTrue(is_bus_arg);
85 if (is_bus == -1)
86 return -1;
88 int is_pin = 0;
89 if (is_pin_arg != NULL) {
90 is_pin = PyObject_IsTrue(is_pin_arg);
91 if (is_pin == -1)
92 return -1;
94 int is_inverted = 0;
95 if (is_inverted_arg != NULL) {
96 is_inverted = PyObject_IsTrue(is_inverted_arg);
97 if (is_inverted == -1)
98 return -1;
101 self->data.pos.x = x_arg;
102 self->data.pos.y = y_arg;
103 self->data.size.x = width_arg;
104 self->data.size.y = height_arg;
105 self->data.color = color_arg;
106 self->data.is_bus = !!is_bus;
107 self->data.is_pin = !!is_pin;
108 self->data.is_inverted = !!is_inverted;
110 return 0;
113 static void Net_dealloc(Net *self)
115 self->ob_type->tp_free((PyObject *)self);
118 static PyMemberDef Net_members[] = {
119 { "x", T_DOUBLE, offsetof(Net, data.pos.x), 0,
120 PyDoc_STR("") },
121 { "y", T_DOUBLE, offsetof(Net, data.pos.y), 0,
122 PyDoc_STR("") },
123 { "width", T_DOUBLE, offsetof(Net, data.size.x), 0,
124 PyDoc_STR("") },
125 { "height", T_DOUBLE, offsetof(Net, data.size.y), 0,
126 PyDoc_STR("") },
127 { "color", T_INT, offsetof(Net, data.color), 0,
128 PyDoc_STR("") },
129 { "is_bus", T_BOOL, offsetof(Net, data.is_bus), 0,
130 PyDoc_STR("") },
131 { "is_pin", T_BOOL, offsetof(Net, data.is_pin), 0,
132 PyDoc_STR("") },
133 { "is_inverted", T_BOOL, offsetof(Net, data.is_inverted), 0,
134 PyDoc_STR("") },
135 { NULL, 0, 0, 0, NULL } /* Sentinel */
138 PyTypeObject NetType = {
139 PyObject_HEAD_INIT(NULL)
140 0, /*ob_size*/
142 /* For printing, in format "<module>.<name>" */
143 "xorn.storage.Net", /* const char *tp_name */
145 /* For allocation */
146 sizeof(Net), /* Py_ssize_t tp_basicsize */
147 0, /* Py_ssize_t tp_itemsize */
149 /* Methods to implement standard operations */
150 (destructor)Net_dealloc, /* destructor tp_dealloc */
151 NULL, /* printfunc tp_print */
152 NULL, /* getattrfunc tp_getattr */
153 NULL, /* setattrfunc tp_setattr */
154 NULL, /* cmpfunc tp_compare */
155 NULL, /* reprfunc tp_repr */
157 /* Method suites for standard classes */
158 NULL, /* PyNumberMethods *tp_as_number */
159 NULL, /* PySequenceMethods *tp_as_sequence */
160 NULL, /* PyMappingMethods *tp_as_mapping */
162 /* More standard operations (here for binary compatibility) */
163 NULL, /* hashfunc tp_hash */
164 NULL, /* ternaryfunc tp_call */
165 NULL, /* reprfunc tp_str */
166 NULL, /* getattrofunc tp_getattro */
167 NULL, /* setattrofunc tp_setattro */
169 /* Functions to access object as input/output buffer */
170 NULL, /* PyBufferProcs *tp_as_buffer */
172 /* Flags to define presence of optional/expanded features */
173 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
174 /* long tp_flags */
176 /* Documentation string */
177 PyDoc_STR("Schematic net segment, bus segment, or pin."),
178 /* const char *tp_doc */
180 /* Assigned meaning in release 2.0 */
181 /* call function for all accessible objects */
182 NULL, /* traverseproc tp_traverse */
184 /* delete references to contained objects */
185 NULL, /* inquiry tp_clear */
187 /* Assigned meaning in release 2.1 */
188 /* rich comparisons */
189 NULL, /* richcmpfunc tp_richcompare */
191 /* weak reference enabler */
192 0, /* Py_ssize_t tp_weaklistoffset */
194 /* Added in release 2.2 */
195 /* Iterators */
196 NULL, /* getiterfunc tp_iter */
197 NULL, /* iternextfunc tp_iternext */
199 /* Attribute descriptor and subclassing stuff */
200 NULL, /* struct PyMethodDef *tp_methods */
201 Net_members, /* struct PyMemberDef *tp_members */
202 NULL, /* struct PyGetSetDef *tp_getset */
203 NULL, /* struct _typeobject *tp_base */
204 NULL, /* PyObject *tp_dict */
205 NULL, /* descrgetfunc tp_descr_get */
206 NULL, /* descrsetfunc tp_descr_set */
207 0, /* Py_ssize_t tp_dictoffset */
208 (initproc)Net_init, /* initproc tp_init */
209 NULL, /* allocfunc tp_alloc */
210 Net_new, /* newfunc tp_new */
211 NULL, /* freefunc tp_free--Low-level free-memory routine */
212 NULL, /* inquiry tp_is_gc--For PyObject_IS_GC */
213 NULL, /* PyObject *tp_bases */
214 NULL, /* PyObject *tp_mro--method resolution order */
215 NULL, /* PyObject *tp_cache */
216 NULL, /* PyObject *tp_subclasses */
217 NULL, /* PyObject *tp_weaklist */
218 NULL, /* destructor tp_del */
220 /* Type attribute cache version tag. Added in version 2.6 */
221 0, /* unsigned int tp_version_tag */