Commit 18959e10 authored by Olivier Aubert's avatar Olivier Aubert

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
parent f376fdb9
...@@ -47,9 +47,6 @@ initvlc( void ) ...@@ -47,9 +47,6 @@ initvlc( void )
{ {
PyObject* p_module; PyObject* p_module;
PyPosition_Type.tp_new = PyType_GenericNew;
PyPosition_Type.tp_alloc = PyType_GenericAlloc;
vlcInput_Type.tp_new = PyType_GenericNew; vlcInput_Type.tp_new = PyType_GenericNew;
vlcInput_Type.tp_alloc = PyType_GenericAlloc; vlcInput_Type.tp_alloc = PyType_GenericAlloc;
......
...@@ -26,13 +26,30 @@ ...@@ -26,13 +26,30 @@
* Position * Position
***********************************************************************/ ***********************************************************************/
static int static PyObject *
PyPosition_init( PyPosition *self, PyObject *args, PyObject *kwds ) PyPosition_new( PyTypeObject *type, PyObject *args, PyObject *kwds )
{ {
self->origin = mediacontrol_AbsolutePosition; PyPosition *self;
self->key = mediacontrol_MediaTime; static char *kwlist[] = { "value", "origin", "key", NULL};
self->value = 0;
return 0; self = PyObject_New( PyPosition, &PyPosition_Type );
self->value=0;
self->origin=mediacontrol_AbsolutePosition;
self->key=mediacontrol_MediaTime;
/* We do not care about the return value, since it will leave the fields
with their default value. */
if(! PyArg_ParseTupleAndKeywords( args, kwds, "|lii", kwlist,
&(self->value),
&(self->origin),
&(self->key) ) )
{
return NULL;
}
Py_INCREF( self );
return ( PyObject * )self;
} }
mediacontrol_PositionKey mediacontrol_PositionKey
...@@ -167,7 +184,7 @@ static PyTypeObject PyPosition_Type = ...@@ -167,7 +184,7 @@ static PyTypeObject PyPosition_Type =
0, /*tp_setattro*/ 0, /*tp_setattro*/
0, /*tp_as_buffer*/ 0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
"Represent a Position with origin, key and value", /* tp_doc */ "Represent a Position with value, origin and key", /* tp_doc */
0, /* tp_traverse */ 0, /* tp_traverse */
0, /* tp_clear */ 0, /* tp_clear */
0, /* tp_richcompare */ 0, /* tp_richcompare */
...@@ -182,7 +199,7 @@ static PyTypeObject PyPosition_Type = ...@@ -182,7 +199,7 @@ static PyTypeObject PyPosition_Type =
0, /* tp_descr_get */ 0, /* tp_descr_get */
0, /* tp_descr_set */ 0, /* tp_descr_set */
0, /* tp_dictoffset */ 0, /* tp_dictoffset */
( initproc )PyPosition_init, /* tp_init */ 0, /* tp_init */
0, /* tp_alloc */ 0, /* tp_alloc */
0, /* tp_new */ PyPosition_new, /* tp_new */
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment