[cairo-commit] rcairo/packages/cairo/ext cairo.def, 1.7, 1.8 extconf.rb, 1.11, 1.12 rb_cairo.c, 1.13, 1.14 rb_cairo.h, 1.14, 1.15 rb_cairo_constants.c, 1.11, 1.12 rb_cairo_surface.c, 1.26, 1.27

Kouhei Sutou commit at pdx.freedesktop.org
Sat Jul 1 07:45:57 PDT 2006


Committed by: kou

Update of /cvs/cairo/rcairo/packages/cairo/ext
In directory kemper:/tmp/cvs-serv13627/packages/cairo/ext

Modified Files:
	cairo.def extconf.rb rb_cairo.c rb_cairo.h 
	rb_cairo_constants.c rb_cairo_surface.c 
Log Message:
* README: supported only 1.2.0 or higher.
* packages/cairo/ext/extconf.rb: ditto.

* packages/cairo/ext/cairo.def: added
  rb_cairo_svg_version_from_ruby_object().

* packages/cairo/ext/rb_cairo.c (Init_cairo): initialize constants
  before other modules.

* packages/cairo/ext/rb_cairo.h:
  - include all available header files.
  - supported cairo_svg_version_t.

* packages/cairo/ext/rb_cairo_constants.c: supported
  cairo_svg_surface_t.

* packages/cairo/ext/rb_cairo_surface.c: supported missing
  functions in cairo-ps.h, cairo-pdf.h and cairo-svg.h.

* packages/cairo/lib/cairo.rb
  (Cairo::SVGSurface.versions_as_string): added convenience method.


Index: cairo.def
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/cairo.def,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- cairo.def	11 Oct 2005 13:23:49 -0000	1.7
+++ cairo.def	1 Jul 2006 14:45:55 -0000	1.8
@@ -54,4 +54,5 @@
     rb_cairo_format_from_ruby_object
     rb_cairo_extend_from_ruby_object
     rb_cairo_filter_from_ruby_object
+    rb_cairo_svg_version_from_ruby_object
     rb_cairo_check_status

Index: extconf.rb
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/extconf.rb,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- extconf.rb	25 Jun 2006 14:29:24 -0000	1.11
+++ extconf.rb	1 Jul 2006 14:45:55 -0000	1.12
@@ -63,7 +63,7 @@
 
 pkg = "cairo"
 modname = "cairo"
-major, minor, micro = 1, 1, 10
+major, minor, micro = 1, 2, 0
 
 PKGConfig.have_package(pkg, major, minor, micro) or exit 1
 

Index: rb_cairo.c
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- rb_cairo.c	27 Jun 2006 13:11:07 -0000	1.13
+++ rb_cairo.c	1 Jul 2006 14:45:55 -0000	1.14
@@ -59,11 +59,12 @@
   rb_define_const (rb_mCairo, "MINOR_VERSION", INT2FIX (minor));
   rb_define_const (rb_mCairo, "MICRO_VERSION", INT2FIX (micro));
   
+  Init_cairo_constants ();
+
   Init_cairo_context ();
   Init_cairo_path ();
   Init_cairo_matrix ();
   Init_cairo_surface ();
-  Init_cairo_constants ();
   Init_cairo_exception ();
   Init_cairo_font ();
   Init_cairo_font_extents ();

Index: rb_cairo.h
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- rb_cairo.h	11 Oct 2005 13:23:49 -0000	1.14
+++ rb_cairo.h	1 Jul 2006 14:45:55 -0000	1.15
@@ -18,6 +18,18 @@
 
 #include <cairo.h>
 
+#if CAIRO_HAS_PS_SURFACE
+#  include <cairo-ps.h>
+#endif
+
+#if CAIRO_HAS_PDF_SURFACE
+#  include <cairo-pdf.h>
+#endif
+
+#if CAIRO_HAS_SVG_SURFACE
+#  include <cairo-svg.h>
+#endif
+
 #include "ruby.h"
 
 #if defined(RUBY_CAIRO_PLATFORM_WIN32) && !defined(RUBY_CAIRO_STATIC_COMPILATION)
@@ -130,6 +142,9 @@
 #define RVAL2CRFORMAT(obj)        (rb_cairo_format_from_ruby_object(obj))
 #define RVAL2CREXTEND(obj)        (rb_cairo_extend_from_ruby_object(obj))
 #define RVAL2CRFILTER(obj)        (rb_cairo_filter_from_ruby_object(obj))
