[cairo-commit] cairo-perl TODO, NONE, 1.1 Cairo.pm, 1.1,
1.2 Cairo.xs, 1.2, 1.3 CairoMatrix.xs, 1.2,
1.3 CairoPattern.xs, 1.2, 1.3 CairoSurface.xs, 1.2,
1.3 Makefile.PL, 1.2, 1.3 cairo-perl.h, 1.2, 1.3
Ross McFarland
commit at pdx.freedesktop.org
Wed Nov 10 18:20:34 PST 2004
Committed by: rwmcfa1
Update of /cvs/cairo/cairo-perl
In directory gabe:/tmp/cvs-serv27130
Modified Files:
Cairo.pm Cairo.xs CairoMatrix.xs CairoPattern.xs
CairoSurface.xs Makefile.PL cairo-perl.h
Added Files:
TODO
Log Message:
* TODO: initial import
* Cairo.pm, Cairo.xs: added %backends facility
* Cario.xs, CairoSurface.xs: stuff moved out of Cairo.xs that belonged
here
* Cairo.xs: fixed some OUTLIST stuff (IN_OUTLIST.) cairo_current_matrix
fixed.
* CairoPattern.xs: added class param to create_for_surface
* Makefile.PL: seperated structs out of objects. add refs to object
typemaps OUTPUT sections. don't return full strings for OUTPUT enum
types.
* cairo-perl.h: don't need stdio.h
* t/Cairo.t: test most all of cairo type. 90% done.
--- NEW FILE: TODO ---
TODO's
- creating/in/output/destroing structs (translate c <-> perl)
Index: Cairo.pm
===================================================================
RCS file: /cvs/cairo/cairo-perl/Cairo.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- Cairo.pm 5 Nov 2004 01:34:04 -0000 1.1
+++ Cairo.pm 11 Nov 2004 02:20:32 -0000 1.2
@@ -14,8 +14,12 @@
our @ISA = qw/DynaLoader/;
+our %backends = ();
+
our $VERSION = '0.02';
bootstrap Cairo $VERSION;
+_register_backends (\%backends);
+
1;
Index: Cairo.xs
===================================================================
RCS file: /cvs/cairo/cairo-perl/Cairo.xs,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Cairo.xs 9 Nov 2004 02:59:43 -0000 1.2
+++ Cairo.xs 11 Nov 2004 02:20:32 -0000 1.3
@@ -150,19 +150,19 @@
## XXX: double *
##void cairo_transform_point (cairo_t * cr, double * x, double * y);
-void cairo_transform_point (cairo_t * cr, OUTLIST double x, OUTLIST double y);
+void cairo_transform_point (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, OUTLIST double dx, OUTLIST double dy);
+void cairo_transform_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, OUTLIST double x, OUTLIST double y);
+void cairo_inverse_transform_point (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, OUTLIST double dx, OUTLIST double dy);
+void cairo_inverse_transform_distance (cairo_t * cr, IN_OUTLIST double dx, IN_OUTLIST double dy);
void cairo_new_path (cairo_t * cr);
@@ -279,7 +279,13 @@
double cairo_current_miter_limit (cairo_t * cr);
-void cairo_current_matrix (cairo_t * cr, cairo_matrix_t * matrix);
+##void cairo_current_matrix (cairo_t * cr, cairo_matrix_t * matrix);
+cairo_matrix_t * cairo_current_matrix (cairo_t * cr);
+ CODE:
+ RETVAL = cairo_matrix_create ();
+ cairo_current_matrix (cr, RETVAL);
+ OUTPUT:
+ RETVAL
cairo_surface_t * cairo_current_target_surface (cairo_t * cr);
@@ -300,65 +306,25 @@
const char * cairo_status_string (cairo_t * cr);
-## XXX: this one is kinda odd, image data is the first param
-cairo_surface_t * cairo_surface_create_for_image (class, char * data, cairo_format_t format, int width, int height, int stride);
- C_ARGS:
- data, format, width, height, stride
-
-cairo_surface_t * cairo_surface_create_similar (cairo_surface_t * other, cairo_format_t format, int width, int height);
-
-void cairo_surface_reference (cairo_surface_t * surface);
-
-void cairo_surface_destroy (cairo_surface_t * surface);
-
-cairo_status_t cairo_surface_set_repeat (cairo_surface_t * surface, int repeat);
-
-cairo_status_t cairo_surface_set_matrix (cairo_surface_t * surface, cairo_matrix_t * matrix);
-
-cairo_status_t cairo_surface_get_matrix (cairo_surface_t * surface, cairo_matrix_t * matrix);
-
-cairo_status_t cairo_surface_set_filter (cairo_surface_t * surface, cairo_filter_t filter);
-
-cairo_filter_t cairo_surface_get_filter (cairo_surface_t * surface);
-
-cairo_surface_t * cairo_image_surface_create (class, cairo_format_t format, int width, int height);
- C_ARGS:
- format, width, height
-
-cairo_surface_t * cairo_image_surface_create_for_data (class, char * data, cairo_format_t format, int width, int height, int stride);
- C_ARGS:
- data, format, width, height, stride
+## XXX: HAS section, test for capibilities, cairo really needs to dynamically
+## register these. and there really ought to be version numbers associated with
+## them
+void _register_backends (HV * backends);
+ CODE:
#ifdef CAIRO_HAS_PS_SURFACE
-
-cairo_surface_t * cairo_ps_surface_create (class, FILE * file, double width_inches, double height_inches, double x_pixels_per_inch, double y_pixels_per_inch);
- C_ARGS:
- file, width_inches, height_inches, x_pixels_per_inch, y_pixels_per_inch
-
-#endif /* CAIRO_HAS_PS_SURFACE */
-
+ hv_store (backends, "ps", 2, newSViv (1), 0);
+#endif
#ifdef CAIRO_HAS_PNG_SURFACE
-
-cairo_surface_t * cairo_png_surface_create (class, FILE * file, cairo_format_t format, int width, int height);
- C_ARGS:
- file, format, width, height
-
-#endif /* CAIRO_HAS_PNG_SURFACE */
-
+ hv_store (backends, "png", 3, newSViv (1), 0);
+#endif
#ifdef CAIRO_HAS_XLIB_SURFACE
-
-## XXX: Display, Drawable ...
-cairo_surface_t * cairo_xlib_surface_create (class, Display * dpy, Drawable drawable, Visual * visual, cairo_format_t format, Colormap colormap);
- C_ARGS:
- dpy, drawable, visual, format, colormap
-
-#endif /* CAIRO_HAS_XLIB_SURFACE */
-
+ hv_store (backends, "xlib", 4, newSViv (1), 0);
+#endif
+#ifdef CAIRO_HAS_XCB_SURFACE
+ hv_store (backends, "xcb", 3, newSViv (1), 0);
+#endif
#ifdef CAIRO_HAS_GLITZ_SURFACE
-
-## XXX: glitz_surface_t
-cairo_surface_t * cairo_glitz_surface_create (class, glitz_surface_t * surface);
- C_ARGS:
- surface
-
-#endif /* CAIRO_HAS_GLITZ_SURFACE */
+ hv_store (backends, "glitz", 5, newSViv (1), 0);
+#endif
+
Index: CairoMatrix.xs
===================================================================
RCS file: /cvs/cairo/cairo-perl/CairoMatrix.xs,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- CairoMatrix.xs 9 Nov 2004 02:59:43 -0000 1.2
+++ CairoMatrix.xs 11 Nov 2004 02:20:32 -0000 1.3
@@ -31,9 +31,9 @@
cairo_status_t cairo_matrix_set_affine (cairo_matrix_t * cr, double a, double b, double c, double d, double tx, double ty);
-## XXX: double *
+## 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);
-cairo_status_t 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_get_affine (cairo_matrix_t * matrix, OUTLIST double a, OUTLIST double b, OUTLIST double c, OUTLIST double d, OUTLIST double tx, OUTLIST double ty);
cairo_status_t cairo_matrix_translate (cairo_matrix_t * matrix, double tx, double ty);
@@ -46,10 +46,10 @@
## XXX:
##cairo_status_t cairo_matrix_multiply (cairo_matrix_t * result, cairo_matrix_t * a, const cairo_matrix_t * b);
-## XXX: double *
+## XXX: status return type?
##cairo_status_t cairo_matrix_transform_distance (cairo_matrix_t * matrix, double * dx, double * dy);
-cairo_status_t cairo_matrix_transform_distance (cairo_matrix_t * matrix, OUTLIST double dx, OUTLIST double dy);
+void cairo_matrix_transform_distance (cairo_matrix_t * matrix, OUTLIST double dx, OUTLIST double dy);
-## XXX: double *
+## XXX: status return type?
##cairo_status_t cairo_matrix_transform_point (cairo_matrix_t * matrix, double * x, double * y);
-cairo_status_t cairo_matrix_transform_point (cairo_matrix_t * matrix, OUTLIST double x, OUTLIST double y);
+void cairo_matrix_transform_point (cairo_matrix_t * matrix, OUTLIST double x, OUTLIST double y);
Index: CairoPattern.xs
===================================================================
RCS file: /cvs/cairo/cairo-perl/CairoPattern.xs,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- CairoPattern.xs 9 Nov 2004 02:59:43 -0000 1.2
+++ CairoPattern.xs 11 Nov 2004 02:20:32 -0000 1.3
@@ -10,11 +10,9 @@
MODULE = Cairo::Pattern PACKAGE = Cairo::Pattern PREFIX = cairo_pattern_
-cairo_pattern_t * cairo_pattern_create_for_surface (cairo_surface_t * surface);
- ALIAS:
- Cairo::Pattern::new = 1
- CLEANUP:
- CAIRO_PERL_UNUSED (ix);
+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:
Index: CairoSurface.xs
===================================================================
RCS file: /cvs/cairo/cairo-perl/CairoSurface.xs,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- CairoSurface.xs 9 Nov 2004 02:59:43 -0000 1.2
+++ CairoSurface.xs 11 Nov 2004 02:20:32 -0000 1.3
@@ -8,6 +8,12 @@
#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::ImageSurface PREFIX = cairo_image_surface_
cairo_surface_t * cairo_image_surface_create (class, cairo_format_t format, int width, int height)
@@ -25,3 +31,67 @@
void cairo_surface_DESTROY (cairo_surface_t * surface);
CODE:
cairo_surface_destroy (surface);
+
+## XXX: this one is kinda odd, image data is the first param
+cairo_surface_t * cairo_surface_create_for_image (class, char * data, cairo_format_t format, int width, int height, int stride);
+ C_ARGS:
+ data, format, width, height, stride
+
+cairo_surface_t * cairo_surface_create_similar (cairo_surface_t * other, cairo_format_t format, int width, int height);
+
+void cairo_surface_reference (cairo_surface_t * surface);
+
+void cairo_surface_destroy (cairo_surface_t * surface);
+
+cairo_status_t cairo_surface_set_repeat (cairo_surface_t * surface, int repeat);
+
+cairo_status_t cairo_surface_set_matrix (cairo_surface_t * surface, cairo_matrix_t * matrix);
+
+cairo_status_t cairo_surface_get_matrix (cairo_surface_t * surface, cairo_matrix_t * matrix);
+
+cairo_status_t cairo_surface_set_filter (cairo_surface_t * surface, cairo_filter_t filter);
+
+cairo_filter_t cairo_surface_get_filter (cairo_surface_t * surface);
+
+cairo_surface_t * cairo_image_surface_create (class, cairo_format_t format, int width, int height);
+ C_ARGS:
+ format, width, height
+
+cairo_surface_t * cairo_image_surface_create_for_data (class, char * data, cairo_format_t format, int width, int height, int stride);
+ C_ARGS:
+ data, format, width, height, stride
+
+#ifdef CAIRO_HAS_PS_SURFACE
+
+cairo_surface_t * cairo_ps_surface_create (class, FILE * file, double width_inches, double height_inches, double x_pixels_per_inch, double y_pixels_per_inch);
+ C_ARGS:
+ file, width_inches, height_inches, x_pixels_per_inch, y_pixels_per_inch
+
+#endif /* CAIRO_HAS_PS_SURFACE */
+
+#ifdef CAIRO_HAS_PNG_SURFACE
+
+cairo_surface_t * cairo_png_surface_create (class, FILE * file, cairo_format_t format, int width, int height);
+ C_ARGS:
+ file, format, width, height
+
+#endif /* CAIRO_HAS_PNG_SURFACE */
+
+#ifdef CAIRO_HAS_XLIB_SURFACE
+
+## XXX: Display, Drawable ...
+cairo_surface_t * cairo_xlib_surface_create (class, Display * dpy, Drawable drawable, Visual * visual, cairo_format_t format, Colormap colormap);
+ C_ARGS:
+ dpy, drawable, visual, format, colormap
+
+#endif /* CAIRO_HAS_XLIB_SURFACE */
+
+#ifdef CAIRO_HAS_GLITZ_SURFACE
+
+## XXX: glitz_surface_t
+cairo_surface_t * cairo_glitz_surface_create (class, glitz_surface_t * surface);
+ C_ARGS:
+ surface
+
+#endif /* CAIRO_HAS_GLITZ_SURFACE */
+
Index: Makefile.PL
===================================================================
RCS file: /cvs/cairo/cairo-perl/Makefile.PL,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Makefile.PL 9 Nov 2004 02:59:43 -0000 1.2
+++ Makefile.PL 11 Nov 2004 02:20:32 -0000 1.3
@@ -8,6 +8,7 @@
# TODO:
# - file spec
# - pull a lot of this out into a helper pm or something
+# - man this is horribly ulgy, stream-of-cons. even.
#
use strict;
@@ -27,9 +28,12 @@
'cairo_t *' => 'Cairo',
'cairo_surface_t *' => 'Cairo::Surface',
'cairo_pattern_t *' => 'Cairo::Pattern',
+ 'cairo_font_t *' => 'Cairo::Font',
+);
+
+our %structs = (
'cairo_matrix_t *' => 'Cairo::Matrix',
'cairo_glyph_t *' => 'Cairo::Glyph',
- 'cairo_font_t *' => 'Cairo::Font',
'cairo_font_extents_t *' => 'Cairo::Font::Extents',
'cairo_text_extents_t *' => 'Cairo::Text::Extents',
'glitz_surface_t *' => 'Glitz::Surface',
@@ -217,7 +221,7 @@
$1;
}
- foreach (keys %objects, keys %enums)
+ foreach (keys %objects, keys %structs, keys %enums)
{
print TYPEMAP $_."\t".type_id ($_)."\n";
}
@@ -237,6 +241,19 @@
';
}
+ foreach (keys %structs)
+ {
+ print TYPEMAP type_id ($_).'
+ if (sv_derived_from($arg, \"'.$structs{$_}.'\")) {
+ IV tmp = SvIV((SV*)SvRV($arg));
+ $var = INT2PTR($type,tmp);
+ }
+ else
+ Perl_croak(aTHX_ \"$var is not of type '.$structs{$_}.'\")
+
+';
+ }
+
foreach (keys %enums)
{
print TYPEMAP type_id ($_).'
@@ -247,14 +264,26 @@
print TYPEMAP "\nOUTPUT\n\n";
+ my $ref;
foreach (keys %objects)
{
- print TYPEMAP type_id ($_).'
+ /^(.*)_t \*/;
+ $ref = $1.'_reference';
+ print TYPEMAP type_id ($_)."
+ $ref (".'$var);
sv_setref_pv($arg, \"'.$objects{$_}.'\", (void*)$var);
';
}
+ foreach (keys %structs)
+ {
+ print TYPEMAP type_id ($_).'
+ sv_setref_pv($arg, \"'.$structs{$_}.'\", (void*)$var);
+
+';
+ }
+
foreach (keys %enums)
{
print TYPEMAP type_id ($_).'
@@ -324,15 +353,19 @@
my $prefix = shift @enums;
my $full = shift @enums;
+ my $name = $full;
+ $name =~ s/$prefix//;
my $str = " if (val == $full)
- return newSVpv (\"$full\", 0);
+ return newSVpv (\"$name\", 0);
";
foreach $full (@enums)
{
+ $name = $full;
+ $name =~ s/$prefix//;
$str .= " else if (val == $full)
- return newSVpv (\"$full\", 0);
+ return newSVpv (\"$name\", 0);
";
}
Index: cairo-perl.h
===================================================================
RCS file: /cvs/cairo/cairo-perl/cairo-perl.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- cairo-perl.h 9 Nov 2004 02:59:44 -0000 1.2
+++ cairo-perl.h 11 Nov 2004 02:20:32 -0000 1.3
@@ -14,7 +14,6 @@
#include "perl.h"
#include "XSUB.h"
-#include <stdio.h>
#include <cairo.h>
#define CAIRO_PERL_UNUSED(var) if (0) { (var) = (var); }
More information about the cairo-commit
mailing list