Changeset 18959e10b702b913c0e9461518d34c4bb160e77b

Show
Ignore:
Timestamp:
05/20/07 17:08:53 (1 year ago)
Author:
Olivier Aubert <olivier.aubert@liris.cnrs.fr>
git-committer:
Olivier Aubert <olivier.aubert@liris.cnrs.fr> 1179673733 +0000
git-parent:

[f376fdb9df8064ab9904c4a50f9ee44210804423]

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

python bindings: allow to pass values in the vlc.Position constructor:

p = vlc.Position(value=16, origin=vlc.RelativePosition?)

Defaults to value=0, origin=AbsolutePosition?, key=MediaTime?

Files:

Legend:

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

    r7b89d13 r18959e1  
    4747{ 
    4848    PyObject* p_module; 
    49  
    50     PyPosition_Type.tp_new = PyType_GenericNew; 
    51     PyPosition_Type.tp_alloc = PyType_GenericAlloc; 
    5249 
    5350    vlcInput_Type.tp_new = PyType_GenericNew; 
  • bindings/python/vlc_position.c

    rc9958ed r18959e1  
    2727 ***********************************************************************/ 
    2828 
    29 static int 
    30 PyPosition_init( PyPosition *self, PyObject *args, PyObject *kwds ) 
    31 
    32     self->origin = mediacontrol_AbsolutePosition; 
    33     self->key    = mediacontrol_MediaTime; 
    34     self->value  = 0; 
    35     return 0; 
     29static PyObject * 
     30PyPosition_new( PyTypeObject *type, PyObject *args, PyObject *kwds ) 
     31
     32    PyPosition *self; 
     33    static char *kwlist[] = { "value", "origin", "key", NULL}; 
     34     
     35    self = PyObject_New( PyPosition, &PyPosition_Type ); 
     36 
     37    self->value=0; 
     38    self->origin=mediacontrol_AbsolutePosition; 
     39    self->key=mediacontrol_MediaTime; 
     40 
     41    /* We do not care about the return value, since it will leave the fields 
     42       with their default value. */ 
     43    if(! PyArg_ParseTupleAndKeywords( args, kwds, "|lii", kwlist, 
     44                                      &(self->value), 
     45                                      &(self->origin), 
     46                                      &(self->key) ) ) 
     47    { 
     48        return NULL;         
     49    } 
     50        
     51    Py_INCREF( self ); 
     52    return ( PyObject * )self;     
    3653} 
    3754 
     
    168185    0,                         /*tp_as_buffer*/ 
    169186    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ 
    170     "Represent a Position with origin, key and value",  /* tp_doc */ 
     187    "Represent a Position with value, origin and key",  /* tp_doc */ 
    171188    0,                        /* tp_traverse */ 
    172189    0,                        /* tp_clear */ 
     
    183200    0,                         /* tp_descr_set */ 
    184201    0,                         /* tp_dictoffset */ 
    185     ( initproc )PyPosition_init, /* tp_init */ 
     202    0,                        /* tp_init */ 
    186203    0,                         /* tp_alloc */ 
    187     0,                         /* tp_new */ 
     204    PyPosition_new,            /* tp_new */ 
    188205};