1 // -*- mode: C; indent-tabs-mode: nil; c-basic-offset: 2; -*-
6 PyObject
*OtkRect_New(int x
, int y
, int width
, int height
)
8 OtkRect
* self
= PyObject_New(OtkRect
, &OtkRect_Type
);
13 self
->height
= height
;
15 return (PyObject
*)self
;
20 static PyObject
*otkrect_getx(OtkRect
*self
, PyObject
*args
)
22 if (!PyArg_ParseTuple(args
, ":getX"))
24 return PyInt_FromLong(self
->x
);
27 static PyObject
*otkrect_gety(OtkRect
*self
, PyObject
*args
)
29 if (!PyArg_ParseTuple(args
, ":getY"))
31 return PyInt_FromLong(self
->y
);
34 static PyObject
*otkrect_getwidth(OtkRect
*self
, PyObject
*args
)
36 if (!PyArg_ParseTuple(args
, ":getWidth"))
38 return PyInt_FromLong(self
->width
);
41 static PyObject
*otkrect_getheight(OtkRect
*self
, PyObject
*args
)
43 if (!PyArg_ParseTuple(args
, ":getHeight"))
45 return PyInt_FromLong(self
->height
);
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
,
56 {"getHeight", (PyCFunction
)otkrect_getheight
, METH_VARARGS
,
63 static void otkrect_dealloc(PyObject
*self
)
68 static PyObject
*otkrect_getattr(PyObject
*obj
, char *name
)
70 return Py_FindMethod(get_methods
, obj
, name
);
74 PyTypeObject OtkRect_Type
= {
75 PyObject_HEAD_INIT(NULL
)
80 otkrect_dealloc
, /*tp_dealloc*/
82 otkrect_getattr
, /*tp_getattr*/