[cairo] [rcairo] fix compile errors and warnings
Kouhei Sutou
kou at cozmixng.org
Thu Sep 8 00:34:58 PDT 2005
Hi,
I made a patch that fixes compile errors and warnings.
Thanks,
--
kou
-------------- next part --------------
Index: packages/cairo/ext/rb_cairo_context.c
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo_context.c,v
retrieving revision 1.6
diff -u -p -r1.6 rb_cairo_context.c
--- packages/cairo/ext/rb_cairo_context.c 23 Jun 2005 09:30:48 -0000 1.6
+++ packages/cairo/ext/rb_cairo_context.c 8 Sep 2005 07:33:35 -0000
@@ -48,7 +48,7 @@ check_context_status (cairo_t *context)
status = cairo_status (context);
if (status)
{
- rb_cairo_raise_exception (status, cairo_status_string (context));
+ rb_cairo_raise_exception (status);
}
}
@@ -770,8 +770,7 @@ rb_cairo_get_font_face (VALUE self)
if (cairo_status (_SELF))
{
rb_free_font_face (xform);
- rb_cairo_raise_exception (cairo_status (_SELF),
- cairo_status_string (_SELF));
+ rb_cairo_raise_exception (cairo_status (_SELF));
}
return Data_Wrap_Struct (rb_cCairo_FontFace, NULL, rb_free_font_face, xform);
}
@@ -910,8 +909,7 @@ rb_cairo_get_matrix (VALUE self)
if (cairo_status (_SELF))
{
rb_free_matrix (matrix);
- rb_cairo_raise_exception (cairo_status (_SELF),
- cairo_status_string (_SELF));
+ rb_cairo_raise_exception (cairo_status (_SELF));
}
return rb_cairo_matrix_wrap (matrix);
}
Index: packages/cairo/ext/rb_cairo_exception.c
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo_exception.c,v
retrieving revision 1.3
diff -u -p -r1.3 rb_cairo_exception.c
--- packages/cairo/ext/rb_cairo_exception.c 23 Jun 2005 09:30:48 -0000 1.3
+++ packages/cairo/ext/rb_cairo_exception.c 8 Sep 2005 07:33:35 -0000
@@ -14,7 +14,7 @@ static VALUE rb_eCairo_InvalidPopGroupEr
static VALUE rb_eCairo_InvalidRestoreError;
static VALUE rb_eCairo_NoCurrentPointError;
static VALUE rb_eCairo_InvalidMatrixError;
-static VALUE rb_eCairo_NoTargetSurfaceError;
+static VALUE rb_eCairo_InvalidStatusError;
static VALUE rb_eCairo_NullPointerError;
static VALUE rb_eCairo_WriteError;
static VALUE rb_eCairo_SurfaceFinishedError;
@@ -23,11 +23,17 @@ static VALUE rb_eCairo_InvalidPathDataEr
static VALUE rb_eCairo_ReadError;
static VALUE rb_eCairo_SurfaceTypeMismatchError;
static VALUE rb_eCairo_PatternTypeMismatchError;
+static VALUE rb_eCairo_InvalidContentError;
+static VALUE rb_eCairo_InvalidFormatError;
+static VALUE rb_eCairo_InvalidVisualError;
+static VALUE rb_eCairo_FileNotFoundError;
+static VALUE rb_eCairo_InvalidDashError;
void
-rb_cairo_raise_exception (cairo_status_t status,
- const char *string)
+rb_cairo_raise_exception (cairo_status_t status)
{
+ const char *string = cairo_status_to_string (status);
+
switch (status)
{
case CAIRO_STATUS_NO_MEMORY:
@@ -45,8 +51,8 @@ rb_cairo_raise_exception (cairo_status_t
case CAIRO_STATUS_INVALID_MATRIX:
rb_raise (rb_eCairo_InvalidMatrixError, string);
break;
- case CAIRO_STATUS_NO_TARGET_SURFACE:
- rb_raise (rb_eCairo_NoTargetSurfaceError, string);
+ case CAIRO_STATUS_INVALID_STATUS:
+ rb_raise (rb_eCairo_InvalidStatusError, string);
break;
case CAIRO_STATUS_NULL_POINTER:
rb_raise (rb_eCairo_NullPointerError, string);
@@ -72,6 +78,21 @@ rb_cairo_raise_exception (cairo_status_t
case CAIRO_STATUS_PATTERN_TYPE_MISMATCH:
rb_raise (rb_eCairo_PatternTypeMismatchError, string);
break;
+ case CAIRO_STATUS_INVALID_CONTENT:
+ rb_raise (rb_eCairo_InvalidContentError, string);
+ break;
+ case CAIRO_STATUS_INVALID_FORMAT:
+ rb_raise (rb_eCairo_InvalidFormatError, string);
+ break;
+ case CAIRO_STATUS_INVALID_VISUAL:
+ rb_raise (rb_eCairo_InvalidVisualError, string);
+ break;
+ case CAIRO_STATUS_FILE_NOT_FOUND:
+ rb_raise (rb_eCairo_FileNotFoundError, string);
+ break;
+ case CAIRO_STATUS_INVALID_DASH:
+ rb_raise (rb_eCairo_InvalidDashError, string);
+ break;
case CAIRO_STATUS_SUCCESS:
break;
}
@@ -92,9 +113,9 @@ Init_cairo_exception ()
rb_eCairo_InvalidMatrixError =
rb_define_class_under (rb_mCairo, "InvalidMatrixError",
rb_eArgError);
- rb_eCairo_NoTargetSurfaceError =
- rb_define_class_under (rb_mCairo, "NoTargetSurfaceError",
- rb_eRuntimeError);
+ rb_eCairo_InvalidStatusError =
+ rb_define_class_under (rb_mCairo, "InvalidStatusError",
+ rb_eArgError);
rb_eCairo_NullPointerError =
rb_define_class_under (rb_mCairo, "NullPointerError",
rb_eTypeError);
@@ -119,4 +140,19 @@ Init_cairo_exception ()
rb_eCairo_PatternTypeMismatchError =
rb_define_class_under (rb_mCairo, "PatternTypeMismatch",
rb_eTypeError);
+ rb_eCairo_InvalidContentError =
+ rb_define_class_under (rb_mCairo, "InvalidContentError",
+ rb_eArgError);
+ rb_eCairo_InvalidFormatError =
+ rb_define_class_under (rb_mCairo, "InvalidFormatError",
+ rb_eArgError);
+ rb_eCairo_InvalidVisualError =
+ rb_define_class_under (rb_mCairo, "InvalidVisualError",
+ rb_eArgError);
+ rb_eCairo_FileNotFoundError =
+ rb_define_class_under (rb_mCairo, "FileNotFound",
+ rb_eRuntimeError);
+ rb_eCairo_InvalidDashError =
+ rb_define_class_under (rb_mCairo, "InvalidDashError",
+ rb_eArgError);
}
Index: packages/cairo/ext/rb_cairo_exception.h
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo_exception.h,v
retrieving revision 1.1
diff -u -p -r1.1 rb_cairo_exception.h
--- packages/cairo/ext/rb_cairo_exception.h 8 Feb 2005 01:28:21 -0000 1.1
+++ packages/cairo/ext/rb_cairo_exception.h 8 Sep 2005 07:33:35 -0000
@@ -15,7 +15,6 @@
void Init_cairo_exception ();
-void rb_cairo_raise_exception (cairo_status_t status,
- const char *string);
+void rb_cairo_raise_exception (cairo_status_t status);
#endif
Index: packages/cairo/ext/rb_cairo_matrix.c
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo_matrix.c,v
retrieving revision 1.4
diff -u -p -r1.4 rb_cairo_matrix.c
--- packages/cairo/ext/rb_cairo_matrix.c 23 Jun 2005 09:30:48 -0000 1.4
+++ packages/cairo/ext/rb_cairo_matrix.c 8 Sep 2005 07:33:36 -0000
@@ -96,8 +96,12 @@ rb_cairo_matrix_new (VALUE klass)
static VALUE
rb_cairo_matrix_copy (VALUE self, VALUE other)
{
- cairo_matrix_copy (_SELF,
- rb_v_to_cairo_matrix_t (other));
+ cairo_matrix_t *matrix = rb_v_to_cairo_matrix_t (other);
+
+ cairo_matrix_init (_SELF,
+ matrix->xx, matrix->yx,
+ matrix->xy, matrix->yy,
+ matrix->x0, matrix->y0);
return self;
}
@@ -165,7 +169,13 @@ rb_cairo_matrix_rotate (VALUE self,
static VALUE
rb_cairo_matrix_invert (VALUE self)
{
- cairo_matrix_invert (_SELF);
+ cairo_status_t status;
+ status = cairo_matrix_invert (_SELF);
+ if (status)
+ {
+ rb_cairo_raise_exception (status);
+ }
+
return self;
}
@@ -226,6 +236,8 @@ Init_cairo_matrix (void)
RUBY_METHOD_FUNC (rb_cairo_matrix_scale), 2);
rb_define_method (rb_cCairo_Matrix, "rotate!",
RUBY_METHOD_FUNC (rb_cairo_matrix_rotate), 2);
+ rb_define_method (rb_cCairo_Matrix, "invert!",
+ RUBY_METHOD_FUNC (rb_cairo_matrix_invert), 0);
rb_define_method (rb_cCairo_Matrix, "multiply!",
RUBY_METHOD_FUNC (rb_cairo_matrix_multiply), 3);
rb_define_method (rb_cCairo_Matrix, "transform_point",
More information about the cairo
mailing list