~ubuntu-branches/ubuntu/karmic/libcairo-ruby/karmic

« back to all changes in this revision

Viewing changes to src/rb_cairo_exception.c

  • Committer: Bazaar Package Importer
  • Author(s): Paul van Tilburg, Gunnar Wolf, Paul van Tilburg
  • Date: 2009-05-05 12:14:31 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20090505121431-n803uyjz51je38l0
Tags: 1.8.0-1
[ Gunnar Wolf ]
* Changed section to Ruby as per ftp-masters' request

[ Paul van Tilburg ]
* New upstream release.
* debian/patches:
  - Dropped patch 01_fix-st.h-ruby1.9-paths: fixed by upstream. 
* debian/control:
  - Bumped standards version to 3.8.1; no changes required.
  - Added ${misc:Depends} to the depends of libcairo-ruby (binary).

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 * Ruby Cairo Binding
4
4
 *
5
5
 * $Author: kou $
6
 
 * $Date: 2008-02-21 13:18:10 $
 
6
 * $Date: 2008-08-16 12:52:16 $
7
7
 *
8
8
 * Copyright 2005 Øyvind Kolås <pippin@freedesktop.org>
9
9
 * Copyright 2004-2005 MenTaLguY <mental@rydia.com>
13
13
*/
14
14
 
15
15
#include "rb_cairo.h"
 
16
#include "rb_cairo_private.h"
16
17
 
17
18
static VALUE rb_eCairo_InvalidRestoreError;
18
19
static VALUE rb_eCairo_InvalidPopGroupError;
41
42
static VALUE rb_eCairo_TempFileError;
42
43
static VALUE rb_eCairo_InvalidStrideError;
43
44
#endif
 
45
#if CAIRO_CHECK_VERSION(1, 7, 2)
 
46
static VALUE rb_eCairo_FontTypeMismatch;
 
47
static VALUE rb_eCairo_UserFontImmutable;
 
48
static VALUE rb_eCairo_UserFontError;
 
49
static VALUE rb_eCairo_NegativeCount;
 
50
static VALUE rb_eCairo_InvalidClusters;
 
51
static VALUE rb_eCairo_InvalidSlant;
 
52
static VALUE rb_eCairo_InvalidWeight;
 
53
#endif
44
54
 
45
55
void
46
56
rb_cairo_check_status (cairo_status_t status)
127
137
      rb_raise (rb_eCairo_InvalidStringError, string);
128
138
      break;
129
139
#endif
 
140
#if CAIRO_CHECK_VERSION(1, 7, 2)
 
141
    case CAIRO_STATUS_FONT_TYPE_MISMATCH:
 
142
      rb_raise (rb_eCairo_FontTypeMismatch, string);
 
143
      break;
 
144
    case CAIRO_STATUS_USER_FONT_IMMUTABLE:
 
145
      rb_raise (rb_eCairo_UserFontImmutable, string);
 
146
      break;
 
147
    case CAIRO_STATUS_USER_FONT_ERROR:
 
148
      rb_raise (rb_eCairo_UserFontError, string);
 
149
      break;
 
150
    case CAIRO_STATUS_NEGATIVE_COUNT:
 
151
      rb_raise (rb_eCairo_NegativeCount, string);
 
152
      break;
 
153
    case CAIRO_STATUS_INVALID_CLUSTERS:
 
154
      rb_raise (rb_eCairo_InvalidClusters, string);
 
155
      break;
 
156
    case CAIRO_STATUS_INVALID_SLANT:
 
157
      rb_raise (rb_eCairo_InvalidSlant, string);
 
158
      break;
 
159
    case CAIRO_STATUS_INVALID_WEIGHT:
 
160
      rb_raise (rb_eCairo_InvalidWeight, string);
 
161
      break;
 
162
#endif
130
163
    }
131
164
}
132
165
 
 
166
cairo_status_t
 
167
rb_cairo__exception_to_status (VALUE exception)
 
168
{
 
169
  if (NIL_P (exception))
 
170
    return CAIRO_STATUS_SUCCESS;
 
171
  else if (rb_cairo__is_kind_of (exception, rb_eNoMemError))
 
172
    return CAIRO_STATUS_NO_MEMORY;
 
173
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_InvalidRestoreError))
 
174
    return CAIRO_STATUS_INVALID_RESTORE;
 
175
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_InvalidPopGroupError))
 
176
    return CAIRO_STATUS_INVALID_POP_GROUP;
 
177
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_NoCurrentPointError))
 
178
    return CAIRO_STATUS_NO_CURRENT_POINT;
 
179
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_InvalidMatrixError))
 
180
    return CAIRO_STATUS_INVALID_MATRIX;
 
181
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_InvalidStatusError))
 
182
    return CAIRO_STATUS_INVALID_STATUS;
 
183
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_NullPointerError))
 
184
    return CAIRO_STATUS_NULL_POINTER;
 
185
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_InvalidStringError))
 
186
    return CAIRO_STATUS_INVALID_STRING;
 
