[cairo-commit] cairo-ocaml/src ml_cairo_surface.c, 1.1,
1.2 ml_cairo_ps.c, 1.1, 1.2 ml_cairo_png.c, 1.1,
1.2 ml_cairo_pdf.c, 1.1, 1.2 ml_cairo_lablgtk.c, 1.11,
1.12 ml_cairo_bigarr.c, 1.6, 1.7 ml_cairo.h, 1.9,
1.10 ml_cairo.c, 1.21, 1.22 cairo_ps.mli, 1.1, 1.2 cairo_ps.ml,
1.1, 1.2 cairo_png.mli, 1.1, 1.2 cairo_png.ml, 1.1,
1.2 cairo_pdf.mli, 1.1, 1.2 cairo_pdf.ml, 1.1, 1.2 cairo.mli,
1.16, 1.17 cairo.ml, 1.14, 1.15
Olivier Andrieu
commit at pdx.freedesktop.org
Thu May 26 16:56:13 PDT 2005
Committed by: oandrieu
Update of /cvs/cairo/cairo-ocaml/src
In directory gabe:/tmp/cvs-serv15183/src
Modified Files:
ml_cairo_surface.c ml_cairo_ps.c ml_cairo_png.c ml_cairo_pdf.c
ml_cairo_lablgtk.c ml_cairo_bigarr.c ml_cairo.h ml_cairo.c
cairo_ps.mli cairo_ps.ml cairo_png.mli cairo_png.ml
cairo_pdf.mli cairo_pdf.ml cairo.mli cairo.ml
Log Message:
* stream-based backends can now use a caml channel
* fixes
Index: ml_cairo_surface.c
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ml_cairo_surface.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ml_cairo_surface.c 22 May 2005 20:03:15 -0000 1.1
+++ ml_cairo_surface.c 26 May 2005 23:56:10 -0000 1.2
@@ -26,23 +26,48 @@
return Val_unit;
}
-static void ml_cairo_destroy_user_data (void *data)
+static void
+ml_cairo_destroy_user_data (void *data)
{
caml_remove_global_root (data);
caml_stat_free (data);
}
void
-ml_cairo_surface_set_user_data (cairo_surface_t *surf, const cairo_user_data_key_t *key, value *v)
+ml_cairo_surface_set_stream_data (cairo_surface_t *surf, value *root)
{
+ static const cairo_user_data_key_t ml_cairo_stream_data_key;
+
cairo_status_t s;
- s = cairo_surface_set_user_data (surf,
- key, v,
+
+ s = cairo_surface_set_user_data (surf,
+ &ml_cairo_stream_data_key, root,
ml_cairo_destroy_user_data);
if (s != CAIRO_STATUS_SUCCESS)
{
cairo_surface_destroy (surf);
- ml_cairo_destroy_user_data (v);
+ ml_cairo_destroy_user_data (root);
+ cairo_treat_status (s);
+ }
+}
+
+void
+ml_cairo_surface_set_image_data (cairo_surface_t *surf, value v)
+{
+ static const cairo_user_data_key_t ml_cairo_image_data_key;
+
+ cairo_status_t s;
+ value *root;
+
+ root = ml_cairo_make_root (v);
+
+ s = cairo_surface_set_user_data (surf,
+ &ml_cairo_image_data_key, root,
+ ml_cairo_destroy_user_data);
+ if (s != CAIRO_STATUS_SUCCESS)
+ {
+ cairo_surface_destroy (surf);
+ ml_cairo_destroy_user_data (root);
cairo_treat_status (s);
}
}
Index: ml_cairo_ps.c
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ml_cairo_ps.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ml_cairo_ps.c 22 May 2005 20:03:15 -0000 1.1
+++ ml_cairo_ps.c 26 May 2005 23:56:10 -0000 1.2
@@ -11,32 +11,40 @@
#if CAIRO_HAS_PS_SURFACE
# include <cairo-ps.h>
-wML_3(cairo_ps_surface_create, String_val, Double_val, Double_val, Val_cairo_surface_t)
-
-CAMLprim value
-ml_cairo_ps_surface_create_for_stream (value f, value w, value h)
+static value
+_ml_cairo_ps_surface_create_for_stream (value f, value w, value h, cairo_bool_t unsafe)
{
- static const cairo_user_data_key_t ps_stream_key;
-
CAMLparam3(f, w, h);
value *c;
cairo_surface_t *surf;
c = ml_cairo_make_closure (f);
- surf = cairo_ps_surface_create_for_stream (ml_cairo_write_func, c,
- Double_val (w), Double_val (h));
+ surf = cairo_ps_surface_create_for_stream (unsafe ? ml_cairo_unsafe_write_func : ml_cairo_write_func,
+ c, Double_val (w), Double_val (h));
- ml_cairo_surface_set_user_data (surf, &ps_stream_key, c);
+ ml_cairo_surface_set_stream_data (surf, c);
CAMLreturn (Val_cairo_surface_t (surf));
}
+CAMLprim value
+ml_cairo_ps_surface_create_for_stream_unsafe (value f, value w, value h)
+{
+ return _ml_cairo_ps_surface_create_for_stream (f, w, h, 1);
+}
+
+CAMLprim value
+ml_cairo_ps_surface_create_for_stream (value f, value w, value h)
+{
+ return _ml_cairo_ps_surface_create_for_stream (f, w, h, 0);
+}
+
/* ML_3(cairo_ps_surface_set_dpi, cairo_surface_t_val, Double_val, Double_val, Unit) */
#else
-Cairo_Unsupported(cairo_ps_surface_create, "PS backend not supported");
-Cairo_Unsupported(cairo_ps_surface_create_for_stream, "PS backend not supported");
-/* Cairo_Unsupported(cairo_ps_surface_set_dpi, "PS backend not supported"); */
+Cairo_Unsupported(cairo_ps_surface_create_for_stream_unsafe, "PS backend not supported");
+Cairo_Unsupported(cairo_ps_surface_create_for_stream, "PS backend not supported");
+/* Cairo_Unsupported(cairo_ps_surface_set_dpi, "PS backend not supported"); */
#endif
Index: ml_cairo_png.c
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ml_cairo_png.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ml_cairo_png.c 22 May 2005 20:03:15 -0000 1.1
+++ ml_cairo_png.c 26 May 2005 23:56:10 -0000 1.2
@@ -9,19 +9,18 @@
#include "ml_cairo.h"
#if CAIRO_HAS_PNG_FUNCTIONS
-wML_1(cairo_image_surface_create_from_png, String_val, Val_cairo_surface_t)
-
-CAMLprim value
-ml_cairo_image_surface_create_from_png_stream (value f)
+static value
+_ml_cairo_image_surface_create_from_png_stream (value f, cairo_bool_t unsafe)
{
- CAMLparam0();
+ CAMLparam1(f);
CAMLlocal1(c);
cairo_surface_t *surf;
c = caml_alloc_small (2, 0);
Field (c, 0) = f;
Field (c, 1) = Val_unit;
- surf = cairo_image_surface_create_from_png_stream (ml_cairo_read_func, &c);
+ surf = cairo_image_surface_create_from_png_stream (unsafe ? ml_cairo_unsafe_read_func : ml_cairo_read_func,
+ &c);
if (Is_exception_result (Field (c, 1)))
caml_raise (Extract_exception (Field (c, 1)));
@@ -29,18 +28,22 @@
}
CAMLprim value
-ml_cairo_surface_write_to_png (value surf, value fname)
+ml_cairo_image_surface_create_from_png_stream_unsafe (value f)
{
- cairo_status_t s;
- s = cairo_surface_write_to_png (cairo_surface_t_val (surf), String_val (fname));
- cairo_treat_status (s);
- return Val_unit;
+ return _ml_cairo_image_surface_create_from_png_stream (f, 1);
}
CAMLprim value
-ml_cairo_surface_write_to_png_stream (value surf, value f)
+ml_cairo_image_surface_create_from_png_stream (value f)
{
- CAMLparam1(surf);
+ return _ml_cairo_image_surface_create_from_png_stream (f, 0);
+}
+
+
+static value
+_ml_cairo_surface_write_to_png_stream (value surf, value f, cairo_bool_t unsafe)
+{
+ CAMLparam2(surf, f);
CAMLlocal1(c);
cairo_status_t s;
@@ -49,7 +52,7 @@
Field (c, 1) = Val_unit;
s = cairo_surface_write_to_png_stream (cairo_surface_t_val (surf),
- ml_cairo_write_func,
+ unsafe ? ml_cairo_unsafe_write_func : ml_cairo_write_func,
&c);
if (Is_exception_result (Field (c, 1)))
caml_raise (Extract_exception (Field (c, 1)));
@@ -58,11 +61,23 @@
CAMLreturn (Val_unit);
}
+CAMLprim value
+ml_cairo_surface_write_to_png_stream_unsafe (value surf, value f)
+{
+ return _ml_cairo_surface_write_to_png_stream (surf, f, 1);
+}
+
+CAMLprim value
+ml_cairo_surface_write_to_png_stream (value surf, value f)
+{
+ return _ml_cairo_surface_write_to_png_stream (surf, f, 0);
+}
+
#else
-Cairo_Unsupported(cairo_image_surface_create_from_png, "PNG functions not supported")
-Cairo_Unsupported(cairo_image_surface_create_from_png_stream, "PNG functions not supported")
-Cairo_Unsupported(cairo_surface_write_to_png, "PNG functions not supported")
-Cairo_Unsupported(cairo_surface_write_to_png_stream, "PNG functions not supported")
+Cairo_Unsupported(cairo_image_surface_create_from_png_stream_unsafe, "PNG functions not supported")
+Cairo_Unsupported(cairo_image_surface_create_from_png_stream, "PNG functions not supported")
+Cairo_Unsupported(cairo_surface_write_to_png_stream_unsafe, "PNG functions not supported")
+Cairo_Unsupported(cairo_surface_write_to_png_stream, "PNG functions not supported")
#endif
Index: ml_cairo_pdf.c
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ml_cairo_pdf.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ml_cairo_pdf.c 22 May 2005 20:03:15 -0000 1.1
+++ ml_cairo_pdf.c 26 May 2005 23:56:10 -0000 1.2
@@ -11,32 +11,40 @@
#if CAIRO_HAS_PDF_SURFACE
# include <cairo-pdf.h>
-wML_3(cairo_pdf_surface_create, String_val, Double_val, Double_val, Val_cairo_surface_t)
-
-CAMLprim value
-ml_cairo_pdf_surface_create_for_stream (value f, value w, value h)
+static value
+_ml_cairo_pdf_surface_create_for_stream (value f, value w, value h, cairo_bool_t unsafe)
{
- static const cairo_user_data_key_t pdf_stream_key;
-
CAMLparam3(f, w, h);
value *c;
cairo_surface_t *surf;
c = ml_cairo_make_closure (f);
- surf = cairo_pdf_surface_create_for_stream (ml_cairo_write_func, c,
- Double_val (w), Double_val (h));
+ surf = cairo_pdf_surface_create_for_stream (unsafe ? ml_cairo_unsafe_write_func : ml_cairo_write_func,
+ c, Double_val (w), Double_val (h));
- ml_cairo_surface_set_user_data (surf, &pdf_stream_key, c);
+ ml_cairo_surface_set_stream_data (surf, c);
CAMLreturn (Val_cairo_surface_t (surf));
}
+CAMLprim value
+ml_cairo_pdf_surface_create_for_stream_unsafe (value f, value w, value h)
+{
+ return _ml_cairo_pdf_surface_create_for_stream (f, w, h, 1);
+}
+
+CAMLprim value
+ml_cairo_pdf_surface_create_for_stream (value f, value w, value h)
+{
+ return _ml_cairo_pdf_surface_create_for_stream (f, w, h, 0);
+}
+
wML_3(cairo_pdf_surface_set_dpi, cairo_surface_t_val, Double_val, Double_val, Unit)
#else
-Cairo_Unsupported(cairo_pdf_surface_create, "PDF backend not supported");
-Cairo_Unsupported(cairo_pdf_surface_create_for_stream, "PDF backend not supported");
+Cairo_Unsupported(cairo_pdf_surface_create_for_stream_unsafe, "PDF backend not supported");
+Cairo_Unsupported(cairo_pdf_surface_create_for_stream, "PDF backend not supported");
Cairo_Unsupported(cairo_pdf_surface_set_dpi, "PDF backend not supported");
#endif
Index: ml_cairo_lablgtk.c
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ml_cairo_lablgtk.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- ml_cairo_lablgtk.c 22 May 2005 20:03:15 -0000 1.11
+++ ml_cairo_lablgtk.c 26 May 2005 23:56:10 -0000 1.12
@@ -23,8 +23,6 @@
CAMLprim value
ml_cairo_lablgtk_of_pixbuf (value pb)
{
- static const cairo_user_data_key_t pixbuf_key;
-
GdkPixbuf *pixbuf = GdkPixbuf_val(pb);
cairo_format_t format;
gboolean alpha = gdk_pixbuf_get_has_alpha(pixbuf);
@@ -43,7 +41,7 @@
gdk_pixbuf_get_height(pixbuf),
gdk_pixbuf_get_rowstride(pixbuf));
- ml_cairo_surface_set_user_data (surf, &pixbuf_key, ml_cairo_make_root (pb));
+ ml_cairo_surface_set_image_data (surf, pb);
return Val_cairo_surface_t (surf);
}
@@ -83,8 +81,6 @@
CAMLprim value
ml_cairo_xlib_surface_create (value d)
{
- static const cairo_user_data_key_t drawable_key;
-
cairo_surface_t *surface;
gint width, height;
GdkDrawable *drawable = GdkDrawable_val(d);
@@ -113,7 +109,7 @@
}
if (surface != NULL)
- ml_cairo_surface_set_user_data (surface, &drawable_key, ml_cairo_make_root (d));
+ ml_cairo_surface_set_image_data (surface, d);
return Val_cairo_surface_t (surface);
}
Index: ml_cairo_bigarr.c
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ml_cairo_bigarr.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- ml_cairo_bigarr.c 22 May 2005 20:03:15 -0000 1.6
+++ ml_cairo_bigarr.c 26 May 2005 23:56:10 -0000 1.7
@@ -38,14 +38,13 @@
CAMLprim value
ml_cairo_image_surface_create_for_data (value img, value fmt, value w, value h, value stride)
{
- static const cairo_user_data_key_t image_data_key;
cairo_surface_t *surf;
surf = cairo_image_surface_create_for_data (Data_bigarray_val (img),
cairo_format_t_val (fmt),
Int_val (w),
Int_val (h),
Int_val (stride));
- ml_cairo_surface_set_user_data (surf, &image_data_key, ml_cairo_make_root (img));
+ ml_cairo_surface_set_image_data (surf, img);
return Val_cairo_surface_t (surf);
}
Index: ml_cairo.h
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ml_cairo.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- ml_cairo.h 22 May 2005 20:03:15 -0000 1.9
+++ ml_cairo.h 26 May 2005 23:56:10 -0000 1.10
@@ -70,5 +70,8 @@
value *ml_cairo_make_root (value);
cairo_status_t ml_cairo_write_func (void *, const unsigned char *, unsigned int);
cairo_status_t ml_cairo_read_func (void *, unsigned char *, unsigned int);
+cairo_status_t ml_cairo_unsafe_write_func (void *, const unsigned char *, unsigned int);
+cairo_status_t ml_cairo_unsafe_read_func (void *, unsigned char *, unsigned int);
-void ml_cairo_surface_set_user_data (cairo_surface_t *, const cairo_user_data_key_t *, value *);
+void ml_cairo_surface_set_stream_data (cairo_surface_t *, value *);
+void ml_cairo_surface_set_image_data (cairo_surface_t *, value);
Index: ml_cairo.c
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ml_cairo.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- ml_cairo.c 22 May 2005 20:03:15 -0000 1.21
+++ ml_cairo.c 26 May 2005 23:56:10 -0000 1.22
@@ -509,6 +509,32 @@
return CAIRO_STATUS_SUCCESS;
}
+cairo_status_t
+ml_cairo_unsafe_write_func (void *closure, const unsigned char *data, unsigned int length)
+{
+ value res, *c = closure;
+ res = caml_callback2_exn (Field (*c, 0), Val_bp (data), Val_int (length));
+ if (Is_exception_result (res))
+ {
+ Store_field (*c, 1, res);
+ return CAIRO_STATUS_WRITE_ERROR;
+ }
+ return CAIRO_STATUS_SUCCESS;
+}
+
+cairo_status_t
+ml_cairo_unsafe_read_func (void *closure, unsigned char *data, unsigned int length)
+{
+ value res, *c = closure;
+ res = caml_callback2_exn (Field (*c, 0), Val_bp (data), Val_int (length));
+ if (Is_exception_result (res))
+ {
+ Store_field (*c, 1, res);
+ return CAIRO_STATUS_READ_ERROR;
+ }
+ return CAIRO_STATUS_SUCCESS;
+}
+
wML_3(cairo_image_surface_create, cairo_format_t_val, Int_val, Int_val, Val_cairo_surface_t)
Index: cairo_ps.mli
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/cairo_ps.mli,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- cairo_ps.mli 22 May 2005 20:03:15 -0000 1.1
+++ cairo_ps.mli 26 May 2005 23:56:10 -0000 1.2
@@ -10,10 +10,10 @@
type surface = [`Any|`PS] Cairo.surface
-external surface_create :
- string ->
+val surface_create_for_channel :
+ out_channel ->
width_in_points:float ->
- height_in_points:float -> surface = "ml_cairo_ps_surface_create"
+ height_in_points:float -> surface
external surface_create_for_stream :
(string -> unit) ->
Index: cairo_ps.ml
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/cairo_ps.ml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- cairo_ps.ml 22 May 2005 20:03:15 -0000 1.1
+++ cairo_ps.ml 26 May 2005 23:56:10 -0000 1.2
@@ -8,10 +8,19 @@
type surface = [`Any|`PS] Cairo.surface
-external surface_create :
- string ->
+external surface_create_for_stream_unsafe :
+ (string -> int -> unit) ->
width_in_points:float ->
- height_in_points:float -> surface = "ml_cairo_ps_surface_create"
+ height_in_points:float -> surface = "ml_cairo_ps_surface_create_for_stream_unsafe"
+
+let unsafe_output_string oc s n =
+ for i = 0 to n - 1 do
+ output_char oc (String.unsafe_get s i)
+ done
+
+let surface_create_for_channel oc ~width_in_points ~height_in_points =
+ surface_create_for_stream_unsafe
+ (unsafe_output_string oc) ~width_in_points ~height_in_points
external surface_create_for_stream :
(string -> unit) ->
Index: cairo_png.mli
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/cairo_png.mli,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- cairo_png.mli 22 May 2005 20:03:15 -0000 1.1
+++ cairo_png.mli 26 May 2005 23:56:11 -0000 1.2
@@ -8,15 +8,21 @@
(** PNG reading/writing functions *)
-external image_surface_create_from_file :
- string -> Cairo.image_surface = "ml_cairo_image_surface_create_from_png"
+val image_surface_create_from_channel :
+ in_channel -> Cairo.image_surface
+
+val image_surface_create_from_file :
+ string -> Cairo.image_surface
external image_surface_create_from_stream :
- (string -> unit) -> Cairo.image_surface = "ml_cairo_image_surface_create_from_stream"
+ (string -> unit) -> Cairo.image_surface = "ml_cairo_image_surface_create_from_png_stream"
-external surface_write_to_file :
- 'a Cairo.surface -> string -> unit = "ml_cairo_surface_write_to_png"
+val surface_write_to_channel :
+ 'a Cairo.surface -> out_channel -> unit
+
+val surface_write_to_file :
+ 'a Cairo.surface -> string -> unit
external surface_write_to_stream :
'a Cairo.surface -> (string -> unit) -> unit = "ml_cairo_surface_write_to_png_stream"
Index: cairo_png.ml
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/cairo_png.ml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- cairo_png.ml 22 May 2005 20:03:15 -0000 1.1
+++ cairo_png.ml 26 May 2005 23:56:11 -0000 1.2
@@ -6,15 +6,52 @@
(* GNU Lesser General Public License version 2.1 (the "LGPL"). *)
(**************************************************************************)
-external image_surface_create_from_file :
- string -> Cairo.image_surface = "ml_cairo_image_surface_create_from_png"
+external image_surface_create_from_stream_unsafe :
+ (string -> int -> unit) -> Cairo.image_surface = "ml_cairo_image_surface_create_from_png_stream_unsafe"
+
+let image_surface_create_from_channel ic =
+ image_surface_create_from_stream_unsafe
+ (fun s n ->
+ for i = 0 to n - 1 do
+ String.unsafe_set s i (input_char ic)
+ done)
+
+let image_surface_create_from_file fname =
+ let ic = open_in fname in
+ try
+ let surf = image_surface_create_from_channel ic in
+ close_in ic ;
+ surf
+ with exn ->
+ close_in_noerr ic ;
+ raise exn
external image_surface_create_from_stream :
- (string -> unit) -> Cairo.image_surface = "ml_cairo_image_surface_create_from_stream"
+ (string -> unit) -> Cairo.image_surface = "ml_cairo_image_surface_create_from_png_stream"
-external surface_write_to_file :
- 'a Cairo.surface -> string -> unit = "ml_cairo_surface_write_to_png"
+
+external surface_write_to_stream_unsafe :
+ 'a Cairo.surface -> (string -> int -> unit) -> unit = "ml_cairo_surface_write_to_png_stream_unsafe"
+
+let unsafe_output_string oc s n =
+ for i = 0 to n - 1 do
+ output_char oc (String.unsafe_get s i)
+ done
+
+let surface_write_to_channel surf oc =
+ surface_write_to_stream_unsafe
+ surf
+ (unsafe_output_string oc)
+
+let surface_write_to_file surf fname =
+ let oc = open_out fname in
+ try
+ surface_write_to_channel surf oc ;
+ close_out oc
+ with exn ->
+ close_out_noerr oc ;
+ raise exn
external surface_write_to_stream :
'a Cairo.surface -> (string -> unit) -> unit = "ml_cairo_surface_write_to_png_stream"
Index: cairo_pdf.mli
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/cairo_pdf.mli,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- cairo_pdf.mli 22 May 2005 20:03:15 -0000 1.1
+++ cairo_pdf.mli 26 May 2005 23:56:11 -0000 1.2
@@ -10,10 +10,10 @@
type surface = [`Any|`PDF] Cairo.surface
-external surface_create :
- string ->
+val surface_create_for_channel :
+ out_channel ->
width_in_points:float ->
- height_in_points:float -> surface = "ml_cairo_pdf_surface_create"
+ height_in_points:float -> surface
external surface_create_for_stream :
(string -> unit) ->
Index: cairo_pdf.ml
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/cairo_pdf.ml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- cairo_pdf.ml 22 May 2005 20:03:15 -0000 1.1
+++ cairo_pdf.ml 26 May 2005 23:56:11 -0000 1.2
@@ -8,10 +8,19 @@
type surface = [`Any|`PDF] Cairo.surface
-external surface_create :
- string ->
+external surface_create_for_stream_unsafe :
+ (string -> int -> unit) ->
width_in_points:float ->
- height_in_points:float -> surface = "ml_cairo_pdf_surface_create"
+ height_in_points:float -> surface = "ml_cairo_pdf_surface_create_for_stream_unsafe"
+
+let unsafe_output_string oc s n =
+ for i = 0 to n - 1 do
+ output_char oc (String.unsafe_get s i)
+ done
+
+let surface_create_for_channel oc ~width_in_points ~height_in_points =
+ surface_create_for_stream_unsafe
+ (unsafe_output_string oc) ~width_in_points ~height_in_points
external surface_create_for_stream :
(string -> unit) ->
Index: cairo.mli
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/cairo.mli,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- cairo.mli 22 May 2005 20:03:15 -0000 1.16
+++ cairo.mli 26 May 2005 23:56:11 -0000 1.17
@@ -24,7 +24,6 @@
| WRITE_ERROR
| SURFACE_FINISHED
| SURFACE_TYPE_MISMATCH
- | BAD_NESTING
exception Error of status
val init : unit
Index: cairo.ml
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/cairo.ml,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- cairo.ml 22 May 2005 20:03:15 -0000 1.14
+++ cairo.ml 26 May 2005 23:56:11 -0000 1.15
@@ -20,7 +20,6 @@
| WRITE_ERROR
| SURFACE_FINISHED
| SURFACE_TYPE_MISMATCH
- | BAD_NESTING
exception Error of status
let init = Callback.register_exception "cairo_status_exn" (Error NULL_POINTER)
More information about the cairo-commit
mailing list