cairo 1.17.6 → 1.17.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,7 @@
5
5
  * $Author: kou $
6
6
  * $Date: 2008-06-12 10:59:54 $
7
7
  *
8
- * Copyright 2012-2019 Kouhei Sutou <kou@cozmixng.org>
8
+ * Copyright 2012-2022 Sutou Kouhei <kou@cozmixng.org>
9
9
  * Copyright 2005 Øyvind Kolås <pippin@freedesktop.org>
10
10
  * Copyright 2004-2005 MenTaLguY <mental@rydia.com>
11
11
  *
@@ -133,6 +133,23 @@ cr_pattern_raster_source_supported_p (VALUE klass)
133
133
  #endif
134
134
  }
135
135
 
136
+ static void
137
+ cr_pattern_free (void *ptr)
138
+ {
139
+ cairo_pattern_destroy ((cairo_pattern_t *) ptr);
140
+ }
141
+
142
+ static const rb_data_type_t cr_pattern_type = {
143
+ "Cairo::Pattern",
144
+ {
145
+ NULL,
146
+ cr_pattern_free,
147
+ },
148
+ NULL,
149
+ NULL,
150
+ RUBY_TYPED_FREE_IMMEDIATELY,
151
+ };
152
+
136
153
  cairo_pattern_t *
137
154
  rb_cairo_pattern_from_ruby_object (VALUE obj)
138
155
  {
@@ -141,19 +158,10 @@ rb_cairo_pattern_from_ruby_object (VALUE obj)
141
158
  {
142
159
  rb_raise (rb_eTypeError, "not a cairo pattern");
143
160
  }
144
- Data_Get_Struct (obj, cairo_pattern_t, pattern);
161
+ TypedData_Get_Struct (obj, cairo_pattern_t, &cr_pattern_type, pattern);
145
162
  return pattern;
146
163
  }
147
164
 
148
- static void
149
- cr_pattern_free (void *ptr)
150
- {
151
- if (ptr)
152
- {
153
- cairo_pattern_destroy ((cairo_pattern_t *) ptr);
154
- }
155
- }
156
-
157
165
  VALUE
158
166
  rb_cairo_pattern_to_ruby_object (cairo_pattern_t *pattern)
159
167
  {
@@ -162,7 +170,7 @@ rb_cairo_pattern_to_ruby_object (cairo_pattern_t *pattern)
162
170
  VALUE klass;
163
171
  klass = cr_pattern_get_klass (pattern);
164
172
  cairo_pattern_reference (pattern);
165
- return Data_Wrap_Struct (klass, NULL, cr_pattern_free, pattern);
173
+ return TypedData_Wrap_Struct (klass, &cr_pattern_type, pattern);
166
174
  }
167
175
  else
