[cairo-commit] pycairo/cairo pycairo-matrix.c, 1.10, 1.11 pycairo-context.c, 1.36, 1.37

Steve Chaplin commit at pdx.freedesktop.org
Mon Apr 18 02:52:44 PDT 2005


Committed by: stevech1097

Update of /cvs/cairo/pycairo/cairo
In directory gabe:/tmp/cvs-serv23121/cairo

Modified Files:
	pycairo-matrix.c pycairo-context.c 
Log Message:
SC 2005/04/18

Index: pycairo-matrix.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-matrix.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- pycairo-matrix.c	13 Apr 2005 10:20:04 -0000	1.10
+++ pycairo-matrix.c	18 Apr 2005 09:52:42 -0000	1.11
@@ -82,6 +82,52 @@
 }
 
 static PyObject *
+matrix_get_xx(PyCairoMatrix *m)
+{
+    return Py_BuildValue("d", m->matrix.xx);
+}
+
+static PyObject *
+matrix_get_yx(PyCairoMatrix *m)
+{
+    return Py_BuildValue("d", m->matrix.yx);
+}
+
+static PyObject *
+matrix_get_xy(PyCairoMatrix *m)
+{
+    return Py_BuildValue("d", m->matrix.xy);
+}
+
+static PyObject *
+matrix_get_yy(PyCairoMatrix *m)
+{
+    return Py_BuildValue("d", m->matrix.yy);
+}
+
+static PyObject *
+matrix_get_x0(PyCairoMatrix *m)
+{
+    return Py_BuildValue("d", m->matrix.x0);
+}
+
+static PyObject *
+matrix_get_y0(PyCairoMatrix *m)
+{
+    return Py_BuildValue("d", m->matrix.y0);
+}
+
+/* return cairo_matrix_t data as a 6-tuple */
+static PyObject *
+matrix_get_value(PyCairoMatrix *m)
+{
+    return Py_BuildValue("(dddddd)",
+			 m->matrix.xx, m->matrix.yx, 
+			 m->matrix.xy, m->matrix.yy, 
+			 m->matrix.x0, m->matrix.y0);
+}
+
+static PyObject *
 matrix_invert(PyCairoMatrix *m)
 {
     if (pycairo_check_status(cairo_matrix_invert(&m->matrix))) {
@@ -234,6 +280,16 @@
     { NULL, NULL, 0 }
 };
 
+static PyGetSetDef matrix_getsets[] = {
+    { "xx",   (getter)matrix_get_xx,     (setter)0 },
+    { "yx",   (getter)matrix_get_yx,     (setter)0 },
+    { "xy",   (getter)matrix_get_xy,     (setter)0 },
+    { "yy",   (getter)matrix_get_yy,     (setter)0 },
+    { "x0",   (getter)matrix_get_x0,     (setter)0 },
+    { "y0",   (getter)matrix_get_y0,     (setter)0 },
+    { "value",(getter)matrix_get_value,  (setter)0 },
+    { NULL, (getter)0, (setter)0 }
+};
 
 PyTypeObject PyCairoMatrix_Type = {
     PyObject_HEAD_INIT(&PyType_Type)
@@ -256,7 +312,7 @@
     0,                                  /* tp_getattro */
     0,                                  /* tp_setattro */
     0,                                  /* tp_as_buffer */
-    Py_TPFLAGS_DEFAULT,                 /* tp_flags */
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
     NULL,                               /* tp_doc */
     0,                                  /* tp_traverse */
     0,                                  /* tp_clear */
@@ -266,7 +322,7 @@
     0,                                  /* tp_iternext */
     matrix_methods,                     /* tp_methods */
     0,                                  /* tp_members */
-    0,                                  /* tp_getset */
+    matrix_getsets,                     /* tp_getset */
     &PyBaseObject_Type,                 /* tp_base */
     0,                                  /* tp_dict */
     0,                                  /* tp_descr_get */

Index: pycairo-context.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-context.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- pycairo-context.c	15 Apr 2005 03:25:37 -0000	1.36
+++ pycairo-context.c	18 Apr 2005 09:52:42 -0000	1.37
@@ -107,85 +107,342 @@
 }
 
 static PyObject *
-pycairo_save(PyCairoContext *c)
+pycairo_device_to_user(PyCairoContext *c, PyObject *args)
 {
-    cairo_save(c->ctx);
+    double x, y;
+
+    if (!PyArg_ParseTuple(args, "dd:Context.device_to_user", &x, &y))
+	return NULL;
+
+    cairo_device_to_user(c->ctx, &x, &y);
     if (pycairo_check_status(cairo_status(c->ctx)))
 	return NULL;
-    Py_RETURN_NONE;
+    return Py_BuildValue("(dd)", x, y);
 }
 
 static PyObject *
-pycairo_restore(PyCairoContext *c)
+pycairo_device_to_user_distance(PyCairoContext *c, PyObject *args)
 {
-    cairo_restore(c->ctx);
+    double dx, dy;
+
+    if (!PyArg_ParseTuple(args, "dd:Context.device_to_user_distance", 
+			  &dx, &dy))
+	return NULL;
+
+    cairo_device_to_user_distance(c->ctx, &dx, &dy);
     if (pycairo_check_status(cairo_status(c->ctx)))
 	return NULL;
+    return Py_BuildValue("(dd)", dx, dy);
+}
+
+static PyObject *
+pycairo_fill_extents(PyCairoContext *c)
+{
+    double x1, y1, x2, y2;
+    cairo_fill_extents(c->ctx, &x1, &y1, &x2, &y2);
+    if (pycairo_check_status(cairo_status(c->ctx)))
+	return NULL;
+    return Py_BuildValue("(dddd)", x1, y1, x2, y2);
+}
+
+static PyObject *
+pycairo_get_current_point(PyCairoContext *c)
+{
+    double x, y;
+
+    cairo_get_current_point(c->ctx, &x, &y);
+    return Py_BuildValue("(dd)", x, y);
+}
+
+static PyObject *
+pycairo_get_fill_rule(PyCairoContext *c)
+{
+    return PyInt_FromLong(cairo_get_fill_rule(c->ctx));
+}
+
+static PyObject *
+pycairo_get_font_face(PyCairoContext *c)
+{
+    PyObject *f;
+    cairo_font_face_t *font_face;
+
+    font_face = cairo_get_font_face(c->ctx);
+    if (!font_face){
+	pycairo_check_status(cairo_status(c->ctx));
+	return NULL;
+    }
+    f = PyCairoFontFace_FromFontFace(font_face);
+    if (f)
+	cairo_font_face_reference(font_face);
+    return f;
+}
+
+static PyObject *
+pycairo_get_font_matrix(PyCairoContext *c)
+{
+    cairo_matrix_t mx1, *mx2;
+    mx1 = cairo_get_font_matrix (c->ctx, mx2); /* cairo does not use mx2! */
+    return PyCairoMatrix_FromMatrix (&mx1);
+}
+
+static PyObject *
+pycairo_get_line_cap(PyCairoContext *c)
+{
+    return PyInt_FromLong(cairo_get_line_cap(c->ctx));
+}
+
+static PyObject *
+pycairo_get_line_join(PyCairoContext *c)
+{
+    return PyInt_FromLong(cairo_get_line_join(c->ctx));
+}
+
+static PyObject *
+pycairo_get_line_width(PyCairoContext *c)
+{
+    return PyFloat_FromDouble(cairo_get_line_width(c->ctx));
+}
+
+static PyObject *
+pycairo_get_matrix(PyCairoContext *c)
+{
+    cairo_matrix_t matrix;
+    cairo_get_matrix (c->ctx, &matrix);
+    return PyCairoMatrix_FromMatrix (&matrix);
+}
+
+static PyObject *
+pycairo_get_miter_limit(PyCairoContext *c)
+{
+    return PyFloat_FromDouble(cairo_get_miter_limit(c->ctx));
+}
+
+static PyObject *
+pycairo_get_operator(PyCairoContext *c)
+{
+    return PyInt_FromLong(cairo_get_operator(c->ctx));
+}
+
+/* struct and wrappers for cairo_get_path() */ 
+typedef struct {
+	PyObject* move_to;
+	PyObject* line_to;
+	PyObject* curve_to;
+	PyObject* close_path;
+} py_path_callbacks;
+
+static void 
+py_wrapper_move_to(void *closure, double x, double y)
+{
+    if(!PyErr_Occurred()) {
+	py_path_callbacks *callbacks = (py_path_callbacks *)closure;
+	PyObject *arglist, *result = NULL;
+	arglist = Py_BuildValue("(dd)", x, y);
+	result = PyEval_CallObject(callbacks->move_to, arglist);
+	Py_DECREF(arglist);
+	Py_XDECREF(result);
+    }
+}
+
+static void 
+py_wrapper_line_to(void *closure, double x, double y)
+{
+    if(!PyErr_Occurred()) {
+	py_path_callbacks *callbacks = (py_path_callbacks *)closure;
+	PyObject *arglist, *result = NULL;
+	arglist = Py_BuildValue("(dd)", x, y);
+	result = PyEval_CallObject(callbacks->line_to, arglist);
+	Py_DECREF(arglist);
+	Py_XDECREF(result);
+    }
+}
+
+static void 
+py_wrapper_curve_to(void *closure, double x1, double y1, double x2, double y2, double x3, double y3)
+{
+    if(!PyErr_Occurred()) {
+	py_path_callbacks *callbacks = (py_path_callbacks *)closure;
+	PyObject *arglist, *result = NULL;
+	arglist = Py_BuildValue("(dddddd)", x1, y1, x2, y2, x3, y3);
+	result = PyEval_CallObject(callbacks->curve_to, arglist);
+	Py_DECREF(arglist);
+	Py_XDECREF(result);
+    }
+}
+
+static void 
+py_wrapper_close_path(void *closure)
+{
+    if(!PyErr_Occurred()) {
+	py_path_callbacks *callbacks = (py_path_callbacks *)closure;
+	PyObject *arglist, *result = NULL;
+    	arglist = Py_BuildValue("()");
+	result = PyEval_CallObject(callbacks->close_path, arglist);
+	Py_DECREF(arglist);
+	Py_XDECREF(result);
+    }
+}
+
+static PyObject *
+pycairo_get_path(PyCairoContext *c, PyObject *args)
+{
+    py_path_callbacks callbacks;
+
+    if(!PyArg_ParseTuple(args, "OOOO:Context.get_path",
+			 &callbacks.move_to, &callbacks.line_to, 
+			 &callbacks.curve_to, &callbacks.close_path))
+	return NULL;
+
+    if(!PyCallable_Check(callbacks.move_to)) {
+	PyErr_SetString(PyExc_TypeError, "move_to must be callable");
+	return NULL;
+    }
+    if(!PyCallable_Check(callbacks.line_to)) {
+	PyErr_SetString(PyExc_TypeError, "line_to must be callable");
+	return NULL;
+    }
+    if(!PyCallable_Check(callbacks.curve_to)) {
+	PyErr_SetString(PyExc_TypeError, "curve_to must be callable");
+	return NULL;
+    }
+    if(!PyCallable_Check(callbacks.close_path)) {
+	PyErr_SetString(PyExc_TypeError, "close_path must be callable");
+	return NULL;
+    }
+
+    cairo_get_path(c->ctx, py_wrapper_move_to, py_wrapper_line_to, 
+		   py_wrapper_curve_to, py_wrapper_close_path, &callbacks);
+    if(PyErr_Occurred() || pycairo_check_status(cairo_status(c->ctx)))
+	return NULL;
     Py_RETURN_NONE;
 }
 
 static PyObject *
-pycairo_set_target_surface(PyCairoContext *c, PyObject *args)
+pycairo_get_path_flat(PyCairoContext *c, PyObject *args)
 {
-    PyCairoSurface *surface;
+    py_path_callbacks callbacks;
 
-    if (!PyArg_ParseTuple(args, "O!:Context.set_target_surface",
-			  &PyCairoSurface_Type, &surface))
+    if(!PyArg_ParseTuple(args, "OOO:Context.get_path_flat",
+			 &callbacks.move_to, &callbacks.line_to, 
+			 &callbacks.close_path))
 	return NULL;
 
-    cairo_set_target_surface(c->ctx, surface->surface);
-    if (pycairo_check_status(cairo_status(c->ctx)))
+    if(!PyCallable_Check(callbacks.move_to)) {
+	PyErr_SetString(PyExc_TypeError, "move_to must be callable");
+	return NULL;
+    }
+    if(!PyCallable_Check(callbacks.line_to)) {
+	PyErr_SetString(PyExc_TypeError, "line_to must be callable");
+	return NULL;
+    }
+    if(!PyCallable_Check(callbacks.close_path)) {
+	PyErr_SetString(PyExc_TypeError, "close_path must be callable");
+	return NULL;
+    }
+
+    cairo_get_path_flat(c->ctx, py_wrapper_move_to, py_wrapper_line_to, 
+			py_wrapper_close_path, &callbacks);
+    if(PyErr_Occurred() || pycairo_check_status(cairo_status(c->ctx)))
 	return NULL;
     Py_RETURN_NONE;
 }
 
-#ifdef CAIRO_HAS_PS_SURFACE
 static PyObject *
-pycairo_set_target_ps(PyCairoContext *c, PyObject *args)
+pycairo_get_rgb_color(PyCairoContext *c)
 {
-    PyObject *file_object;
-    double width_inches, height_inches;
-    double x_pixels_per_inch, y_pixels_per_inch;
+    double red, green, blue;
 
-    if (!PyArg_ParseTuple(args, "O!dddd:Context.set_target_ps",
-			  &PyFile_Type, &file_object,
-			  &width_inches, &height_inches,
-			  &x_pixels_per_inch, &y_pixels_per_inch))
+    cairo_get_rgb_color(c->ctx, &red, &green, &blue);
+    return Py_BuildValue("(ddd)", red, green, blue);
+}
+
+static PyObject *
+pycairo_get_source(PyCairoContext *c)
+{
+    PyObject *p;
+    cairo_pattern_t *pattern = cairo_get_source(c->ctx);
+
+    if (!pattern)
+	return PyErr_NoMemory();
+
+    p = PyCairoPattern_FromPattern(pattern);
+    if (p)
+	cairo_pattern_reference(pattern);
+    return p;
+
+}
+
+static PyObject *
+pycairo_get_target_surface(PyCairoContext *c)
+{
+    PyObject *py_surface;
+    /* This function is scheduled to be removed as part of the upcoming API 
+       Shakeup.*/
+    cairo_surface_t *surface = cairo_get_target_surface(c->ctx);
+    if (!surface)
+	return PyErr_NoMemory();
+
+    py_surface = PyCairoSurface_FromSurface(surface, NULL);
+    if (py_surface)
+	cairo_surface_reference(surface);
+    return py_surface;
+}
+
+static PyObject *
+pycairo_get_tolerance(PyCairoContext *c)
+{
+    return PyFloat_FromDouble(cairo_get_tolerance(c->ctx));
+}
+
+static PyObject *
+pycairo_in_fill(PyCairoContext *c, PyObject *args)
+{
+    double x, y;
+    PyObject *result;
+
+    if (!PyArg_ParseTuple(args, "dd:Context.in_fill", &x, &y))
 	return NULL;
 
-    cairo_set_target_ps(c->ctx, PyFile_AsFile(file_object),
-			width_inches, height_inches,
-			x_pixels_per_inch, y_pixels_per_inch);
+    result = cairo_in_fill(c->ctx, x, y) ? Py_True : Py_False;
     if (pycairo_check_status(cairo_status(c->ctx)))
 	return NULL;
-    Py_RETURN_NONE;
+    Py_INCREF(result);
+    return result;
 }
-#endif  /* CAIRO_HAS_PS_SURFACE */
 
-#if 0
-#ifdef CAIRO_HAS_PDF_SURFACE
 static PyObject *
-pycairo_set_target_pdf(PyCairoContext *c, PyObject *args)
+pycairo_in_stroke(PyCairoContext *c, PyObject *args)
 {
-    PyObject *file_object;
-    double width_inches, height_inches;
-    double x_pixels_per_inch, y_pixels_per_inch;
+    double x, y;
+    PyObject *result;
 
-    if (!PyArg_ParseTuple(args, "O!dddd:Context.set_target_pdf",
-			  &PyFile_Type, &file_object,
-			  &width_inches, &height_inches,
-			  &x_pixels_per_inch, &y_pixels_per_inch))
+    if (!PyArg_ParseTuple(args, "dd:Context.in_stroke", &x, &y))
 	return NULL;
 
-    cairo_set_target_pdf(c->ctx, PyFile_AsFile(file_object),
-			width_inches, height_inches,
-			x_pixels_per_inch, y_pixels_per_inch);
+    result = cairo_in_stroke(c->ctx, x, y) ? Py_True : Py_False;
+    if (pycairo_check_status(cairo_status(c->ctx)))
+	return NULL;
+    Py_INCREF(result);
+    return result;
+}
+
+static PyObject *
+pycairo_restore(PyCairoContext *c)
+{
+    cairo_restore(c->ctx);
+    if (pycairo_check_status(cairo_status(c->ctx)))
+	return NULL;
+    Py_RETURN_NONE;
+}
+
+static PyObject *
+pycairo_save(PyCairoContext *c)
+{
+    cairo_save(c->ctx);
     if (pycairo_check_status(cairo_status(c->ctx)))
 	return NULL;
     Py_RETURN_NONE;
 }
-#endif  /* CAIRO_HAS_PDF_SURFACE */
-#endif
 
 static PyObject *
 pycairo_set_operator(PyCairoContext *c, PyObject *args)
@@ -201,54 +458,74 @@
     Py_RETURN_NONE;
 }
 
