Back to index

gcompris  8.2.2
py-mod-score.c
Go to the documentation of this file.
00001 #include <Python.h>
00002 #include <pygobject.h>
00003 #include "gcompris/gcompris.h"
00004 #include "py-mod-utils.h"
00005 #include "py-gcompris-board.h"
00006 
00007 /* All functions provided by this python module
00008  * wraps a gcompris function. Each "py_*" function wraps the
00009  * "*" C function.
00010  */
00011 
00012 /* void gc_score_start (ScoreStyleList style, guint x, guint y, guint max); */
00013 static PyObject*
00014 py_gc_score_start(PyObject* self, PyObject* args)
00015 {
00016   int style;
00017   int x,y;
00018   guint max;
00019 
00020   /* Parse arguments */
00021   if(!PyArg_ParseTuple(args, "iiii:gc_score_start", &style, &x, &y, &max))
00022     return NULL;
00023   if(max<0) return NULL;
00024 
00025   /* Call the corresponding C function */
00026   gc_score_start(style, x, y, max);
00027 
00028   /* Create and return the result */
00029   Py_INCREF(Py_None);
00030   return Py_None;
00031 }
00032 
00033 
00034 /* void gc_score_end(); */
00035 static PyObject*
00036 py_gc_score_end(PyObject* self, PyObject* args)
00037 {
00038   /* Parse arguments */
00039   if(!PyArg_ParseTuple(args, ":gc_score_end"))
00040     return NULL;
00041 
00042   /* Call the corresponding C function */
00043   gc_score_end();
00044 
00045   /* Create and return the result */
00046   Py_INCREF(Py_None);
00047   return Py_None;
00048 }
00049 
00050 
00051 /* void gc_score_set(guint value); */
00052 static PyObject*
00053 py_gc_score_set(PyObject* self, PyObject* args)
00054 {
00055   guint value;
00056 
00057   /* Parse arguments */
00058   if(!PyArg_ParseTuple(args, "i:gc_score_set", &value))
00059     return NULL;
00060   if(value<0) return NULL;
00061 
00062   /* Call the corresponding C function */
00063   gc_score_set(value);
00064 
00065   /* Create and return the result */
00066   Py_INCREF(Py_None);
00067   return Py_None;
00068 }
00069 
00070 
00071 static PyMethodDef PythonGcomprisScoreModule[] = {
00072   { "start",  py_gc_score_start, METH_VARARGS, "gc_score_start" },
00073   { "end",  py_gc_score_end, METH_VARARGS, "gc_score_end" },
00074   { "set",  py_gc_score_set, METH_VARARGS, "gc_score_set" },
00075   { NULL, NULL, 0, NULL}
00076 };
00077 
00078 void python_gc_score_module_init(void)
00079 {
00080   PyObject* module;
00081   module = Py_InitModule("_gcompris_score", PythonGcomprisScoreModule);
00082 
00083   /* Misc constants */
00084   PyModule_AddIntConstant(module, "STYLE_NOTE", SCORESTYLE_NOTE ); 
00085   PyModule_AddIntConstant(module, "STYLE_LIFE", SCORESTYLE_LIFE ); 
00086 }
00087 
00088 /* Some usefull code parts ... */
00089 /*
00090 static PyObject*
00091 py_gcompris_(PyObject* self, PyObject* args)
00092 {
00093 */  /* Parse arguments */
00094 /*  if(!PyArg_ParseTuple(args, ":gcompris_"))
00095     return NULL;
00096 */
00097   /* Call the corresponding C function */
00098 /*  gcompris_();
00099 */
00100   /* Create and return the result */
00101 /*  Py_INCREF(Py_None);
00102   return Py_None;
00103 }
00104 */
00105 /*
00106   { "",  py_gcompris_, METH_VARARGS, "gcompris_" },
00107 */