[cairo-commit] cairo-perl Cairo.pm, 1.2, 1.3 Cairo.xs, 1.4, 1.5 CairoFont.xs, 1.2, 1.3 CairoMatrix.xs, 1.4, 1.5 CairoPath.xs, NONE, 1.1 CairoPattern.xs, 1.4, 1.5 CairoSurface.xs, 1.5, 1.6 ChangeLog, 1.6, 1.7 MakeHelper.pm, 1.1, 1.2 Makefile.PL, 1.4, 1.5 README, 1.1, 1.2 cairo-perl.h, 1.5, 1.6 cairo-perl.typemap, 1.1, 1.2

Torsten Schoenfeld commit at pdx.freedesktop.org
Tue Jul 12 13:29:51 PDT 2005


Committed by: tsch

Update of /cvs/cairo/cairo-perl
In directory gabe:/tmp/cvs-serv30085

Modified Files:
	Cairo.pm Cairo.xs CairoFont.xs CairoMatrix.xs CairoPattern.xs 
	CairoSurface.xs ChangeLog MakeHelper.pm Makefile.PL README 
	cairo-perl.h cairo-perl.typemap 
Added Files:
	CairoPath.xs 
Log Message:
	* Cairo.pm, Cairo.xs, t/Cairo.t: Replace the %backends hash with
	Cairo::HAS_PS_SURFACE, HAS_PDF_SURFACE, HAS_XLIB_SURFACE,
	HAS_FT_FONT and HAS_PNG_FUNCTIONS.

	* Cairo.pm, CairoPattern.xs, CairoSurface.xs, Makefile.PL:
	Implement the pattern and surface hierarchy suggested by the
	language bindings guidelines.

	* Cairo.xs: Use Cairo::Context for the namespace of cairo_t,
	instead of just Cairo, as suggested by the guidelines.

	* Cairo.xs, CairoFont.xs, CairoMatrix.xs, CairoPattern.xs,
	CairoSurface.xs, cairo-perl.h: Add new, remove old API.  Shuffle
	some things around.

	* Cairo.xs: Convert font and text extents and glyphs to and from
	native Perl data structures.

	* Cairo.xs, cairo-perl.h, cairo-perl.typemap: Remove everything
	that cannot be used from Perl, like the XLib and Glitz stuff.

	* CairoPath.xs, t/CairoPath.t: Add support for cairo_path_t,
	including a nice tied interface that lets you iterate over paths
	as if they were normal array references.

	* MakeHelper.pm: Extend the typemap generator to support "const"
	and "_noinc" types.  Change the enum handling to use the Glib
	convention, i.e. lowercase and hyphen instead of underscore.

	* Makefile.PL, README: Use ExtUtils::Depends.

	* examples/simple.pl, examples/png/caps_join.pl,
	examples/png/hering.pl, examples/png/outline.pl,
	examples/png/spiral.pl, examples/png/splines_tolerance.pl,
	examples/png/stars.pl: Update the examples to make them work again
	after all those API changes.

	* t/Cairo.t, t/CairoFont.t, CairoMatrix.t, CairoPattern.t,
	CairoSurface.t: Redo and/or expand the whole test suite.


Index: Cairo.pm
===================================================================
RCS file: /cvs/cairo/cairo-perl/Cairo.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Cairo.pm	11 Nov 2004 02:20:32 -0000	1.2
+++ Cairo.pm	12 Jul 2005 20:29:47 -0000	1.3
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004 by the cairo  perl team (see the file README)
+# Copyright (c) 2004-2005 by the cairo perl team (see the file README)
 #
 # Licensed under the LGPL, see LICENSE file for more information.
 #
@@ -14,12 +14,42 @@
 
 our @ISA = qw/DynaLoader/;
 
-our %backends = ();
-
 our $VERSION = '0.02';
 
-bootstrap Cairo $VERSION;
+Cairo->bootstrap ($VERSION);
 
-_register_backends (\%backends);
+# --------------------------------------------------------------------------- #
+
+package Cairo::ImageSurface;
+
+our @ISA = qw/Cairo::Surface/;
+
+package Cairo::PdfSurface;
+
+our @ISA = qw/Cairo::Surface/;
+
+package Cairo::PsSurface;
+
+our @ISA = qw/Cairo::Surface/;
+
+# --------------------------------------------------------------------------- #
+
+package Cairo::SurfacePattern;
+
+our @ISA = qw/Cairo::Pattern/;
+
+package Cairo::Gradient;
+
+our @ISA = qw/Cairo::Pattern/;
+
+package Cairo::LinearGradient;
+
+our @ISA = qw/Cairo::Gradient/;
+
+package Cairo::RadialGradient;
+
+our @ISA = qw/Cairo::Gradient/;
+
+# --------------------------------------------------------------------------- #
 
 1;

Index: Cairo.xs
===================================================================
RCS file: /cvs/cairo/cairo-perl/Cairo.xs,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Cairo.xs	12 Nov 2004 03:26:34 -0000	1.4
+++ Cairo.xs	12 Jul 2005 20:29:47 -0000	1.5
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004 by the cairo  perl team (see the file README)
+ * Copyright (c) 2004-2005 by the cairo perl team (see the file README)
  *
  * Licensed under the LGPL, see LICENSE file for more information.
  *
@@ -9,6 +9,8 @@
 
 #include <cairo-perl.h>
 
+/* ------------------------------------------------------------------------- */
+
 void
 _cairo_perl_call_XS (pTHX_ void (*subaddr) (pTHX_ CV *), CV * cv, SV ** mark)
 {
@@ -18,94 +20,186 @@
 	PUTBACK;	/* forget return values */
 }
 
-MODULE = Cairo	PACKAGE = Cairo	PREFIX = cairo_
+/* ------------------------------------------------------------------------- */
 