168
176
  {
@@ -173,7 +181,7 @@ rb_cairo_pattern_to_ruby_object (cairo_pattern_t *pattern)
173
181
  static VALUE
174
182
  cr_pattern_allocate (VALUE klass)
175
183
  {
176
- return Data_Wrap_Struct (klass, NULL, cr_pattern_free, NULL);
184
+ return TypedData_Wrap_Struct (klass, &cr_pattern_type, NULL);
177
185
  }
178
186
 
179
187
  static VALUE
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  * Ruby Cairo Binding
4
4
  *
5
- * Copyright 2005-2014 Kouhei Sutou <kou@cozmixng.org>
5
+ * Copyright 2005-2022 Sutou Kouhei <kou@cozmixng.org>
6
6
  *
7
7
  * This file is made available under the same terms as Ruby
8
8
  *
@@ -15,10 +15,21 @@ VALUE rb_cCairo_Rectangle;
15
15
  #define _SELF ((cairo_rectangle_int_t *)DATA_PTR (self))
16
16
 
17
17
  #if CAIRO_CHECK_VERSION(1, 10, 0)
18
+ static const rb_data_type_t cr_rectangle_type = {
19
+ "Cairo::Rectangle",
20
+ {
21
+ NULL,
22
+ ruby_xfree,
23
+ },
24
+ NULL,
25
+ NULL,
26
+ RUBY_TYPED_FREE_IMMEDIATELY,
27
+ };
28
+
18
29
  static VALUE
19
30
  cr_rectangle_allocate (VALUE klass)
20
31
  {
21
- return Data_Wrap_Struct (klass, NULL, xfree, NULL);
32
+ return TypedData_Wrap_Struct (klass, &cr_rectangle_type, NULL);
22
33
  }
23
34
 
24
35
  static VALUE
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  * Ruby Cairo Binding
4
4
  *
5
- * Copyright 2010 Kouhei Sutou <kou@cozmixng.org>
5
+ * Copyright 2010-2022 Sutou Kouhei <kou@cozmixng.org>
6
6
  *
7
7
  * This file is made available under the same terms as Ruby
8
8
  *
@@ -18,6 +18,23 @@ VALUE rb_cCairo_Region = Qnil;
18
18
 
19
19
  #define _SELF (RVAL2CRREGION(self))
20
20
 
21
+ static void
22
+ cr_region_free (void *ptr)
23
+ {
24
+ cairo_region_destroy ((cairo_region_t *) ptr);
25
+ }
26
+
27
+ static const rb_data_type_t cr_region_type = {
28
+ "Cairo::Region",
29
+ {
30
+ NULL,
31
+ cr_region_free,
32
+ },
33
+ NULL,
34
+ NULL,
35
+ RUBY_TYPED_FREE_IMMEDIATELY,
36
+ };
37
+
21
38
  static inline void
22
39
  cr_region_check_status (cairo_region_t *region)
23
40
  {
@@ -32,26 +49,17 @@ rb_cairo_region_from_ruby_object (VALUE obj)
32
49
  {
33
50
  rb_raise (rb_eTypeError, "not a cairo region");
34
51
  }
35
- Data_Get_Struct (obj, cairo_region_t, region);
52
+ TypedData_Get_Struct (obj, cairo_region_t, &cr_region_type, region);
36
53
  return region;
37
54
  }
38
55
 
39
- static void
40
- cr_region_free (void *ptr)
41
- {
42
- if (ptr)
43
- {
44
- cairo_region_destroy ((cairo_region_t *) ptr);
45
- }
46
- }
47
-
48
56
  VALUE
49
57
  rb_cairo_region_to_ruby_object (cairo_region_t *region)
50
58
  {
51
59
  if (region)
52
60
  {
53
61
  cairo_region_reference (region);
54
- return Data_Wrap_Struct (rb_cCairo_Region, NULL, cr_region_free, region);
62
+ return TypedData_Wrap_Struct (rb_cCairo_Region, &cr_region_type, region);
55
63
  }
56
64
  else
57
65
  {
@@ -62,7 +70,7 @@ rb_cairo_region_to_ruby_object (cairo_region_t *region)
62
70
  static VALUE
63
71
  cr_region_allocate (VALUE klass)
64
72
  {
65
- return Data_Wrap_Struct (klass, NULL, cr_region_free, NULL);
73
+ return TypedData_Wrap_Struct (klass, &cr_region_type, NULL);
66
74
  }
67
75
 
68
76
  static VALUE
@@ -5,7 +5,7 @@
5
5
  * $Author: kou $
6
6
  * $Date: 2008-09-19 12:56:27 $
7
7
  *
8
- * Copyright 2005-2019 Kouhei Sutou <kou@cozmixng.org>
8
+ * Copyright 2005-2022 Sutou Kouhei <kou@cozmixng.org>
9
9
  *
10
10
  * This file is made available under the same terms as Ruby
11
11
  *
@@ -19,6 +19,23 @@ VALUE rb_cCairo_ScaledFont;
19
19
 
20
20
  #define _SELF(self) (RVAL2CRSCALEDFONT(self))
21
21
 
22
+ static void
23
+ cr_scaled_font_free (void *ptr)
24
+ {
25
+ cairo_scaled_font_destroy ((cairo_scaled_font_t *) ptr);
26
+ }
27
+
28
+ static const rb_data_type_t cr_scaled_font_type = {
29
+ "Cairo::ScaledFont",
30
+ {
31
+ NULL,
32
+ cr_scaled_font_free,
33
+ },
34
+ NULL,
35
+ NULL,
36
+ RUBY_TYPED_FREE_IMMEDIATELY,
37
+ };
38
+
22
39
  static inline void
23
40
  cr_scaled_font_check_status (cairo_scaled_font_t *font)
24
41
  {
@@ -33,27 +50,19 @@ rb_cairo_scaled_font_from_ruby_object (VALUE obj)
33
50
  {
34
51
  rb_raise (rb_eTypeError, "not a cairo scaled font");
35
52
  }
36
- Data_Get_Struct (obj, cairo_scaled_font_t, font);
53
+ TypedData_Get_Struct (obj, cairo_scaled_font_t, &cr_scaled_font_type, font);
37
54
  return font;
38
55
  }
39
56
 
40
- static void
41
- cr_scaled_font_free (void *ptr)
42
- {
43
- if (ptr)
44
- {
45
- cairo_scaled_font_destroy ((cairo_scaled_font_t *) ptr);
46
- }
47
- }
48
-
49
57
  VALUE
50
58
  rb_cairo_scaled_font_to_ruby_object (cairo_scaled_font_t *font)
51
59
  {
52
60
  if (font)
53
61
  {
54
62
  cairo_scaled_font_reference (font);
55
- return Data_Wrap_Struct (rb_cCairo_ScaledFont, NULL,
56
- cr_scaled_font_free, font);
63
+ return TypedData_Wrap_Struct (rb_cCairo_ScaledFont,
64
+ &cr_scaled_font_type,
65
+ font);
57
66
  }
58
67
  else
59
68
  {
@@ -64,7 +73,7 @@ rb_cairo_scaled_font_to_ruby_object (cairo_scaled_font_t *font)
64
73
  static VALUE
65
74
  cr_scaled_font_allocate (VALUE klass)
66
75
  {
67
- return Data_Wrap_Struct (klass, NULL, cr_scaled_font_free, NULL);
76
+ return TypedData_Wrap_Struct (klass, &cr_scaled_font_type, NULL);
68
77
  }
69
78
 
70
79
  static VALUE
@@ -103,6 +103,18 @@ static cairo_user_data_key_t cr_finished_key;
103
103
 
104
104
  #define _SELF (RVAL2CRSURFACE(self))
105
105
 
106
+ static void cr_surface_free (void *ptr);
107
+ static const rb_data_type_t cr_surface_type = {
108
+ "Cairo::Surface",
109
+ {
110
+ NULL,
111
+ cr_surface_free,
112
+ },
113
+ NULL,
114
+ NULL,
115
+ RUBY_TYPED_FREE_IMMEDIATELY,
116
+ };
117
+
106
118
  static VALUE
107
119
  cr_paper_parse (VALUE paper_description)
108
120
  {
@@ -240,7 +252,7 @@ rb_cairo_surface_from_ruby_object_without_null_check (VALUE obj)
240
252
  {
241
253
  rb_raise (rb_eTypeError, "not a cairo surface");
242
254
  }
243
- Data_Get_Struct (obj, cairo_surface_t, surface);
255
+ TypedData_Get_Struct (obj, cairo_surface_t, &cr_surface_type, surface);
244
256
  return surface;
245
257
  }
246
258
 
@@ -461,7 +473,7 @@ rb_cairo_surface_to_ruby_object (cairo_surface_t *surface)
461
473
  klass = cr_surface_get_klass (surface);
462
474
  cairo_surface_reference (surface);
463
475
  rb_cairo_surface_adjust_memory_usage (surface, CR_TRUE);
464
- return Data_Wrap_Struct (klass, NULL, cr_surface_free, surface);
476
+ return TypedData_Wrap_Struct (klass, &cr_surface_type, surface);
465
477
  }
466
478
  else
467
479
  {
@@ -484,7 +496,7 @@ rb_cairo_surface_to_ruby_object_with_destroy (cairo_surface_t *surface)
484
496
  static VALUE
485
497
  cr_surface_allocate (VALUE klass)
486
498
  {
487
- return Data_Wrap_Struct (klass, NULL, cr_surface_free, NULL);
499
+ return TypedData_Wrap_Struct (klass, &cr_surface_type, NULL);
488
500
  }
489
501
 
490
502
  static VALUE
@@ -5,7 +5,7 @@
5
5
  * $Author: kou $
6
6
  * $Date: 2008-08-16 08:16:40 $
7
7
  *
8
- * Copyright 2008 Kouhei Sutou <kou@cozmixng.org>
8
+ * Copyright 2008-2022 Sutou Kouhei <kou@cozmixng.org>
9
9
  *
10
10
  * This file is made available under the same terms as Ruby
11
11
  *
@@ -20,6 +20,17 @@ VALUE rb_cCairo_TextCluster = Qnil;
20
20
  #if CAIRO_CHECK_VERSION(1, 7, 2)
21
21
  #define _SELF(self) (RVAL2CRTEXTCLUSTER(self))
22
22
 
23
+ static const rb_data_type_t cr_text_cluster_type = {
24
+ "Cairo::TextCluster",
25
+ {
26
+ NULL,
27
+ ruby_xfree,
28
+ },
29
+ NULL,
30
+ NULL,
31
+ RUBY_TYPED_FREE_IMMEDIATELY,
32
+ };
33
+
23
34
  cairo_text_cluster_t *
24
35
  rb_cairo_text_cluster_from_ruby_object (VALUE obj)
25
36
  {
@@ -29,19 +40,13 @@ rb_cairo_text_cluster_from_ruby_object (VALUE obj)
29
40
  rb_raise (rb_eTypeError,
30
41
  "not a cairo cluster: %s", rb_cairo__inspect (obj));
31
42
  }
32
- Data_Get_Struct (obj, cairo_text_cluster_t, cluster);
43
+ TypedData_Get_Struct (obj,
44
+ cairo_text_cluster_t,
45
+ &cr_text_cluster_type,
46
+ cluster);
33
47
  return cluster;
34
48
  }
35
49
 
36
- static void
37
- cr_text_cluster_free (void *ptr)
38
- {
39
- if (ptr)
40
- {
41
- xfree (ptr);
42
- }
43
- }
44
-
45
50
  VALUE
46
51
  rb_cairo_text_cluster_to_ruby_object (cairo_text_cluster_t *cluster)
47
52
  {
@@ -51,8 +56,9 @@ rb_cairo_text_cluster_to_ruby_object (cairo_text_cluster_t *cluster)
51
56
 
52
57
  new_cluster = ALLOC (cairo_text_cluster_t);
53
58
  *new_cluster = *cluster;
54
- return Data_Wrap_Struct (rb_cCairo_TextCluster, NULL,
55
- cr_text_cluster_free, new_cluster);
59
+ return TypedData_Wrap_Struct (rb_cCairo_TextCluster,
60
+ &cr_text_cluster_type,
61
+ new_cluster);
56
62
  }
57
63
  else
58
64
  {
@@ -63,7 +69,7 @@ rb_cairo_text_cluster_to_ruby_object (cairo_text_cluster_t *cluster)
63
69
  static VALUE
64
70
  cr_text_cluster_allocate (VALUE klass)
65
71
  {
66
- return Data_Wrap_Struct (klass, NULL, cr_text_cluster_free, NULL);
72
+ return TypedData_Wrap_Struct (klass, &cr_text_cluster_type, NULL);
67
73
  }
68
74
 
69
75
  static VALUE
@@ -5,6 +5,7 @@
5
5
  * $Author: kou $
6
6
  * $Date: 2008-08-17 05:41:28 $
7
7
  *
8
+ * Copyright 2022 Sutou Kouhei <kou@cozmixng.org>
8
9
  * Copyright 2005 Øyvind Kolås <pippin@freedesktop.org>
9
10
  * Copyright 2004-2005 MenTaLguY <mental@rydia.com>
10
11
  *
@@ -19,6 +20,17 @@ VALUE rb_cCairo_TextExtents;
19
20
 
20
21
  #define _SELF(self) (RVAL2CRTEXTEXTENTS(self))
21
22
 
23
+ static const rb_data_type_t cr_text_extents_type = {
24
+ "Cairo::TextExtents",
25
+ {
26
+ NULL,
27
+ ruby_xfree,
28
+ },
29
+ NULL,
30
+ NULL,
31
+ RUBY_TYPED_FREE_IMMEDIATELY,
32
+ };
33
+
22
34
  cairo_text_extents_t *
23
35
  rb_cairo_text_extents_from_ruby_object (VALUE obj)
24
36
  {
@@ -27,7 +39,10 @@ rb_cairo_text_extents_from_ruby_object (VALUE obj)
27
39
  {
28
40
  rb_raise (rb_eTypeError, "not a cairo text_extents");
29
41
  }
30
- Data_Get_Struct (obj, cairo_text_extents_t, extents);
42
+ TypedData_Get_Struct (obj,
43
+ cairo_text_extents_t,
44
+ &cr_text_extents_type,
45
+ extents);
31
46
  return extents;
32
47
  }
33
48
 
@@ -38,7 +53,9 @@ rb_cairo_text_extents_to_ruby_object (cairo_text_extents_t *extents)
38
53
  {
39
54
  cairo_text_extents_t *new_extents = ALLOC (cairo_text_extents_t);
40
55
  *new_extents = *extents;
41
- return Data_Wrap_Struct (rb_cCairo_TextExtents, NULL, -1, new_extents);
56
+ return TypedData_Wrap_Struct (rb_cCairo_TextExtents,
57
+ &cr_text_extents_type,
58
+ new_extents);
42
59
  }
43
60
  else
44
61
  {
@@ -49,7 +66,7 @@ rb_cairo_text_extents_to_ruby_object (cairo_text_extents_t *extents)
49
66
  static VALUE
50
67
  cr_text_extents_allocate (VALUE klass)
51
68
  {
52
- return Data_Wrap_Struct (klass, NULL, -1, NULL);
69
+ return TypedData_Wrap_Struct (klass, &cr_text_extents_type, NULL);
53
70
  }
54
71
 
55
72
  static VALUE