187
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_InvalidPathDataError))
 
188
    return CAIRO_STATUS_INVALID_PATH_DATA;
 
189
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_ReadError))
 
190
    return CAIRO_STATUS_READ_ERROR;
 
191
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_WriteError))
 
192
    return CAIRO_STATUS_WRITE_ERROR;
 
193
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_SurfaceFinishedError))
 
194
    return CAIRO_STATUS_SURFACE_FINISHED;
 
195
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_SurfaceTypeMismatchError))
 
196
    return CAIRO_STATUS_SURFACE_TYPE_MISMATCH;
 
197
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_PatternTypeMismatchError))
 
198
    return CAIRO_STATUS_PATTERN_TYPE_MISMATCH;
 
199
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_InvalidContentError))
 
200
    return CAIRO_STATUS_INVALID_CONTENT;
 
201
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_InvalidFormatError))
 
202
    return CAIRO_STATUS_INVALID_FORMAT;
 
203
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_InvalidVisualError))
 
204
    return CAIRO_STATUS_INVALID_VISUAL;
 
205
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_FileNotFoundError))
 
206
    return CAIRO_STATUS_FILE_NOT_FOUND;
 
207
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_InvalidDashError))
 
208
    return CAIRO_STATUS_INVALID_DASH;
 
209
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_InvalidDscCommentError))
 
210
    return CAIRO_STATUS_INVALID_DSC_COMMENT;
 
211
#if CAIRO_CHECK_VERSION(1, 3, 0)
 
212
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_InvalidIndexError))
 
213
    return CAIRO_STATUS_INVALID_INDEX;
 
214
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_ClipNotRepresentableError))
 
215
    return CAIRO_STATUS_CLIP_NOT_REPRESENTABLE;
 
216
#endif
 
217
#if CAIRO_CHECK_VERSION(1, 5, 6)
 
218
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_TempFileError))
 
219
    return CAIRO_STATUS_TEMP_FILE_ERROR;
 
220
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_InvalidStringError))
 
221
    return CAIRO_STATUS_INVALID_STRIDE;
 
222
#endif
 
223
#if CAIRO_CHECK_VERSION(1, 7, 2)
 
224
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_FontTypeMismatch))
 
225
    return CAIRO_STATUS_FONT_TYPE_MISMATCH;
 
226
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_UserFontImmutable))
 
227
    return CAIRO_STATUS_USER_FONT_IMMUTABLE;
 
228
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_UserFontError))
 
229
    return CAIRO_STATUS_USER_FONT_ERROR;
 
230
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_NegativeCount))
 
231
    return CAIRO_STATUS_NEGATIVE_COUNT;
 
232
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_InvalidClusters))
 
233
    return CAIRO_STATUS_INVALID_CLUSTERS;
 
234
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_InvalidSlant))
 
235
    return CAIRO_STATUS_INVALID_SLANT;
 
236
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_InvalidWeight))
 
237
    return CAIRO_STATUS_INVALID_WEIGHT;
 
238
#endif
 
239
 
 
240
  return -1;
 
241
}
 
242
 
133
243
void
134
244
Init_cairo_exception ()
135
245
{
208
318
                           rb_eCairo_Error);
209
319
 
210
320
  rb_eCairo_InvalidStrideError =
211
 
        rb_define_class_under (rb_mCairo, "InvalidStrideError",
212
 
                               rb_eArgError);
 
321
    rb_define_class_under (rb_mCairo, "InvalidStrideError",
 
322
                           rb_eArgError);
 
323
#endif
 
324
 
 
325
#if CAIRO_CHECK_VERSION(1, 7, 2)
 
326
  rb_eCairo_FontTypeMismatch =
 
327
    rb_define_class_under (rb_mCairo, "FontTypeMismatch",
 
328
                           rb_eCairo_Error);
 
329
 
 
330
  rb_eCairo_UserFontImmutable =
 
331
    rb_define_class_under (rb_mCairo, "UserFontImmutable",
 
332
                           rb_eCairo_Error);
 
333
 
 
334
  rb_eCairo_UserFontError =
 
335
    rb_define_class_under (rb_mCairo, "UserFontError",
 
336
                           rb_eCairo_Error);
 
337
 
 
338
  rb_eCairo_NegativeCount =
 
339
    rb_define_class_under (rb_mCairo, "NegativeCount",
 
340
                           rb_eCairo_Error);
 
341
 
 
342
  rb_eCairo_InvalidClusters =
 
343
    rb_define_class_under (rb_mCairo, "InvalidClusters",
 
344
                           rb_eArgError);
 
345
 
 
346
  rb_eCairo_InvalidSlant =
 
347
    rb_define_class_under (rb_mCairo, "InvalidSlant",
 
348
                           rb_eCairo_Error);
 
349
 
 
350
  rb_eCairo_InvalidWeight =
 
351
    rb_define_class_under (rb_mCairo, "InvalidWeight",
 
352
                           rb_eArgError);
213
353
#endif
214
354
}