Split __init__ into __init__ and __new__, code clean up

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/trunk@1056 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
remi-k 2009-03-14 22:28:16 +00:00
parent 15ba8f9b3c
commit d4e7e7724f
30 changed files with 305 additions and 542 deletions

View file

@ -29,17 +29,9 @@
static PyObject *
PySfInput_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
PySfInput *self;
self = (PySfInput *)type->tp_alloc(type, 0);
return (PyObject *)self;
}
static int
PySfInput_init(PySfInput *self, PyObject *args, PyObject *kwds)
{
PyErr_SetString(PyExc_RuntimeError, "You can't create an Input object yourself, because an Input object must always be associated to its window.\nThe only way to get an Input is by creating a window and calling : Input = MyWindow.GetInput().");
return -1;
return NULL;
}
static PyObject*
@ -129,7 +121,7 @@ PyTypeObject PySfInputType = {
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)PySfInput_init, /* tp_init */
0, /* tp_init */
0, /* tp_alloc */
PySfInput_new, /* tp_new */
};
@ -137,6 +129,6 @@ PyTypeObject PySfInputType = {
PySfInput *
GetNewPySfInput()
{
return (PySfInput *)PySfInput_new(&PySfInputType, NULL, NULL);
return PyObject_New(PySfInput, &PySfInputType);
}