[cairo-commit] cairo-perl Cairo.xs, 1.14, 1.15 CairoPattern.xs, 1.11, 1.12 ChangeLog, 1.44, 1.45 Makefile.PL, 1.20, 1.21 cairo-perl-private.h, 1.4, 1.5

Torsten Schoenfeld commit at pdx.freedesktop.org
Thu Nov 9 11:43:46 PST 2006


Committed by: tsch

Update of /cvs/cairo/cairo-perl
In directory kemper:/tmp/cvs-serv21345

Modified Files:
	Cairo.xs CairoPattern.xs ChangeLog Makefile.PL 
	cairo-perl-private.h 
Log Message:
	* Cairo.xs, cairo-perl-private.h: Export cairo_perl_alloc_temp
	privately.

	* Cairo.xs: Remove the DOUBLES_ macros and inline them.  They were
	used only in one place.

	* Cairo.xs, t/Cairo.t: Wrap cairo_get_dash.

	* CairoPattern.xs, cairo-perl-private.h, t/CairoPattern.t: Wrap
	cairo_pattern_get_rgba, cairo_pattern_get_surface,
	cairo_pattern_get_color_stop_rgba, cairo_pattern_get_points, and
	cairo_pattern_get_circles.

	* Makefile.PL: Support new cairo_status_t values.


Index: Cairo.xs
===================================================================
RCS file: /cvs/cairo/cairo-perl/Cairo.xs,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- Cairo.xs	10 Aug 2006 17:34:40 -0000	1.14
+++ Cairo.xs	9 Nov 2006 19:43:43 -0000	1.15
@@ -29,23 +29,6 @@
 
 /* ------------------------------------------------------------------------- */
 