+#if CAIRO_HAS_SVG_SURFACE
+#define RVAL2CRSVGVERSION(obj)    (rb_cairo_svg_version_from_ruby_object(obj))
+#endif
 
 cairo_operator_t       rb_cairo_operator_from_ruby_object       (VALUE obj);
 cairo_antialias_t      rb_cairo_antialias_from_ruby_object      (VALUE obj);
@@ -146,7 +161,9 @@
 cairo_format_t         rb_cairo_format_from_ruby_object         (VALUE obj);
 cairo_extend_t         rb_cairo_extend_from_ruby_object         (VALUE obj);
 cairo_filter_t         rb_cairo_filter_from_ruby_object         (VALUE obj);
-
+#if CAIRO_HAS_SVG_SURFACE
+cairo_svg_version_t    rb_cairo_svg_version_from_ruby_object    (VALUE obj);
+#endif
 
 void rb_cairo_check_status (cairo_status_t status);
 

Index: rb_cairo_constants.c
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo_constants.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- rb_cairo_constants.c	25 Jun 2006 14:29:24 -0000	1.11
+++ rb_cairo_constants.c	1 Jul 2006 14:45:55 -0000	1.12
@@ -60,6 +60,9 @@
 #define CAIRO_FILTER_MIN CAIRO_FILTER_FAST
 #define CAIRO_FILTER_MAX CAIRO_FILTER_GAUSSIAN
 
+#define CAIRO_SVG_VERSION_MIN CAIRO_SVG_VERSION_1_1
+#define CAIRO_SVG_VERSION_MAX CAIRO_SVG_VERSION_1_2
+
 #define DEFINE_RVAL2ENUM(name, const_name)                  \
 cairo_ ## name ## _t                                        \
 rb_cairo_ ## name ## _from_ruby_object (VALUE rb_ ## name)  \
@@ -94,6 +97,7 @@
 DEFINE_RVAL2ENUM(format, FORMAT)
 DEFINE_RVAL2ENUM(extend, EXTEND)
 DEFINE_RVAL2ENUM(filter, FILTER)
+DEFINE_RVAL2ENUM(svg_version, SVG_VERSION)
 
 
 void
@@ -320,4 +324,12 @@
                    INT2FIX (CAIRO_FILTER_BILINEAR));
   rb_define_const (rb_mCairo,    "FILTER_GAUSSIAN",
                    INT2FIX (CAIRO_FILTER_GAUSSIAN));
+
+#if CAIRO_HAS_SVG_SURFACE
+  /* cairo_svg_version_t */
+  rb_define_const (rb_mCairo,    "SVG_VERSION_1_1",
+                   INT2FIX (CAIRO_SVG_VERSION_1_1));
+  rb_define_const (rb_mCairo,    "SVG_VERSION_1_2",
+                   INT2FIX (CAIRO_SVG_VERSION_1_2));
+#endif
 }

Index: rb_cairo_surface.c
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo_surface.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- rb_cairo_surface.c	27 Jun 2006 14:34:49 -0000	1.26
+++ rb_cairo_surface.c	1 Jul 2006 14:45:55 -0000	1.27
@@ -15,18 +15,6 @@
 #include "rb_cairo.h"
 #include "rubyio.h"
 
-#if CAIRO_HAS_PS_SURFACE
-#  include <cairo-ps.h>
-#endif
-
-#if CAIRO_HAS_PDF_SURFACE
-#  include <cairo-pdf.h>
-#endif
-
-#if CAIRO_HAS_SVG_SURFACE
-#  include <cairo-svg.h>
-#endif
-
 #if CAIRO_HAS_PS_SURFACE || CAIRO_HAS_PDF_SURFACE || CAIRO_HAS_SVG_SURFACE
 #  define HAS_CREATE_CR_CLOSURE_SURFACE 1
 #else
@@ -690,16 +678,105 @@
 #if CAIRO_HAS_PS_SURFACE
 /* PS-surface functions */
 DEFINE_SURFACE(ps)
+
+static VALUE
+cr_ps_surface_set_size (VALUE self,
+                        VALUE width_in_points,
+                        VALUE height_in_points)
+{
+  cairo_ps_surface_set_size (_SELF,
+                             NUM2DBL (width_in_points),
+                             NUM2DBL (height_in_points));
+  cr_surface_check_status (_SELF);
+  return Qnil;
+}
+
+static VALUE
+cr_ps_surface_dsc_comment (VALUE self, VALUE comment)
+{
+  cairo_ps_surface_dsc_comment (_SELF, StringValueCStr (comment));
+  cr_surface_check_status (_SELF);
+  return Qnil;
+}
+
+static VALUE
+cr_ps_surface_dsc_begin_setup (VALUE self)
+{
+  cairo_ps_surface_dsc_begin_setup (_SELF);
+  cr_surface_check_status (_SELF);
+  if (rb_block_given_p ())
+    return rb_yield (self);
+  else
+    return Qnil;
+}
+
+static VALUE
+cr_ps_surface_dsc_begin_page_setup (VALUE self)
+{
+  cairo_ps_surface_dsc_begin_page_setup (_SELF);
+  cr_surface_check_status (_SELF);
+  if (rb_block_given_p ())
+    return rb_yield (self);
+  else
+    return Qnil;
+}
 #endif
 
 #if CAIRO_HAS_PDF_SURFACE
 /* PDF-surface functions */
 DEFINE_SURFACE(pdf)