+#if 0
+#ifdef CAIRO_HAS_PDF_SURFACE
 static PyObject *
-pycairo_in_stroke(PyCairoContext *c, PyObject *args)
+pycairo_set_target_pdf(PyCairoContext *c, PyObject *args)
 {
-    double x, y;
-    PyObject *result;
+    PyObject *file_object;
+    double width_inches, height_inches;
+    double x_pixels_per_inch, y_pixels_per_inch;
 
-    if (!PyArg_ParseTuple(args, "dd:Context.in_stroke", &x, &y))
+    if (!PyArg_ParseTuple(args, "O!dddd:Context.set_target_pdf",
+			  &PyFile_Type, &file_object,
+			  &width_inches, &height_inches,
+			  &x_pixels_per_inch, &y_pixels_per_inch))
 	return NULL;
 
-    result = cairo_in_stroke(c->ctx, x, y) ? Py_True : Py_False;
+    cairo_set_target_pdf(c->ctx, PyFile_AsFile(file_object),
+			width_inches, height_inches,
+			x_pixels_per_inch, y_pixels_per_inch);
     if (pycairo_check_status(cairo_status(c->ctx)))
 	return NULL;
-    Py_INCREF(result);
-    return result;
+    Py_RETURN_NONE;
 }
+#endif  /* CAIRO_HAS_PDF_SURFACE */
+#endif
 