-#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);
-
-/* ------------------------------------------------------------------------- */
-
 /* Copied from Glib/GType.xs. */
 void
 cairo_perl_set_isa (const char *child_package,
@@ -169,8 +152,8 @@
 /* ------------------------------------------------------------------------- */
 
 /* taken from Glib/Glib.xs */
-static void *
-alloc_temp (int nbytes)
+void *
+cairo_perl_alloc_temp (int nbytes)
 {
 	dTHR;
 	SV * s;
@@ -217,7 +200,7 @@
 		croak ("cairo_glyph_t must be a hash reference");
 
 	hv = (HV *) SvRV (sv);
-	glyph = alloc_temp (sizeof (cairo_glyph_t));
+	glyph = cairo_perl_alloc_temp (sizeof (cairo_glyph_t));
 
 	value = hv_fetch (hv, "index", 5, 0);
 	if (value && SvOK (*value))
@@ -328,14 +311,27 @@
 void cairo_set_line_join (cairo_t * cr, cairo_line_join_t line_join);
 
 ##void cairo_set_dash (cairo_t * cr, double * dashes, int ndash, double offset);
-void cairo_set_dash (cairo_t * cr, double offset, dash1, ...)
+void cairo_set_dash (cairo_t * cr, double offset, ...)
     PREINIT:
-	DOUBLES_DECLARE
+	int i, n;
+	double *pts;
     CODE:
-	DOUBLES_SLURP_FROM_STACK (2)
-	cairo_set_dash (cr, DOUBLES_ARRAY, DOUBLES_LEN, offset);
+#define FIRST 2
+	n = (items - FIRST);
+	if (n == 0) {
+		pts = NULL;
+	} else {
+		pts = malloc (sizeof (double) * n);
+		if (!pts)
+			croak ("malloc failure for (%d) elements", n);
+		for (i = FIRST ; i < items ; i++)
+			pts[i - FIRST] = SvNV (ST (i));
+	}
+#undef FIRST
+	cairo_set_dash (cr, pts, n, offset);
     CLEANUP:
-	DOUBLES_CLEANUP
+	if (pts)
+		free (pts);
 
 void cairo_set_miter_limit (cairo_t * cr, double limit);
 
@@ -544,6 +540,35 @@
 
 double cairo_get_miter_limit (cairo_t *cr);
 
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 3, 0) /* FIXME: 1.4 */
+
+## cairo_status_t cairo_get_dash_count (cairo_t *cr, int *count);
+## cairo_status_t cairo_get_dash (cairo_t *cr, double *dashes, double *offset);
+void cairo_get_dash (cairo_t *cr)
+    PREINIT:
+	cairo_status_t status;
+	int count, i;
+	double *dashes, offset;
+    PPCODE:
+	status = cairo_get_dash_count (cr, &count);
+	CAIRO_PERL_CHECK_STATUS (status);
+	if (count == 0) {
+		dashes = NULL;
+	} else {
+		dashes = malloc (sizeof (double) * count);
+		if (!dashes)
+			croak ("malloc failure for (%d) elements", count);
+	}
+	status = cairo_get_dash (cr, dashes, &offset);
+	CAIRO_PERL_CHECK_STATUS (status);
+	EXTEND (sp, count + 1);
+	PUSHs (sv_2mortal (newSVnv (offset)));
+	for (i = 0; i < count; i++)
+		PUSHs (sv_2mortal (newSVnv (dashes[i])));
+	free (dashes);
+
+#endif
+
 ##void cairo_get_matrix (cairo_t *cr, cairo_matrix_t *matrix);
 cairo_matrix_t * cairo_get_matrix (cairo_t *cr)
     PREINIT:

Index: CairoPattern.xs
===================================================================
RCS file: /cvs/cairo/cairo-perl/CairoPattern.xs,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- CairoPattern.xs	10 Aug 2006 17:34:40 -0000	1.11
+++ CairoPattern.xs	9 Nov 2006 19:43:43 -0000	1.12
@@ -108,6 +108,24 @@
 	cairo_perl_package_table_insert (RETVAL, "Cairo::SolidPattern");
 #endif
 
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 3, 0) /* FIXME: 1.4 */
+
+## cairo_status_t cairo_pattern_get_rgba (cairo_pattern_t *pattern, double *red, double *green, double *blue, double *alpha);
+void cairo_pattern_get_rgba (cairo_pattern_t *pattern)
+    PREINIT:
+	cairo_status_t status;
+	double red, green, blue, alpha;
+    PPCODE:
+	status = cairo_pattern_get_rgba (pattern, &red, &green, &blue, &alpha);
+	CAIRO_PERL_CHECK_STATUS (status);
+	EXTEND (sp, 4);
+	PUSHs (sv_2mortal (newSVnv (red)));
+	PUSHs (sv_2mortal (newSVnv (green)));
+	PUSHs (sv_2mortal (newSVnv (blue)));
+	PUSHs (sv_2mortal (newSVnv (alpha)));
+
+#endif
+
 # --------------------------------------------------------------------------- #
 
 MODULE = Cairo::Pattern	PACKAGE = Cairo::SurfacePattern	PREFIX = cairo_pattern_
@@ -132,6 +150,20 @@
 
 cairo_filter_t cairo_pattern_get_filter (cairo_pattern_t * pattern);
 
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 3, 0) /* FIXME: 1.4 */
+
+## cairo_status_t cairo_pattern_get_surface (cairo_pattern_t *pattern, cairo_surface_t **surface);
+cairo_surface_t * cairo_pattern_get_surface (cairo_pattern_t *pattern)
+    PREINIT:
+	cairo_status_t status;
+    CODE:
+	status = cairo_pattern_get_surface (pattern, &RETVAL);
+	CAIRO_PERL_CHECK_STATUS (status);
+    OUTPUT:
+	RETVAL
+
+#endif
+
 # --------------------------------------------------------------------------- #
 
 MODULE = Cairo::Pattern	PACKAGE = Cairo::Gradient	PREFIX = cairo_pattern_