-BOOT:
-	{
-#include "cairo-perl-boot.xsh"
+/* XXX: these need extensive testing */
+
+#define DOUBLES_DECLARE	\
+	int i, n; double * pts;
+#define DOUBLES_SLURP_FROM_STACK(first)				\
+	n = (items - first);					\
+	pts = (double*)malloc (sizeof (double) * n);		\
+	if (!pts)						\
+		croak ("malloc failure for (%d) elements", n);	\
+	for (i = first ; i < items ; i++) {			\
+		pts[i-first] = SvIV (ST (i));			\
 	}
+#define DOUBLES_LEN	n
+#define DOUBLES_ARRAY	pts
+#define DOUBLES_CLEANUP	\
+	free (pts);
 
-cairo_t * cairo_create (class);
-    C_ARGS:
-	/* void */
+/* ------------------------------------------------------------------------- */
 
-## shouldn't have to deal with references from perl
-##void cairo_reference (cairo_t * cr);
+SV *
+newSVCairoFontExtents (cairo_font_extents_t * extents)
+{
+	HV *hv;
+	double value;
 
-## destroy should happen auto-magically
-##void cairo_destroy (cairo_t * cr);
-void cairo_DESTROY (cairo_t * cr);
-    CODE:
-	cairo_destroy (cr);
+	if (!extents)
+		return &PL_sv_undef;
 
-void cairo_save (cairo_t * cr);
+	hv = newHV ();
 
-void cairo_restore (cairo_t * cr);
+	value = extents->ascent;
+	hv_store (hv, "ascent", 6, newSVnv (value), 0);
 
-## void cairo_copy (cairo_t * dest, cairo_t * src);
-cairo_t * cairo_copy (cairo_t * src)
-    CODE:
-	RETVAL = cairo_create ();
-	cairo_copy (RETVAL, src);
-    OUTPUT:
-	RETVAL
+	value = extents->descent;
+	hv_store (hv, "descent", 7, newSVnv (value), 0);
 
-void cairo_set_target_surface (cairo_t * cr, cairo_surface_t * surface);
+	value = extents->height;
+	hv_store (hv, "height", 6, newSVnv (value), 0);
 
-void cairo_set_target_image (cairo_t * cr, char * data, cairo_format_t format, int width, int height, int stride);
+	value = extents->max_x_advance;
+	hv_store (hv, "max_x_advance", 13, newSVnv (value), 0);
 
+	value = extents->max_y_advance;
+	hv_store (hv, "max_y_advance", 13, newSVnv (value), 0);
 
-#ifdef CAIRO_HAS_PS_SURFACE
-# include <stdio.h>
+	return newRV_noinc ((SV *) hv);
+}
 
-void cairo_set_target_ps (cairo_t * cr, FILE * file, double width_inches, double height_inches, double x_pixels_per_inch, double y_pixels_per_inch);
+/* ------------------------------------------------------------------------- */
 
-#endif /* CAIRO_HAS_PS_SURFACE */
+SV *
+newSVCairoTextExtents (cairo_text_extents_t * extents)
+{
+	HV *hv;
+	double value;
 
+	if (!extents)
+		return &PL_sv_undef;
 
-#ifdef CAIRO_HAS_PNG_SURFACE
-# include <stdio.h>
+	hv = newHV ();
 
-void cairo_set_target_png (cairo_t * cr, FILE * file, cairo_format_t format, int width, int height);
+	value = extents->x_bearing;
+	hv_store (hv, "x_bearing", 9, newSVnv (value), 0);
 
-#endif /* CAIRO_HAS_PNG_SURFACE */
+	value = extents->y_bearing;
+	hv_store (hv, "y_bearing", 9, newSVnv (value), 0);
 
+	value = extents->width;
+	hv_store (hv, "width", 5, newSVnv (value), 0);
 
-#ifdef CAIRO_HAS_XLIB_SURFACE
-# include <X11/extensions/Xrender.h>
+	value = extents->height;
+	hv_store (hv, "height", 6, newSVnv (value), 0);
 
-## XXX: how would you get a Display and Drawable in perl
-void cairo_set_target_drawable (cairo_t * cr, Display * dpy, Drawable drawable);
+	value = extents->x_advance;
+	hv_store (hv, "x_advance", 9, newSVnv (value), 0);
 
-#endif /* CAIRO_HAS_XLIB_SURFACE */
+	value = extents->y_advance;
+	hv_store (hv, "y_advance", 9, newSVnv (value), 0);
 
+	return newRV_noinc ((SV *) hv);
+}
 
-#ifdef CAIRO_HAS_XCB_SURFACE
-# include <X11/XCB/xcb.h>
-# include <X11/XCB/render.h>
+/* ------------------------------------------------------------------------- */
 
-## XXX: how would you get these XCB types in perl
-void cairo_set_target_xcb (cairo_t * cr, XCBConnection * dpy, XCBDRAWABLE drawable, XCBVISUALTYPE * visual, cairo_format_t format);
+/* taken from Glib/Glib.xs */
+static void *
+alloc_temp (int nbytes)
+{
+	dTHR;
+	SV * s;
 
-#endif /* CAIRO_HAS_XCB_SURFACE */
+	if (nbytes <= 0) return NULL;
 
+	s = sv_2mortal (NEWSV (0, nbytes));
+	memset (SvPVX (s), 0, nbytes);
+	return SvPVX (s);
+}
 
-#ifdef CAIRO_HAS_GLITZ_SURFACE
-# include <glitz.h>
+SV *
+newSVCairoGlyph (cairo_glyph_t * glyph)
+{
+	HV *hv;
+	unsigned long index;
+	double value;
 
-## XXX: how would you get a glitz_surface_t in perl
-void cairo_set_target_glitz (cairo_t * cr, glitz_surface_t * surface);
+	if (!glyph)
+		return &PL_sv_undef;
 
-#endif /* CAIRO_HAS_GLITZ_SURFACE */
+	hv = newHV ();
+
+	index = glyph->index;
+	hv_store (hv, "index", 5, newSVuv (index), 0);
+
+	value = glyph->x;
+	hv_store (hv, "x", 1, newSVnv (value), 0);
+
+	value = glyph->y;
+	hv_store (hv, "y", 1, newSVnv (value), 0);
+
+	return newRV_noinc ((SV *) hv);
+}
+
+cairo_glyph_t *
+SvCairoGlyph (SV * sv)
+{
+	HV *hv;
+	SV **value;
+	cairo_glyph_t *glyph;
+
+	if (!SvOK (sv) || !SvRV (sv) || SvTYPE (SvRV (sv)) != SVt_PVHV)
+		croak ("cairo_glyph_t must be a hash reference");
+
+	hv = (HV *) SvRV (sv);
+	glyph = alloc_temp (sizeof (cairo_glyph_t));
 
+	value = hv_fetch (hv, "index", 5, 0);
+	if (value && SvOK (*value))
+		glyph->index = SvUV (*value);
+
+	value = hv_fetch (hv, "x", 1, 0);
+	if (value && SvOK (*value))
+		glyph->x = SvNV (*value);
+
+	value = hv_fetch (hv, "y", 1, 0);
+	if (value && SvOK (*value))
+		glyph->y = SvNV (*value);
+
+	return glyph;
+}
+
+/* ------------------------------------------------------------------------- */
+
+MODULE = Cairo	PACKAGE = Cairo::Context	PREFIX = cairo_
+
+BOOT:
+#include "cairo-perl-boot.xsh"
+
+cairo_t_noinc * cairo_create (class, cairo_surface_t * target);
+    C_ARGS:
+	target
+
+void DESTROY (cairo_t * cr);
+    CODE:
+	cairo_destroy (cr);
+
+void cairo_save (cairo_t * cr);
+
+void cairo_restore (cairo_t * cr);
 
 void cairo_set_operator (cairo_t * cr, cairo_operator_t op);
 
-void cairo_set_rgb_color (cairo_t * cr, double red, double green, double blue);
+void cairo_set_source_rgb (cairo_t *cr, double red, double green, double blue);
 
-void cairo_set_pattern (cairo_t * cr, cairo_pattern_t * pattern);
+void cairo_set_source_rgba (cairo_t *cr, double red, double green, double blue, double alpha);
 
-void cairo_set_alpha (cairo_t * cr, double alpha);
+void cairo_set_source (cairo_t *cr, cairo_pattern_t *source);
+
+void cairo_set_source_surface (cairo_t *cr, cairo_surface_t *surface, double x, double y);
 
 void cairo_set_tolerance (cairo_t * cr, double tolerance);
 
@@ -117,7 +211,6 @@
 
 void cairo_set_line_join (cairo_t * cr, cairo_line_join_t line_join);
 
-## XXX: double *
 ##void cairo_set_dash (cairo_t * cr, double * dashes, int ndash, double offset);
 void cairo_set_dash (cairo_t * cr, double offset, dash1, ...)
     PREINIT:
@@ -136,29 +229,19 @@
 
 void cairo_rotate (cairo_t * cr, double angle);
 
-void cairo_concat_matrix (cairo_t * cr, cairo_matrix_t * matrix);
-
-void cairo_set_matrix (cairo_t * cr, cairo_matrix_t * matrix);
+void cairo_transform (cairo_t *cr, const cairo_matrix_t *matrix);
 
-void cairo_default_matrix (cairo_t * cr);
+void cairo_set_matrix (cairo_t * cr, const cairo_matrix_t * matrix);
 
 void cairo_identity_matrix (cairo_t * cr);
 
-## XXX: double *
-##void cairo_transform_point (cairo_t * cr, double * x, double * y);
-void cairo_transform_point (cairo_t * cr, IN_OUTLIST double x, IN_OUTLIST double y);
+void cairo_user_to_device (cairo_t *cr, IN_OUTLIST double x, IN_OUTLIST double y);
 
-## XXX: double *
-##void cairo_transform_distance (cairo_t * cr, double * dx, double * dy);
-void cairo_transform_distance (cairo_t * cr, IN_OUTLIST double dx, IN_OUTLIST double dy);
+void cairo_user_to_device_distance (cairo_t *cr, IN_OUTLIST double dx, IN_OUTLIST double dy);
 
-## XXX: double *
-##void cairo_inverse_transform_point (cairo_t * cr, double * x, double * y);
-void cairo_inverse_transform_point (cairo_t * cr, IN_OUTLIST double x, IN_OUTLIST double y);
+void cairo_device_to_user (cairo_t *cr, IN_OUTLIST double x, IN_OUTLIST double y);
 
-## XXX: double *
-##void cairo_inverse_transform_distance (cairo_t * cr, double * dx, double * dy);
-void cairo_inverse_transform_distance (cairo_t * cr, IN_OUTLIST double dx, IN_OUTLIST double dy);
+void cairo_device_to_user_distance (cairo_t *cr, IN_OUTLIST double dx, IN_OUTLIST double dy);
 
 void cairo_new_path (cairo_t * cr);
 
@@ -182,10 +265,22 @@
 
 void cairo_close_path (cairo_t * cr);
 
+void cairo_paint (cairo_t *cr);
+
+void cairo_paint_with_alpha (cairo_t *cr, double alpha);
+
+void cairo_mask (cairo_t *cr, cairo_pattern_t *pattern);
+
+void cairo_mask_surface (cairo_t *cr, cairo_surface_t *surface, double surface_x, double surface_y);
+
 void cairo_stroke (cairo_t * cr);
 
+void cairo_stroke_preserve (cairo_t *cr);
+
 void cairo_fill (cairo_t * cr);
 
+void cairo_fill_preserve (cairo_t *cr);
+
 void cairo_copy_page (cairo_t * cr);
 
 void cairo_show_page (cairo_t * cr);
@@ -194,133 +289,192 @@
 
 int cairo_in_fill (cairo_t * cr, double x, double y);
 
-## XXX: double *
-##void cairo_stroke_extents (cairo_t * cr, double * x1, double * y1, double * x2, double * y2);
 void cairo_stroke_extents (cairo_t * cr, OUTLIST double x1, OUTLIST double y1, OUTLIST double x2, OUTLIST double y2);
 
-## XXX: double *
-##void cairo_fill_extents (cairo_t * cr, double * x1, double * y1, double * x2, double * y2);
 void cairo_fill_extents (cairo_t * cr, OUTLIST double x1, OUTLIST double y1, OUTLIST double x2, OUTLIST double y2);
 
-void cairo_init_clip (cairo_t * cr);
-
 void cairo_clip (cairo_t * cr);
 
-void cairo_select_font (cairo_t * cr, const char * family, cairo_font_slant_t slant, cairo_font_weight_t weight);
-
-void cairo_scale_font (cairo_t * cr, double scale);
-
-void cairo_transform_font (cairo_t * cr, cairo_matrix_t * matrix);
-
-void cairo_show_text (cairo_t * cr, const unsigned char * utf8);
-
-void cairo_show_glyphs (cairo_t * cr, cairo_glyph_t * glyphs, int num_glyphs);
-
-cairo_font_t * cairo_current_font (cairo_t * cr);
-
-void cairo_current_font_extents (cairo_t * cr, cairo_font_extents_t * extents);
+void cairo_clip_preserve (cairo_t *cr);
 
-void cairo_set_font (cairo_t * cr, cairo_font_t * font);
+void cairo_reset_clip (cairo_t *cr);
 
-void cairo_text_extents (cairo_t * cr, const unsigned char * utf8, cairo_text_extents_t * extents);
+void cairo_select_font_face (cairo_t *cr, const char *family, cairo_font_slant_t slant, cairo_font_weight_t weight);
 
-void cairo_glyph_extents (cairo_t * cr, cairo_glyph_t * glyphs, int num_glyphs, cairo_text_extents_t * extents);
+void cairo_set_font_size (cairo_t *cr, double size);
 
-void cairo_text_path  (cairo_t * cr, const unsigned char * utf8);
+void cairo_set_font_matrix (cairo_t *cr, const cairo_matrix_t *matrix);
 
-void cairo_glyph_path (cairo_t * cr, cairo_glyph_t * glyphs, int num_glyphs);
+##void cairo_get_font_matrix (cairo_t *cr, cairo_matrix_t *matrix);
+cairo_matrix_t * cairo_get_font_matrix (cairo_t *cr)
+    CODE:
+	RETVAL = malloc (sizeof (cairo_matrix_t));
+	cairo_get_font_matrix (cr, RETVAL);
+    OUTPUT:
+	RETVAL
 
-#include <fontconfig/fontconfig.h>
-#include <ft2build.h>
-#include FT_FREETYPE_H
+void cairo_show_text (cairo_t * cr, const char * utf8);
 
-## XXX: FT...
-##cairo_font_t * cairo_ft_font_create (FT_Library ft_library, FcPattern * pattern);
+##void cairo_show_glyphs (cairo_t * cr, cairo_glyph_t * glyphs, int num_glyphs);
+void cairo_show_glyphs (cairo_t * cr, ...)
+    PREINIT:
+	cairo_glyph_t * glyphs = NULL;
+	int num_glyphs, i;
+    CODE:
+	num_glyphs = items - 1;
+	glyphs = calloc (sizeof (cairo_glyph_t), num_glyphs);
+	for (i = 1; i < items; i++)
+		glyphs[i - 1] = *SvCairoGlyph (ST (i));
+	cairo_show_glyphs (cr, glyphs, num_glyphs);
+	free (glyphs);
 
-## XXX: FT...
-##cairo_font_t * cairo_ft_font_create_for_ft_face (FT_Face face);
+cairo_font_face_t * cairo_get_font_face (cairo_t *cr);
 
-## XXX: this symbol is undefined
-##void cairo_ft_font_destroy (cairo_font_t * ft_font);
+##void cairo_font_extents (cairo_t *cr, cairo_font_extents_t *extents);
+cairo_font_extents_t * cairo_font_extents (cairo_t *cr)
+    PREINIT:
+	cairo_font_extents_t extents;
+    CODE:
+	cairo_font_extents (cr, &extents);
+	RETVAL = &extents;
+    OUTPUT:
+	RETVAL
 
-## XXX: FT...
-##FT_Face cairo_ft_font_face (cairo_font_t * ft_font);
+void cairo_set_font_face (cairo_t *cr, cairo_font_face_t *font_face);
 
-## XXX: Fc...
-##FcPattern * cairo_ft_font_pattern (cairo_font_t  * ft_font);
+##void cairo_text_extents (cairo_t * cr, const unsigned char * utf8, cairo_text_extents_t * extents);
+cairo_text_extents_t * cairo_text_extents (cairo_t * cr, const char * utf8)
+    PREINIT:
+	cairo_text_extents_t extents;
+    CODE:
+	cairo_text_extents (cr, utf8, &extents);
+	RETVAL = &extents;
+    OUTPUT:
+	RETVAL
 
-void cairo_show_surface (cairo_t * cr, cairo_surface_t * surface, int width, int height);
+##void cairo_glyph_extents (cairo_t * cr, cairo_glyph_t * glyphs, int num_glyphs, cairo_text_extents_t * extents);
+cairo_text_extents_t * cairo_glyph_extents (cairo_t * cr, ...)
+    PREINIT:
+	cairo_text_extents_t extents;
+	cairo_glyph_t * glyphs = NULL;
+	int num_glyphs, i;
+    CODE:
+	num_glyphs = items - 1;
+	glyphs = calloc (sizeof (cairo_glyph_t), num_glyphs);
+	for (i = 1; i < items; i++)
+		glyphs[i - 1] = *SvCairoGlyph (ST (i));
+	cairo_glyph_extents (cr, glyphs, num_glyphs, &extents);
+	RETVAL = &extents;
+	free (glyphs);
+    OUTPUT:
+	RETVAL
 
-cairo_operator_t cairo_current_operator (cairo_t * cr);
+void cairo_text_path  (cairo_t * cr, const char * utf8);
 
-##void cairo_current_rgb_color (cairo_t * cr, double * red, double * green, double * blue);
-void cairo_current_rgb_color (cairo_t * cr, OUTLIST double red, OUTLIST double green, OUTLIST double blue);
+##void cairo_glyph_path (cairo_t * cr, cairo_glyph_t * glyphs, int num_glyphs);
+void cairo_glyph_path (cairo_t * cr, ...)
+    PREINIT:
+	cairo_glyph_t * glyphs = NULL;
+	int num_glyphs, i;
+    CODE:
+	num_glyphs = items - 1;
+	glyphs = calloc (sizeof (cairo_glyph_t), num_glyphs);
+	for (i = 1; i < items; i++)
+		glyphs[i - 1] = *SvCairoGlyph (ST (i));
+	cairo_glyph_path (cr, glyphs, num_glyphs);
+	free (glyphs);
 
-cairo_pattern_t * cairo_current_pattern (cairo_t * cr);
+cairo_operator_t cairo_get_operator (cairo_t *cr);
 
-double cairo_current_alpha (cairo_t * cr);
+cairo_pattern_t * cairo_get_source (cairo_t *cr);
 
-double cairo_current_tolerance (cairo_t * cr);
+double cairo_get_tolerance (cairo_t *cr);
 
-##void cairo_current_point (cairo_t * cr, double * x, double * y);
-void cairo_current_point (cairo_t * cr, OUTLIST double x, OUTLIST double y);
+void cairo_get_current_point (cairo_t *cr, OUTLIST double x, OUTLIST double y);
 
-cairo_fill_rule_t cairo_current_fill_rule (cairo_t * cr);
+cairo_fill_rule_t cairo_get_fill_rule (cairo_t *cr);
 
-double cairo_current_line_width (cairo_t * cr);
+double cairo_get_line_width (cairo_t *cr);
 
-cairo_line_cap_t cairo_current_line_cap (cairo_t * cr);
+cairo_line_cap_t cairo_get_line_cap (cairo_t *cr);
 
-cairo_line_join_t cairo_current_line_join (cairo_t * cr);
+cairo_line_join_t cairo_get_line_join (cairo_t *cr);
 
-double cairo_current_miter_limit (cairo_t * cr);
+double cairo_get_miter_limit (cairo_t *cr);
 
-##void cairo_current_matrix (cairo_t * cr, cairo_matrix_t * matrix);
-cairo_matrix_t * cairo_current_matrix (cairo_t * cr);
+##void cairo_get_matrix (cairo_t *cr, cairo_matrix_t *matrix);
+cairo_matrix_t * cairo_get_matrix (cairo_t *cr)
     CODE:
-	RETVAL = cairo_matrix_create ();
-	cairo_current_matrix (cr, RETVAL);
+	RETVAL = malloc (sizeof (cairo_matrix_t));
+	cairo_get_matrix (cr, RETVAL);
     OUTPUT:
 	RETVAL
 
-cairo_surface_t * cairo_current_target_surface (cairo_t * cr);
+cairo_surface_t * cairo_get_target (cairo_t *cr);
 
-## XXX: callbacks
-##typedef void (cairo_move_to_func_t) (void * closure, double x, double y);
-##
-##typedef void (cairo_line_to_func_t) (void * closure, double x, double y);
-##
-##typedef void (cairo_curve_to_func_t) (void * closure, double x1, double y1, double x2, double y2, double x3, double y3);
-##
-##typedef void (cairo_close_path_func_t) (void * closure);
-##
-##extern void cairo_current_path (cairo_t * cr, cairo_move_to_func_t * move_to, cairo_line_to_func_t * line_to, cairo_curve_to_func_t * curve_to, cairo_close_path_func_t * close_path, void * closure);
-##
-##extern void cairo_current_path_flat (cairo_t * cr, cairo_move_to_func_t * move_to, cairo_line_to_func_t * line_to, cairo_close_path_func_t * close_path, void * closure);
+cairo_path_t * cairo_copy_path (cairo_t *cr);
 
-cairo_status_t cairo_status (cairo_t * cr);
+cairo_path_t * cairo_copy_path_flat (cairo_t *cr);
 
-const char * cairo_status_string (cairo_t * cr);
+void cairo_append_path (cairo_t *cr, cairo_path_t *path);
 
-## XXX: HAS section, test for capibilities, cairo really needs to dynamically
-## register these. and there really ought to be version numbers associated with
-## them
+cairo_status_t cairo_status (cairo_t *cr);
 
-void _register_backends (HV * backends);
+# --------------------------------------------------------------------------- #
+
+MODULE = Cairo	PACKAGE = Cairo	PREFIX = cairo_
+
+bool
+HAS_PS_SURFACE ()
     CODE:
 #ifdef CAIRO_HAS_PS_SURFACE
-	hv_store (backends, "ps", 2, newSViv (1), 0);
+	RETVAL = TRUE;
+#else
+	RETVAL = FALSE;
 #endif
-#ifdef CAIRO_HAS_PNG_SURFACE
-	hv_store (backends, "png", 3, newSViv (1), 0);
+    OUTPUT:
+	RETVAL
+
+bool
+HAS_PDF_SURFACE ()
+    CODE:
+#ifdef CAIRO_HAS_PDF_SURFACE
+	RETVAL = TRUE;
+#else
+	RETVAL = FALSE;
 #endif
+    OUTPUT:
+	RETVAL
+
+bool
+HAS_XLIB_SURFACE ()
+    CODE:
 #ifdef CAIRO_HAS_XLIB_SURFACE
-	hv_store (backends, "xlib", 4, newSViv (1), 0);
+	RETVAL = TRUE;
+#else
+	RETVAL = FALSE;
 #endif
-#ifdef CAIRO_HAS_XCB_SURFACE
-	hv_store (backends, "xcb", 3, newSViv (1), 0);
+    OUTPUT:
+	RETVAL
+
+bool
+HAS_FT_FONT ()
+    CODE:
+#ifdef CAIRO_HAS_FT_FONT
+	RETVAL = TRUE;
+#else
+	RETVAL = FALSE;
 #endif
-#ifdef CAIRO_HAS_GLITZ_SURFACE
-	hv_store (backends, "glitz", 5, newSViv (1), 0);
+    OUTPUT:
+	RETVAL
+
+bool
+HAS_PNG_FUNCTIONS ()
+    CODE:
+#ifdef CAIRO_HAS_PNG_FUNCTIONS
+	RETVAL = TRUE;
+#else
+	RETVAL = FALSE;
 #endif
- 
+    OUTPUT:
+	RETVAL

Index: CairoFont.xs
===================================================================
RCS file: /cvs/cairo/cairo-perl/CairoFont.xs,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- CairoFont.xs	12 Nov 2004 03:26:34 -0000	1.2
+++ CairoFont.xs	12 Jul 2005 20:29:47 -0000	1.3
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004 by the cairo  perl team (see the file README)
+ * Copyright (c) 2004-2005 by the cairo perl team (see the file README)
  *
  * Licensed under the LGPL, see LICENSE file for more information.
  *
@@ -8,14 +8,49 @@
 
 #include <cairo-perl.h>
 
-MODULE = Cairo::Font	PACKAGE = Cairo::Font PREFIX = cairo_font_
+MODULE = Cairo::Font	PACKAGE = Cairo::FontFace
 
-## XXX: what about all of these
+void DESTROY (cairo_font_face_t * font)
+    CODE:
+	cairo_font_face_destroy (font);
 
-## void cairo_font_reference (cairo_font_t * font);
+MODULE = Cairo::Font	PACKAGE = Cairo::ScaledFont	PREFIX = cairo_scaled_font_
 
-## void cairo_font_destroy (cairo_font_t * font);
+##cairo_scaled_font_t* cairo_scaled_font_create (cairo_font_face_t *font_face, const cairo_matrix_t *font_matrix, const cairo_matrix_t *ctm);
+cairo_scaled_font_t_noinc * cairo_scaled_font_create (class, cairo_font_face_t *font_face, const cairo_matrix_t *font_matrix, const cairo_matrix_t *ctm)
+    C_ARGS:
+	font_face, font_matrix, ctm
 
-## void cairo_font_set_transform (cairo_font_t * font, cairo_matrix_t * matrix);
+##cairo_status_t cairo_scaled_font_extents (cairo_scaled_font_t *scaled_font, cairo_font_extents_t *extents);
+cairo_font_extents_t * cairo_scaled_font_extents (cairo_scaled_font_t *scaled_font)
+    PREINIT:
+	cairo_font_extents_t extents;
+    CODE:
+	if (CAIRO_STATUS_SUCCESS !=
+	    cairo_scaled_font_extents (scaled_font, &extents))
+		RETVAL = NULL;
+	else
+		RETVAL = &extents;
+    OUTPUT:
+	RETVAL
 
-## void cairo_font_current_transform (cairo_font_t * font, cairo_matrix_t * matrix);
+##void cairo_scaled_font_glyph_extents (cairo_scaled_font_t *scaled_font, cairo_glyph_t *glyphs, int num_glyphs, cairo_text_extents_t *extents);
+cairo_text_extents_t * cairo_scaled_font_glyph_extents (cairo_scaled_font_t *scaled_font, ...)
+    PREINIT:
+	cairo_glyph_t * glyphs = NULL;
+	int num_glyphs, i;
+	cairo_text_extents_t extents;
+    CODE:
+	num_glyphs = items - 1;
+	glyphs = calloc (sizeof (cairo_glyph_t), num_glyphs);
+	for (i = 1; i < items; i++)
+		glyphs[i - 1] = *SvCairoGlyph (ST (i));
+	cairo_scaled_font_glyph_extents (scaled_font, glyphs, num_glyphs, &extents);
+	RETVAL = &extents;
+	free (glyphs);
+    OUTPUT:
+	RETVAL
+
+void DESTROY (cairo_scaled_font_t * font)
+    CODE:
+	cairo_scaled_font_destroy (font);

Index: CairoMatrix.xs
===================================================================
RCS file: /cvs/cairo/cairo-perl/CairoMatrix.xs,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- CairoMatrix.xs	12 Nov 2004 03:26:34 -0000	1.4
+++ CairoMatrix.xs	12 Jul 2005 20:29:47 -0000	1.5
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004 by the cairo  perl team (see the file README)
+ * Copyright (c) 2004-2005 by the cairo perl team (see the file README)
  *
  * Licensed under the LGPL, see LICENSE file for more information.
  *
@@ -10,54 +10,68 @@
 
 MODULE = Cairo::Matrix	PACKAGE = Cairo::Matrix PREFIX = cairo_matrix_
 
-cairo_matrix_t * cairo_matrix_create (class);
-    C_ARGS:
-	/* void */
-
-## destroy should happen auto-magically
-##void cairo_matrix_destroy (cairo_matrix_t * matrix);
-void cairo_matrix_DESTROY (cairo_matrix_t * matrix);
+##void cairo_matrix_init (cairo_matrix_t *matrix, double xx, double yx, double xy, double yy, double x0, double y0);
+cairo_matrix_t * cairo_matrix_init (class, double xx, double yx, double xy, double yy, double x0, double y0)
     CODE:
-	cairo_matrix_destroy (matrix);
+	RETVAL = malloc (sizeof (cairo_matrix_t));
+	cairo_matrix_init (RETVAL, xx, yx, xy, yy, x0, y0);
+    OUTPUT:
+	RETVAL
 
-## XXX: status return type?
-## XXX: cairo_status_t cairo_matrix_copy (cairo_matrix_t * matrix, const cairo_matrix_t * other);
-cairo_matrix_t * cairo_matrix_copy (cairo_matrix_t * matrix);
+##void cairo_matrix_init_identity (cairo_matrix_t *matrix);
+cairo_matrix_t * cairo_matrix_init_identity (class)
     CODE:
-	RETVAL = cairo_matrix_create ();
-	cairo_matrix_copy (matrix, RETVAL);
+	RETVAL = malloc (sizeof (cairo_matrix_t));
+	cairo_matrix_init_identity (RETVAL);
     OUTPUT:
 	RETVAL
 
-cairo_status_t cairo_matrix_set_identity (cairo_matrix_t * matrix);
+##void cairo_matrix_init_translate (cairo_matrix_t *matrix, double tx, double ty);
+cairo_matrix_t * cairo_matrix_init_translate (class, double tx, double ty)
+    CODE:
+	RETVAL = malloc (sizeof (cairo_matrix_t));
+	cairo_matrix_init_translate (RETVAL, tx, ty);
+    OUTPUT:
+	RETVAL
 
-cairo_status_t cairo_matrix_set_affine (cairo_matrix_t * cr, double a, double b, double c, double d, double tx, double ty);
+##void cairo_matrix_init_scale (cairo_matrix_t *matrix, double sx, double sy);
+cairo_matrix_t * cairo_matrix_init_scale (class, double sx, double sy)
+    CODE:
+	RETVAL = malloc (sizeof (cairo_matrix_t));
+	cairo_matrix_init_scale (RETVAL, sx, sy);
+    OUTPUT:
+	RETVAL
 
-## XXX: status return type?
-##cairo_status_t cairo_matrix_get_affine (cairo_matrix_t * matrix, double * a, double * b, double * c, double * d, double * tx, double * ty);
-void cairo_matrix_get_affine (cairo_matrix_t * matrix, OUTLIST double a, OUTLIST double b, OUTLIST double c, OUTLIST double d, OUTLIST double tx, OUTLIST double ty);
+##void cairo_matrix_init_rotate (cairo_matrix_t *matrix, double radians);
+cairo_matrix_t * cairo_matrix_init_rotate (class, double radians)
+    CODE:
+	RETVAL = malloc (sizeof (cairo_matrix_t));
+	cairo_matrix_init_rotate (RETVAL, radians);
+    OUTPUT:
+	RETVAL
 
-cairo_status_t cairo_matrix_translate (cairo_matrix_t * matrix, double tx, double ty);
+void cairo_matrix_translate (cairo_matrix_t * matrix, double tx, double ty);
 
-cairo_status_t cairo_matrix_scale (cairo_matrix_t * matrix, double sx, double sy);
+void cairo_matrix_scale (cairo_matrix_t * matrix, double sx, double sy);
 
-cairo_status_t cairo_matrix_rotate (cairo_matrix_t * matrix, double radians);
+void cairo_matrix_rotate (cairo_matrix_t * matrix, double radians);
 
 cairo_status_t cairo_matrix_invert (cairo_matrix_t * matrix);
 
-## XXX: status return type?
-##cairo_status_t cairo_matrix_multiply (cairo_matrix_t * result, cairo_matrix_t * a, const cairo_matrix_t * b);
+##void cairo_matrix_multiply (cairo_matrix_t * result, const cairo_matrix_t * a, const cairo_matrix_t * b);
 cairo_matrix_t * cairo_matrix_multiply (cairo_matrix_t * a, cairo_matrix_t * b);
     CODE:
-	RETVAL = cairo_matrix_create ();
+	RETVAL = malloc (sizeof (cairo_matrix_t));
 	cairo_matrix_multiply (RETVAL, a, b);
     OUTPUT:
 	RETVAL
 
-## XXX: status return type?
-##cairo_status_t cairo_matrix_transform_distance (cairo_matrix_t * matrix, double * dx, double * dy);
+##void cairo_matrix_transform_distance (cairo_matrix_t * matrix, double * dx, double * dy);
 void cairo_matrix_transform_distance (cairo_matrix_t * matrix, IN_OUTLIST double dx, IN_OUTLIST double dy);
 
-## XXX: status return type?
-##cairo_status_t cairo_matrix_transform_point (cairo_matrix_t * matrix, double * x, double * y);
+##void cairo_matrix_transform_point (cairo_matrix_t * matrix, double * x, double * y);
 void cairo_matrix_transform_point (cairo_matrix_t * matrix, IN_OUTLIST double x, IN_OUTLIST double y);
+
+void DESTROY (cairo_matrix_t * matrix)
+    CODE:
+	free (matrix);

--- NEW FILE: CairoPath.xs ---
/*
 * Copyright (c) 2004-2005 by the cairo perl team (see the file README)
 *
 * Licensed under the LGPL, see LICENSE file for more information.
 *
 * $Header: /cvs/cairo/cairo-perl/CairoPath.xs,v 1.1 2005/07/12 20:29:47 tsch Exp $
 */

#include <cairo-perl.h>

SV *
newSVCairoPath (cairo_path_t * path)
{
	AV * av, * dummy;
	SV * tie;
	HV * stash;

	av = newAV ();
	dummy = newAV ();

	tie = newRV_noinc ((SV *) dummy);
	stash = gv_stashpv ("Cairo::Path", TRUE);
	sv_bless (tie, stash);

	/* Both the dummy and the real array need to have the path stored in
	 * the ext slot.  SvCairoPath looks for it in the real array.
	 * FETCHSIZE and FETCH look for it in the dummy. */
	sv_magic ((SV *) dummy, 0, PERL_MAGIC_ext, (const char *) path, 0);
	sv_magic ((SV *) av, 0, PERL_MAGIC_ext, (const char *) path, 0);
	sv_magic ((SV *) av, tie, PERL_MAGIC_tied, "", 0);

	return newRV_noinc ((SV *) av);
}

cairo_path_t *
SvCairoPath (SV * sv)
{
	MAGIC * mg;
	if (!sv || !SvROK (sv) || !(mg = mg_find (SvRV (sv), PERL_MAGIC_ext)))
		return NULL;
	return (cairo_path_t *) mg->mg_ptr;
}

MODULE = Cairo::Path	PACKAGE = Cairo::Path

void DESTROY (cairo_path_t * path)
    CODE:
	cairo_path_destroy (path);

IV FETCHSIZE (cairo_path_t * path, i_do_not_care_what_this_undocumented_second_argument_is)
    PREINIT:
	int i;
    CODE:
	RETVAL = 0;
	for (i = 0; i < path->num_data; i += path->data[i].header.length)
		RETVAL++;
    OUTPUT:
	RETVAL

SV * FETCH (cairo_path_t * path, IV index)
    PREINIT:
	int i, counter = 0;
    CODE:
	RETVAL = &PL_sv_undef;
	for (i = 0; i < path->num_data; i += path->data[i].header.length) {
		if (counter++ == index) {
			cairo_path_data_t *data = &path->data[i];
			HV *hash = newHV ();
			AV *points = newAV (), *tmp;

			switch (data->header.type) {
			    case CAIRO_PATH_MOVE_TO:
			    case CAIRO_PATH_LINE_TO:
				tmp = newAV ();
				av_store (tmp, 0, newSVnv (data[1].point.x));
				av_store (tmp, 1, newSVnv (data[1].point.y));
				av_store (points, 0, newRV_noinc ((SV *) tmp));
				break;
			    case CAIRO_PATH_CURVE_TO:
				tmp = newAV ();
				av_store (tmp, 0, newSVnv (data[1].point.x));
				av_store (tmp, 1, newSVnv (data[1].point.y));
				av_store (points, 0, newRV_noinc ((SV *) tmp));

				tmp = newAV ();
				av_store (tmp, 0, newSVnv (data[2].point.x));
				av_store (tmp, 1, newSVnv (data[2].point.y));
				av_store (points, 1, newRV_noinc ((SV *) tmp));

				tmp = newAV ();
				av_store (tmp, 0, newSVnv (data[3].point.x));
				av_store (tmp, 1, newSVnv (data[3].point.y));
				av_store (points, 2, newRV_noinc ((SV *) tmp));
				break;
			    case CAIRO_PATH_CLOSE_PATH:
				break;
			}

			hv_store (hash, "type", 4, cairo_path_data_type_to_sv (data->header.type), 0);
			hv_store (hash, "points", 6, newRV_noinc ((SV *) points), 0);

			RETVAL = newRV_noinc ((SV *) hash);

			break;
		}
	}
    OUTPUT:
	RETVAL

Index: CairoPattern.xs
===================================================================
RCS file: /cvs/cairo/cairo-perl/CairoPattern.xs,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- CairoPattern.xs	12 Nov 2004 03:26:34 -0000	1.4
+++ CairoPattern.xs	12 Jul 2005 20:29:47 -0000	1.5
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004 by the cairo  perl team (see the file README)
+ * Copyright (c) 2004-2005 by the cairo perl team (see the file README)
  *
  * Licensed under the LGPL, see LICENSE file for more information.
  *
@@ -10,44 +10,64 @@
 
 MODULE = Cairo::Pattern	PACKAGE = Cairo::Pattern PREFIX = cairo_pattern_
 
-cairo_pattern_t * cairo_pattern_create_for_surface (class, cairo_surface_t * surface);
-    C_ARGS:
-	surface
-
-cairo_pattern_t * cairo_pattern_create_linear (class, double x0, double y0, double x1, double y1);
-    C_ARGS:
-	x0, y0, x1, y1
-
-cairo_pattern_t * cairo_pattern_create_radial (class, double cx0, double cy0, double radius0, double cx1, double cy1, double radius1);
-    C_ARGS:
-	cx0, cy0, radius0, cx1, cy1, radius1
-
-## shouldn't have to deal with references from perl
-##void cairo_pattern_reference (cairo_pattern_t * pattern);
-
-## destroy should happen auto-magically
-void cairo_pattern_DESTROY (cairo_pattern_t * pattern);
+void DESTROY (cairo_pattern_t * pattern);
     CODE:
 	cairo_pattern_destroy (pattern);
-  
-cairo_status_t cairo_pattern_add_color_stop (cairo_pattern_t * pattern, double offset, double red, double green, double blue, double alpha);
-  
-cairo_status_t cairo_pattern_set_matrix (cairo_pattern_t * pattern, cairo_matrix_t * matrix);
 
-## XXX: status return type?
-## cairo_status_t cairo_pattern_get_matrix (cairo_pattern_t * pattern, cairo_matrix_t * matrix);
+void cairo_pattern_set_matrix (cairo_pattern_t * pattern, cairo_matrix_t * matrix);
+
+## void cairo_pattern_get_matrix (cairo_pattern_t * pattern, cairo_matrix_t * matrix);
 cairo_matrix_t * cairo_pattern_get_matrix (cairo_pattern_t * pattern);
     CODE:
-	RETVAL = cairo_matrix_create ();
+	RETVAL = malloc (sizeof (cairo_matrix_t));
 	cairo_pattern_get_matrix (pattern, RETVAL);
     OUTPUT:
 	RETVAL
 
-cairo_status_t cairo_pattern_set_extend (cairo_pattern_t * pattern, cairo_extend_t extend);
+cairo_status_t cairo_pattern_status (cairo_pattern_t *pattern);
+
+# --------------------------------------------------------------------------- #
+
+MODULE = Cairo::Pattern	PACKAGE = Cairo::SurfacePattern	PREFIX = cairo_pattern_
+
+cairo_surface_pattern_t_noinc * create (class, cairo_surface_t * surface);
+    CODE:
+	RETVAL = cairo_pattern_create_for_surface (surface);
+    OUTPUT:
+	RETVAL
+
+void cairo_pattern_set_extend (cairo_pattern_t * pattern, cairo_extend_t extend);
 
 cairo_extend_t cairo_pattern_get_extend (cairo_pattern_t * pattern);
 
-cairo_status_t cairo_pattern_set_filter (cairo_pattern_t * pattern, cairo_filter_t filter);
+void cairo_pattern_set_filter (cairo_pattern_t * pattern, cairo_filter_t filter);
 
 cairo_filter_t cairo_pattern_get_filter (cairo_pattern_t * pattern);
 
+# --------------------------------------------------------------------------- #
+
+MODULE = Cairo::Pattern	PACKAGE = Cairo::Gradient	PREFIX = cairo_pattern_
+
+void cairo_pattern_add_color_stop_rgb (cairo_pattern_t *pattern, double offset, double red, double green, double blue);
+
+void cairo_pattern_add_color_stop_rgba (cairo_pattern_t *pattern, double offset, double red, double green, double blue, double alpha);
+
+# --------------------------------------------------------------------------- #
+
+MODULE = Cairo::Pattern	PACKAGE = Cairo::LinearGradient	PREFIX = cairo_pattern_
+
+cairo_linear_gradient_t_noinc * create (class, double x0, double y0, double x1, double y1);
+    CODE:
+	RETVAL = cairo_pattern_create_linear (x0, y0, x1, y1);
+    OUTPUT:
+	RETVAL
+
+# --------------------------------------------------------------------------- #
+
+MODULE = Cairo::Pattern	PACKAGE = Cairo::RadialGradient	PREFIX = cairo_pattern_
+
+cairo_radial_gradient_t_noinc * create (class, double cx0, double cy0, double radius0, double cx1, double cy1, double radius1);
+    CODE:
+	RETVAL = cairo_pattern_create_radial (cx0, cy0, radius0, cx1, cy1, radius1);
+    OUTPUT:
+	RETVAL

Index: CairoSurface.xs
===================================================================
RCS file: /cvs/cairo/cairo-perl/CairoSurface.xs,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- CairoSurface.xs	6 Feb 2005 16:21:26 -0000	1.5
+++ CairoSurface.xs	12 Jul 2005 20:29:47 -0000	1.6
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004 by the cairo  perl team (see the file README)
+ * Copyright (c) 2004-2005 by the cairo perl team (see the file README)
  *
  * Licensed under the LGPL, see LICENSE file for more information.
  *
@@ -8,100 +8,105 @@
 
 #include <cairo-perl.h>
 
-/*
- * TODO:
- *	- the names are bad on these, should be cairo_surface_image_create etc.
- *	  don't want to put them in these pkgs, going to have to mangle somehow.
- */
-
-MODULE = Cairo::Surface	PACKAGE = Cairo::Surface PREFIX = cairo_surface_
+MODULE = Cairo::Surface	PACKAGE = Cairo::Surface	PREFIX = cairo_surface_
 
-cairo_surface_t * image_create (class, cairo_format_t format, int width, int height)
+void DESTROY (cairo_surface_t * surface);
     CODE:
-	RETVAL = cairo_image_surface_create (format, width, height);
-    OUTPUT:
-	RETVAL
+	cairo_surface_destroy (surface);
 
-cairo_surface_t * image_create_for_data (class, char * data, cairo_format_t format, int width, int height, int stride);
+##cairo_surface_t * cairo_surface_create_similar (cairo_surface_t * other, cairo_content_t content, int width, int height);
+SV * cairo_surface_create_similar (SV * other, cairo_content_t content, int width, int height)
+    PREINIT:
+	char *package;
+	IV pointer;
+	cairo_surface_t *other_surface, *surface;
     CODE:
-	RETVAL = cairo_image_surface_create_for_data (data, format, width,
-						      height, stride);
+	package = sv_reftype (SvRV (other), TRUE);
+	pointer = SvIV ((SV *) SvRV (other));
+	other_surface = INT2PTR (cairo_surface_t *, pointer);
+
+	surface = cairo_surface_create_similar (other_surface, content, width, height);
+	RETVAL = newSV (0);
+	sv_setref_pv (RETVAL, package, (void *) surface);
     OUTPUT:
 	RETVAL
 
-## XXX: duplicates the above, no need to bind
-##cairo_surface_t * cairo_surface_create_for_image (class, char * data, cairo_format_t format, int width, int height, int stride);
+cairo_status_t cairo_surface_finish (cairo_surface_t *surface);
 
-#ifdef CAIRO_HAS_PS_SURFACE
+void cairo_surface_set_device_offset (cairo_surface_t *surface, double x_offset, double y_offset);
 
-cairo_surface_t * ps_create (class, FILE * file, double width_inches, double height_inches, double x_pixels_per_inch, double y_pixels_per_inch);
-   CODE:
-	RETVAL = cairo_ps_surface_create (file, width_inches, height_inches,
-					  x_pixels_per_inch, y_pixels_per_inch);
-    OUTPUT:
-	RETVAL
+#ifdef CAIRO_HAS_PNG_FUNCTIONS
 
-#endif /* CAIRO_HAS_PS_SURFACE */
+cairo_status_t cairo_surface_write_to_png (cairo_surface_t *surface, const char *filename);
 
-#ifdef CAIRO_HAS_PNG_SURFACE
+# FIXME?
+##cairo_status_t cairo_surface_write_to_png_stream (cairo_surface_t *surface, cairo_write_func_t write_func, void *closure);
 
-cairo_surface_t * png_create (class, FILE * file, cairo_format_t format, int width, int height);
-    CODE:
-	RETVAL = cairo_png_surface_create (file, format, width, height);
-    OUTPUT:
-	RETVAL
+#endif
 
-#endif /* CAIRO_HAS_PNG_SURFACE */
+# --------------------------------------------------------------------------- #
 
-#ifdef CAIRO_HAS_XLIB_SURFACE
+MODULE = Cairo::Surface	PACKAGE = Cairo::ImageSurface	PREFIX = cairo_image_surface_
 
-## XXX: Display, Drawable ...
-cairo_surface_t * xlib_create (class, Display * dpy, Drawable drawable, Visual * visual, cairo_format_t format, Colormap colormap);
-    CODE:
-	RETVAL = cairo_xlib_surface_create (dpy, drawable, visual, format, colormap);
-    OUTPUT:
-	RETVAL
+##cairo_surface_t * cairo_image_surface_create (cairo_format_t format, int width, int height);
+cairo_image_surface_t_noinc * cairo_image_surface_create (class, cairo_format_t format, int width, int height)
+    C_ARGS:
+	format, width, height
 
-#endif /* CAIRO_HAS_XLIB_SURFACE */
+##cairo_surface_t * cairo_image_surface_create_for_data (unsigned char *data, cairo_format_t format, int width, int height, int stride);
+cairo_image_surface_t_noinc * cairo_image_surface_create_for_data (class, unsigned char *data, cairo_format_t format, int width, int height, int stride)
+    C_ARGS:
+	data, format, width, height, stride
 
-#ifdef CAIRO_HAS_GLITZ_SURFACE
+int cairo_image_surface_get_width (cairo_surface_t *surface);
 
-## XXX: glitz_surface_t
-cairo_surface_t * glitz_create (class, glitz_surface_t * surface);
-    CODE:
-	RETVAL = cairo_glitz_surface_create (surface);
-    OUTPUT:
-	RETVAL
+int cairo_image_surface_get_height (cairo_surface_t *surface);
 
-#endif /* CAIRO_HAS_GLITZ_SURFACE */
+#ifdef CAIRO_HAS_PNG_FUNCTIONS
 
-## shouldn't have to deal with references from perl
-##void cairo_surface_reference (cairo_surface_t * surface);
+##cairo_surface_t * cairo_image_surface_create_from_png (const char *filename);
+cairo_image_surface_t_noinc * cairo_image_surface_create_from_png (class, const char *filename)
+    C_ARGS:
+	filename
 
-## destroy should happen auto-magically
-## void cairo_surface_destroy (cairo_surface_t * surface);
-void cairo_surface_DESTROY (cairo_surface_t * surface);
-    CODE:
-	cairo_surface_destroy (surface);
+# FIXME?
+##cairo_surface_t * cairo_image_surface_create_from_png_stream (cairo_read_func_t read_func, void *closure);
 
-cairo_surface_t * cairo_surface_create_similar (cairo_surface_t * other, cairo_format_t format, int width, int height);
+#endif
 
-void cairo_surface_destroy (cairo_surface_t * surface);
+# --------------------------------------------------------------------------- #
 
-cairo_status_t cairo_surface_set_repeat (cairo_surface_t * surface, int repeat);
+#ifdef CAIRO_HAS_PDF_SURFACE
 
-cairo_status_t cairo_surface_set_matrix (cairo_surface_t * surface, cairo_matrix_t * matrix);
+MODULE = Cairo::Surface	PACKAGE = Cairo::PdfSurface	PREFIX = cairo_pdf_surface_
 
-## XXX: status return type?
-## cairo_status_t cairo_surface_get_matrix (cairo_surface_t * surface, cairo_matrix_t * matrix);
-cairo_matrix_t * cairo_surface_get_matrix (cairo_surface_t * surface);
-    CODE:
-	RETVAL = cairo_matrix_create ();
-	cairo_surface_get_matrix (surface, RETVAL);
-    OUTPUT:
-	RETVAL
+##cairo_surface_t * cairo_pdf_surface_create (const char *filename, double width_in_points, double height_in_points);
+cairo_pdf_surface_t_noinc * cairo_pdf_surface_create (class, const char *filename, double width_in_points, double height_in_points)
+    C_ARGS:
+	filename, width_in_points, height_in_points
 
-cairo_status_t cairo_surface_set_filter (cairo_surface_t * surface, cairo_filter_t filter);
+# FIXME?
+##cairo_surface_t * cairo_pdf_surface_create_for_stream (cairo_write_func_t write_func, void *closure, double width_in_points, double height_in_points);
 
-cairo_filter_t cairo_surface_get_filter (cairo_surface_t * surface);
+void cairo_pdf_surface_set_dpi (cairo_surface_t *surface, double x_dpi, double y_dpi);
+
+#endif
 
+# --------------------------------------------------------------------------- #
+
+#ifdef CAIRO_HAS_PS_SURFACE
+
+MODULE = Cairo::Surface	PACKAGE = Cairo::PsSurface	PREFIX = cairo_ps_surface_
+
+##cairo_surface_t * cairo_ps_surface_create (const char *filename, double width_in_points, double height_in_points);
+cairo_ps_surface_t_noinc * cairo_ps_surface_create (class, const char *filename, double width_in_points, double height_in_points)
+    C_ARGS:
+	filename, width_in_points, height_in_points
+
+# FIXME?
+##cairo_surface_t * cairo_ps_surface_create_for_stream (cairo_write_func_t write_func, void *closure, double width_in_points, double height_in_points);
+
+# FIXME: this is listed in the header but apparently not implemented yet.
+##void cairo_ps_surface_set_dpi (cairo_surface_t *surface, double x_dpi, double y_dpi);
+
+#endif

Index: ChangeLog
===================================================================
RCS file: /cvs/cairo/cairo-perl/ChangeLog,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- ChangeLog	6 Feb 2005 16:21:26 -0000	1.6
+++ ChangeLog	12 Jul 2005 20:29:47 -0000	1.7
@@ -1,3 +1,45 @@
+2005/07/12	tsch
+
+	* Cairo.pm, Cairo.xs, t/Cairo.t: Replace the %backends hash with
+	Cairo::HAS_PS_SURFACE, HAS_PDF_SURFACE, HAS_XLIB_SURFACE,
+	HAS_FT_FONT and HAS_PNG_FUNCTIONS.
+
+	* Cairo.pm, CairoPattern.xs, CairoSurface.xs, Makefile.PL:
+	Implement the pattern and surface hierarchy suggested by the
+	language bindings guidelines.
+
+	* Cairo.xs: Use Cairo::Context for the namespace of cairo_t,
+	instead of just Cairo, as suggested by the guidelines.
+
+	* Cairo.xs, CairoFont.xs, CairoMatrix.xs, CairoPattern.xs,
+	CairoSurface.xs, cairo-perl.h: Add new, remove old API.  Shuffle
+	some things around.
+
+	* Cairo.xs: Convert font and text extents and glyphs to and from
+	native Perl data structures.
+
+	* Cairo.xs, cairo-perl.h, cairo-perl.typemap: Remove everything
+	that cannot be used from Perl, like the XLib and Glitz stuff.
+
+	* CairoPath.xs, t/CairoPath.t: Add support for cairo_path_t,
+	including a nice tied interface that lets you iterate over paths
+	as if they were normal array references.
+
+	* MakeHelper.pm: Extend the typemap generator to support "const"
+	and "_noinc" types.  Change the enum handling to use the Glib
+	convention, i.e. lowercase and hyphen instead of underscore.
+
+	* Makefile.PL, README: Use ExtUtils::Depends.
+
+	* examples/simple.pl, examples/png/caps_join.pl,
+	examples/png/hering.pl, examples/png/outline.pl,
+	examples/png/spiral.pl, examples/png/splines_tolerance.pl,
+	examples/png/stars.pl: Update the examples to make them work again
+	after all those API changes.
+
+	* t/Cairo.t, t/CairoFont.t, CairoMatrix.t, CairoPattern.t,
+	CairoSurface.t: Redo and/or expand the whole test suite.
+
 2005/02/06 11:18 (-0500) rwmcfa1
 
 	* CairoSurface.xs: fixed a bug in wrapping of cairo_surface_xlib_create

Index: MakeHelper.pm
===================================================================
RCS file: /cvs/cairo/cairo-perl/MakeHelper.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- MakeHelper.pm	28 Nov 2004 18:27:10 -0000	1.1
+++ MakeHelper.pm	12 Jul 2005 20:29:47 -0000	1.2
@@ -19,7 +19,7 @@
 {
 	my %opts = (
 		ignore => '^[^:]+$',	# ignore package with no colons in it
-		filename => File::Spec->catdir ($autogen_dir, 
+		filename => File::Spec->catdir ($autogen_dir,
 						'cairo-perl-boot.xsh'),
 		'glob' => File::Spec->catfile ('xs', '*.xs'),
 		@_,
@@ -27,7 +27,7 @@
 	my $ignore = $opts{ignore};
 
 	my $file = IO::File->new (">$opts{filename}")
-		or die "Cannot write $opts{filename}: $!"; 
+		or die "Cannot write $opts{filename}: $!";
 
 	print $file "\n\n/* This file is automatically generated, any changes made here will be lost! */\n\n";
 
@@ -46,7 +46,7 @@
 			#warn "found $1 in $&\n";
 
 			my $package = $1;
-			
+
 			next if $package =~ m/$ignore/;
 
 			$package =~ s/:/_/g;
@@ -70,10 +70,17 @@
 
 	my $cairo_perl = File::Spec->catfile ($autogen_dir,
 					      'cairo-perl-auto.typemap');
-	open TYPEMAP, '>'.$cairo_perl
+	open TYPEMAP, '>', $cairo_perl
 		or die "unable to open ($cairo_perl) for output";
 
-	print TYPEMAP "#\n#\n#\n\nTYPEMAP\n\n";
+	print TYPEMAP <<EOS;
+#
+# This file was automatically generated.  Do not edit.
+#
+
+TYPEMAP
+
+EOS
 
 	sub type_id
 	{
@@ -87,10 +94,19 @@
 		$_[0] =~ /cairo_(\w+)_t/;
 		$1;
 	}
-	
+
 	foreach (keys %objects, keys %structs, keys %enums)
 	{
-		print TYPEMAP $_."\t".type_id ($_)."\n";
+		print TYPEMAP "$_\t".type_id ($_)."\n";
+		print TYPEMAP "const $_\t".type_id ($_)."\n";
+	}
+
+	foreach (keys %objects)
+	{
+		my $trunk = $_;
+		$trunk =~ s/ \*//;
+
+		print TYPEMAP "${trunk}_noinc *\t".type_id ($_)."_NOINC\n";
 	}
 
 	print TYPEMAP "\nINPUT\n\n";
@@ -128,7 +144,7 @@
 
 ';
 	}
-	
+
 	print TYPEMAP "\nOUTPUT\n\n";
 
 	my $ref;
@@ -141,6 +157,10 @@
 	sv_setref_pv($arg, \"'.$objects{$_}.'\", (void*)$var);
 
 ';
+		print TYPEMAP type_id ($_).'_NOINC
+	sv_setref_pv($arg, \"'.$objects{$_}.'\", (void*)$var);
+
+';
 	}
 
 	foreach (keys %structs)
@@ -160,7 +180,29 @@
 	}
 
 	close TYPEMAP;
-	
+
+	my $header = File::Spec->catfile ($autogen_dir,
+					  'cairo-perl-auto.h');
+	open HEADER, '>', $header
+		or die "unable to open ($header) for output";
+
+	print HEADER <<EOS;
+/*
+ * This file was automatically generated.  Do not edit.
+ */
+
+#include <cairo.h>
+
+EOS
+
+	foreach (keys %objects)
+	{
+		/^(.*) \*/;
+		print HEADER "typedef $1 ${1}_noinc;\n";
+	}
+
+	close HEADER;
+
 	return ($cairo_perl);
 }
 
@@ -168,8 +210,8 @@
 {
 	my %enums = %{shift ()};
 
-	my $cairo_enums = 'CairoEnums.xs';
-	open ENUMS, '>'.$cairo_enums
+	my $cairo_enums = 'cairo-perl-enums.c';
+	open ENUMS, '>', $cairo_enums
 		or die "unable to open ($cairo_enums) for output";
 
 	sub name
@@ -180,7 +222,7 @@
 
 	print ENUMS "
 /*
- *
+ * This file was automatically generated.  Do not edit.
  */
 
 #include <cairo-perl.h>
@@ -196,6 +238,8 @@
 		my $full = shift @enums;
 		my $name = $full;
 		$name =~ s/$prefix//;
+		$name =~ tr/_/-/;
+		$name = lc ($name);
 		my $len = length ($name);
 
 		my $str = "	if (strncmp (str, \"$name\", $len) == 0)
@@ -206,6 +250,8 @@
 		{
 			$name = $full;
 			$name =~ s/$prefix//;
+			$name =~ tr/_/-/;
+			$name = lc ($name);
 			$len = length ($name);
 
 			$str .= "	else if (strncmp (str, \"$name\", $len) == 0)
@@ -224,6 +270,8 @@
 		my $full = shift @enums;
 		my $name = $full;
 		$name =~ s/$prefix//;
+		$name =~ tr/_/-/;
+		$name = lc ($name);
 
 		my $str = "	if (val == $full)
 		return newSVpv (\"$name\", 0);
@@ -233,6 +281,8 @@
 		{
 			$name = $full;
 			$name =~ s/$prefix//;
+			$name =~ tr/_/-/;
+			$name = lc ($name);
 			$str .= "	else if (val == $full)
 		return newSVpv (\"$name\", 0);
 ";
@@ -241,9 +291,9 @@
 		$str;
 	}
 
-	open HDR, ">$autogen_dir/cairo-perl-enums.h";
+	open HDR, '>', "$autogen_dir/cairo-perl-enums.h";
 	print HDR "/*
- *
+ * This file was automatically generated.  Do not edit.
  */
 
 #ifndef _CAIRO_PERL_ENUMS_H_
@@ -258,7 +308,7 @@
 int cairo_".$name."_from_sv (SV * $name);
 SV * cairo_".$name."_to_sv (int val);
 ";
-		
+
 		print ENUMS 'int
 cairo_'.$name.'_from_sv (SV * '.$name.')
 {
@@ -284,13 +334,8 @@
 	print HDR "
 #endif /* _CAIRO_PERL_ENUMS_H_ */\n";
 	close HDR;
-	
-	print ENUMS "MODULE = Cairo::Enums	PACKAGE = Cairo::Enums	PREFIX = cairo_enums_
-
-";
 
 	close ENUMS;
-	return ($cairo_enums);
 }
 
 1;

Index: Makefile.PL
===================================================================
RCS file: /cvs/cairo/cairo-perl/Makefile.PL,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Makefile.PL	28 Nov 2004 18:27:10 -0000	1.4
+++ Makefile.PL	12 Jul 2005 20:29:47 -0000	1.5
@@ -1,16 +1,14 @@
 #
-# Copyright (c) 2004 by the cairo  perl team (see the file README)
+# Copyright (c) 2004-2005 by the cairo perl team (see the file README)
 #
 # Licensed under the LGPL, see LICENSE file for more information.
 #
 # $Header$
 #
-# TODO:
-#	- man this is horribly ulgy, stream-of-cons. even.
-#
 
 use strict;
 use warnings;
+use ExtUtils::Depends;
 use ExtUtils::PkgConfig;
 use ExtUtils::MakeMaker;
 
@@ -23,18 +21,22 @@
 my %cairo_cfg = ExtUtils::PkgConfig->find ('cairo');
 
 my %objects = (
-	'cairo_t *' => 'Cairo',
+	'cairo_t *' => 'Cairo::Context',
 	'cairo_surface_t *' => 'Cairo::Surface',
+	'cairo_image_surface_t *' => 'Cairo::ImageSurface',
+	'cairo_pdf_surface_t *' => 'Cairo::PdfSurface',
+	'cairo_ps_surface_t *' => 'Cairo::PsSurface',
 	'cairo_pattern_t *' => 'Cairo::Pattern',
-	'cairo_font_t *' => 'Cairo::Font',
+	'cairo_surface_pattern_t *' => 'Cairo::SurfacePattern',
+	'cairo_gradient_t *' => 'Cairo::Gradient',
+	'cairo_linear_gradient_t *' => 'Cairo::LinearGradient',
+	'cairo_radial_gradient_t *' => 'Cairo::RadialGradient',
+	'cairo_font_face_t *' => 'Cairo::FontFace',
+	'cairo_scaled_font_t *' => 'Cairo::ScaledFont',
 );
 
 my %structs = (
 	'cairo_matrix_t *' => 'Cairo::Matrix',
-	'cairo_glyph_t *' => 'Cairo::Glyph',
-	'cairo_font_extents_t *' => 'Cairo::Font::Extents',
-	'cairo_text_extents_t *' => 'Cairo::Text::Extents',
-	'glitz_surface_t *' => 'Glitz::Surface',
 );
 
 my %enums = (
@@ -48,16 +50,16 @@
 	cairo_operator_t => [qw/
 			CAIRO_OPERATOR_
 			CAIRO_OPERATOR_CLEAR
-			CAIRO_OPERATOR_SRC
-			CAIRO_OPERATOR_DST
+			CAIRO_OPERATOR_SOURCE
 			CAIRO_OPERATOR_OVER
-			CAIRO_OPERATOR_OVER_REVERSE
 			CAIRO_OPERATOR_IN
-			CAIRO_OPERATOR_IN_REVERSE
 			CAIRO_OPERATOR_OUT
-			CAIRO_OPERATOR_OUT_REVERSE
 			CAIRO_OPERATOR_ATOP
-			CAIRO_OPERATOR_ATOP_REVERSE
+			CAIRO_OPERATOR_DEST
+			CAIRO_OPERATOR_DEST_OVER
+			CAIRO_OPERATOR_DEST_IN
+			CAIRO_OPERATOR_DEST_OUT
+			CAIRO_OPERATOR_DEST_ATOP
 			CAIRO_OPERATOR_XOR
 			CAIRO_OPERATOR_ADD
 			CAIRO_OPERATOR_SATURATE
@@ -98,8 +100,15 @@
 			CAIRO_STATUS_INVALID_POP_GROUP
 			CAIRO_STATUS_NO_CURRENT_POINT
 			CAIRO_STATUS_INVALID_MATRIX
-			CAIRO_STATUS_NO_TARGET_SURFACE
+			CAIRO_STATUS_INVALID_STATUS
 			CAIRO_STATUS_NULL_POINTER
+			CAIRO_STATUS_INVALID_STRING
+			CAIRO_STATUS_INVALID_PATH_DATA
+			CAIRO_STATUS_READ_ERROR
+			CAIRO_STATUS_WRITE_ERROR
+			CAIRO_STATUS_SURFACE_FINISHED
+			CAIRO_STATUS_SURFACE_TYPE_MISMATCH
+			CAIRO_STATUS_PATTERN_TYPE_MISMATCH
 	/],
 	cairo_filter_t => [qw/
 			CAIRO_FILTER_
@@ -116,44 +125,57 @@
 			CAIRO_EXTEND_REPEAT
 			CAIRO_EXTEND_REFLECT
 	/],
+	cairo_path_data_type_t => [qw/
+			CAIRO_PATH_
+			CAIRO_PATH_MOVE_TO
+			CAIRO_PATH_LINE_TO
+			CAIRO_PATH_CURVE_TO
+			CAIRO_PATH_CLOSE_PATH
+	/],
+	cairo_content_t => [qw/
+			CAIRO_CONTENT_
+			CAIRO_CONTENT_COLOR
+			CAIRO_CONTENT_ALPHA
+			CAIRO_CONTENT_COLOR_ALPHA
+	/],
 );
 
+MakeHelper::do_enums (\%enums);
+
 my @xs_files = <*.xs>;
-my %xs = map { /^(.*)\.xs$/; $_ => "$1.c"; } @xs_files, 
-		MakeHelper::do_enums (\%enums);
 
 MakeHelper::write_boot (
 	xs_files => \@xs_files,
-	ignore => '(^Cairo$|Enums)',
+	ignore => '^Cairo$',
 );
 
 my @typemaps = MakeHelper::do_typemaps (\%objects, \%structs, \%enums);
 push @typemaps, 'cairo-perl.typemap';
 
-my %pm = (
-	'Cairo.pm' => '$(INST_LIBDIR)/Cairo.pm',
-);
+my $dep = ExtUtils::Depends->new ('Cairo');
+$dep->set_inc ('-I. -I'.$autogen_dir.' '.$cairo_cfg{cflags});
+$dep->set_libs ($cairo_cfg{libs});
+$dep->add_xs (@xs_files);
+$dep->add_c ('cairo-perl-enums.c');
+$dep->add_pm ('Cairo.pm' => '$(INST_LIBDIR)/Cairo.pm');
+$dep->add_typemaps (@typemaps);
+
+$dep->install (qw(cairo-perl.h));
+$dep->save_config ('build/IFiles.pm');
 
 WriteMakefile (
 	NAME => 'Cairo',
 	VERSION_FROM => 'Cairo.pm',
-	INC => '-I. -I'.$autogen_dir.' '.$cairo_cfg{cflags},
-	LIBS => $cairo_cfg{libs},
-	XS => \%xs,
-	PM => \%pm,
-	OBJECT => q/$(O_FILES)/,
 	XSPROTOARG => '-noprototypes',
-	TYPEMAPS => \@typemaps,
+	$dep->get_makefile_vars,
 );
 
-
 package MY;
- 
+
 sub postamble
 {
 	my $autogen_dir = $MakeHelper::autogen_dir;
 
 	"realclean ::
-	-\$(RM_RF) $autogen_dir CairoEnums.xs";
+	-\$(RM_RF) $autogen_dir cairo-perl-enums.c";
 }
-

Index: README
===================================================================
RCS file: /cvs/cairo/cairo-perl/README,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- README	5 Nov 2004 01:34:04 -0000	1.1
+++ README	12 Jul 2005 20:29:47 -0000	1.2
@@ -45,12 +45,14 @@
 In order to build it from source, you'll also need
 
   ExtUtils::PkgConfig (perl module)
+  ExtUtils::Depends (perl module)
 
 COPYRIGHT AND LICENSE
 
-Copyright (C) 2004 by the Cairo perl team
+Copyright (C) 2004-2005 by the cairo perl team
 
 Ross McFarland           rwmcfa1 at neces dot com
+Torsten Schoenfeld       kaffeetisch at gmx dot de
 
 This library is free software; you can redistribute it and/or modify it under
 the terms of the GNU Library General Public License as published by the Free

Index: cairo-perl.h
===================================================================
RCS file: /cvs/cairo/cairo-perl/cairo-perl.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- cairo-perl.h	6 Feb 2005 16:21:26 -0000	1.5
+++ cairo-perl.h	12 Jul 2005 20:29:47 -0000	1.6
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004 by the cairo  perl team (see the file README)
+ * Copyright (c) 2004-2005 by the cairo perl team (see the file README)
  *
  * Licensed under the LGPL, see LICENSE file for more information.
  *
@@ -16,10 +16,6 @@
 
 #include <cairo.h>
 
-#ifdef CAIRO_HAS_GLITZ_SURFACE
-# include <cairo-glitz.h>
-#endif
-
 #ifdef CAIRO_HAS_PNG_SURFACE
 # include <cairo-png.h>
 #endif
@@ -28,14 +24,60 @@
 # include <cairo-ps.h>
 #endif
 
-#ifdef CAIRO_HAS_XLIB_SURFACE
-# include <cairo-xlib.h>
+#ifdef CAIRO_HAS_PDF_SURFACE
+# include <cairo-pdf.h>
 #endif
 
-#define CAIRO_PERL_UNUSED(var) if (0) { (var) = (var); }
+#include <cairo-perl-enums.h>
+
+/*
+ * custom struct handling
+ */
+SV * newSVCairoFontExtents (cairo_font_extents_t * extents);
+
+SV * newSVCairoTextExtents (cairo_text_extents_t * extents);
+
+SV * newSVCairoGlyph (cairo_glyph_t * glyph);
+cairo_glyph_t * SvCairoGlyph (SV * sv);
+
+SV * newSVCairoPath (cairo_path_t * path);
+cairo_path_t * SvCairoPath (SV * sv);
+
+/*
+ * support for custom surface types
+ */
+typedef cairo_surface_t cairo_image_surface_t;
+#define cairo_image_surface_reference cairo_surface_reference
+#define cairo_image_surface_destroy cairo_surface_destroy
+#ifdef CAIRO_HAS_PDF_SURFACE
+  typedef cairo_surface_t cairo_pdf_surface_t;
+# define cairo_pdf_surface_reference cairo_surface_reference
+# define cairo_pdf_surface_destroy cairo_surface_destroy
+#endif
+#ifdef CAIRO_HAS_PS_SURFACE
+  typedef cairo_surface_t cairo_ps_surface_t;
+# define cairo_ps_surface_reference cairo_surface_reference
+# define cairo_ps_surface_destroy cairo_surface_destroy
+#endif
+
+/*
+ * support for custom pattern types
+ */
+typedef cairo_pattern_t cairo_surface_pattern_t;
+#define cairo_surface_pattern_reference cairo_pattern_reference
+#define cairo_surface_pattern_destroy cairo_pattern_destroy
+typedef cairo_pattern_t cairo_gradient_t;
+#define cairo_gradient_reference cairo_pattern_reference
+#define cairo_gradient_destroy cairo_pattern_destroy
+typedef cairo_pattern_t cairo_linear_gradient_t;
+#define cairo_linear_gradient_reference cairo_pattern_reference
+#define cairo_linear_gradient_destroy cairo_pattern_destroy
+typedef cairo_pattern_t cairo_radial_gradient_t;
+#define cairo_radial_gradient_reference cairo_pattern_reference
+#define cairo_radial_gradient_destroy cairo_pattern_destroy
+
+#include <cairo-perl-auto.h>
 
-/* XXX: copied/borrowed from gtk2-perl */
-void _cairo_perl_call_XS (pTHX_ void (*subaddr) (pTHX_ CV *), CV * cv, SV ** mark);
 /* XXX: copied/borrowed from gtk2-perl
  *
  * call the boot code of a module by symbol rather than by name.
@@ -45,15 +87,14 @@
  * exported to perl.  if the file has MODULE = Foo::Bar, the boot symbol
  * would be boot_Foo__Bar.
  */
-
+void _cairo_perl_call_XS (pTHX_ void (*subaddr) (pTHX_ CV *), CV * cv, SV ** mark);
 #define CAIRO_PERL_CALL_BOOT(name)				\
 	{							\
 		extern XS(name);				\
 		_cairo_perl_call_XS (aTHX_ name, cv, mark);	\
 	}
 
-#include <cairo-perl-enums.h>
-
+#define CAIRO_PERL_UNUSED(var) if (0) { (var) = (var); }
 
 #ifdef CAIRO_DEBUG
 # define DBG(format, args...)	fprintf (stderr, format , ## args)
@@ -61,21 +102,4 @@
 # define DBG
 #endif
 
-/* XXX: both of these need extensive testing */
-
-#define DOUBLES_DECLARE	\
-	int i, n; double * pts;
-#define DOUBLES_SLURP_FROM_STACK(first)				\
-	n = (items - first);					\
-	pts = (double*)malloc (sizeof (double) * n);		\
-	if (!pts)						\
-		croak ("malloc failure for (%d) elements", n);	\
-	for (i = first ; i < items ; i++) {			\
-		pts[i-first] = SvIV (ST (i));			\
-	}
-#define DOUBLES_LEN	n
-#define DOUBLES_ARRAY	pts
-#define DOUBLES_CLEANUP	\
-	free (pts);
-
-#endif /* _CAIRO_PERL_G_ */
+#endif /* _CAIRO_PERL_H_ */

Index: cairo-perl.typemap
===================================================================
RCS file: /cvs/cairo/cairo-perl/cairo-perl.typemap,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- cairo-perl.typemap	5 Nov 2004 01:34:04 -0000	1.1
+++ cairo-perl.typemap	12 Jul 2005 20:29:47 -0000	1.2
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004 by the cairo  perl team (see the file README)
+# Copyright (c) 2004-2005 by the cairo perl team (see the file README)
 #
 # Licensed under the LGPL, see LICENSE file for more information.
 #
@@ -8,16 +8,29 @@
 
 TYPEMAP
 
-# Xlib
-Display *	T_PTROBJ
-Drawable 	T_PTROBJ
-Visual *	T_PTROBJ
-Colormap	T_PTROBJ
+cairo_font_extents_t *	T_CAIRO_FONT_EXTENTS
+cairo_text_extents_t *	T_CAIRO_TEXT_EXTENTS
+cairo_glyph_t *		T_CAIRO_GLYPH
+cairo_path_t *		T_CAIRO_PATH
 
-# XCB
-XCBConnection *	T_PTROBJ
-XCBDRAWABLE	T_PTROBJ
-XCBVISUALTYPE *	T_PTROBJ
+INPUT
 
-# others
-const unsigned char *	T_PV
+T_CAIRO_GLYPH
+	$var = SvCairoGlyph ($arg);
+
+T_CAIRO_PATH
+	$var = SvCairoPath ($arg);
+
+OUTPUT
+
+T_CAIRO_FONT_EXTENTS
+	$arg = newSVCairoFontExtents ($var);
+
+T_CAIRO_TEXT_EXTENTS
+	$arg = newSVCairoTextExtents ($var);
+
+T_CAIRO_GLYPH
+	$arg = newSVCairoGlyph ($var);
+
+T_CAIRO_PATH
+	$arg = newSVCairoPath ($var);




More information about the cairo-commit mailing list