xlsxwriter 0.2.2 → 0.2.3.pre.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8f03eb87d448a902c6067b95d4a3d7598cecd3456a3f8097e40da1bd0351c8d4
4
- data.tar.gz: 2af72c3d678d22a1990f960ee0b7f2315e39d37a780b5e589ebce7794b1b23f6
3
+ metadata.gz: 5bf5fbd1b3f4d6e80dc28c189f63478ff9a7d6253e6630abf697ebfd5c9b7cb5
4
+ data.tar.gz: a75bd6805709c6688497e5df0bcc9a4b3a53b94361e7cc09d9d67843f2cd0501
5
5
  SHA512:
6
- metadata.gz: 2ebcf14300b3cbaf46fc3a784c2ad9b5c114fa2ea3dccca08976ae8af7f50265beb05ed4233da92db1398bed7e17144779ca2c973cab59dad55e95fb3ee926ae
7
- data.tar.gz: 0cd298302d3c354ced238ed5fba71b7b05498db56c76df2b307d90603c122308c79780db9af55d1f46c7aece7f30da517a39d30f5d0b56acfd3107f79fbc9fb5
6
+ metadata.gz: d5be08fe10209e21d0956b58366fb06a0480f8f0145e3607cffeb78ecc12b0eec375a450165384278a0a0770a4d409c1e4bd9f3bb9852297c421cae481d10591
7
+ data.tar.gz: 83d7ed483b2f2245b5fc4f22afeca555f8216eb1f084504df8075855c50a49a96b24878638b6a63a8e8eb84c1dcdca46c4c3c92bba37c9de85a6ea73a0b887fe
@@ -10,9 +10,57 @@ VALUE cChart;
10
10
  VALUE cChartSeries;
11
11
  VALUE cChartAxis;
12
12
 
13
+ size_t
14
+ chart_size(const void *data) {
15
+ return sizeof(struct chart);
16
+ }
17
+
18
+ const rb_data_type_t chart_type = {
19
+ .wrap_struct_name = "chart",
20
+ .function = {
21
+ .dmark = NULL,
22
+ .dfree = ruby_xfree,
23
+ .dsize = chart_size,
24
+ },
25
+ .data = NULL,
26
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY,
27
+ };
28
+
29
+ size_t
30
+ chart_axis_size(const void *data) {
31
+ return sizeof(struct chart_axis);
32
+ }
33
+
34
+ const rb_data_type_t chart_axis_type = {
35
+ .wrap_struct_name = "chart_axis",
36
+ .function = {
37
+ .dmark = NULL,
38
+ .dfree = ruby_xfree,
39
+ .dsize = chart_axis_size,
40
+ },
41
+ .data = NULL,
42
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY,
43
+ };
44
+
45
+ size_t
46
+ chart_series_size(const void *data) {
47
+ return sizeof(struct chart_series);
48
+ }
49
+
50
+ const rb_data_type_t chart_series_type = {
51
+ .wrap_struct_name = "chart_series",
52
+ .function = {
53
+ .dmark = NULL,
54
+ .dfree = ruby_xfree,
55
+ .dsize = chart_series_size,
56
+ },
57
+ .data = NULL,
58
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY,
59
+ };
60
+
13
61
  #define DEF_PROP_SETTER(type, field, value) VALUE type ## _set_ ## field ## _ (VALUE self, VALUE val) { \
14
62
  struct type *ptr; \
