[cairo-commit] pycairo/cairo cairomodule.c, 1.79, 1.80 pycairo-context.c, 1.90, 1.91

Steve Chaplin commit at pdx.freedesktop.org
Sat Jun 20 23:14:15 PDT 2009


Committed by: stevech1097

Update of /cvs/cairo/pycairo/cairo
In directory kemper:/tmp/cvs-serv19067/cairo

Modified Files:
	cairomodule.c pycairo-context.c 
Log Message:
'SC'

Index: cairomodule.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/cairomodule.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -d -r1.79 -r1.80
--- cairomodule.c	24 Mar 2009 01:21:10 -0000	1.79
+++ cairomodule.c	21 Jun 2009 06:14:12 -0000	1.80
@@ -442,7 +442,6 @@
     CONSTANT(FORMAT_RGB24);
     CONSTANT(FORMAT_A8);
     CONSTANT(FORMAT_A1);
-    CONSTANT(FORMAT_RGB16_565);
 
     CONSTANT(HINT_METRICS_DEFAULT);
     CONSTANT(HINT_METRICS_OFF);

Index: pycairo-context.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-context.c,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -d -r1.90 -r1.91
--- pycairo-context.c	7 Jan 2009 03:03:53 -0000	1.90
+++ pycairo-context.c	21 Jun 2009 06:14:12 -0000	1.91
@@ -38,7 +38,8 @@
 
 
 /* Take a PyBaseString (str or unicode) object and return a pointer to the
- * UTF-8 encoded string.
+ * UTF-8 encoded C string.
+ * Note: in Python 3.x a string is a unicode object
  */
 char *
 __PyBaseString_AsUTF8 (PyObject *o)
@@ -51,7 +52,10 @@
 	PyObject *u = PyUnicode_AsUTF8String(o);
 	if (u != NULL) {
 	    char *utf8 = PyString_AsString(u);
-	    Py_DECREF(u);
+	    Py_DECREF(u); // error: deallocate object too early ?
+	                  // so copy C string, but then need to free later,
+	                  // or unroll into the calling functions - is
+                          // useful when move to Python 3.x
 	    return utf8;
 	}
     }
@@ -198,9 +202,6 @@
     Py_RETURN_NONE;
 }
 
-/* a possible candidate for an iterator (like cairo_copy_path), but for the
- * typical rectangle_list a simple Python tuple in fine?
- */
 static PyObject *
 pycairo_copy_clip_rectangle_list (PycairoContext *o)
 {
@@ -898,6 +899,7 @@
 			  &PyBaseString_Type, &obj, &slant, &weight))
 	return NULL;
 
+    /* accept str and unicode family, auto convert to utf8 as required */
     family = __PyBaseString_AsUTF8 (obj);
     if (family == NULL)
 	return NULL;
@@ -971,20 +973,6 @@
 }
 
 static PyObject *
-pycairo_set_font_matrix (PycairoContext *o, PyObject *args)
-{
-    PycairoMatrix *matrix;
-
-    if (!PyArg_ParseTuple (args, "O!:Context.set_font_matrix",
-			   &PycairoMatrix_Type, &matrix))
-	return NULL;
-
-    cairo_set_font_matrix (o->ctx, &matrix->matrix);
-    RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
-    Py_RETURN_NONE;
-}
-
-static PyObject *
 pycairo_set_font_face (PycairoContext *o, PyObject *obj)
 {
     if (PyObject_TypeCheck(obj, &PycairoFontFace_Type))
@@ -1002,6 +990,20 @@
 }
 
 static PyObject *
+pycairo_set_font_matrix (PycairoContext *o, PyObject *args)
+{
+    PycairoMatrix *matrix;
+
+    if (!PyArg_ParseTuple (args, "O!:Context.set_font_matrix",
+			   &PycairoMatrix_Type, &matrix))
+	return NULL;
+
+    cairo_set_font_matrix (o->ctx, &matrix->matrix);
+    RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
+    Py_RETURN_NONE;
+}
+
+static PyObject *
 pycairo_set_font_options (PycairoContext *o, PyObject *args)
 {
     PycairoFontOptions *options;
@@ -1224,6 +1226,7 @@
 static PyObject *
 pycairo_show_text (PycairoContext *o, PyObject *obj)
 {
+    /* accept str and unicode text, auto convert to utf8 as required */
     const char *utf8 = __PyBaseString_AsUTF8 (obj);
     if (utf8==NULL) {
 	PyErr_SetString(PyExc_TypeError,
@@ -1271,6 +1274,7 @@
 static PyObject *
 pycairo_text_extents (PycairoContext *o, PyObject *obj)
 {
+    /* accept str and unicode text, auto convert to utf8 as required */
     cairo_text_extents_t extents;
     const char *utf8 = __PyBaseString_AsUTF8 (obj);
     if (utf8==NULL) {
@@ -1290,6 +1294,7 @@
 static PyObject *
 pycairo_text_path (PycairoContext *o, PyObject *obj)
 {
+    /* accept str and unicode text, auto convert to utf8 as required */
     const char *utf8 = __PyBaseString_AsUTF8 (obj);
     if (utf8==NULL) {
 	PyErr_SetString(PyExc_TypeError,
@@ -1304,28 +1309,28 @@
 }
 
 static PyObject *
-pycairo_translate (PycairoContext *o, PyObject *args)
+pycairo_transform (PycairoContext *o, PyObject *args)
 {
-    double tx, ty;
+    PycairoMatrix *matrix;
 
-    if (!PyArg_ParseTuple (args, "dd:Context.translate", &tx, &ty))
+    if (!PyArg_ParseTuple (args, "O!:Context.transform",
+			   &PycairoMatrix_Type, &matrix))
 	return NULL;
 
-    cairo_translate (o->ctx, tx, ty);
+    cairo_transform (o->ctx, &matrix->matrix);
     RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
     Py_RETURN_NONE;
 }
 
 static PyObject *
-pycairo_transform (PycairoContext *o, PyObject *args)
+pycairo_translate (PycairoContext *o, PyObject *args)
 {
-    PycairoMatrix *matrix;
+    double tx, ty;
 
-    if (!PyArg_ParseTuple (args, "O!:Context.transform",
-			   &PycairoMatrix_Type, &matrix))
+    if (!PyArg_ParseTuple (args, "dd:Context.translate", &tx, &ty))
 	return NULL;
 
-    cairo_transform (o->ctx, &matrix->matrix);
+    cairo_translate (o->ctx, tx, ty);
     RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
     Py_RETURN_NONE;
 }



More information about the cairo-commit mailing list