Back to index

gcompris  8.2.2
Functions | Variables
py-gcompris-user.c File Reference
#include "py-gcompris-profile.h"
#include <pygobject.h>

Go to the source code of this file.

Functions

PyObject * gcompris_new_pyGcomprisUserObject (GcomprisUser *user)
static void pyGcomprisUserType_dealloc (pyGcomprisUserObject *self)
static PyObject * pyGcomprisUserType_getattr (pyGcomprisUserObject *self, char *name)
static int pyGcomprisUserType_setattr (pyGcomprisUserObject *self, char *name, PyObject *v)

Variables

staticforward PyTypeObject pyGcomprisUserType
static PyMethodDef pyGcomprisUserType_methods []

Function Documentation

PyObject* gcompris_new_pyGcomprisUserObject ( GcomprisUser *  user)

Definition at line 13 of file py-gcompris-user.c.

{
  pyGcomprisUserObject* theuser = NULL;

  theuser = PyObject_New(pyGcomprisUserObject, &pyGcomprisUserType);
  if (theuser!=NULL)
    theuser->cdata = user;

  return (PyObject*)theuser;
}

Here is the caller graph for this function:

static void pyGcomprisUserType_dealloc ( pyGcomprisUserObject self) [static]

Definition at line 27 of file py-gcompris-user.c.

{
  self->cdata = NULL;
  PyObject_DEL(self);
}
static PyObject* pyGcomprisUserType_getattr ( pyGcomprisUserObject self,
char *  name 
) [static]

Definition at line 42 of file py-gcompris-user.c.

{
    /* int */
    if(strcmp(name,"user_id")==0) return Py_BuildValue("i", self->cdata->user_id);
    /* int */
    if(strcmp(name,"class_id")==0) return Py_BuildValue("i", self->cdata->class_id);
    /* str */
    if(strcmp(name,"login")==0) return Py_BuildValue("s", self->cdata->login);
    /* str */
    if(strcmp(name,"lastname")==0) return Py_BuildValue("s", self->cdata->lastname);
    /* str */
    if(strcmp(name,"firstname")==0) return Py_BuildValue("s", self->cdata->firstname);
    /* str */
    if(strcmp(name,"birthdate")==0) return Py_BuildValue("s", self->cdata->birthdate);
    /* u int */
    if(strcmp(name,"session_id")==0) return Py_BuildValue("i", self->cdata->session_id);

  return Py_FindMethod(pyGcomprisUserType_methods, (PyObject *)self, name);
}
static int pyGcomprisUserType_setattr ( pyGcomprisUserObject self,
char *  name,
PyObject *  v 
) [static]

Definition at line 64 of file py-gcompris-user.c.

{
  if (self->cdata==NULL) return -1;
  if (v==NULL) return -1;

  /*  if (strcmp(name,"level")==0){
    value = (int) PyInt_AsLong(v);
    if ( value < 0 ) return -1;
    self->cdata->level=value;
    return 0;
    } */
  /* members are supposed to be read only */

  return -1;
}

Variable Documentation

static PyTypeObject pyGcomprisUserType
Initial value:
 {


 
  PyObject_HEAD_INIT(&PyType_Type)

  0,                                        
  "pyGcomprisUser",                        
  sizeof(pyGcomprisUserObject),            
  0,                                        
  
  (destructor)pyGcomprisUserType_dealloc,  
  0,                                        
  (getattrfunc)pyGcomprisUserType_getattr, 
  (setattrfunc)pyGcomprisUserType_setattr, 
  0,                                        
  0,                                        
  0,                                        
  0,                                        
  0,                                        
  0,                                        
}

Definition at line 4 of file py-gcompris-user.c.

PyMethodDef pyGcomprisUserType_methods[] [static]
Initial value:
 {
        {NULL,          NULL}           
}

Definition at line 35 of file py-gcompris-user.c.