]> Dogcows Code - chaz/openbox/blob - otk_c/rect.c
rm debug shit
[chaz/openbox] / otk_c / rect.c
1 // -*- mode: C; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2
3 #include "../config.h"
4 #include "rect.h"
5
6 PyObject *OtkRect_New(int x, int y, int width, int height)
7 {
8 OtkRect* self = PyObject_New(OtkRect, &OtkRect_Type);
9
10 self->x = x;
11 self->y = y;
12 self->width = width;
13 self->height = height;
14
15 return (PyObject*)self;
16 }
17
18
19
20 static PyObject *otkrect_getx(OtkRect *self, PyObject *args)
21 {
22 if (!PyArg_ParseTuple(args, ":getX"))
23 return NULL;
24 return PyInt_FromLong(self->x);
25 }
26
27 static PyObject *otkrect_gety(OtkRect *self, PyObject *args)
28 {
29 if (!PyArg_ParseTuple(args, ":getY"))
30 return NULL;
31 return PyInt_FromLong(self->y);
32 }
33
34 static PyObject *otkrect_getwidth(OtkRect *self, PyObject *args)
35 {
36 if (!PyArg_ParseTuple(args, ":getWidth"))
37 return NULL;
38 return PyInt_FromLong(self->width);
39 }
40
41 static PyObject *otkrect_getheight(OtkRect *self, PyObject *args)
42 {
43 if (!PyArg_ParseTuple(args, ":getHeight"))
44 return NULL;
45 return PyInt_FromLong(self->height);
46 }
47
48
49 static PyMethodDef get_methods[] = {
50 {"getX", (PyCFunction)otkrect_getx, METH_VARARGS,
51 "Get the X coordinate."},
52 {"getY", (PyCFunction)otkrect_gety, METH_VARARGS,
53 "Get the Y coordinate."},
54 {"getWidth", (PyCFunction)otkrect_getwidth, METH_VARARGS,
55 "Get the width."},
56 {"getHeight", (PyCFunction)otkrect_getheight, METH_VARARGS,
57 "Get the height."},
58 {NULL, NULL, 0, NULL}
59 };
60
61
62
63 static void otkrect_dealloc(PyObject *self)
64 {
65 PyObject_Del(self);
66 }
67
68 static PyObject *otkrect_getattr(PyObject *obj, char *name)
69 {
70 return Py_FindMethod(get_methods, obj, name);
71 }
72
73
74 PyTypeObject OtkRect_Type = {
75 PyObject_HEAD_INIT(NULL)
76 0,
77 "OtkRect",
78 sizeof(OtkRect),
79 0,
80 otkrect_dealloc, /*tp_dealloc*/
81 0, /*tp_print*/
82 otkrect_getattr, /*tp_getattr*/
83 0, /*tp_setattr*/
84 0, /*tp_compare*/
85 0, /*tp_repr*/
86 0, /*tp_as_number*/
87 0, /*tp_as_sequence*/
88 0, /*tp_as_mapping*/
89 0, /*tp_hash */
90 };
This page took 0.037591 seconds and 4 git commands to generate.