Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/boards/py-mod-score.c
blob: 49fe5348f4ebf4a16361e4b1799378d2db9c6e9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include <Python.h>
#define NO_IMPORT_PYGOBJECT 1
#include <pygobject.h>
#include "gcompris/gcompris.h"
#include "py-mod-utils.h"
#include "py-gcompris-board.h"

/* All functions provided by this python module
 * wraps a gcompris function. Each "py_*" function wraps the
 * "*" C function.
 */

/* void gc_score_start (ScoreStyleList style, guint x, guint y, guint max); */
static PyObject*
py_gc_score_start(PyObject* self, PyObject* args)
{
  int style;
  int x,y;
  guint max;

  /* Parse arguments */
  if(!PyArg_ParseTuple(args, "iiii:gc_score_start", &style, &x, &y, &max))
    return NULL;
  if(max<0) return NULL;

  /* Call the corresponding C function */
  gc_score_start(style, x, y, max);

  /* Create and return the result */
  Py_INCREF(Py_None);
  return Py_None;
}


/* void gc_score_end(); */
static PyObject*
py_gc_score_end(PyObject* self, PyObject* args)
{
  /* Parse arguments */
  if(!PyArg_ParseTuple(args, ":gc_score_end"))
    return NULL;

  /* Call the corresponding C function */
  gc_score_end();

  /* Create and return the result */
  Py_INCREF(Py_None);
  return Py_None;
}


/* void gc_score_set(guint value); */
static PyObject*
py_gc_score_set(PyObject* self, PyObject* args)
{
  guint value;

  /* Parse arguments */
  if(!PyArg_ParseTuple(args, "i:gc_score_set", &value))
    return NULL;
  if(value<0) return NULL;

  /* Call the corresponding C function */
  gc_score_set(value);

  /* Create and return the result */
  Py_INCREF(Py_None);
  return Py_None;
}


static PyMethodDef PythonGcomprisScoreModule[] = {
  { "start",  py_gc_score_start, METH_VARARGS, "gc_score_start" },
  { "end",  py_gc_score_end, METH_VARARGS, "gc_score_end" },
  { "set",  py_gc_score_set, METH_VARARGS, "gc_score_set" },
  { NULL, NULL, 0, NULL}
};

void python_gc_score_module_init(void)
{
  PyObject* module;
  module = Py_InitModule("_gcompris_score", PythonGcomprisScoreModule);

  /* Misc constants */
  PyModule_AddIntConstant(module, "STYLE_NOTE", SCORESTYLE_NOTE ); 
  PyModule_AddIntConstant(module, "STYLE_LIFE", SCORESTYLE_LIFE ); 
}

/* Some usefull code parts ... */
/*
static PyObject*
py_gcompris_(PyObject* self, PyObject* args)
{
*/  /* Parse arguments */
/*  if(!PyArg_ParseTuple(args, ":gcompris_"))
    return NULL;
*/
  /* Call the corresponding C function */
/*  gcompris_();
*/
  /* Create and return the result */
/*  Py_INCREF(Py_None);
  return Py_None;
}
*/
/*
  { "",  py_gcompris_, METH_VARARGS, "gcompris_" },
*/