[perl-Cairo] Fix compiling and testing against older versions of cairo



commit 21dd8a0600cbfac46723c7745b377fce94c8bdc3
Author: Torsten SchÃnfeld <kaffeetisch gmx de>
Date:   Sat Mar 31 12:34:11 2012 +0200

    Fix compiling and testing against older versions of cairo

 CairoFont.xs    |   14 +++++++++++++-
 CairoSurface.xs |    4 ++++
 Makefile.PL     |    7 +++----
 t/CairoFont.t   |   10 +++++-----
 t/CairoPath.t   |    8 +++++++-
 5 files changed, 32 insertions(+), 11 deletions(-)
---
diff --git a/CairoFont.xs b/CairoFont.xs
index 41a4331..c1af1d8 100644
--- a/CairoFont.xs
+++ b/CairoFont.xs
@@ -28,8 +28,12 @@ get_package (cairo_font_face_t *face)
 
 	    /* These aren't wrapped yet: */
 	    case CAIRO_FONT_TYPE_WIN32:
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 6, 0)
 	    case CAIRO_FONT_TYPE_QUARTZ:
+#endif
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 8, 0)
 	    case CAIRO_FONT_TYPE_USER:
+#endif
 		package = "Cairo::FontFace";
 		break;
 
@@ -41,7 +45,7 @@ get_package (cairo_font_face_t *face)
 
 	return package;
 #else
-	const char *package = cairo_perl_package_table_lookup (pattern);
+	const char *package = cairo_perl_package_table_lookup (face);
 	return package ? package : "Cairo::FontFace";
 #endif
 }
@@ -84,6 +88,10 @@ cairo_font_face_t_noinc *
 cairo_toy_font_face_create (class, const char *family, cairo_font_slant_t slant, cairo_font_weight_t weight)
     C_ARGS:
 	family, slant, weight
+    POSTCALL:
+#if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 2, 0)
+	cairo_perl_package_table_insert (RETVAL, "Cairo::ToyFontFace");
+#endif
 
 const char * cairo_toy_font_face_get_family (cairo_font_face_t *font_face);
 
@@ -101,6 +109,10 @@ MODULE = Cairo::Font	PACKAGE = Cairo::ScaledFont	PREFIX = cairo_scaled_font_
 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, const cairo_font_options_t *options)
     C_ARGS:
 	font_face, font_matrix, ctm, options
+    POSTCALL:
+#if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 2, 0)
+	cairo_perl_package_table_insert (RETVAL, "Cairo::ScaledFont");
+#endif
 
 cairo_status_t cairo_scaled_font_status (cairo_scaled_font_t *scaled_font);
 
diff --git a/CairoSurface.xs b/CairoSurface.xs
index 59a4b06..d4d3c82 100644
--- a/CairoSurface.xs
+++ b/CairoSurface.xs
@@ -98,9 +98,13 @@ get_package (cairo_surface_t *surface)
 	    case CAIRO_SURFACE_TYPE_WIN32:
 	    case CAIRO_SURFACE_TYPE_BEOS:
 	    case CAIRO_SURFACE_TYPE_DIRECTFB:
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 4, 0)
 	    case CAIRO_SURFACE_TYPE_OS2:
+#endif
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 6, 0)
 	    case CAIRO_SURFACE_TYPE_WIN32_PRINTING:
 	    case CAIRO_SURFACE_TYPE_QUARTZ_IMAGE:
+#endif
 #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 10, 0)
 	    case CAIRO_SURFACE_TYPE_SCRIPT:
 	    case CAIRO_SURFACE_TYPE_QT:
diff --git a/Makefile.PL b/Makefile.PL
index 2adf424..39afa77 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -321,9 +321,6 @@ if ($have_cairo_1_2) {
 		CAIRO_SURFACE_TYPE_BEOS
 		CAIRO_SURFACE_TYPE_DIRECTFB
 		CAIRO_SURFACE_TYPE_SVG
-		CAIRO_SURFACE_TYPE_OS2
-		CAIRO_SURFACE_TYPE_WIN32_PRINTING
-		CAIRO_SURFACE_TYPE_QUARTZ_IMAGE
 	/];
 
 	$enums{cairo_svg_version_t} = [qw/
@@ -354,6 +351,7 @@ if ($have_cairo_1_4) {
 	add_new_enum_values(
 		cairo_status_t => [qw/CAIRO_STATUS_INVALID_INDEX
 		                      CAIRO_STATUS_CLIP_NOT_REPRESENTABLE/],
+		cairo_surface_type_t => [qw/CAIRO_SURFACE_TYPE_OS2/],
 	);
 
 	push @exports, qw/newSVCairoRectangle
@@ -365,7 +363,8 @@ if ($have_cairo_1_6) {
 		cairo_font_type_t => [qw/CAIRO_FONT_TYPE_QUARTZ/],
 		cairo_status_t => [qw/CAIRO_STATUS_TEMP_FILE_ERROR
 				      CAIRO_STATUS_INVALID_STRIDE/],
-
+		cairo_surface_type_t => [qw/CAIRO_SURFACE_TYPE_WIN32_PRINTING
+					    CAIRO_SURFACE_TYPE_QUARTZ_IMAGE/],
 	);
 
 	$enums{cairo_ps_level_t} = [qw/
diff --git a/t/CairoFont.t b/t/CairoFont.t
index f9571dc..d8e974c 100644
--- a/t/CairoFont.t
+++ b/t/CairoFont.t
@@ -62,17 +62,17 @@ my $ctm = Cairo::Matrix->init_identity;
 my $font = Cairo::ScaledFont->create ($face, $matrix, $ctm, $options);
 isa_ok ($font, 'Cairo::ScaledFont');
 
-$cr->set_scaled_font ($font);
-is ($font->status, 'success');
-is ($cr->status, 'success');
-
 isa_ok ($font->extents, 'HASH');
 isa_ok ($font->glyph_extents ({ index => 1, x => 2, y => 3 }), 'HASH');
 
 SKIP: {
-	skip 'new stuff', 6
+	skip 'new stuff', 8
 		unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 2, 0);
 
+	$cr->set_scaled_font ($font);
+	is ($font->status, 'success');
+	is ($cr->status, 'success');
+
 	ok (defined $font->get_type);
 
 	isa_ok ($font->text_extents('Bla'), 'HASH');
diff --git a/t/CairoPath.t b/t/CairoPath.t
index e515172..770e464 100644
--- a/t/CairoPath.t
+++ b/t/CairoPath.t
@@ -11,11 +11,17 @@ use strict;
 use warnings;
 use Cairo;
 
-use Test::More tests => 6;
+use Test::More;
 
 use constant IMG_WIDTH => 256;
 use constant IMG_HEIGHT => 256;
 
+if (Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 4, 0)) {
+  plan tests => 6;
+} else {
+  plan skip_all => 'path behavior not predictable on cairo < 1.4';
+}
+
 my $surf = Cairo::ImageSurface->create ('rgb24', IMG_WIDTH, IMG_HEIGHT);
 my $cr = Cairo::Context->create ($surf);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]