+#ifdef CAIRO_HAS_PS_SURFACE
 static PyObject *
-pycairo_in_fill(PyCairoContext *c, PyObject *args)
+pycairo_set_target_ps(PyCairoContext *c, PyObject *args)
 {
-    double x, y;
-    PyObject *result;
+    PyObject *file_object;
+    double width_inches, height_inches;
+    double x_pixels_per_inch, y_pixels_per_inch;
 
-    if (!PyArg_ParseTuple(args, "dd:Context.in_fill", &x, &y))
+    if (!PyArg_ParseTuple(args, "O!dddd:Context.set_target_ps",
+			  &PyFile_Type, &file_object,
+			  &width_inches, &height_inches,
+			  &x_pixels_per_inch, &y_pixels_per_inch))
 	return NULL;
 
-    result = cairo_in_fill(c->ctx, x, y) ? Py_True : Py_False;
+    cairo_set_target_ps(c->ctx, PyFile_AsFile(file_object),
+			width_inches, height_inches,
+			x_pixels_per_inch, y_pixels_per_inch);
     if (pycairo_check_status(cairo_status(c->ctx)))
 	return NULL;
-    Py_INCREF(result);
-    return result;
+    Py_RETURN_NONE;
 }
-
+#endif  /* CAIRO_HAS_PS_SURFACE */
 
 static PyObject *
