[perl-Cairo] Wrap the PDF version API
- From: Torsten Schönfeld <tsch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [perl-Cairo] Wrap the PDF version API
- Date: Sun, 1 May 2011 18:03:12 +0000 (UTC)
commit 9b8ec24521a18e73160bde6d3a25f64483aabddc
Author: Torsten Schönfeld <kaffeetisch gmx de>
Date: Sun May 1 19:03:18 2011 +0200
Wrap the PDF version API
CairoSurface.xs | 34 ++++++++++++++++++++++++++++++++++
Makefile.PL | 11 +++++++++++
t/CairoSurface.t | 28 ++++++++++++++++++++++++----
3 files changed, 69 insertions(+), 4 deletions(-)
---
diff --git a/CairoSurface.xs b/CairoSurface.xs
index 4fa7b2d..bdee9bd 100644
--- a/CairoSurface.xs
+++ b/CairoSurface.xs
@@ -506,6 +506,40 @@ void cairo_pdf_surface_set_size (cairo_surface_t *surface, double width_in_point
#endif
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 10, 0)
+
+void cairo_pdf_surface_restrict_to_version (cairo_surface_t *surface, cairo_pdf_version_t version);
+
+# void cairo_pdf_get_versions (cairo_pdf_version_t const **versions, int *num_versions);
+void
+cairo_pdf_surface_get_versions (class=NULL)
+ PREINIT:
+ cairo_pdf_version_t const *versions = NULL;
+ int num_versions = 0, i;
+ PPCODE:
+ PERL_UNUSED_VAR (ax);
+ cairo_pdf_get_versions (&versions, &num_versions);
+ EXTEND (sp, num_versions);
+ for (i = 0; i < num_versions; i++)
+ PUSHs (sv_2mortal (newSVCairoPdfVersion (versions[i])));
+
+# const char * cairo_pdf_version_to_string (cairo_pdf_version_t version);
+const char *
+cairo_pdf_surface_version_to_string (...)
+ CODE:
+ if (items == 1) {
+ RETVAL = cairo_pdf_version_to_string (SvCairoPdfVersion (ST (0)));
+ } else if (items == 2) {
+ RETVAL = cairo_pdf_version_to_string (SvCairoPdfVersion (ST (1)));
+ } else {
+ RETVAL = NULL;
+ croak ("Usage: Cairo::PdfSurface::version_to_string (version) or Cairo::PdfSurface->version_to_string (version)");
+ }
+ OUTPUT:
+ RETVAL
+
+#endif
+
#endif
# --------------------------------------------------------------------------- #
diff --git a/Makefile.PL b/Makefile.PL
index 9a45a87..12f5949 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -227,6 +227,7 @@ my $have_cairo_1_2 = ExtUtils::PkgConfig->atleast_version("cairo", "1.2.0");
my $have_cairo_1_4 = ExtUtils::PkgConfig->atleast_version("cairo", "1.4.0");
my $have_cairo_1_6 = ExtUtils::PkgConfig->atleast_version("cairo", "1.6.0");
my $have_cairo_1_8 = ExtUtils::PkgConfig->atleast_version("cairo", "1.8.0");
+my $have_cairo_1_10 = ExtUtils::PkgConfig->atleast_version("cairo", "1.10.0");
if ($have_cairo_1_2) {
add_new_enum_values(
@@ -324,6 +325,16 @@ if ($have_cairo_1_8) {
$flags{cairo_text_cluster_flags_t} = [];
}
+if ($have_cairo_1_10) {
+ $enums{cairo_pdf_version_t} = [qw/
+ CAIRO_PDF_VERSION_
+ CAIRO_PDF_VERSION_1_4
+ CAIRO_PDF_VERSION_1_5
+ /];
+} else {
+ $enums{cairo_pdf_version_t} = [];
+}
+
# --------------------------------------------------------------------------- #
my %object_guards = ();
diff --git a/t/CairoSurface.t b/t/CairoSurface.t
index d088b36..50ea475 100644
--- a/t/CairoSurface.t
+++ b/t/CairoSurface.t
@@ -12,7 +12,7 @@ use warnings;
use Config; # for byteorder
-use Test::More tests => 77;
+use Test::More tests => 83;
use constant IMG_WIDTH => 256;
use constant IMG_HEIGHT => 256;
@@ -195,7 +195,7 @@ SKIP: {
}
SKIP: {
- skip 'pdf surface', 7
+ skip 'pdf surface', 13
unless Cairo::HAS_PDF_SURFACE;
my $surf = Cairo::PdfSurface->create ('tmp.pdf', IMG_WIDTH, IMG_HEIGHT);
@@ -213,8 +213,6 @@ SKIP: {
$surf = $surf->create_similar ('alpha', IMG_WIDTH, IMG_HEIGHT);
isa_ok ($surf, 'Cairo::Surface');
- unlink 'tmp.pdf';
-
SKIP: {
skip 'create_for_stream on pdf surfaces', 4
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 2, 0);
@@ -228,6 +226,28 @@ SKIP: {
isa_ok ($surf, 'Cairo::PdfSurface');
isa_ok ($surf, 'Cairo::Surface');
}
+
+ SKIP: {
+ skip 'new stuff', 6
+ unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 10, 0);
+
+ my $surf = Cairo::PdfSurface->create ('tmp.pdf', IMG_WIDTH, IMG_HEIGHT);
+ $surf->restrict_to_version ('1-4');
+ $surf->restrict_to_version ('1-5');
+
+ my @versions = Cairo::PdfSurface::get_versions();
+ ok (scalar @versions > 0);
+ is ($versions[0], '1-4');
+
+ @versions = Cairo::PdfSurface->get_versions();
+ ok (scalar @versions > 0);
+ is ($versions[0], '1-4');
+
+ like (Cairo::PdfSurface::version_to_string('1-4'), qr/1\.4/);
+ like (Cairo::PdfSurface->version_to_string('1-4'), qr/1\.4/);
+ }
+
+ unlink 'tmp.pdf';
}
SKIP: {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]