Changeset 1fb54fc49d803b13021310bbacaebd8b9804088f

Show
Ignore:
Timestamp:
15/12/05 11:14:42 (3 years ago)
Author:
Olivier Aubert <olivier.aubert@liris.cnrs.fr>
git-committer:
Olivier Aubert <olivier.aubert@liris.cnrs.fr> 1134641682 +0000
git-parent:

[9992f3424ae25a0931d502d0354954108ce9693d]

git-author:
Olivier Aubert <olivier.aubert@liris.cnrs.fr> 1134641682 +0000
Message:

python bindings: formatted to VLC coding style

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • bindings/python/vlcglue.c

    rf1cb32c r1fb54fc  
    3333 
    3434static PyMethodDef vlc_methods[] = { 
    35     {NULL}  /* Sentinel */ 
     35    { NULL }  /* Sentinel */ 
    3636}; 
    3737 
     
    4343PyObject *MediaControl_PlaylistException          = NULL; 
    4444 
    45 vlcMODINIT_FUNC  initvlc(void) 
    46 
    47     PyObject* m; 
     45vlcMODINIT_FUNC 
     46initvlc( void ) 
     47
     48    PyObject* p_module; 
    4849 
    4950    PyPosition_Type.tp_new = PyType_GenericNew; 
    5051    PyPosition_Type.tp_alloc = PyType_GenericAlloc; 
    5152 
    52     m = Py_InitModule3( "vlc", vlc_methods, 
    53                         "VLC media player embedding module."); 
    54   
    55     if (! m
     53    p_module = Py_InitModule3( "vlc", vlc_methods, 
     54                               "VLC media player embedding module." ); 
     55 
     56    if( !p_module
    5657      return; 
    5758 
    58     if (PyType_Ready(&PyPosition_Type) < 0
     59    if( PyType_Ready( &PyPosition_Type ) < 0
    5960        return; 
    60     if (PyType_Ready(&MediaControl_Type) < 0
     61    if( PyType_Ready( &MediaControl_Type ) < 0
    6162        return; 
    62 #ifdef VLCOBJECT_SUPPORT 
    63     if (PyType_Ready(&vlcObject_Type) < 0) 
     63    if( PyType_Ready( &vlcObject_Type ) < 0 ) 
    6464        return; 
    65 #endif 
    6665 
    6766    /* Exceptions */ 
    6867    MediaControl_InternalException = 
    69             PyErr_NewException("vlc.InternalException", NULL, NULL); 
    70     Py_INCREF(MediaControl_InternalException); 
    71     PyModule_AddObject(m, "InternalException", MediaControl_InternalException); 
     68            PyErr_NewException( "vlc.InternalException", NULL, NULL ); 
     69    Py_INCREF( MediaControl_InternalException ); 
     70    PyModule_AddObject( p_module, "InternalException", 
     71                        MediaControl_InternalException ); 
    7272 
    7373    MediaControl_PositionKeyNotSupported = 
    74             PyErr_NewException("vlc.PositionKeyNotSupported", NULL, NULL); 
    75     Py_INCREF(MediaControl_PositionKeyNotSupported); 
    76     PyModule_AddObject(m, "PositionKeyNotSupported", 
    77                     MediaControl_PositionKeyNotSupported); 
     74            PyErr_NewException( "vlc.PositionKeyNotSupported", NULL, NULL ); 
     75    Py_INCREF( MediaControl_PositionKeyNotSupported ); 
     76    PyModule_AddObject( p_module, "PositionKeyNotSupported", 
     77                        MediaControl_PositionKeyNotSupported ); 
    7878 
    7979    MediaControl_PositionOriginNotSupported= 
    80             PyErr_NewException("vlc.InvalidPosition", NULL, NULL); 
    81     Py_INCREF(MediaControl_PositionOriginNotSupported); 
    82     PyModule_AddObject(m, "PositionOriginNotSupported", 
    83                     MediaControl_PositionOriginNotSupported); 
     80            PyErr_NewException( "vlc.InvalidPosition", NULL, NULL ); 
     81    Py_INCREF( MediaControl_PositionOriginNotSupported ); 
     82    PyModule_AddObject( p_module, "PositionOriginNotSupported", 
     83                        MediaControl_PositionOriginNotSupported ); 
    8484 
    8585    MediaControl_InvalidPosition = 
    86             PyErr_NewException("vlc.InvalidPosition", NULL, NULL); 
    87     Py_INCREF(MediaControl_InvalidPosition); 
    88     PyModule_AddObject(m, "InvalidPosition", MediaControl_InvalidPosition); 
     86            PyErr_NewException( "vlc.InvalidPosition", NULL, NULL ); 
     87    Py_INCREF( MediaControl_InvalidPosition ); 
     88    PyModule_AddObject( p_module, "InvalidPosition", 
     89                        MediaControl_InvalidPosition ); 
    8990 
    9091    MediaControl_PlaylistException = 
    91             PyErr_NewException("vlc.PlaylistException", NULL, NULL); 
    92     Py_INCREF(MediaControl_PlaylistException); 
    93     PyModule_AddObject(m, "PlaylistException", MediaControl_PlaylistException); 
     92            PyErr_NewException( "vlc.PlaylistException", NULL, NULL ); 
     93    Py_INCREF( MediaControl_PlaylistException ); 
     94    PyModule_AddObject( p_module, "PlaylistException", 
     95                        MediaControl_PlaylistException ); 
    9496 
    9597    /* Types */ 
    96     Py_INCREF(&PyPosition_Type); 
    97     PyModule_AddObject(m, "Position", (PyObject *)&PyPosition_Type); 
    98  
    99     Py_INCREF(&MediaControl_Type); 
    100     PyModule_AddObject(m, "MediaControl", (PyObject *)&MediaControl_Type); 
    101  
    102 #ifdef VLCOBJECT_SUPPORT 
    103     Py_INCREF(&vlcObject_Type); 
    104     PyModule_AddObject(m, "Object", (PyObject *)&vlcObject_Type); 
    105 #endif 
     98    Py_INCREF( &PyPosition_Type ); 
     99    PyModule_AddObject( p_module, "Position", 
     100                        ( PyObject * )&PyPosition_Type ); 
     101 
     102    Py_INCREF( &MediaControl_Type ); 
     103    PyModule_AddObject( p_module, "MediaControl", 
     104                        ( PyObject * )&MediaControl_Type ); 
     105 
     106    Py_INCREF( &vlcObject_Type ); 
     107    PyModule_AddObject( p_module, "Object", 
     108                        ( PyObject * )&vlcObject_Type ); 
    106109 
    107110    /* Constants */ 
    108     PyModule_AddIntConstant(m, "AbsolutePosition", 
    109                     mediacontrol_AbsolutePosition); 
    110     PyModule_AddIntConstant(m, "RelativePosition", 
    111                     mediacontrol_RelativePosition); 
    112     PyModule_AddIntConstant(m, "ModuloPosition", 
    113                     mediacontrol_ModuloPosition); 
    114  
    115     PyModule_AddIntConstant(m, "ByteCount",        mediacontrol_ByteCount); 
    116     PyModule_AddIntConstant(m, "SampleCount",      mediacontrol_SampleCount); 
    117     PyModule_AddIntConstant(m, "MediaTime",        mediacontrol_MediaTime); 
    118     PyModule_AddIntConstant(m, "PlayingStatus",    mediacontrol_PlayingStatus); 
    119     PyModule_AddIntConstant(m, "PauseStatus", mediacontrol_PauseStatus); 
    120     PyModule_AddIntConstant(m, "ForwardStatus", mediacontrol_ForwardStatus); 
    121     PyModule_AddIntConstant(m, "BackwardStatus", mediacontrol_BackwardStatus); 
    122     PyModule_AddIntConstant(m, "InitStatus", mediacontrol_InitStatus); 
    123     PyModule_AddIntConstant(m, "EndStatus", mediacontrol_EndStatus); 
    124     PyModule_AddIntConstant(m, "UndefinedStatus", mediacontrol_UndefinedStatus); 
     111    PyModule_AddIntConstant( p_module, "AbsolutePosition", 
     112                             mediacontrol_AbsolutePosition ); 
     113    PyModule_AddIntConstant( p_module, "RelativePosition", 
     114                             mediacontrol_RelativePosition ); 
     115    PyModule_AddIntConstant( p_module, "ModuloPosition", 
     116                             mediacontrol_ModuloPosition ); 
     117 
     118    PyModule_AddIntConstant( p_module, "ByteCount", 
     119                             mediacontrol_ByteCount ); 
     120    PyModule_AddIntConstant( p_module, "SampleCount", 
     121                             mediacontrol_SampleCount ); 
     122    PyModule_AddIntConstant( p_module, "MediaTime", 
     123                             mediacontrol_MediaTime ); 
     124    PyModule_AddIntConstant( p_module, "PlayingStatus", 
     125                             mediacontrol_PlayingStatus ); 
     126    PyModule_AddIntConstant( p_module, "PauseStatus", 
     127                             mediacontrol_PauseStatus ); 
     128    PyModule_AddIntConstant( p_module, "ForwardStatus", 
     129                             mediacontrol_ForwardStatus ); 
     130    PyModule_AddIntConstant( p_module, "BackwardStatus", 
     131                             mediacontrol_BackwardStatus ); 
     132    PyModule_AddIntConstant( p_module, "InitStatus", 
     133                             mediacontrol_InitStatus ); 
     134    PyModule_AddIntConstant( p_module, "EndStatus", 
     135                             mediacontrol_EndStatus ); 
     136    PyModule_AddIntConstant( p_module, "UndefinedStatus", 
     137                             mediacontrol_UndefinedStatus ); 
    125138} 
    126139 
    127140 
    128141/* Make libpostproc happy... */ 
    129 void * fast_memcpy(void * to, const void * from, size_t len
    130 { 
    131   return memcpy(to, from, len); 
     142void * fast_memcpy( void * to, const void * from, size_t len
     143{ 
     144  return memcpy( to, from, len ); 
    132145} 
    133146 
     
    137150 *****************************************************************************/ 
    138151 
    139 #ifdef VLCOBJECT_SUPPORT 
    140  
    141 static PyObject *vlcObject_new( 
    142                 PyTypeObject *type, PyObject *args, PyObject *kwds) 
     152static PyObject 
     153*vlcObject_new( PyTypeObject *p_type, PyObject *p_args, PyObject *p_kwds ) 
    143154{ 
    144155    vlcObject *self; 
     
    146157    int i_id; 
    147158 
    148     self = PyObject_New(vlcObject, &vlcObject_Type); 
    149  
    150     if ( !PyArg_ParseTuple(args, "i", &i_id) ) 
     159    self = PyObject_New( vlcObject, &vlcObject_Type ); 
     160 
     161    if( !PyArg_ParseTuple( p_args, "i", &i_id ) ) 
    151162      return NULL; 
    152163 
    153164    /* Maybe we were already initialized */ 
    154     p_object = (vlc_object_t*)vlc_current_object(i_id); 
    155  
    156     if (! p_object
     165    p_object = ( vlc_object_t* )vlc_current_object( i_id ); 
     166 
     167    if( !p_object
    157168    { 
    158169        /* Try to initialize */ 
    159170        i_id = VLC_Create(); 
    160         p_object = (vlc_object_t*)vlc_current_object(i_id); 
    161     } 
    162  
    163     if (! p_object
    164     { 
    165         PyErr_SetString(PyExc_StandardError, "Unable to get object."); 
     171        p_object = ( vlc_object_t* )vlc_current_object( i_id ); 
     172    } 
     173 
     174    if( !p_object
     175    { 
     176        PyErr_SetString( PyExc_StandardError, "Unable to get object." ); 
    166177        return NULL; 
    167178    } 
     
    170181    self->b_released = 0; 
    171182 
    172     Py_INCREF( self ); /* Ah bon ? */ 
    173     return (PyObject *)self; 
    174 
    175  
    176 static PyObject * vlcObject_release( PyObject *self, PyObject *args ) 
     183    Py_INCREF(  self ); /* Ah bon ? */ 
     184    return ( PyObject * )self; 
     185
     186 
     187static PyObject * 
     188vlcObject_release(  PyObject *self, PyObject *p_args ) 
    177189{ 
    178190    if( VLCSELF->b_released == 0 ) 
     
    181193        VLCSELF->b_released = 1; 
    182194    } 
    183     Py_INCREF( Py_None ); 
     195    Py_INCREF( Py_None ); 
    184196    return Py_None; 
    185197} 
    186198 
    187 static void  vlcObject_dealloc(PyObject *self) 
     199static void 
     200vlcObject_dealloc( PyObject *self ) 
    188201{ 
    189202    vlcObject_release( self, NULL ); 
    190     PyMem_DEL(self); 
    191 
    192  
    193 static PyObject * vlcObject_find_object(PyObject *self, PyObject *args) 
    194 
    195     vlcObject *retval; 
     203    PyMem_DEL( self ); 
     204
     205 
     206static PyObject * 
     207vlcObject_find_object( PyObject *self, PyObject *args ) 
     208
     209    vlcObject *p_retval; 
    196210    vlc_object_t *p_obj; 
    197211    char *psz_name; 
    198212    int i_object_type; 
    199213 
    200     if ( !PyArg_ParseTuple(args, "s", &psz_name) ) 
    201       return NULL; 
     214    if( !PyArg_ParseTuple( args, "s", &psz_name ) ) 
     215        return NULL; 
    202216 
    203217    /* psz_name is in 
    204        (aout, decoder, input, httpd, intf, playlist, root, vlc, vout
     218       ( aout, decoder, input, httpd, intf, playlist, root, vlc, vout
    205219    */ 
    206     switch (psz_name[0]
     220    switch ( psz_name[0]
    207221    { 
    208222        case 'a': 
     
    216230            break; 
    217231        case 'i': 
    218             if (strlen(psz_name) < 3
     232            if( strlen( psz_name ) < 3
    219233                    i_object_type = VLC_OBJECT_INTF; 
    220             else if (psz_name[2] == 't'
     234            else if( psz_name[2] == 't'
    221235                    i_object_type = VLC_OBJECT_INTF; 
    222236            else 
     
    230244            break; 
    231245        case 'v': 
    232             if (strlen(psz_name) < 3
     246            if( strlen( psz_name ) < 3
    233247                    i_object_type = VLC_OBJECT_VLC; 
    234             else if (psz_name[1] == 'l'
     248            else if( psz_name[1] == 'l'
    235249                    i_object_type = VLC_OBJECT_VLC; 
    236250            else 
     
    238252            break; 
    239253        default: 
    240             /* FIXME: raise an exception */ 
     254            /* FIXME: raise an exception ? */ 
    241255            return Py_None; 
    242256    } 
     
    244258    p_obj = vlc_object_find( VLCSELF->p_object, i_object_type, FIND_ANYWHERE ); 
    245259 
    246     if (! p_obj
    247     { 
    248         Py_INCREF(Py_None); 
     260    if( !p_obj
     261    { 
     262        Py_INCREF( Py_None ); 
    249263        return Py_None; 
    250264    } 
    251265 
    252     retval = PyObject_New(vlcObject, &vlcObject_Type); 
    253  
    254     retval->p_object = p_obj; 
    255  
    256     return (PyObject *)retval; 
    257 
    258  
    259 static PyObject * vlcObject_info(PyObject *self, PyObject *args) 
    260 
    261     PyObject *retval; 
     266    p_retval = PyObject_New( vlcObject, &vlcObject_Type ); 
     267 
     268    p_retval->p_object = p_obj; 
     269 
     270    return ( PyObject * )p_retval; 
     271
     272 
     273static PyObject * 
     274vlcObject_info( PyObject *self, PyObject *args ) 
     275
     276    PyObject *p_retval; 
    262277    vlc_object_t *p_obj; 
    263278 
     
    265280 
    266281    /* Return information about the object as a dict. */ 
    267     retval = PyDict_New(); 
    268  
    269     PyDict_SetItemString(retval, "object-id", 
    270                     Py_BuildValue("l", p_obj->i_object_id)); 
    271     PyDict_SetItemString(retval, "object-type", 
    272                   Py_BuildValue("s", p_obj->psz_object_type)); 
    273     PyDict_SetItemString(retval, "object-name", 
    274                   Py_BuildValue("s", p_obj->psz_object_name)); 
    275     PyDict_SetItemString(retval, "thread", 
    276                   PyBool_FromLong(p_obj->b_thread)); 
    277     PyDict_SetItemString(retval, "thread-id", 
    278                   PyLong_FromLongLong(p_obj->thread_id)); 
    279     PyDict_SetItemString(retval, "refcount", 
    280                   PyInt_FromLong(p_obj->i_refcount)); 
    281  
    282     return retval; 
    283 
    284  
    285 static PyObject * vlcObject_find_id(PyObject *self, PyObject *args) 
    286 
    287     vlcObject *retval; 
     282    p_retval = PyDict_New(); 
     283 
     284    PyDict_SetItemString( p_retval, "object-id", 
     285                          Py_BuildValue( "l", p_obj->i_object_id ) ); 
     286    PyDict_SetItemString( p_retval, "object-type", 
     287                          Py_BuildValue( "s", p_obj->psz_object_type ) ); 
     288    PyDict_SetItemString( p_retval, "object-name", 
     289                          Py_BuildValue( "s", p_obj->psz_object_name ) ); 
     290    PyDict_SetItemString( p_retval, "thread", 
     291                          PyBool_FromLong( p_obj->b_thread ) ); 
     292    PyDict_SetItemString( p_retval, "thread-id", 
     293                          PyLong_FromLongLong( p_obj->thread_id ) ); 
     294    PyDict_SetItemString( p_retval, "refcount", 
     295                          PyInt_FromLong( p_obj->i_refcount ) ); 
     296 
     297    return p_retval; 
     298
     299 
     300static PyObject * 
     301vlcObject_find_id( PyObject *self, PyObject *args ) 
     302
     303    vlcObject *p_retval; 
    288304    vlc_object_t* p_object; 
    289305    int i_id; 
    290306 
    291     if ( !PyArg_ParseTuple(args, "i", &i_id) ) 
    292         return NULL; 
    293  
    294     p_object = (vlc_object_t*)vlc_current_object(i_id); 
    295  
    296     if (! p_object
    297     { 
    298         Py_INCREF(Py_None); 
     307    if( !PyArg_ParseTuple( args, "i", &i_id ) ) 
     308        return NULL; 
     309 
     310    p_object = ( vlc_object_t* )vlc_current_object( i_id ); 
     311 
     312    if( !p_object
     313    { 
     314        Py_INCREF( Py_None ); 
    299315        return Py_None; 
    300316    } 
    301317 
    302     retval = PyObject_NEW(vlcObject, &vlcObject_Type); 
    303  
    304     retval->p_object = p_object; 
    305  
    306     return (PyObject *)retval; 
     318    p_retval = PyObject_NEW( vlcObject, &vlcObject_Type ); 
     319 
     320    p_retval->p_object = p_object; 
     321 
     322    return ( PyObject * )p_retval; 
    307323} 
    308324 
    309325/* Do a var_Get call on the object. Parameter: the variable name. */ 
    310 /* FIXME: We should make them attributes */ 
    311 static PyObject * vlcObject_var_get(PyObject *self, PyObject *args
    312 { 
    313     PyObject *retval; 
     326static PyObject * 
     327vlcObject_var_get( PyObject *self, PyObject *args
     328{ 
     329    PyObject *p_retval; 
    314330    vlc_value_t value; 
    315331    char *psz_name; 
    316332    int i_type; 
    317333 
    318     if ( !PyArg_ParseTuple(args, "s", &psz_name) ) 
     334    if( !PyArg_ParseTuple( args, "s", &psz_name ) ) 
    319335        return NULL; 
    320336 
    321337    if( var_Get( VLCSELF->p_object, psz_name, &value ) != VLC_SUCCESS ) 
    322338    { 
    323             PyErr_SetString(PyExc_StandardError, "Error: no variable name was given.\n"); 
    324             return NULL; 
    325     } 
    326  
    327     i_type = var_Type (VLCSELF->p_object, psz_name); 
    328  
    329     switch (i_type) 
    330     { 
    331             case VLC_VAR_VOID   : 
    332                     retval = PyString_FromString("A void variable"); 
    333                     break; 
    334             case VLC_VAR_BOOL      : 
    335                     retval = PyBool_FromLong(value.b_bool); 
    336                     break; 
    337             case VLC_VAR_INTEGER   : 
    338                     retval = PyInt_FromLong((long)value.i_int); 
    339                     break; 
    340             case VLC_VAR_HOTKEY   : 
    341                     retval = PyString_FromFormat("A hotkey variable (%d)", value.i_int); 
    342                     break; 
    343             case VLC_VAR_FILE      : 
    344             case VLC_VAR_STRING    : 
    345             case VLC_VAR_DIRECTORY : 
    346             case VLC_VAR_VARIABLE  : 
    347                     retval = PyString_FromString(value.psz_string); 
    348                     break; 
    349             case VLC_VAR_MODULE   : 
    350                     retval = (PyObject*)PyObject_New(vlcObject, &vlcObject_Type); 
    351                     ((vlcObject*)retval)->p_object = value.p_object; 
    352                     break; 
    353             case VLC_VAR_FLOAT     : 
    354                     retval = PyFloat_FromDouble((double)value.f_float); 
    355                     break; 
    356             case VLC_VAR_TIME      : 
    357                     retval = PyLong_FromLongLong(value.i_time); 
    358                     break; 
    359             case VLC_VAR_ADDRESS   : 
    360                     retval = PyString_FromString("A VLC address (not handled yet)"); 
    361                     break; 
    362             case VLC_VAR_LIST      : 
    363                     retval = PyString_FromString("A VLC list (not handled yet)"); 
    364                     break; 
    365             case VLC_VAR_MUTEX : 
    366                     retval = PyString_FromString("A mutex"); 
    367                     break; 
    368             default: 
    369                     retval = Py_None; 
    370     } 
    371  
    372     Py_INCREF(retval); 
    373     return retval; 
    374 
    375  
    376 static PyObject * vlcObject_var_type(PyObject *self, 
    377                 PyObject *args) 
    378 
    379         char *psz_name; 
    380         PyObject *retval; 
    381         int i_type; 
    382  
    383         if ( !PyArg_ParseTuple(args, "s", &psz_name)) 
    384             return NULL; 
    385  
    386         i_type = var_Type(VLCSELF->p_object, psz_name); 
    387  
    388         switch (i_type) 
    389         { 
    390                 case VLC_VAR_VOID   : 
    391                         retval = PyString_FromString("Void"); 
    392                         break; 
    393                 case VLC_VAR_BOOL      : 
    394                         retval = PyString_FromString("Boolean"); 
    395                         break; 
    396                 case VLC_VAR_INTEGER   : 
    397                         retval = PyString_FromString("Integer"); 
    398                         break; 
    399                 case VLC_VAR_HOTKEY   : 
    400                         retval = PyString_FromString("Hotkey"); 
    401                         break; 
    402                 case VLC_VAR_FILE      : 
    403                         retval = PyString_FromString("File"); 
    404                         break; 
    405                 case VLC_VAR_STRING    : 
    406                         retval = PyString_FromString("String"); 
    407                         break; 
    408                 case VLC_VAR_DIRECTORY : 
    409                         retval = PyString_FromString("Directory"); 
    410                         break; 
    411                 case VLC_VAR_VARIABLE  : 
    412                         retval = PyString_FromString("Variable"); 
    413                         break; 
    414                 case VLC_VAR_MODULE   : 
    415                         retval = PyString_FromString("Module"); 
    416                         break; 
    417                 case VLC_VAR_FLOAT     : 
    418                         retval = PyString_FromString("Float"); 
    419                         break; 
    420                 case VLC_VAR_TIME      : 
    421                         retval = PyString_FromString("Time"); 
    422                         break; 
    423                 case VLC_VAR_ADDRESS   : 
    424                         retval = PyString_FromString("Address"); 
    425                         break; 
    426                 case VLC_VAR_LIST      : 
    427                         retval = PyString_FromString("List"); 
    428                         break; 
    429                 case VLC_VAR_MUTEX : 
    430                         retval = PyString_FromString("Mutex"); 
    431                         break; 
    432                 default: 
    433                         retval = PyString_FromString("Unknown"); 
    434         } 
    435         return retval; 
     339        PyErr_SetString( PyExc_StandardError, 
     340                         "Error: variable does not exist.\n" ); 
     341        return NULL; 
     342    } 
     343 
     344    i_type = var_Type ( VLCSELF->p_object, psz_name ); 
     345 
     346    switch ( i_type ) 
     347    { 
     348    case VLC_VAR_VOID      : 
     349        p_retval = PyString_FromString( "A void variable" ); 
     350        break; 
     351    case VLC_VAR_BOOL      : 
     352        p_retval = PyBool_FromLong( value.b_bool ); 
     353        break; 
     354    case VLC_VAR_INTEGER   : 
     355        p_retval = PyInt_FromLong( ( long )value.i_int ); 
     356        break; 
     357    case VLC_VAR_HOTKEY    : 
     358        p_retval = PyString_FromFormat( "A hotkey variable ( %d )", value.i_int ); 
     359        break; 
     360    case VLC_VAR_FILE      : 
     361    case VLC_VAR_STRING    : 
     362    case VLC_VAR_DIRECTORY : 
     363    case VLC_VAR_VARIABLE  : 
     364        p_retval = PyString_FromString( value.psz_string ); 
     365        break; 
     366    case VLC_VAR_MODULE   : 
     367        p_retval = ( PyObject* )PyObject_New( vlcObject, &vlcObject_Type ); 
     368        ( ( vlcObject* )p_retval )->p_object = value.p_object; 
     369        break; 
     370    case VLC_VAR_FLOAT     : 
     371        p_retval = PyFloat_FromDouble( ( double )value.f_float ); 
     372        break; 
     373    case VLC_VAR_TIME      : 
     374        p_retval = PyLong_FromLongLong( value.i_time ); 
     375        break; 
     376    case VLC_VAR_ADDRESS   : 
     377        p_retval = PyString_FromString( "A VLC address ( not handled yet )" ); 
     378        break; 
     379    case VLC_VAR_LIST      : 
     380        p_retval = PyString_FromString( "A VLC list ( not handled yet )" ); 
     381        break; 
     382    case VLC_VAR_MUTEX : 
     383        p_retval = PyString_FromString( "A mutex" ); 
     384        break; 
     385    default: 
     386        p_retval = Py_None; 
     387    } 
     388 
     389    Py_INCREF( p_retval ); 
     390    return p_retval; 
     391
     392 
     393static PyObject * 
     394vlcObject_var_type( PyObject *self, PyObject *args ) 
     395
     396    char *psz_name; 
     397    PyObject *p_retval; 
     398    int i_type; 
     399 
     400    if( !PyArg_ParseTuple( args, "s", &psz_name ) ) 
     401        return NULL; 
     402 
     403    i_type = var_Type( VLCSELF->p_object, psz_name ); 
     404 
     405    switch ( i_type ) 
     406    { 
     407    case VLC_VAR_VOID   : 
     408        p_retval = PyString_FromString( "Void" ); 
     409        break; 
     410    case VLC_VAR_BOOL      : 
     411        p_retval = PyString_FromString( "Boolean" ); 
     412        break; 
     413    case VLC_VAR_INTEGER   : 
     414        p_retval = PyString_FromString( "Integer" ); 
     415        break; 
     416    case VLC_VAR_HOTKEY   : 
     417        p_retval = PyString_FromString( "Hotkey" ); 
     418        break; 
     419    case VLC_VAR_FILE      : 
     420        p_retval = PyString_FromString( "File" ); 
     421        break; 
     422    case VLC_VAR_STRING    : 
     423        p_retval = PyString_FromString( "String" ); 
     424        break; 
     425    case VLC_VAR_DIRECTORY : 
     426        p_retval = PyString_FromString( "Directory" ); 
     427        break; 
     428    case VLC_VAR_VARIABLE  : 
     429        p_retval = PyString_FromString( "Variable" ); 
     430        break; 
     431    case VLC_VAR_MODULE   : 
     432        p_retval = PyString_FromString( "Module" ); 
     433        break; 
     434    case VLC_VAR_FLOAT     : 
     435        p_retval = PyString_FromString( "Float" ); 
     436        break; 
     437    case VLC_VAR_TIME      : 
     438        p_retval = PyString_FromString( "Time" ); 
     439        break; 
     440    case VLC_VAR_ADDRESS   : 
     441        p_retval = PyString_FromString( "Address" ); 
     442        break; 
     443    case VLC_VAR_LIST      : 
     444        p_retval = PyString_FromString( "List" ); 
     445        break; 
     446    case VLC_VAR_MUTEX : 
     447        p_retval = PyString_FromString( "Mutex" ); 
     448        break; 
     449    default: 
     450        p_retval = PyString_FromString( "Unknown" ); 
     451    } 
     452    return p_retval; 
    436453} 
    437454 
    438455/* Do a var_Set call on the object. Parameter: the variable name. */ 
    439 /* FIXME: We should make them attributes */ 
    440 static PyObject * vlcObject_var_set(PyObject *self, 
    441                 PyObject *args) 
    442 
    443         vlc_value_t value; 
    444         char *psz_name; 
    445         PyObject *py_value; 
    446         int i_type; 
    447         vlc_object_t *p_obj; 
    448  
    449         if ( !PyArg_ParseTuple(args, "sO", &psz_name, &py_value) ) 
    450             return NULL; 
    451  
    452         p_obj = VLCSELF->p_object; 
    453         i_type = var_Type(p_obj, psz_name); 
    454  
    455         switch (i_type) 
    456         { 
    457                 case VLC_VAR_VOID   : 
    458                         break; 
    459                 case VLC_VAR_BOOL      : 
    460                         value.b_bool = PyInt_AsLong(py_value); 
    461                         break; 
    462                 case VLC_VAR_INTEGER   : 
    463                 case VLC_VAR_HOTKEY   : 
    464                         value.i_int = PyInt_AsLong(py_value); 
    465                         break; 
    466                 case VLC_VAR_FILE      : 
    467                 case VLC_VAR_STRING    : 
    468                 case VLC_VAR_DIRECTORY : 
    469                 case VLC_VAR_VARIABLE  : 
    470                         value.psz_string = strdup(PyString_AsString(py_value)); 
    471                         break; 
    472                 case VLC_VAR_MODULE   : 
    473                         /* FIXME: we should check the PyObject type and get its p_object */ 
    474                         value.p_object = ((vlcObject*)p_obj)->p_object; 
    475                         break; 
    476                 case VLC_VAR_FLOAT     : 
    477                         value.f_float = PyFloat_AsDouble(py_value); 
    478                         break; 
    479                 case VLC_VAR_TIME      : 
    480                         value.i_time = PyLong_AsLongLong(py_value); 
    481                         break; 
    482                 case VLC_VAR_ADDRESS   : 
    483                         value.p_address = (char*)PyLong_AsVoidPtr(py_value); 
    484                         break; 
    485                 case VLC_VAR_LIST      : 
    486                         /* FIXME */ 
    487                         value.p_list = NULL; 
    488                         break; 
    489                 case VLC_VAR_MUTEX : 
    490                         break; 
    491         } 
    492  
    493         var_Set(p_obj, psz_name, value); 
    494  
    495         Py_INCREF(Py_None); 
    496         return Py_None; 
    497 
    498  
    499 static PyObject * vlcObject_var_list(PyObject *self, PyObject *args) 
    500 
    501         PyObject *retval; 
    502         int i_size; 
    503         int i_index; 
    504  
    505         i_size = VLCSELF->p_object->i_vars; 
    506         retval = PyTuple_New(i_size); 
    507  
    508         for (i_index = 0 ; i_index < i_size ; i_index++) 
    509         { 
    510                 PyTuple_SetItem(retval, i_index,  
    511                                 Py_BuildValue("s", VLCSELF->p_object->p_vars[i_index].psz_name)); 
    512         } 
    513  
    514         /* Py_INCREF(retval); */ 
    515         return retval; 
     456static PyObject * 
     457vlcObject_var_set( PyObject *self, PyObject *args ) 
     458
     459    vlc_value_t value; 
     460    char *psz_name; 
     461    PyObject *py_value; 
     462    int i_type; 
     463    vlc_object_t *p_obj; 
     464 
     465    if( !PyArg_ParseTuple( args, "sO", &psz_name, &py_value ) ) 
     466        return NULL; 
     467 
     468    p_obj = VLCSELF->p_object; 
     469    i_type = var_Type( p_obj, psz_name ); 
     470 
     471    switch ( i_type ) 
     472    { 
     473    case VLC_VAR_VOID   : 
     474        break; 
     475    case VLC_VAR_BOOL      : 
     476        value.b_bool = PyInt_AsLong( py_value ); 
     477        break; 
     478    case VLC_VAR_INTEGER   : 
     479    case VLC_VAR_HOTKEY   : 
     480        value.i_int = PyInt_AsLong( py_value ); 
     481        break; 
     482    case VLC_VAR_FILE      : 
     483    case VLC_VAR_STRING    : 
     484    case VLC_VAR_DIRECTORY : 
     485    case VLC_VAR_VARIABLE  : 
     486        value.psz_string = strdup( PyString_AsString( py_value ) ); 
     487        break; 
     488    case VLC_VAR_MODULE   : 
     489        /* FIXME: we should check the PyObject type and get its p_object */ 
     490        value.p_object = ( ( vlcObject* )p_obj )->p_object; 
     491        break; 
     492    case VLC_VAR_FLOAT     : 
     493        value.f_float = PyFloat_AsDouble( py_value ); 
     494        break; 
     495    case VLC_VAR_TIME      : 
     496        value.i_time = PyLong_AsLongLong( py_value ); 
     497        break; 
     498    case VLC_VAR_ADDRESS   : 
     499        value.p_address = ( char* )PyLong_AsVoidPtr( py_value ); 
     500        break; 
     501    case VLC_VAR_LIST      : 
     502        /* FIXME */ 
     503        value.p_list = NULL; 
     504        break; 
     505    case VLC_VAR_MUTEX : 
     506        break; 
     507    } 
     508 
     509    var_Set( p_obj, psz_name, value ); 
     510 
     511    Py_INCREF( Py_None ); 
     512    return Py_None; 
     513
     514 
     515static PyObject * 
     516vlcObject_var_list( PyObject *self, PyObject *args ) 
     517
     518    PyObject *p_retval; 
     519    int i_size; 
     520    int i_index; 
     521 
     522    i_size = VLCSELF->p_object->i_vars; 
     523    p_retval = PyTuple_New( i_size ); 
     524 
     525    for ( i_index = 0 ; i_index < i_size ; i_index++ ) 
     526    { 
     527        PyTuple_SetItem( p_retval, i_index, 
     528                         Py_BuildValue( "s", VLCSELF->p_object->p_vars[i_index].psz_name ) ); 
     529    } 
     530 
     531    return p_retval; 
    516532} 
    517533 
    518534/* Do a config_Get call on the object. Parameter: the variable name. */ 
    519 static PyObject * vlcObject_config_get(PyObject *self, 
    520                 PyObject *args) 
    521 
    522         PyObject *retval; 
    523         vlc_value_t value; 
    524         char *psz_name; 
    525         module_config_t *p_config; 
    526  
    527         if ( !PyArg_ParseTuple(args, "s", &psz_name) ) 
    528             return NULL; 
    529  
    530         p_config = config_FindConfig( VLCSELF->p_object, psz_name ); 
    531  
    532         if( !p_config ) 
    533         { 
    534                 PyErr_SetString(PyExc_StandardError, "Error: config variable does not exist.\n"); 
    535                 Py_INCREF(Py_None); 
    536                 return Py_None; 
    537         } 
    538  
    539         switch (p_config->i_type) 
    540         { 
    541                 case CONFIG_ITEM_BOOL      : 
    542                         retval = PyBool_FromLong(p_config->i_value); 
    543                         break; 
    544                 case CONFIG_ITEM_INTEGER   : 
    545                         retval = PyInt_FromLong((long)p_config->i_value); 
    546                         break; 
    547                 case CONFIG_ITEM_KEY   : 
    548                         retval = PyString_FromFormat("A hotkey variable (%d)", p_config->i_value); 
    549                         break; 
    550                 case CONFIG_ITEM_FILE      : 
    551                 case CONFIG_ITEM_STRING    : 
    552                 case CONFIG_ITEM_DIRECTORY : 
    553                 case CONFIG_ITEM_MODULE    : 
    554                         vlc_mutex_lock( p_config->p_lock ); 
    555                         if( p_config->psz_value ) 
    556                                 retval = PyString_FromString( p_config->psz_value ); 
    557                         else 
    558                                 retval = PyString_FromString( "" ); 
    559                         vlc_mutex_unlock( p_config->p_lock ); 
    560                         break; 
    561                         retval = (PyObject*)PyObject_New(vlcObject, &vlcObject_Type); 
    562                         ((vlcObject*)retval)->p_object = value.p_object; 
    563                         break; 
    564                 case CONFIG_ITEM_FLOAT     : 
    565                         retval = PyFloat_FromDouble((double)p_config->f_value); 
    566                         break; 
    567                 default: 
    568                         retval = Py_None; 
    569                         Py_INCREF(retval); 
    570         } 
    571  
    572         return retval; 
    573 
    574  
    575 /* Do a var_Set call on the object. Parameter: the variable name. */ 
    576 /* FIXME: We should make them attributes */ 
    577 static PyObject * vlcObject_config_set(PyObject *self, 
    578                 PyObject *args) 
    579 
    580         char *psz_name; 
    581         PyObject *py_value; 
    582         vlc_object_t *p_obj; 
    583         module_config_t *p_config; 
    584  
    585  
    586         if ( !PyArg_ParseTuple(args, "sO", &psz_name, &py_value) ) 
    587             return NULL; 
    588  
    589         p_obj = VLCSELF->p_object; 
    590         p_config = config_FindConfig( p_obj, psz_name ); 
    591         /* sanity checks */ 
    592         if( !p_config ) 
    593         { 
    594             PyErr_SetString(PyExc_StandardError, 
    595                             "Error: option does not exist.\n"); 
    596             Py_INCREF(Py_None); 
    597             return Py_None; 
    598         } 
    599  
    600         switch (p_config->i_type) 
    601         { 
    602                 case CONFIG_ITEM_BOOL      : 
    603                 case CONFIG_ITEM_INTEGER   : 
    604                 case CONFIG_ITEM_KEY       : 
    605                         config_PutInt(p_obj, psz_name, PyInt_AsLong(py_value)); 
    606                         break; 
    607                 case CONFIG_ITEM_FILE      : 
    608                 case CONFIG_ITEM_STRING    : 
    609                 case CONFIG_ITEM_DIRECTORY : 
    610                 case CONFIG_ITEM_MODULE   : 
    611                         config_PutPsz(p_obj, psz_name, PyString_AsString(py_value)); 
    612                         break; 
    613                 case CONFIG_ITEM_FLOAT     : 
    614                         config_PutFloat(p_obj, psz_name, PyFloat_AsDouble(py_value)); 
    615                         break; 
    616         } 
    617         Py_INCREF(Py_None); 
    618         return Py_None; 
    619 
    620  
    621 static PyObject * vlcObject_children(PyObject *self, PyObject *args) 
    622 
    623         PyObject *retval; 
    624         int i_size; 
    625         int i_index; 
    626  
    627         i_size = VLCSELF->p_object->i_children; 
    628         retval = PyTuple_New(i_size); 
    629  
    630         for (i_index = 0 ; i_index < i_size ; i_index++) 
    631         { 
    632             PyTuple_SetItem(retval, i_index, 
    633                  Py_BuildValue("i", 
    634                       VLCSELF->p_object->pp_children[i_index]->i_object_id)); 
    635         } 
    636  
    637         /* Py_INCREF(retval); */ 
    638         return retval; 
     535static PyObject * 
     536vlcObject_config_get( PyObject *self, PyObject *args ) 
     537
     538    PyObject *p_retval; 
     539    vlc_value_t value; 
     540    char *psz_name; 
     541    module_config_t *p_config; 
     542 
     543    if( !PyArg_ParseTuple( args, "s", &psz_name ) ) 
     544        return NULL; 
     545 
     546    p_config = config_FindConfig( VLCSELF->p_object, psz_name ); 
     547 
     548    if( !p_config ) 
     549    { 
     550        PyErr_SetString( PyExc_StandardError, 
     551                         "Error: config variable does not exist.\n" ); 
     552        return NULL; 
     553    } 
     554 
     555    switch ( p_config->i_type ) 
     556    { 
     557    case CONFIG_ITEM_BOOL      : 
     558        p_retval = PyBool_FromLong( p_config->i_value ); 
     559        break; 
     560    case CONFIG_ITEM_INTEGER   : 
     561        p_retval = PyInt_FromLong( ( long )p_config->i_value ); 
     562        break; 
     563    case CONFIG_ITEM_KEY   : 
     564        p_retval = PyString_FromFormat( "A hotkey variable ( %d )", p_config->i_value ); 
     565        break; 
     566    case CONFIG_ITEM_FILE      : 
     567    case CONFIG_ITEM_STRING    : 
     568    case CONFIG_ITEM_DIRECTORY : 
     569    case CONFIG_ITEM_MODULE    : 
     570        vlc_mutex_lock( p_config->p_lock ); 
     571        if( p_config->psz_value ) 
     572            p_retval = PyString_FromString( p_config->psz_value ); 
     573        else 
     574            p_retval = PyString_FromString( "" ); 
     575        vlc_mutex_unlock( p_config->p_lock ); 
     576        break; 
     577        p_retval = ( PyObject* )PyObject_New( vlcObject, &vlcObject_Type ); 
     578        ( ( vlcObject* )p_retval )->p_object = value.p_object; 
     579        break; 
     580    case CONFIG_ITEM_FLOAT     : 
     581        p_retval = PyFloat_FromDouble( ( double )p_config->f_value ); 
     582        break; 
     583    default: 
     584        p_retval = Py_None; 
     585        Py_INCREF( p_retval ); 
     586    } 
     587 
     588    return p_retval; 
     589
     590 
     591/* Do a config_put* call on the object. Parameter: the variable name. */ 
     592static PyObject * 
     593vlcObject_config_set( PyObject *self, PyObject *args ) 
     594
     595    char *psz_name; 
     596