]> granicus.if.org Git - python/commitdiff
Allow None as TimeBase value in TimeValue records (becomes NULL in C structure,
authorJack Jansen <jack.jansen@cwi.nl>
Mon, 6 Mar 2000 16:34:49 +0000 (16:34 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Mon, 6 Mar 2000 16:34:49 +0000 (16:34 +0000)
used for delta-t values by quicktime).

Mac/Modules/qt/Qtmodule.c
Mac/Modules/qt/qtsupport.py

index 36c3efa88c36ad387fc4bd564455654d3947cb13..d374b45a40d75249292d4a5c7b51fafca766c915 100644 (file)
@@ -71,9 +71,12 @@ static PyObject *
 QtTimeRecord_New(itself)
        TimeRecord *itself;
 {
-
-       return Py_BuildValue("O&lO&", PyMac_Buildwide, &itself->value, itself->scale, 
+       if (itself->base)
+               return Py_BuildValue("O&lO&", PyMac_Buildwide, &itself->value, itself->scale, 
                        TimeBaseObj_New, itself->base);
+       else
+               return  Py_BuildValue("O&lO", PyMac_Buildwide, &itself->value, itself->scale, 
+                       Py_None);
 }
 
 static int
@@ -81,10 +84,15 @@ QtTimeRecord_Convert(v, p_itself)
        PyObject *v;
        TimeRecord *p_itself;
 {
-       
-       if( !PyArg_ParseTuple(v, "O&lO&", PyMac_Getwide, &p_itself->value, &p_itself->scale,
-                       TimeBaseObj_Convert, &p_itself->base) )
+       PyObject *base = NULL;
+       if( !PyArg_ParseTuple(v, "O&l|O", PyMac_Getwide, &p_itself->value, &p_itself->scale,
+                       &base) )
                return 0;
+       if ( base == NULL || base == Py_None )
+               p_itself->base = NULL;
+       else
+               if ( !TimeBaseObj_Convert(base, &p_itself->base) )
+                       return 0;
        return 1;
 }
 
index 2e26888bfc5428740a8363ae1dd28810102e8565..f4186f7a1038fb1366465787efca4e080ac1f731 100644 (file)
@@ -53,9 +53,12 @@ static PyObject *
 QtTimeRecord_New(itself)
        TimeRecord *itself;
 {
-
-       return Py_BuildValue("O&lO&", PyMac_Buildwide, &itself->value, itself->scale, 
+       if (itself->base)
+               return Py_BuildValue("O&lO&", PyMac_Buildwide, &itself->value, itself->scale, 
                        TimeBaseObj_New, itself->base);
+       else
+               return  Py_BuildValue("O&lO", PyMac_Buildwide, &itself->value, itself->scale, 
+                       Py_None);
 }
 
 static int
@@ -63,10 +66,15 @@ QtTimeRecord_Convert(v, p_itself)
        PyObject *v;
        TimeRecord *p_itself;
 {
-       
-       if( !PyArg_ParseTuple(v, "O&lO&", PyMac_Getwide, &p_itself->value, &p_itself->scale,
-                       TimeBaseObj_Convert, &p_itself->base) )
+       PyObject *base = NULL;
+       if( !PyArg_ParseTuple(v, "O&l|O", PyMac_Getwide, &p_itself->value, &p_itself->scale,
+                       &base) )
                return 0;
+       if ( base == NULL || base == Py_None )
+               p_itself->base = NULL;
+       else
+               if ( !TimeBaseObj_Convert(base, &p_itself->base) )
+                       return 0;
        return 1;
 }