-pycairo_stroke_extents(PyCairoContext *c)
+pycairo_set_target_surface(PyCairoContext *c, PyObject *args)
 {
-    double x1, y1, x2, y2;
-    cairo_stroke_extents(c->ctx, &x1, &y1, &x2, &y2);
+    PyCairoSurface *surface;
+
+    if (!PyArg_ParseTuple(args, "O!:Context.set_target_surface",
+			  &PyCairoSurface_Type, &surface))
+	return NULL;
+
+    cairo_set_target_surface(c->ctx, surface->surface);
     if (pycairo_check_status(cairo_status(c->ctx)))
 	return NULL;
-    return Py_BuildValue("(dddd)", x1, y1, x2, y2);
+    Py_RETURN_NONE;
 }
 
 static PyObject *
-pycairo_fill_extents(PyCairoContext *c)
+pycairo_stroke_extents(PyCairoContext *c)
 {
     double x1, y1, x2, y2;
-    cairo_fill_extents(c->ctx, &x1, &y1, &x2, &y2);
+    cairo_stroke_extents(c->ctx, &x1, &y1, &x2, &y2);
     if (pycairo_check_status(cairo_status(c->ctx)))
 	return NULL;
     return Py_BuildValue("(dddd)", x1, y1, x2, y2);
@@ -550,35 +827,6 @@
 }
 
 static PyObject *
