1 // -*- mode: C; indent-tabs-mode: nil; -*-
6 extern PyTypeObject OtkRect_Type;
8 PyObject *OtkRect_New(int x, int y, int width, int height)
10 OtkRect* self = PyObject_New(OtkRect, &OtkRect_Type);
15 self->height = height;
17 return (PyObject*)self;
22 static PyObject *otkrect_getx(OtkRect* self, PyObject* args)
24 if (!PyArg_ParseTuple(args, ":getX"))
26 return PyInt_FromLong(self->x);
29 static PyObject *otkrect_gety(OtkRect* self, PyObject* args)
31 if (!PyArg_ParseTuple(args, ":getY"))
33 return PyInt_FromLong(self->y);
36 static PyObject *otkrect_getwidth(OtkRect* self, PyObject* args)
38 if (!PyArg_ParseTuple(args, ":getWidth"))
40 return PyInt_FromLong(self->width);
43 static PyObject *otkrect_getheight(OtkRect* self, PyObject* args)
45 if (!PyArg_ParseTuple(args, ":getHeight"))
47 return PyInt_FromLong(self->height);
51 static PyMethodDef get_methods[] = {
52 {"getX", (PyCFunction)otkrect_getx, METH_VARARGS,
53 "Get the X coordinate."},
54 {"getY", (PyCFunction)otkrect_gety, METH_VARARGS,
55 "Get the Y coordinate."},
56 {"getWidth", (PyCFunction)otkrect_getwidth, METH_VARARGS,
58 {"getHeight", (PyCFunction)otkrect_getheight, METH_VARARGS,
65 static void otkrect_dealloc(PyObject* self)
70 static PyObject *otkrect_getattr(PyObject *obj, char *name)
72 return Py_FindMethod(get_methods, obj, name);
76 PyTypeObject OtkRect_Type = {
77 PyObject_HEAD_INIT(NULL)
82 otkrect_dealloc, /*tp_dealloc*/
84 otkrect_getattr, /*tp_getattr*/