@@ -143,6 +175,34 @@
 
 void cairo_pattern_add_color_stop_rgba (cairo_pattern_t *pattern, double offset, double red, double green, double blue, double alpha);
 
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 3, 0) /* FIXME: 1.4 */
+
+## cairo_status_t cairo_pattern_get_color_stop_count (cairo_pattern_t *pattern, int *count);
+## cairo_status_t cairo_pattern_get_color_stop_rgba (cairo_pattern_t *pattern, int index, double *offset, double *red, double *green, double *blue, double *alpha);
+void cairo_pattern_get_color_stops (cairo_pattern_t *pattern)
+    PREINIT:
+	cairo_status_t status;
+	int count, i;
+	double offset, red, green, blue, alpha;
+    PPCODE:
+	status = cairo_pattern_get_color_stop_count (pattern, &count);
+	CAIRO_PERL_CHECK_STATUS (status);
+	EXTEND (sp, count);
+	for (i = 0; i < count; i++) {
+		AV *av;
+		status = cairo_pattern_get_color_stop_rgba (pattern, i, &offset, &red, &green, &blue, &alpha);
+		CAIRO_PERL_CHECK_STATUS (status);
+		av = newAV ();
+		av_push (av, newSVnv (offset));
+		av_push (av, newSVnv (red));
+		av_push (av, newSVnv (green));
+		av_push (av, newSVnv (blue));
+		av_push (av, newSVnv (alpha));
+		PUSHs (sv_2mortal (newRV_noinc ((SV *) av)));
+	}
+
+#endif
+
 # --------------------------------------------------------------------------- #
 
 MODULE = Cairo::Pattern	PACKAGE = Cairo::LinearGradient	PREFIX = cairo_pattern_
@@ -159,6 +219,24 @@
     OUTPUT:
 	RETVAL
 
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 3, 0) /* FIXME: 1.4 */
+
+## cairo_status_t cairo_pattern_get_linear_points (cairo_pattern_t *pattern, double *x0, double *y0, double *x1, double *y1);
+void cairo_pattern_get_points (cairo_pattern_t *pattern)
+    PREINIT:
+	cairo_status_t status;
+	double x0, y0, x1, y1;
+    PPCODE:
+	status = cairo_pattern_get_linear_points (pattern, &x0, &y0, &x1, &y1);
+	CAIRO_PERL_CHECK_STATUS (status);
+	EXTEND (sp, 4);
+	PUSHs (sv_2mortal (newSVnv (x0)));
+	PUSHs (sv_2mortal (newSVnv (y0)));
+	PUSHs (sv_2mortal (newSVnv (x1)));
+	PUSHs (sv_2mortal (newSVnv (y1)));
+
+#endif
+
 # --------------------------------------------------------------------------- #
 
 MODULE = Cairo::Pattern	PACKAGE = Cairo::RadialGradient	PREFIX = cairo_pattern_
@@ -174,3 +252,23 @@
 #endif
     OUTPUT:
 	RETVAL
+
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 3, 0) /* FIXME: 1.4 */
+
+## cairo_status_t cairo_pattern_get_radial_circles (cairo_pattern_t *pattern, double *x0, double *y0, double *r0, double *x1, double *y1, double *r1)
+void cairo_pattern_get_circles (cairo_pattern_t *pattern)
+    PREINIT:
+	cairo_status_t status;
+	double x0, y0, r0, x1, y1, r1;
+    PPCODE:
+	status = cairo_pattern_get_radial_circles (pattern, &x0, &y0, &r0, &x1, &y1, &r1);
+	CAIRO_PERL_CHECK_STATUS (status);
+	EXTEND (sp, 6);
+	PUSHs (sv_2mortal (newSVnv (x0)));
+	PUSHs (sv_2mortal (newSVnv (y0)));
+	PUSHs (sv_2mortal (newSVnv (r0)));
+	PUSHs (sv_2mortal (newSVnv (x1)));
+	PUSHs (sv_2mortal (newSVnv (y1)));
+	PUSHs (sv_2mortal (newSVnv (r1)));
+
+#endif