+
+static VALUE
+cr_pdf_surface_set_size (VALUE self,
+                         VALUE width_in_points,
+                         VALUE height_in_points)
+{
+  cairo_pdf_surface_set_size (_SELF,
+                              NUM2DBL (width_in_points),
+                              NUM2DBL (height_in_points));
+  cr_surface_check_status (_SELF);
+  return Qnil;
+}
 #endif
 
 #if CAIRO_HAS_SVG_SURFACE
 /* SVG-surface functions */
 DEFINE_SURFACE(svg)
+
+static VALUE
+cr_svg_surface_restrict_to_version (VALUE self, VALUE version)
+{
+  cairo_svg_surface_restrict_to_version (_SELF, RVAL2CRSVGVERSION (version));
+  cr_surface_check_status (_SELF);
+  return Qnil;
+}
+
+static VALUE
+cr_svg_get_versions (VALUE self)
+{
+  VALUE rb_versions;
+  int i, num_versions;
+  cairo_svg_version_t const *versions;
+
+  cairo_svg_get_versions (&versions, &num_versions);
+
+  rb_versions = rb_ary_new2 (num_versions);
+
+  for (i = 0; i < num_versions; i++)
+    {
+      rb_ary_push (rb_versions, INT2NUM (versions[i]));
+    }
+
+  return rb_versions;
+}
+
+static VALUE
+cr_svg_version_to_string (VALUE self, VALUE version)
+{
+  const char *ver_str;
+  ver_str = cairo_svg_version_to_string (RVAL2CRSVGVERSION(version));
+  return rb_str_new2 (ver_str);
+}
 #endif
 
 
@@ -776,6 +853,14 @@
 #if CAIRO_HAS_PS_SURFACE
   /* PS-surface */
   INIT_SURFACE(ps, PS)
+
+  rb_define_method (rb_cCairo_PSSurface, "set_size", cr_ps_surface_set_size, 2);
+  rb_define_method (rb_cCairo_PSSurface, "dsc_comment",
+                    cr_ps_surface_dsc_comment, 1);
+  rb_define_method (rb_cCairo_PSSurface, "dsc_begin_setup",
+                    cr_ps_surface_dsc_begin_setup, 0);
+  rb_define_method (rb_cCairo_PSSurface, "dsc_begin_page_setup",
+                    cr_ps_surface_dsc_begin_page_setup, 0);
 #else
   rb_cCairo_PSSurface = Qnil;
 #endif
@@ -783,6 +868,9 @@
 #if CAIRO_HAS_PDF_SURFACE
   /* PDF-surface */
   INIT_SURFACE(pdf, PDF)
+
+  rb_define_method (rb_cCairo_PDFSurface, "set_size",
+                    cr_pdf_surface_set_size, 2);
 #else
   rb_cCairo_PDFSurface = Qnil;
 #endif
@@ -790,6 +878,19 @@
 #if CAIRO_HAS_SVG_SURFACE
   /* SVG-surface */
   INIT_SURFACE(svg, SVG)
+
+  rb_define_const (rb_cCairo_SVGSurface, "VERSION_1_1",
+                   rb_const_get (rb_mCairo, rb_intern ("SVG_VERSION_1_1")));
+  rb_define_const (rb_cCairo_SVGSurface, "VERSION_1_2",
+                   rb_const_get (rb_mCairo, rb_intern ("SVG_VERSION_1_2")));
+
+  rb_define_singleton_method (rb_cCairo_SVGSurface, "versions",
+                              cr_svg_get_versions, 0);
+  rb_define_singleton_method (rb_cCairo_SVGSurface, "version_to_string",
+                              cr_svg_version_to_string, 1);
+
+  rb_define_method (rb_cCairo_SVGSurface, "restrict_to_version",
+                    cr_svg_surface_restrict_to_version, 1);
 #else
   rb_cCairo_SVGSurface = Qnil;
 #endif



More information about the cairo-commit mailing list