-pycairo_device_to_user_distance(PyCairoContext *c, PyObject *args)
-{
-    double dx, dy;
-
-    if (!PyArg_ParseTuple(args, "dd:Context.device_to_user_distance", 
-			  &dx, &dy))
-	return NULL;
-
-    cairo_device_to_user_distance(c->ctx, &dx, &dy);
-    if (pycairo_check_status(cairo_status(c->ctx)))
-	return NULL;
-    return Py_BuildValue("(dd)", dx, dy);
-}
-
-static PyObject *
-pycairo_device_to_user(PyCairoContext *c, PyObject *args)
-{
-    double x, y;
-
-    if (!PyArg_ParseTuple(args, "dd:Context.device_to_user", &x, &y))
-	return NULL;
-
-    cairo_device_to_user(c->ctx, &x, &y);
-    if (pycairo_check_status(cairo_status(c->ctx)))
-	return NULL;
-    return Py_BuildValue("(dd)", x, y);
-}
-
-static PyObject *
 pycairo_new_path(PyCairoContext *c)
 {
     cairo_new_path(c->ctx);
@@ -894,239 +1142,6 @@
     Py_RETURN_NONE;
 }
 
-static PyObject *
-pycairo_get_font_face(PyCairoContext *c)
-{
-    PyObject *f;
-    cairo_font_face_t *font_face;
-
-    font_face = cairo_get_font_face(c->ctx);
-    if (!font_face){
-	pycairo_check_status(cairo_status(c->ctx));
-	return NULL;
-    }
-    f = PyCairoFontFace_FromFontFace(font_face);
-    if (f)
-	cairo_font_face_reference(font_face);
-    return f;
-}
-
-static PyObject *
-pycairo_get_operator(PyCairoContext *c)
-{
-    return PyInt_FromLong(cairo_get_operator(c->ctx));
-}
-
-static PyObject *
-pycairo_get_rgb_color(PyCairoContext *c)
-{
-    double red, green, blue;
-
-    cairo_get_rgb_color(c->ctx, &red, &green, &blue);
-    return Py_BuildValue("(ddd)", red, green, blue);
-}
-
-static PyObject *
-pycairo_get_tolerance(PyCairoContext *c)
-{
-    return PyFloat_FromDouble(cairo_get_tolerance(c->ctx));
-}
-
-static PyObject *
-pycairo_get_current_point(PyCairoContext *c)
-{
-    double x, y;
-
-    cairo_get_current_point(c->ctx, &x, &y);
-    return Py_BuildValue("(dd)", x, y);
-}
-
-static PyObject *
-pycairo_get_fill_rule(PyCairoContext *c)
-{
-    return PyInt_FromLong(cairo_get_fill_rule(c->ctx));
-}
-
-static PyObject *
-pycairo_get_line_width(PyCairoContext *c)
-{
-    return PyFloat_FromDouble(cairo_get_line_width(c->ctx));
-}
-
-static PyObject *
-pycairo_get_line_cap(PyCairoContext *c)
-{
-    return PyInt_FromLong(cairo_get_line_cap(c->ctx));
-}
-
-static PyObject *
-pycairo_get_line_join(PyCairoContext *c)
-{
-    return PyInt_FromLong(cairo_get_line_join(c->ctx));
-}
-
-static PyObject *
-pycairo_get_miter_limit(PyCairoContext *c)
-{
-    return PyFloat_FromDouble(cairo_get_miter_limit(c->ctx));
-}
-
-static PyObject *
-pycairo_get_target_surface(PyCairoContext *c)
-{
-    PyObject *py_surface;
-    /* This function is scheduled to be removed as part of the upcoming API 
-       Shakeup.*/
-    cairo_surface_t *surface = cairo_get_target_surface(c->ctx);
-    if (!surface)
-	return PyErr_NoMemory();
-
-    py_surface = PyCairoSurface_FromSurface(surface, NULL);
-    if (py_surface)
-	cairo_surface_reference(surface);
-    return py_surface;
-}
-
-static PyObject *
-pycairo_get_source(PyCairoContext *c)
-{
-    PyObject *p;
-    cairo_pattern_t *pattern = cairo_get_source(c->ctx);
-
-    if (!pattern)
-	return PyErr_NoMemory();
-
-    p = PyCairoPattern_FromPattern(pattern);
-    if (p)
-	cairo_pattern_reference(pattern);
-    return p;
-
-}
-
-/* struct and wrappers for cairo_get_path() */ 
-typedef struct {
-	PyObject* move_to;
-	PyObject* line_to;
-	PyObject* curve_to;
-	PyObject* close_path;
-} py_path_callbacks;
-
-static void 
-py_wrapper_move_to(void *closure, double x, double y)
-{
-    if(!PyErr_Occurred()) {
-	py_path_callbacks *callbacks = (py_path_callbacks *)closure;
-	PyObject *arglist, *result = NULL;
-	arglist = Py_BuildValue("(dd)", x, y);
-	result = PyEval_CallObject(callbacks->move_to, arglist);
-	Py_DECREF(arglist);
-	Py_XDECREF(result);
-    }
-}
-
-static void 
-py_wrapper_line_to(void *closure, double x, double y)
-{
-    if(!PyErr_Occurred()) {
-	py_path_callbacks *callbacks = (py_path_callbacks *)closure;
-	PyObject *arglist, *result = NULL;
-	arglist = Py_BuildValue("(dd)", x, y);
-	result = PyEval_CallObject(callbacks->line_to, arglist);
-	Py_DECREF(arglist);
-	Py_XDECREF(result);
-    }
-}
-
-static void 
-py_wrapper_curve_to(void *closure, double x1, double y1, double x2, double y2, double x3, double y3)
-{
-    if(!PyErr_Occurred()) {
-	py_path_callbacks *callbacks = (py_path_callbacks *)closure;
-	PyObject *arglist, *result = NULL;
-	arglist = Py_BuildValue("(dddddd)", x1, y1, x2, y2, x3, y3);
-	result = PyEval_CallObject(callbacks->curve_to, arglist);
-	Py_DECREF(arglist);
-	Py_XDECREF(result);
-    }
-}
-
-static void 
-py_wrapper_close_path(void *closure)
-{
-    if(!PyErr_Occurred()) {
-	py_path_callbacks *callbacks = (py_path_callbacks *)closure;
-	PyObject *arglist, *result = NULL;
-    	arglist = Py_BuildValue("()");
-	result = PyEval_CallObject(callbacks->close_path, arglist);
-	Py_DECREF(arglist);
-	Py_XDECREF(result);
-    }
-}
-
-static PyObject *
-pycairo_get_path(PyCairoContext *c, PyObject *args)
-{
-    py_path_callbacks callbacks;
-
-    if(!PyArg_ParseTuple(args, "OOOO:Context.get_path",
-			 &callbacks.move_to, &callbacks.line_to, 
-			 &callbacks.curve_to, &callbacks.close_path))
-	return NULL;
-
-    if(!PyCallable_Check(callbacks.move_to)) {
-	PyErr_SetString(PyExc_TypeError, "move_to must be callable");
-	return NULL;
-    }
-    if(!PyCallable_Check(callbacks.line_to)) {
-	PyErr_SetString(PyExc_TypeError, "line_to must be callable");
-	return NULL;
-    }
-    if(!PyCallable_Check(callbacks.curve_to)) {
-	PyErr_SetString(PyExc_TypeError, "curve_to must be callable");
-	return NULL;
-    }
-    if(!PyCallable_Check(callbacks.close_path)) {
-	PyErr_SetString(PyExc_TypeError, "close_path must be callable");
-	return NULL;
-    }
-
-    cairo_get_path(c->ctx, py_wrapper_move_to, py_wrapper_line_to, 
-		   py_wrapper_curve_to, py_wrapper_close_path, &callbacks);
-    if(PyErr_Occurred() || pycairo_check_status(cairo_status(c->ctx)))
-	return NULL;
-    Py_RETURN_NONE;
-}
-
-static PyObject *
-pycairo_get_path_flat(PyCairoContext *c, PyObject *args)
-{
-    py_path_callbacks callbacks;
-
-    if(!PyArg_ParseTuple(args, "OOO:Context.get_path_flat",
-			 &callbacks.move_to, &callbacks.line_to, 
-			 &callbacks.close_path))
-	return NULL;
-
-    if(!PyCallable_Check(callbacks.move_to)) {
-	PyErr_SetString(PyExc_TypeError, "move_to must be callable");
-	return NULL;
-    }
-    if(!PyCallable_Check(callbacks.line_to)) {
-	PyErr_SetString(PyExc_TypeError, "line_to must be callable");
-	return NULL;
-    }
-    if(!PyCallable_Check(callbacks.close_path)) {
-	PyErr_SetString(PyExc_TypeError, "close_path must be callable");
-	return NULL;
-    }
-
-    cairo_get_path_flat(c->ctx, py_wrapper_move_to, py_wrapper_line_to, 
-			py_wrapper_close_path, &callbacks);
-    if(PyErr_Occurred() || pycairo_check_status(cairo_status(c->ctx)))
-	return NULL;
-    Py_RETURN_NONE;
-}
-
 static PyMethodDef pycairo_methods[] = {
     /* append_path_data */
     { "arc",           (PyCFunction)pycairo_arc,           METH_VARARGS },
@@ -1208,10 +1223,11 @@
     { "fill_rule",      (getter)pycairo_get_fill_rule,    (setter)0 },
     { "font_face",      (getter)pycairo_get_font_face,    (setter)0 },
     { "font_extents",   (getter)pycairo_font_extents,     (setter)0 },
-    /* (get_)font_matrix */
+    { "font_matrix",    (getter)pycairo_get_font_matrix,  (setter)0 },
     { "line_cap",       (getter)pycairo_get_line_cap,     (setter)0 },
     { "line_join",      (getter)pycairo_get_line_join,    (setter)0 },
     { "line_width",     (getter)pycairo_get_line_width,   (setter)0 },
+    { "matrix",         (getter)pycairo_get_matrix,       (setter)0 },
     { "miter_limit",    (getter)pycairo_get_miter_limit,  (setter)0 },
     { "operator",       (getter)pycairo_get_operator,     (setter)0 },
     { "point",          (getter)pycairo_get_current_point,(setter)0 },




More information about the cairo-commit mailing list