Index: ChangeLog
===================================================================
RCS file: /cvs/cairo/cairo-perl/ChangeLog,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- ChangeLog	9 Nov 2006 19:37:15 -0000	1.44
+++ ChangeLog	9 Nov 2006 19:43:43 -0000	1.45
@@ -1,5 +1,22 @@
 2006-11-09	tsch
 
+	* Cairo.xs, cairo-perl-private.h: Export cairo_perl_alloc_temp
+	privately.
+
+	* Cairo.xs: Remove the DOUBLES_ macros and inline them.  They were
+	used only in one place.
+
+	* Cairo.xs, t/Cairo.t: Wrap cairo_get_dash.
+
+	* CairoPattern.xs, cairo-perl-private.h, t/CairoPattern.t: Wrap
+	cairo_pattern_get_rgba, cairo_pattern_get_surface,
+	cairo_pattern_get_color_stop_rgba, cairo_pattern_get_points, and
+	cairo_pattern_get_circles.
+
+	* Makefile.PL: Support new cairo_status_t values.
+
+2006-11-09	tsch
+
 	* Cairo.pm, NEWS, README: Stable release 1.02.
 
 2006-11-09	tsch

Index: Makefile.PL
===================================================================
RCS file: /cvs/cairo/cairo-perl/Makefile.PL,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- Makefile.PL	27 Aug 2006 12:42:32 -0000	1.20
+++ Makefile.PL	9 Nov 2006 19:43:43 -0000	1.21
@@ -207,7 +207,10 @@
 	/],
 );
 
+# --------------------------------------------------------------------------- #
+
 my $have_cairo_1_2 = ExtUtils::PkgConfig->atleast_version("cairo", "1.2.0");
+my $have_cairo_1_4 = ExtUtils::PkgConfig->atleast_version("cairo", "1.3.0"); # FIXME: 1.4
 
 if ($have_cairo_1_2) {
 	my %new = (
@@ -268,6 +271,21 @@
 	$enums{cairo_svg_version_t} = [];
 }
 
+if ($have_cairo_1_4) {
+	my %new = (
+		cairo_status_t => [qw/CAIRO_STATUS_INVALID_INDEX
+		                      CAIRO_STATUS_CLIP_NOT_REPRESENTABLE/],
+	);
+
+	foreach my $enum (keys %new) {
+		foreach my $value (@{$new{$enum}}) {
+			push @{$enums{$enum}}, $value;
+		}
+	}
+}
+
+# --------------------------------------------------------------------------- #
+
 my %enum_guards = (
 	cairo_svg_version_t => $backend_guards{cairo_svg_surface_t},
 );

Index: cairo-perl-private.h
===================================================================
RCS file: /cvs/cairo/cairo-perl/cairo-perl-private.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- cairo-perl-private.h	10 Aug 2006 17:34:40 -0000	1.4
+++ cairo-perl-private.h	9 Nov 2006 19:43:43 -0000	1.5
@@ -10,6 +10,8 @@
 #ifndef _CAIRO_PERL_PRIVATE_H_
 #define _CAIRO_PERL_PRIVATE_H_
 
+void * cairo_perl_alloc_temp (int nbytes);
+
 void cairo_perl_set_isa (const char * child_package, const char * parent_package);
 
 cairo_matrix_t * cairo_perl_copy_matrix (cairo_matrix_t *matrix);
@@ -22,4 +24,11 @@
 
 #endif
 
+#define CAIRO_PERL_CHECK_STATUS(status)				\
+	if (CAIRO_STATUS_SUCCESS != status) {			\
+		SV *errsv = get_sv ("@", TRUE);			\
+		sv_setsv (errsv, newSVCairoStatus (status));	\
+		croak (Nullch);					\
+	}
+
 #endif /* _CAIRO_PERL_PRIVATE_H_ */



More information about the cairo-commit mailing list