1 // -*- mode: C; indent-tabs-mode: nil; -*-
6 extern PyTypeObject OtkRect_Type;
8 PyObject *OtkRect_New(int x, int y, int width, int height)
12 self = PyObject_New(OtkRect, &OtkRect_Type);
17 self->height = height;
19 return (PyObject*)self;
24 static PyObject *otkrect_getx(OtkRect* self, PyObject* args)
26 if (!PyArg_ParseTuple(args, ":getX"))
28 return PyInt_FromLong(self->x);
31 static PyObject *otkrect_gety(OtkRect* self, PyObject* args)
33 if (!PyArg_ParseTuple(args, ":getY"))
35 return PyInt_FromLong(self->y);
38 static PyObject *otkrect_getwidth(OtkRect* self, PyObject* args)
40 if (!PyArg_ParseTuple(args, ":getWidth"))
42 return PyInt_FromLong(self->width);
45 static PyObject *otkrect_getheight(OtkRect* self, PyObject* args)
47 if (!PyArg_ParseTuple(args, ":getHeight"))
49 return PyInt_FromLong(self->height);
53 static PyMethodDef get_methods[] = {
54 {"getX", (PyCFunction)otkrect_getx, METH_VARARGS,
55 "Get the X coordinate."},
56 {"getY", (PyCFunction)otkrect_gety, METH_VARARGS,
57 "Get the Y coordinate."},
58 {"getWidth", (PyCFunction)otkrect_getwidth, METH_VARARGS,
60 {"getHeight", (PyCFunction)otkrect_getheight, METH_VARARGS,
67 static void otkrect_dealloc(PyObject* self)
72 static PyObject *otkrect_getattr(PyObject *obj, char *name)
74 return Py_FindMethod(get_methods, obj, name);
78 PyTypeObject OtkRect_Type = {
79 PyObject_HEAD_INIT(NULL)
84 otkrect_dealloc, /*tp_dealloc*/
86 otkrect_getattr, /*tp_getattr*/