Re: Perl-Cairo patches

2020-11-08 Thread Torsten Schoenfeld

On 08.11.20 21:12, Torsten Schoenfeld wrote:

Patch 2 adds Perl bindings for:
 cairo_surface_set_mime_data
 cairo_surface_get_mime_data
 cairo_surface_supports_mime_type
 cairo_recording_surface_get_extents

Patch 2 also adds an example file to demonstrate the new bindings.


Looks good too, but could you also be bothered to add docs and unit
tests for the new functionality [...]?


I'm sorry, I misread the patch initially  It already contains unit tests
and docs.  So I committed it, with a few tiny adjustments.  Thanks for
your work!

-Torsten
___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-perl-list


Re: Perl-Cairo patches

2020-11-08 Thread Torsten Schoenfeld

On 31.10.20 15:51, Raymond S Brand wrote:

Patch 1 updates the MANIFEST file to reflect the filename case change of
the "doap" file that was changed last year.


Looks good, applied and pushed.  Thanks!


Patch 2 adds Perl bindings for:
 cairo_surface_set_mime_data
 cairo_surface_get_mime_data
 cairo_surface_supports_mime_type
 cairo_recording_surface_get_extents

Patch 2 also adds an example file to demonstrate the new bindings.


Looks good too, but could you also be bothered to add docs and unit
tests for the new functionality and perhaps wrappers for all the
CAIRO_MIME_TYPE_* defines with newCONSTSUB as in
?

-Torsten
___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-perl-list


Perl-Cairo patches

2020-11-01 Thread Raymond S Brand

The attached 2 patches are for the Perl-Cairo project.

Patch 1 updates the MANIFEST file to reflect the filename case change of 
the "doap" file that was changed last year.


Patch 2 adds Perl bindings for:
cairo_surface_set_mime_data
cairo_surface_get_mime_data
cairo_surface_supports_mime_type
cairo_recording_surface_get_extents

Patch 2 also adds an example file to demonstrate the new bindings.


Raymond S Brand
>From 778856700523d44d609947b5acc89fd65a545c7b Mon Sep 17 00:00:00 2001
From: Raymond S Brand 
Date: Sat, 31 Oct 2020 10:11:15 -0400
Subject: [PATCH 1/2] Update MANIFEST to reflect filename case change

Followup to a4c8f7d7.
---
 MANIFEST | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MANIFEST b/MANIFEST
index ce52091..83b5019 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -37,7 +37,7 @@ Makefile.PL
 MANIFEST
 MANIFEST.SKIP
 NEWS
-perl-Cairo.doap
+perl-cairo.doap
 ppport.h
 README
 t/00-loading.t
-- 
2.20.1

>From 70c0c58ead7766a5bff22ca8582c274c2963e0a7 Mon Sep 17 00:00:00 2001
From: Raymond S Brand 
Date: Sat, 31 Oct 2020 10:16:25 -0400
Subject: [PATCH 2/2] Add Perl bindings for Cairo surface mime type
 setting/getting and get extents

Also add an example to exercise the new bindings.
---
 CairoSurface.xs|  59 
 MANIFEST   |   1 +
 examples/mime-unique-id.pl | 281 +
 lib/Cairo.pm   |  22 +++
 t/CairoSurface.t   |  38 -
 5 files changed, 399 insertions(+), 2 deletions(-)
 create mode 100755 examples/mime-unique-id.pl

diff --git a/CairoSurface.xs b/CairoSurface.xs
index 11468ec..d14caf2 100644
--- a/CairoSurface.xs
+++ b/CairoSurface.xs
@@ -295,6 +295,14 @@ read_func_marshaller (void *closure,
 
 /* -- */
 
+static void
+data_destroy (void *data)
+{
+	SvREFCNT_dec ((SV *) data);
+}
+
+/* -- */
+
 MODULE = Cairo::Surface	PACKAGE = Cairo::Surface	PREFIX = cairo_surface_
 
 void DESTROY (cairo_surface_t * surface);
@@ -374,6 +382,41 @@ cairo_content_t cairo_surface_get_content (cairo_surface_t *surface);
 
 #endif
 
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 10, 0)
+
+# cairo_status_t cairo_surface_set_mime_data (cairo_surface_t *surface, const char *mime_type, const unsigned char *data, unsigned long  length, cairo_destroy_func_t destroy, void *closure);
+cairo_status_t
+cairo_surface_set_mime_data (cairo_surface_t *surface, const char *mime_type, SV *data);
+PREINIT:
+	const unsigned char *mime_data;
+	unsigned long length;
+CODE:
+	SvREFCNT_inc(data);
+	mime_data = SvPV(data, length);
+	RETVAL = cairo_surface_set_mime_data (surface, mime_type, mime_data, length, data_destroy, data);
+OUTPUT:
+	RETVAL
+
+# void cairo_surface_get_mime_data (cairo_surface_t *surface, const char *mime_type, const unsigned char **data, unsigned long *length);
+SV *
+cairo_surface_get_mime_data (cairo_surface_t *surface, const char *mime_type);
+PREINIT:
+	const unsigned char *data;
+	unsigned long length;
+CODE:
+	cairo_surface_get_mime_data(surface, mime_type, , );
+	RETVAL = newSVpvn(data, length);
+OUTPUT:
+	RETVAL
+
+#endif
+
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0)
+
+cairo_bool_t cairo_surface_supports_mime_type (cairo_surface_t *surface, const char *mime_type);
+
+#endif
+
 #ifdef CAIRO_HAS_PNG_FUNCTIONS
 
 cairo_status_t cairo_surface_write_to_png (cairo_surface_t *surface, const char *filename);
@@ -765,6 +808,22 @@ cairo_recording_surface_create (class, cairo_content_t content, cairo_rectangle_
 
 void cairo_recording_surface_ink_extents (cairo_surface_t *surface, OUTLIST double x0, OUTLIST double y0, OUTLIST double width, OUTLIST double height);
 
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0)
+
+# cairo_bool_t cairo_recording_surface_get_extents (cairo_surface_t *surface, cairo_rectangle_t *extents);
+cairo_rectangle_t *
+cairo_recording_surface_get_extents (cairo_surface_t *surface)
+PREINIT:
+	cairo_bool_t status;
+	cairo_rectangle_t rect;
+CODE:
+	status = cairo_recording_surface_get_extents (surface, );
+	RETVAL = status ?  : NULL;
+OUTPUT:
+	RETVAL
+
+#endif
+
 #endif
 
 # --- #
diff --git a/MANIFEST b/MANIFEST
index 83b5019..a76ca7c 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -13,6 +13,7 @@ ChangeLog.pre-git
 doctypes
 examples/freetype-font.pl
 examples/glyph-text.pl
+examples/mime-unique-id.pl
 examples/png-streams.pl
 examples/png/bevels.pl
 examples/png/caps_joins.pl
diff --git a/examples/mime-unique-id.pl b/examples/mime-unique-id.pl
new file mode 100755
index 000..131ddbf
--- /dev/null
+++ b/examples/mime-unique-id.pl
@@ -0,0 +1,281 @@
+#! /usr/bin/perl
+
+# Adapted and translated to Perl from the test/mime-unique-id.c file in the
+# Cairo (version 1.17.3) source repository.
+
+#