15
- Data_Get_Struct(self, struct type, ptr); \
63
+ TypedData_Get_Struct(self, struct type, &(type ## _type), ptr); \
16
64
  type ## _set_ ## field (ptr->type, value); \
17
65
  return val; \
18
66
  }
@@ -20,10 +68,8 @@ VALUE cChartAxis;
20
68
 
21
69
  VALUE
22
70
  chart_alloc(VALUE klass) {
23
- VALUE obj;
24
71
  struct chart *ptr;
25
-
26
- obj = Data_Make_Struct(klass, struct chart, NULL, NULL, ptr);
72
+ VALUE obj = TypedData_Make_Struct(klass, struct chart, &chart_type, ptr);
27
73
 
28
74
  ptr->chart = NULL;
29
75
 
@@ -36,8 +82,8 @@ chart_init(VALUE self, VALUE workbook, VALUE type) {
36
82
  struct chart *ptr;
37
83
  struct workbook *wb_ptr;
38
84
 
39
- Data_Get_Struct(workbook, struct workbook, wb_ptr);
40
- Data_Get_Struct(self, struct chart, ptr);
85
+ TypedData_Get_Struct(workbook, struct workbook, &workbook_type, wb_ptr);
86
+ TypedData_Get_Struct(self, struct chart, &chart_type, ptr);
41
87
  if (wb_ptr && wb_ptr->workbook) {
42
88
  ptr->chart = workbook_add_chart(wb_ptr->workbook, NUM2INT(type));
43
89
  }
@@ -52,7 +98,7 @@ chart_axis_alloc(VALUE klass) {
52
98
  VALUE obj;
53
99
  struct chart_axis *ptr;
54
100
 
55
- obj = Data_Make_Struct(klass, struct chart_axis, NULL, NULL, ptr);
101
+ obj = TypedData_Make_Struct(klass, struct chart_axis, &chart_axis_type, ptr);
56
102
 
57
103
  return obj;
58
104
  }
@@ -63,8 +109,8 @@ chart_axis_init(VALUE self, VALUE chart, VALUE type) {
63
109
  struct chart_axis *ptr;
64
110
  struct chart *c_ptr;
65
111
 
66
- Data_Get_Struct(chart, struct chart, c_ptr);
67
- Data_Get_Struct(self, struct chart_axis, ptr);
112
+ TypedData_Get_Struct(chart, struct chart, &chart_type, c_ptr);
113
+ TypedData_Get_Struct(self, struct chart_axis, &chart_axis_type, ptr);
68
114
  rb_iv_set(self, "@chart", chart);
69
115
  if (c_ptr && c_ptr->chart) {
70
116
  ID axis = rb_check_id_cstr("x", 1, NULL);
@@ -92,7 +138,7 @@ chart_series_alloc(VALUE klass) {
92
138
  VALUE obj;
93
139
  struct chart_series *ptr;
94
140
 
95
- obj = Data_Make_Struct(klass, struct chart_series, NULL, NULL, ptr);
141
+ obj = TypedData_Make_Struct(klass, struct chart_series, &chart_series_type, ptr);
96
142
 
97
143
  ptr->chart_series = NULL;
98
144
 
@@ -107,8 +153,8 @@ chart_series_init(int argc, VALUE *argv, VALUE self) {
107
153
  char *cats = NULL, *vals = NULL;
108
154
  rb_check_arity(argc, 1, 3);
109
155
 
110
- Data_Get_Struct(argv[0], struct chart, c_ptr);
111
- Data_Get_Struct(self, struct chart_series, ptr);
156
+ TypedData_Get_Struct(argv[0], struct chart, &chart_type, c_ptr);
157
+ TypedData_Get_Struct(self, struct chart_series, &chart_series_type, ptr);
112
158
 
113
159
  if (argc > 2) {
114
160
  cats = StringValueCStr(argv[1]);
@@ -160,7 +206,7 @@ chart_y_axis_(VALUE self) {
160
206
  VALUE
161
207
  chart_title_set_name_(VALUE self, VALUE name) {
162
208
  struct chart *ptr;
163
- Data_Get_Struct(self, struct chart, ptr);
209
+ TypedData_Get_Struct(self, struct chart, &chart_type, ptr);
164
210
 
165
211
  if (RTEST(name)) {
166
212
  chart_title_set_name(ptr->chart, StringValueCStr(name));
@@ -259,7 +305,7 @@ DEF_PROP_SETTER(chart, hole_size, NUM2UINT(rb_check_to_int(val)))
259
305
  VALUE
260
306
  chart_set_show_blank_as_(VALUE self, VALUE val) {
261
307
  struct chart *ptr;
262
- Data_Get_Struct(self, struct chart, ptr);
308
+ TypedData_Get_Struct(self, struct chart, &chart_type, ptr);
263
309
  ptr->chart->show_blanks_as = NUM2INT(rb_check_to_int(val));
264
310
  return val;
265
311
  }
@@ -269,7 +315,7 @@ chart_set_show_blank_as_(VALUE self, VALUE val) {
269
315
  VALUE
270
316
  chart_get_axis_id_1_(VALUE self) {
271
317
  struct chart *ptr;
272
- Data_Get_Struct(self, struct chart, ptr);
318
+ TypedData_Get_Struct(self, struct chart, &chart_type, ptr);
273
319
  return UINT2NUM(ptr->chart->axis_id_1);
274
320
  }
275
321
 
@@ -277,7 +323,7 @@ chart_get_axis_id_1_(VALUE self) {
277
323
  VALUE
278
324
  chart_set_axis_id_1_(VALUE self, VALUE val) {
279
325
  struct chart *ptr;
280
- Data_Get_Struct(self, struct chart, ptr);
326
+ TypedData_Get_Struct(self, struct chart, &chart_type, ptr);
281
327
  ptr->chart->axis_id_1 = NUM2UINT(rb_check_to_int(val));
282
328
  return val;
283
329
  }
@@ -286,7 +332,7 @@ chart_set_axis_id_1_(VALUE self, VALUE val) {
286
332
  VALUE
287
333
  chart_get_axis_id_2_(VALUE self) {
288
334
  struct chart *ptr;
289
- Data_Get_Struct(self, struct chart, ptr);
335
+ TypedData_Get_Struct(self, struct chart, &chart_type, ptr);
290
336
  return UINT2NUM(ptr->chart->axis_id_2);
291
337
  }
292
338
 
@@ -294,7 +340,7 @@ chart_get_axis_id_2_(VALUE self) {
294
340
  VALUE
295
341
  chart_set_axis_id_2_(VALUE self, VALUE val) {
296
342
  struct chart *ptr;
297
- Data_Get_Struct(self, struct chart, ptr);
343
+ TypedData_Get_Struct(self, struct chart, &chart_type, ptr);
298
344
  ptr->chart->axis_id_2 = NUM2UINT(rb_check_to_int(val));
299
345
  return val;
300
346
  }
@@ -456,7 +502,7 @@ VALUE
456
502
  chart_axis_set_source_linked_(VALUE self, VALUE val) {
457
503
  struct chart_axis *ptr;
458
504
 
459
- Data_Get_Struct(self, struct chart_axis, ptr);
505
+ TypedData_Get_Struct(self, struct chart_axis, &chart_axis_type, ptr);
460
506
 
461
507
  ptr->chart_axis->source_linked = NUM2UINT(rb_check_to_int(val));
462
508
 
@@ -25,5 +25,6 @@ void init_xlsxwriter_chart();
25
25
  extern VALUE cChart;
26
26
  extern VALUE cChartSeries;
27
27
  extern VALUE cChartAxis;
28
+ extern const rb_data_type_t chart_type;
28
29
 
29
30
  #endif // __CHART__
@@ -6,15 +6,31 @@
6
6
 
7
7
  VALUE cChartsheet;
8
8
 
9
+ void chartsheet_clear(void *p);
9
10
  void chartsheet_free(void *p);
10
11
 
12
+ size_t
13
+ chartsheet_size(const void *data) {
14
+ return sizeof(struct chartsheet);
15
+ }
16
+
17
+ const rb_data_type_t chartsheet_type = {
18
+ .wrap_struct_name = "chartsheet",
19
+ .function = {
20
+ .dmark = NULL,
21
+ .dfree = chartsheet_free,
22
+ .dsize = chartsheet_size,
23
+ },
24
+ .data = NULL,
25
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY,
26
+ };
11
27
 
12
28
  VALUE
13
29
  chartsheet_alloc(VALUE klass) {
14
30
  VALUE obj;
15
31
  struct chartsheet *ptr;
16
32
 
17
- obj = Data_Make_Struct(klass, struct chartsheet, NULL, chartsheet_free, ptr);
33
+ obj = TypedData_Make_Struct(klass, struct chartsheet, &chartsheet_type, ptr);
18
34
 
19
35
  ptr->chartsheet = NULL;
20
36
 
@@ -28,7 +44,7 @@ chartsheet_init(int argc, VALUE *argv, VALUE self) {
28
44
  struct workbook *wb_ptr;
29
45
  struct chartsheet *ptr;
30
46
 
31
- Data_Get_Struct(self, struct chartsheet, ptr);
47
+ TypedData_Get_Struct(self, struct chartsheet, &chartsheet_type, ptr);
32
48
 
33
49
  if (argc == 2) {
34
50
  name = StringValueCStr(argv[1]);
@@ -36,7 +52,7 @@ chartsheet_init(int argc, VALUE *argv, VALUE self) {
36
52
 
37
53
  rb_iv_set(self, "@workbook", argv[0]);
38
54
 
39
- Data_Get_Struct(argv[0], struct workbook, wb_ptr);
55
+ TypedData_Get_Struct(argv[0], struct workbook, &workbook_type, wb_ptr);
40
56
  ptr->chartsheet = workbook_add_chartsheet(wb_ptr->workbook, name);
41
57
  if (!ptr->chartsheet)
42
58
  rb_raise(eXlsxWriterError, "chartsheet was not created");
@@ -47,20 +63,25 @@ chartsheet_init(int argc, VALUE *argv, VALUE self) {
47
63
  VALUE
48
64
  chartsheet_release(VALUE self) {
49
65
  struct chartsheet *ptr;
50
- Data_Get_Struct(self, struct chartsheet, ptr);
66
+ TypedData_Get_Struct(self, struct chartsheet, &chartsheet_type, ptr);
51
67
 
52
- chartsheet_free(ptr);
68
+ chartsheet_clear(ptr);
53
69
  return self;
54
70
  }
55
71
 
56
72
  void
57
- chartsheet_free(void *p) {
73
+ chartsheet_clear(void *p) {
58
74
  struct chartsheet *ptr = p;
59
75
 
60
76
  if (ptr->chartsheet)
61
77
  ptr->chartsheet = NULL;
62
78
  }
63
79
 
80
+ void
81
+ chartsheet_free(void *p) {
82
+ chartsheet_clear(p);
83
+ ruby_xfree(p);
84
+ }
64
85
 
65
86
  /* call-seq: cs.activate -> self
66
87
  *
@@ -79,7 +100,7 @@ chartsheet_activate_(VALUE self) {
79
100
  VALUE
80
101
  chartsheet_set_chart_(VALUE self, VALUE chart) {
81
102
  struct chart *chart_ptr;
82
- Data_Get_Struct(chart, struct chart, chart_ptr);
103
+ TypedData_Get_Struct(chart, struct chart, &chart_type, chart_ptr);
83
104
 
84
105
  LXW_ERR_RESULT_CALL(chartsheet, set_chart, chart_ptr->chart);
85
106
  return self;
@@ -139,7 +160,7 @@ chartsheet_set_footer_(int argc, VALUE *argv, VALUE self) {
139
160
  rb_check_arity(argc, 1, 2);
140
161
  struct _header_options ho = _extract_header_options(argc, argv);
141
162
  struct chartsheet *ptr;
142
- Data_Get_Struct(self, struct chartsheet, ptr);
163
+ TypedData_Get_Struct(self, struct chartsheet, &chartsheet_type, ptr);
143
164
  lxw_error err;
144
165
  if (!ho.with_options) {
145
166
  err = chartsheet_set_footer(ptr->chartsheet, ho.str);
@@ -169,7 +190,7 @@ chartsheet_set_header_(int argc, VALUE *argv, VALUE self) {
169
190
  rb_check_arity(argc, 1, 2);
170
191
  struct _header_options ho = _extract_header_options(argc, argv);
171
192
  struct chartsheet *ptr;
172
- Data_Get_Struct(self, struct chartsheet, ptr);
193
+ TypedData_Get_Struct(self, struct chartsheet, &chartsheet_type, ptr);
173
194
  lxw_error err;
174
195
  if (!ho.with_options) {
175
196
  err = chartsheet_set_header(ptr->chartsheet, ho.str);
@@ -236,7 +257,7 @@ chartsheet_set_zoom_(VALUE self, VALUE val) {
236
257
  VALUE
237
258
  chartsheet_get_horizontal_dpi_(VALUE self) {
238
259
  struct chartsheet *ptr;
239
- Data_Get_Struct(self, struct chartsheet, ptr);
260
+ TypedData_Get_Struct(self, struct chartsheet, &chartsheet_type, ptr);
240
261
  return INT2NUM(ptr->chartsheet->worksheet->horizontal_dpi);
241
262
  }
242
263
 
@@ -247,7 +268,7 @@ chartsheet_get_horizontal_dpi_(VALUE self) {
247
268
  VALUE
248
269
  chartsheet_set_horizontal_dpi_(VALUE self, VALUE val) {
249
270
  struct chartsheet *ptr;
250
- Data_Get_Struct(self, struct chartsheet, ptr);
271
+ TypedData_Get_Struct(self, struct chartsheet, &chartsheet_type, ptr);
251
272
  ptr->chartsheet->worksheet->horizontal_dpi = NUM2INT(val);
252
273
  return val;
253
274
  }
@@ -259,7 +280,7 @@ chartsheet_set_horizontal_dpi_(VALUE self, VALUE val) {
259
280
  VALUE
260
281
  chartsheet_get_vertical_dpi_(VALUE self) {
261
282
  struct chartsheet *ptr;
262
- Data_Get_Struct(self, struct chartsheet, ptr);
283
+ TypedData_Get_Struct(self, struct chartsheet, &chartsheet_type, ptr);
263
284
  return INT2NUM(ptr->chartsheet->worksheet->vertical_dpi);
264
285
  }
265
286
 
@@ -270,7 +291,7 @@ chartsheet_get_vertical_dpi_(VALUE self) {
270
291
  VALUE
271
292
  chartsheet_set_vertical_dpi_(VALUE self, VALUE val) {
272
293
  struct chartsheet *ptr;
273
- Data_Get_Struct(self, struct chartsheet, ptr);
294
+ TypedData_Get_Struct(self, struct chartsheet, &chartsheet_type, ptr);
274
295
  ptr->chartsheet->worksheet->vertical_dpi = NUM2INT(val);
275
296
  return val;
276
297
  }
@@ -1,18 +1,18 @@
1
1
  #include <ruby.h>
2
2
  #include <ruby/intern.h>
3
- #include <xlsxwriter_ext.h>
3
+ #include "xlsxwriter_ext.h"
4
4
 
5
5
  #ifndef __COMMON__
6
6
  #define __COMMON__
7
7
 
8
8
  #define LXW_NO_RESULT_CALL(cls, method, ...) { \
9
9
  struct cls *ptr; \
10
- Data_Get_Struct(self, struct cls, ptr); \
10
+ TypedData_Get_Struct(self, struct cls, &(cls ## _type), ptr); \
11
11
  cls ## _ ## method(ptr->cls, ##__VA_ARGS__); }
12
12
 
13
13
  #define LXW_ERR_RESULT_CALL(cls, method, ...) { \
14
14
  struct cls *ptr; \
15
- Data_Get_Struct(self, struct cls, ptr); \
15
+ TypedData_Get_Struct(self, struct cls, &(cls ## _type), ptr); \
16
16
  lxw_error err = cls ## _ ## method(ptr->cls, ##__VA_ARGS__); \
17
17
  handle_lxw_error(err); }
18
18
 
@@ -38,7 +38,7 @@ _extract_protect_options(int argc, VALUE *argv) {
38
38
  opts = argv[0];
39
39
  break;
40
40
  default:
41
- rb_raise(rb_eArgError, "Wrong argument %"PRIsVALUE", expected a String or Hash", rb_obj_class(argv[0]));
41
+ rb_raise(rb_eArgError, "Wrong argument %" PRIsVALUE ", expected a String or Hash", rb_obj_class(argv[0]));
42
42
  }
43
43
  }
44
44
 
@@ -46,7 +46,7 @@ _extract_protect_options(int argc, VALUE *argv) {
46
46
  if (TYPE(argv[1]) == T_HASH) {
47
47
  opts = argv[1];
48
48
  } else {
49
- rb_raise(rb_eArgError, "Expected a Hash, but got %"PRIsVALUE, rb_obj_class(argv[1]));
49
+ rb_raise(rb_eArgError, "Expected a Hash, but got %" PRIsVALUE, rb_obj_class(argv[1]));
50
50
  }
51
51
  }
52
52
 
@@ -5,22 +5,39 @@
5
5
 
6
6
  VALUE cRichString;
7
7
 
8
+ void rich_string_clear(void *p);
8
9
  void rich_string_free(void *p);
9
10
 
11
+ size_t
12
+ rich_string_size(const void *data) {
13
+ return sizeof(lxw_rich_string_tuple *);
14
+ }
15
+
16
+ const rb_data_type_t rich_string_type = {
17
+ .wrap_struct_name = "lxw_rich_string_tuple",
18
+ .function =
19
+ {
20
+ .dmark = NULL,
21
+ .dfree = rich_string_free,
22
+ .dsize = rich_string_size,
23
+ },
24
+ .data = NULL,
25
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY,
26
+ };
10
27
 
11
28
  VALUE
12
29
  rich_string_alloc(VALUE klass) {
13
30
  VALUE obj;
14
31
  lxw_rich_string_tuple **ptr;
15
32
 
16
- obj = Data_Make_Struct(klass, lxw_rich_string_tuple *, NULL, rich_string_free, ptr);
33
+ obj = TypedData_Make_Struct(klass, lxw_rich_string_tuple *, &rich_string_type, ptr);
17
34
  *ptr = NULL;
18
35
 
19
36
  return obj;
20
37
  }
21
38
 
22
39
  void
23
- rich_string_free(void *p) {
40
+ rich_string_clear(void *p) {
24
41
  lxw_rich_string_tuple **ptr = p;
25
42
  if (*ptr) {
26
43
  ruby_xfree(*ptr);
@@ -28,16 +45,18 @@ rich_string_free(void *p) {
28
45
  }
29
46
  }
30
47
 
48
+ void
49
+ rich_string_free(void *p) {
50
+ rich_string_clear(p);
51
+ ruby_xfree(p);
52
+ }
53
+
31
54
  VALUE
32
55
  rich_string_cached_p(VALUE self) {
33
56
  lxw_rich_string_tuple **ptr;
34
- Data_Get_Struct(self, lxw_rich_string_tuple *, ptr);
57
+ TypedData_Get_Struct(self, lxw_rich_string_tuple *, &rich_string_type, ptr);
35
58
 
36
- if (*ptr) {
37
- return Qtrue;
38
- } else {
39
- return Qfalse;
40
- }
59
+ return (*ptr ? Qtrue : Qfalse);
41
60
  }
42
61
 
43
62
  lxw_rich_string_tuple **
@@ -48,7 +67,7 @@ serialize_rich_string(VALUE rs) {
48
67
  int len = RARRAY_LEN(arr);
49
68
 
50
69
  lxw_rich_string_tuple **ptr;
51
- Data_Get_Struct(rs, lxw_rich_string_tuple *, ptr);
70
+ TypedData_Get_Struct(rs, lxw_rich_string_tuple *, &rich_string_type, ptr);
52
71
 
53
72
  if (*ptr) { // cached
54
73
  return (lxw_rich_string_tuple **) *ptr;
@@ -10,14 +10,28 @@ struct sst {
10
10
 
11
11
  VALUE cSharedStringsTable;
12
12
 
13
- void sst_free(void *p);
13
+ size_t sst_size(const void *data) {
14
+ return sizeof(struct sst);
15
+ }
16
+
17
+ const rb_data_type_t sst_type = {
18
+ .wrap_struct_name = "lxw_rich_string_tuple",
19
+ .function =
20
+ {
21
+ .dmark = NULL,
22
+ .dfree = ruby_xfree,
23
+ .dsize = sst_size,
24
+ },
25
+ .data = NULL,
26
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY,
27
+ };
14
28
 
15
29
  /* :nodoc: */
16
30
  VALUE
17
31
  sst_alloc(VALUE klass) {
18
32
  VALUE obj;
19
33
  struct sst *sst_ptr;
20
- obj = Data_Make_Struct(klass, struct sst, NULL, sst_free, sst_ptr);
34
+ obj = TypedData_Make_Struct(klass, struct sst, &sst_type, sst_ptr);
21
35
  sst_ptr->sst = NULL;
22
36
 
23
37
  return obj;
@@ -30,26 +44,22 @@ alloc_shared_strings_table_by_ref(struct lxw_sst *sst) {
30
44
 
31
45
  VALUE object = rb_obj_alloc(cSharedStringsTable);
32
46
  struct sst *sst_ptr;
33
- Data_Get_Struct(object, struct sst, sst_ptr);
47
+ TypedData_Get_Struct(object, struct sst, &sst_type, sst_ptr);
34
48
  sst_ptr->sst = sst;
35
49
  return object;
36
50
  }
37
51
 
38
- void
39
- sst_free(void *p) {
40
- }
41
-
42
52
  VALUE
43
53
  sst_string_count_get_(VALUE self) {
44
54
  struct sst *sst_ptr;
45
- Data_Get_Struct(self, struct sst, sst_ptr);
55
+ TypedData_Get_Struct(self, struct sst, &sst_type, sst_ptr);
46
56
  return INT2NUM(sst_ptr->sst->string_count);
47
57
  }
48
58
 
49
59
  VALUE
50
60
  sst_string_count_set_(VALUE self, VALUE val) {
51
61
  struct sst *sst_ptr;
52
- Data_Get_Struct(self, struct sst, sst_ptr);
62
+ TypedData_Get_Struct(self, struct sst, &sst_type, sst_ptr);
53
63
 
54
64
  sst_ptr->sst->string_count = NUM2INT(val);
55
65
  return val;
@@ -15,16 +15,30 @@
15
15
 
16
16
  VALUE cWorkbook;
17
17
 
18
+ void workbook_clear(void *p);
18
19
  void workbook_free(void *p);
19
20
  VALUE workbook_release(VALUE self);
20
21
 
22
+ size_t
23
+ workbook_size(const void *data) {
24
+ return sizeof(struct workbook);
25
+ }
26
+
27
+ const rb_data_type_t workbook_type = {
28
+ .wrap_struct_name = "workbook",
29
+ .function = {
30
+ .dmark = NULL,
31
+ .dfree = workbook_free,
32
+ .dsize = workbook_size,
33
+ },
34
+ .data = NULL,
35
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY,
36
+ };
21
37
 
22
38
  VALUE
23
39
  workbook_alloc(VALUE klass) {
24
- VALUE obj;
25
40
  struct workbook *ptr;
26
-
27
- obj = Data_Make_Struct(klass, struct workbook, NULL, workbook_free, ptr);
41
+ VALUE obj = TypedData_Make_Struct(klass, struct workbook, &workbook_type, ptr);
28
42
 
29
43
  ptr->path = NULL;
30
44
  ptr->workbook = NULL;
@@ -89,7 +103,7 @@ workbook_init(int argc, VALUE *argv, VALUE self) {
89
103
  }
90
104
  }
91
105
 
92
- Data_Get_Struct(self, struct workbook, ptr);
106
+ TypedData_Get_Struct(self, struct workbook, &workbook_type, ptr);
93
107
 
94
108
  size_t len = RSTRING_LEN(argv[0]);
95
109
  ptr->path = malloc(len + 1);
@@ -120,14 +134,14 @@ workbook_init(int argc, VALUE *argv, VALUE self) {
120
134
  VALUE
121
135
  workbook_release(VALUE self) {
122
136
  struct workbook *ptr;
123
- Data_Get_Struct(self, struct workbook, ptr);
137
+ TypedData_Get_Struct(self, struct workbook, &workbook_type, ptr);
124
138
 
125
- workbook_free(ptr);
139
+ workbook_clear(ptr);
126
140
  return self;
127
141
  }
128
142
 
129
143
  void
130
- workbook_free(void *p) {
144
+ workbook_clear(void *p) {
131
145
  struct workbook *ptr = p;
132
146
 
133
147
  if (ptr->workbook) {
@@ -169,6 +183,11 @@ workbook_free(void *p) {
169
183
  }
170
184
  }
171
185
 
186
+ void workbook_free(void *p) {
187
+ workbook_clear(p);
188
+ ruby_xfree(p);
189
+ };
190
+
172
191
  /* call-seq:
173
192
  * wb.add_worksheet([name]) -> ws
174
193
  * wb.add_worksheet([name]) { |ws| block } -> obj
@@ -188,7 +207,7 @@ workbook_add_worksheet_(int argc, VALUE *argv, VALUE self) {
188
207
  rb_check_arity(argc, 0, 1);
189
208
 
190
209
  struct workbook *ptr;
191
- Data_Get_Struct(self, struct workbook, ptr);
210
+ TypedData_Get_Struct(self, struct workbook, &workbook_type, ptr);
192
211
  if (ptr->workbook) {
193
212
  worksheet = rb_funcall(cWorksheet, rb_intern("new"), argc + 1, self, argv[0]);
194
213
  }
@@ -220,7 +239,7 @@ workbook_add_chartsheet_(int argc, VALUE *argv, VALUE self) {
220
239
  rb_check_arity(argc, 0, 1);
221
240
 
222
241
  struct workbook *ptr;
223
- Data_Get_Struct(self, struct workbook, ptr);
242
+ TypedData_Get_Struct(self, struct workbook, &workbook_type, ptr);
224
243
  if (ptr->workbook) {
225
244
  chartsheet = rb_funcall(cChartsheet, rb_intern("new"), argc + 1, self, argv[0]);
226
245
  }
@@ -268,7 +287,7 @@ VALUE
268
287
  workbook_add_format_(VALUE self, VALUE key, VALUE opts) {
269
288
  struct workbook *ptr;
270
289
  lxw_format *format;
271
- Data_Get_Struct(self, struct workbook, ptr);
290
+ TypedData_Get_Struct(self, struct workbook, &workbook_type, ptr);
272
291
 
273
292
  if (!ptr->formats) {
274
293
  ptr->formats = st_init_numtable();
@@ -335,7 +354,7 @@ workbook_add_vba_project_(VALUE self, VALUE filename) {
335
354
  VALUE
336
355
  workbook_set_default_xf_indices_(VALUE self) {
337
356
  struct workbook *ptr;
338
- Data_Get_Struct(self, struct workbook, ptr);
357
+ TypedData_Get_Struct(self, struct workbook, &workbook_type, ptr);
339
358
  lxw_workbook_set_default_xf_indices(ptr->workbook);
340
359
  return self;
341
360
  }
@@ -385,7 +404,7 @@ VALUE
385
404
  workbook_unset_default_url_format_(VALUE self) {
386
405
  struct workbook *ptr;
387
406
 
388
- Data_Get_Struct(self, struct workbook, ptr);
407
+ TypedData_Get_Struct(self, struct workbook, &workbook_type, ptr);
389
408
  workbook_unset_default_url_format(ptr->workbook);
390
409
 
391
410
  return self;
@@ -396,7 +415,7 @@ workbook_unset_default_url_format_(VALUE self) {
396
415
  VALUE
397
416
  workbook_max_url_length_(VALUE self) {
398
417
  struct workbook *ptr;
399
- Data_Get_Struct(self, struct workbook, ptr);
418
+ TypedData_Get_Struct(self, struct workbook, &workbook_type, ptr);
400
419
  return INT2NUM(ptr->workbook->max_url_length);
401
420
  }
402
421
 
@@ -406,7 +425,7 @@ VALUE
406
425
  workbook_max_url_length_set_(VALUE self, VALUE value) {
407
426
  struct workbook *ptr;
408
427
 
409
- Data_Get_Struct(self, struct workbook, ptr);
428
+ TypedData_Get_Struct(self, struct workbook, &workbook_type, ptr);
410
429
 
411
430
  ptr->workbook->max_url_length = NUM2INT(value);
412
431
 
@@ -422,7 +441,7 @@ VALUE
422
441
  workbook_sst_(VALUE self) {
423
442
  struct workbook *ptr;
424
443
 
425
- Data_Get_Struct(self, struct workbook, ptr);
444
+ TypedData_Get_Struct(self, struct workbook, &workbook_type, ptr);
426
445
 
427
446
  return alloc_shared_strings_table_by_ref(ptr->workbook->sst);
428
447
  }
@@ -450,7 +469,7 @@ workbook_get_format(VALUE self, VALUE key) {
450
469
  if (NIL_P(key))
451
470
  return NULL;
452
471
 
453
- Data_Get_Struct(self, struct workbook, ptr);
472
+ TypedData_Get_Struct(self, struct workbook, &workbook_type, ptr);
454
473
 
455
474
  if (!ptr->formats)
456
475
  return NULL;
@@ -17,5 +17,6 @@ void init_xlsxwriter_workbook();
17
17
 
18
18
  extern VALUE mXlsxWriter;
19
19
  extern VALUE cWorkbook;
20
+ extern const rb_data_type_t workbook_type;
20
21
 
21
22
  #endif // __WORKBOOK__
@@ -11,7 +11,7 @@ VALUE
11
11
  workbook_properties_init_(VALUE self, VALUE workbook) {
12
12
  struct workbook *wb_ptr;
13
13
  rb_iv_set(self, "@workbook", workbook);
14
- Data_Get_Struct(workbook, struct workbook, wb_ptr);
14
+ TypedData_Get_Struct(workbook, struct workbook, &workbook_type, wb_ptr);
15
15
  if (!wb_ptr->properties) {
16
16
  wb_ptr->properties = calloc(1, sizeof(lxw_doc_properties));
17
17
  }
@@ -42,7 +42,7 @@ workbook_properties_set_(VALUE self, VALUE key, VALUE value) {
42
42
  }
43
43
 
44
44
  struct workbook *wb_ptr;
45
- Data_Get_Struct(rb_iv_get(self, "@workbook"), struct workbook, wb_ptr);
45
+ TypedData_Get_Struct(rb_iv_get(self, "@workbook"), struct workbook, &workbook_type, wb_ptr);
46
46
  lxw_doc_properties *props = wb_ptr->properties;
47
47
  if (!props) {
48
48
  rb_raise(rb_eRuntimeError, "Workbook properties are already freed.");
@@ -7,15 +7,32 @@
7
7
 
8
8
  VALUE cWorksheet;
9
9
 
10
+ void worksheet_clear(void *p);
10
11
  void worksheet_free(void *p);
11
12
 
13
+ size_t worksheet_size(const void *data) {
14
+ return sizeof(struct worksheet);
15
+ }
16
+
17
+ const rb_data_type_t worksheet_type = {
18
+ .wrap_struct_name = "worksheet",
19
+ .function =
20
+ {
21
+ .dmark = NULL,
22
+ .dfree = worksheet_free,
23
+ .dsize = worksheet_size,
24
+ },
25
+ .data = NULL,
26
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY,
27
+ };
28
+
12
29
 
13
30
  VALUE
14
31
  worksheet_alloc(VALUE klass) {
15
32
  VALUE obj;
16
33
  struct worksheet *ptr;
17
34
 
18
- obj = Data_Make_Struct(klass, struct worksheet, NULL, worksheet_free, ptr);
35
+ obj = TypedData_Make_Struct(klass, struct worksheet, &worksheet_type, ptr);
19
36
 
20
37
  ptr->worksheet = NULL;
21
38
 
@@ -31,7 +48,7 @@ worksheet_init(int argc, VALUE *argv, VALUE self) {
31
48
  struct workbook *wb_ptr;
32
49
  struct worksheet *ptr;
33
50
 
34
- Data_Get_Struct(self, struct worksheet, ptr);
51
+ TypedData_Get_Struct(self, struct worksheet, &worksheet_type, ptr);
35
52
 
36
53
  rb_check_arity(argc, 1, 2);
37
54
  if (argc == 2) {
@@ -66,7 +83,7 @@ worksheet_init(int argc, VALUE *argv, VALUE self) {
66
83
  rb_iv_set(self, "@use_auto_width", auto_width);
67
84
  rb_iv_set(self, "@col_auto_widths", rb_ary_new());
68
85
 
69
- Data_Get_Struct(argv[0], struct workbook, wb_ptr);
86
+ TypedData_Get_Struct(argv[0], struct workbook, &workbook_type, wb_ptr);
70
87
  ptr->worksheet = workbook_add_worksheet(wb_ptr->workbook, name);
71
88
  if (!ptr->worksheet)
72
89
  rb_raise(eXlsxWriterError, "worksheet was not created");
@@ -77,14 +94,14 @@ worksheet_init(int argc, VALUE *argv, VALUE self) {
77
94
  VALUE
78
95
  worksheet_release(VALUE self) {
79
96
  struct worksheet *ptr;
80
- Data_Get_Struct(self, struct worksheet, ptr);
97
+ TypedData_Get_Struct(self, struct worksheet, &worksheet_type, ptr);
81
98
 
82
- worksheet_free(ptr);
99
+ worksheet_clear(ptr);
83
100
  return self;
84
101
  }
85
102
 
86
103
  void
87
- worksheet_free(void *p) {
104
+ worksheet_clear(void *p) {
88
105
  struct worksheet *ptr = p;
89
106
 
90
107
  if (ptr->worksheet) {
@@ -92,6 +109,12 @@ worksheet_free(void *p) {
92
109
  }
93
110
  }
94
111
 
112
+ void
113
+ worksheet_free(void *p) {
114
+ worksheet_clear(p);
115
+ ruby_xfree(p);
116
+ }
117
+
95
118
  /* call-seq:
96
119
  * ws.write_string(cell, value, format = nil) -> self
97
120
  * ws.write_string(row, col, value, format = nil) -> self
@@ -314,7 +337,7 @@ worksheet_write_url_(int argc, VALUE *argv, VALUE self) {
314
337
  struct worksheet *ptr;
315
338
  VALUE workbook = rb_iv_get(self, "@workbook");
316
339
  lxw_format *format = workbook_get_format(workbook, format_key);
317
- Data_Get_Struct(self, struct worksheet, ptr);
340
+ TypedData_Get_Struct(self, struct worksheet, &worksheet_type, ptr);
318
341
  if (string || tooltip) {
319
342
  worksheet_write_url_opt(ptr->worksheet, row, col, url_str, format, string, tooltip);
320
343
  } else {
@@ -500,7 +523,7 @@ worksheet_set_row_(VALUE self, VALUE row, VALUE opts) {
500
523
  options.level = NUM2INT(val);
501
524
 
502
525
  struct worksheet *ptr;
503
- Data_Get_Struct(self, struct worksheet, ptr);
526
+ TypedData_Get_Struct(self, struct worksheet, &worksheet_type, ptr);
504
527
  if (options.hidden || options.collapsed || options.level) {
505
528
  worksheet_set_row_opt(ptr->worksheet, NUM2INT(row), height, format, &options);
506
529
  } else {
@@ -547,7 +570,7 @@ worksheet_set_column_(VALUE self, VALUE col_from, VALUE col_to, VALUE opts) {
547
570
  options.level = NUM2INT(val);
548
571
 
549
572
  struct worksheet *ptr;
550
- Data_Get_Struct(self, struct worksheet, ptr);
573
+ TypedData_Get_Struct(self, struct worksheet, &worksheet_type, ptr);
551
574
  if (options.hidden || options.collapsed || options.level) {
552
575
  worksheet_set_column_opt(ptr->worksheet, col1, col2, width, format, &options);
553
576
  } else {
@@ -589,7 +612,7 @@ worksheet_insert_image_(int argc, VALUE *argv, VALUE self) {
589
612
  }
590
613
 
591
614
  struct worksheet *ptr;
592
- Data_Get_Struct(self, struct worksheet, ptr);
615
+ TypedData_Get_Struct(self, struct worksheet, &worksheet_type, ptr);
593
616
 
594
617
  if (!NIL_P(opts)) {
595
618
  options = val_to_lxw_image_options(opts, &with_options);
@@ -634,7 +657,7 @@ worksheet_insert_image_buffer_(int argc, VALUE *argv, VALUE self) {
634
657
  ++larg;
635
658
  }
636
659
  struct worksheet *ptr;
637
- Data_Get_Struct(self, struct worksheet, ptr);
660
+ TypedData_Get_Struct(self, struct worksheet, &worksheet_type, ptr);
638
661
 
639
662
  if (!NIL_P(opts)) {
640
663
  options = val_to_lxw_image_options(opts, &with_options);
@@ -688,8 +711,8 @@ worksheet_insert_chart_(int argc, VALUE *argv, VALUE self) {
688
711
 
689
712
  struct worksheet *ptr;
690
713
  struct chart *chart_ptr;
691
- Data_Get_Struct(self, struct worksheet, ptr);
692
- Data_Get_Struct(chart, struct chart, chart_ptr);
714
+ TypedData_Get_Struct(self, struct worksheet, &worksheet_type, ptr);
715
+ TypedData_Get_Struct(chart, struct chart, &chart_type, chart_ptr);
693
716
 
694
717
  if (with_options) {
695
718
  worksheet_insert_chart_opt(ptr->worksheet, row, col, chart_ptr->chart, &options);
@@ -820,7 +843,7 @@ worksheet_freeze_panes_(int argc, VALUE *argv, VALUE self) {
820
843
  rb_check_arity(argc, 1, 5);
821
844
  int larg = extract_cell(argc, argv, &row, &col);
822
845
  struct worksheet *ptr;
823
- Data_Get_Struct(self, struct worksheet, ptr);
846
+ TypedData_Get_Struct(self, struct worksheet, &worksheet_type, ptr);
824
847
  if (larg >= argc) {
825
848
  worksheet_freeze_panes(ptr->worksheet, row, col);
826
849
  } else {
@@ -928,7 +951,7 @@ worksheet_set_header_(int argc, VALUE *argv, VALUE self) {
928
951
  rb_check_arity(argc, 1, 2);
929
952
  struct _header_options ho = _extract_header_options(argc, argv);
930
953
  struct worksheet *ptr;
931
- Data_Get_Struct(self, struct worksheet, ptr);
954
+ TypedData_Get_Struct(self, struct worksheet, &worksheet_type, ptr);
932
955
  lxw_error err;
933
956
  if (!ho.with_options) {
934
957
  err = worksheet_set_header(ptr->worksheet, ho.str);
@@ -948,7 +971,7 @@ worksheet_set_footer_(int argc, VALUE *argv, VALUE self) {
948
971
  struct worksheet *ptr;
949
972
  rb_check_arity(argc, 1, 2);
950
973
  struct _header_options ho = _extract_header_options(argc, argv);
951
- Data_Get_Struct(self, struct worksheet, ptr);
974
+ TypedData_Get_Struct(self, struct worksheet, &worksheet_type, ptr);
952
975
  lxw_error err;
953
976
  if (!ho.with_options) {
954
977
  err = worksheet_set_footer(ptr->worksheet, ho.str);
@@ -1194,7 +1217,7 @@ worksheet_set_default_row_(VALUE self, VALUE height, VALUE hide_unused_rows) {
1194
1217
  VALUE
1195
1218
  worksheet_get_horizontal_dpi_(VALUE self) {
1196
1219
  struct worksheet *ptr;
1197
- Data_Get_Struct(self, struct worksheet, ptr);
1220
+ TypedData_Get_Struct(self, struct worksheet, &worksheet_type, ptr);
1198
1221
  return INT2NUM(ptr->worksheet->horizontal_dpi);
1199
1222
  }
1200
1223
 
@@ -1205,7 +1228,7 @@ worksheet_get_horizontal_dpi_(VALUE self) {
1205
1228
  VALUE
1206
1229
  worksheet_set_horizontal_dpi_(VALUE self, VALUE val) {
1207
1230
  struct worksheet *ptr;
1208
- Data_Get_Struct(self, struct worksheet, ptr);
1231
+ TypedData_Get_Struct(self, struct worksheet, &worksheet_type, ptr);
1209
1232
  ptr->worksheet->horizontal_dpi = NUM2INT(val);
1210
1233
  return val;
1211
1234
  }
@@ -1217,7 +1240,7 @@ worksheet_set_horizontal_dpi_(VALUE self, VALUE val) {
1217
1240
  VALUE
1218
1241
  worksheet_get_vertical_dpi_(VALUE self) {
1219
1242
  struct worksheet *ptr;
1220
- Data_Get_Struct(self, struct worksheet, ptr);
1243
+ TypedData_Get_Struct(self, struct worksheet, &worksheet_type, ptr);
1221
1244
  return INT2NUM(ptr->worksheet->vertical_dpi);
1222
1245
  }
1223
1246
 
@@ -1228,7 +1251,7 @@ worksheet_get_vertical_dpi_(VALUE self) {
1228
1251
  VALUE
1229
1252
  worksheet_set_vertical_dpi_(VALUE self, VALUE val) {
1230
1253
  struct worksheet *ptr;
1231
- Data_Get_Struct(self, struct worksheet, ptr);
1254
+ TypedData_Get_Struct(self, struct worksheet, &worksheet_type, ptr);
1232
1255
  ptr->worksheet->vertical_dpi = NUM2INT(val);
1233
1256
  return val;
1234
1257
  }
@@ -1379,7 +1402,7 @@ worksheet_data_validation_(int argc, VALUE *argv, VALUE self) {
1379
1402
  #undef parse_value
1380
1403
 
1381
1404
  struct worksheet *ptr;
1382
- Data_Get_Struct(self, struct worksheet, ptr);
1405
+ TypedData_Get_Struct(self, struct worksheet, &worksheet_type, ptr);
1383
1406
  lxw_error err;
1384
1407
  if (range) {
1385
1408
  err = worksheet_data_validation_range(ptr->worksheet, row, col, row2, col2, &data_validation);
@@ -2,5 +2,5 @@
2
2
 
3
3
  module XlsxWriter
4
4
  # :nodoc:
5
- VERSION = '0.2.2'
5
+ VERSION = '0.2.3.pre.1'
6
6
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xlsxwriter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3.pre.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick H
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2023-12-04 00:00:00.000000000 Z
10
+ date: 2025-01-06 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: diffy
@@ -66,8 +65,6 @@ dependencies:
66
65
  - - "~>"
67
66
  - !ruby/object:Gem::Version
68
67
  version: '3.2'
69
- description:
70
- email:
71
68
  executables: []
72
69
  extensions:
73
70
  - ext/xlsxwriter/extconf.rb
@@ -226,7 +223,6 @@ homepage: https://github.com/gekola/xlsxwriter-rb
226
223
  licenses:
227
224
  - BSD-2-Clause-FreeBSD
228
225
  metadata: {}
229
- post_install_message:
230
226
  rdoc_options: []
231
227
  require_paths:
232
228
  - lib
@@ -241,8 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
241
237
  - !ruby/object:Gem::Version
242
238
  version: '0'
243
239
  requirements: []
244
- rubygems_version: 3.4.19
245
- signing_key:
240
+ rubygems_version: 3.6.2
246
241
  specification_version: 4
247
242
  summary: Ruby interface to libxlsxwriter
248
243
  test_files: