diff options
author | Tavian Barnes <tavianator@gmail.com> | 2011-05-20 16:34:52 -0600 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2011-05-20 16:34:52 -0600 |
commit | 250b980002419746fc099c7633b9600a15afb1c6 (patch) | |
tree | c146041da19654d565a6dc433eebada324fc9fb9 /libdimension-python/Scene.c | |
parent | ad716acc7fa7fd151ff96fe6d17f0ba1a3a66379 (diff) | |
download | dimension-250b980002419746fc099c7633b9600a15afb1c6.tar.xz |
Add Canvases to the Python module.
Diffstat (limited to 'libdimension-python/Scene.c')
-rw-r--r-- | libdimension-python/Scene.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/libdimension-python/Scene.c b/libdimension-python/Scene.c index 6323402..29a623a 100644 --- a/libdimension-python/Scene.c +++ b/libdimension-python/Scene.c @@ -18,20 +18,22 @@ * <http://www.gnu.org/licenses/>. * *************************************************************************/ +#include "Canvas.h" #include "Scene.h" -static PyObject * -dmnsn_py_Scene_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - dmnsn_py_Scene *self; - self = (dmnsn_py_Scene *)type->tp_alloc(type, 0); - self->scene = dmnsn_new_scene(); - return (PyObject *)self; -} - static int dmnsn_py_Scene_init(dmnsn_py_Scene *self, PyObject *args, PyObject *kwds) { + static char *kwlist[] = { "canvas", NULL }; + + dmnsn_py_Canvas *canvas; + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", kwlist, + &dmnsn_py_CanvasType, &canvas)) + return -1; + + dmnsn_delete_scene(self->scene); + self->scene = dmnsn_new_scene(); + dmnsn_scene_set_canvas(self->scene, canvas->canvas); return 0; } @@ -60,11 +62,11 @@ PyTypeObject dmnsn_py_SceneType = { .tp_methods = dmnsn_py_Scene_methods, .tp_getset = dmnsn_py_Scene_getsetters, .tp_init = (initproc)dmnsn_py_Scene_init, - .tp_new = dmnsn_py_Scene_new, }; bool dmnsn_py_init_SceneType(void) { + dmnsn_py_SceneType.tp_new = PyType_GenericNew; return PyType_Ready(&dmnsn_py_SceneType) >= 0; } |