gmt 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/ext/gmt/gmt.c +37 -10
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c3d9adf57be499c296fab1aa6c6c23d1001d17709f96c0cfc62d5a3fa344a66
4
- data.tar.gz: e51bafc40060577b2bc98a376dcc23b863e586697122e28335582ac0ffea522b
3
+ metadata.gz: 47175ab0f9f220eec500e98bb1b392ec93ae42b61e13c851bae392a0dd4d9d08
4
+ data.tar.gz: 0f24492604a31c82461d730be0afbc508849ff757939ac99596020f8ffe0c6f7
5
5
  SHA512:
6
- metadata.gz: 29d50bccf9a8868617653da560a520e2af073e81dcd8a99e75086f4108abfd6516f4a08073cadad8d78b60687434c06032299708b5dac9c674a09c2b5fdf9ed1
7
- data.tar.gz: 8f57a9db15bd3a1d5afbd899af330632e6fc72fec26c64c5ba64781ec939d42cc502a07b9d373ce02e1874e423d607dab608735d155b360130a66c81a3746ec4
6
+ metadata.gz: 7fb19342fb1e3480531f02e1d9ca34203791820952c2d683d5294af027a5f9cc8205f9f2ed07fa452b7a0f9bb4dd51b9bafe36e7b08934e745fea6410cfb4c30
7
+ data.tar.gz: 8e59daf96977b38a4498c7934d04ec302c7044a50af43e07ad36118742c87070d1d1eb268578f4c3a17c41a3c04912d3db1afd849b0e16d96cce98b7b13f9172
data/ext/gmt/gmt.c CHANGED
@@ -1,4 +1,6 @@
1
1
  #include <ruby.h>
2
+ #include <ruby/version.h>
3
+
2
4
  #include <gmt.h>
3
5
  #include <gmt_version.h>
4
6
 
@@ -27,6 +29,26 @@ static void raise_if_error(int err, const char *module)
27
29
  rb_raise(rb_eRuntimeError, "failed call to GMT module %s", module);
28
30
  }
29
31
 
32
+ static void gmt_free(void*);
33
+
34
+ static rb_data_type_t data_type = {
35
+ .wrap_struct_name = "ruby-gmt-wrap",
36
+ .function = {
37
+ .dmark = NULL,
38
+ .dfree = gmt_free,
39
+ .dsize = NULL,
40
+ #if RUBY_API_VERSION_CODE < 20700
41
+ .reserved = { NULL, NULL }
42
+ #else
43
+ .dcompact = NULL,
44
+ .reserved = { NULL }
45
+ #endif
46
+ },
47
+ .parent = NULL,
48
+ .data = NULL,
49
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY
50
+ };
51
+
30
52
  /* ruby object interface */
31
53
 
32
54
  static void gmt_free(void *p)
@@ -38,13 +60,18 @@ static void gmt_free(void *p)
38
60
  GMT_Destroy_Session(gmt->session);
39
61
  gmt->session = NULL;
40
62
  }
63
+
64
+ free(gmt);
41
65
  }
42
66
 
43
- static VALUE gmt_alloc(VALUE klass)
67
+ static VALUE gmt_alloc(VALUE cls)
44
68
  {
45
69
  gmt_t *gmt;
46
70
 
47
- VALUE obj = Data_Make_Struct(klass, gmt_t, NULL, gmt_free, gmt);
71
+ if ((gmt = malloc(sizeof(gmt_t))) == NULL)
72
+ rb_raise(rb_eNoMemError, "failed to alloc GMT struct");
73
+
74
+ VALUE obj = TypedData_Wrap_Struct(cls, &data_type, gmt);
48
75
 
49
76
  gmt->session = NULL;
50
77
 
@@ -55,7 +82,7 @@ static VALUE gmt_init(VALUE self)
55
82
  {
56
83
  gmt_t *gmt;
57
84
 
58
- Data_Get_Struct(self, gmt_t, gmt);
85
+ TypedData_Get_Struct(self, gmt_t, &data_type, gmt);
59
86
 
60
87
  gmt->session =
61
88
  GMT_Create_Session("Session name", 2, 0, NULL);
@@ -70,7 +97,7 @@ static VALUE gmt_release(VALUE self)
70
97
  {
71
98
  gmt_t *gmt;
72
99
 
73
- Data_Get_Struct(self, gmt_t, gmt);
100
+ TypedData_Get_Struct(self, gmt_t, &data_type, gmt);
74
101
 
75
102
  if (gmt->session)
76
103
  {
@@ -89,7 +116,7 @@ static VALUE gmt_simple(const char *name, int argc, VALUE *argv, VALUE self)
89
116
  rb_scan_args(argc, argv, "*1", &files, &opts);
90
117
 
91
118
  gmt_t *gmt;
92
- Data_Get_Struct(self, gmt_t, gmt);
119
+ TypedData_Get_Struct(self, gmt_t, &data_type, gmt);
93
120
  raise_unless_class_data(gmt);
94
121
 
95
122
  void *session = gmt->session;
@@ -114,7 +141,7 @@ static VALUE gmt_simple(const char *name, int argc, VALUE *argv, VALUE self)
114
141
 
115
142
  The "modern mode" modules (which have a slicker way of routing and
116
143
  combining postscript output) will probably need a different treatment,
117
- possibly a more attractive on from the Ruby perspective; for now we
144
+ possibly a more attractive one from the Ruby perspective; for now we
118
145
  just limit ourselves to the classic mode.
119
146
  */
120
147
 
@@ -218,10 +245,6 @@ GMT_FUN(sphtriangulate)
218
245
 
219
246
  /* Convert or extract subsets of data */
220
247
 
221
- #if API_AT_LEAST(6, 2, 0)
222
- GMT_FUN(gmtbinstats)
223
- #endif
224
-
225
248
  GMT_FUN(gmtconnect)
226
249
  GMT_FUN(gmtconvert)
227
250
  GMT_FUN(gmtselect)
@@ -241,6 +264,10 @@ GMT_FUN(grd2kml)
241
264
  GMT_FUN(grd2rgb) /* https://github.com/GenericMappingTools/gmt/pull/425 */
242
265
  #endif
243
266
 
267
+ #if API_AT_LEAST(6, 2, 0)
268
+ GMT_FUN(gmtbinstats)
269
+ #endif
270
+
244
271
  /* trends in 1-D and 2-D data */
245
272
 
246
273
  GMT_FUN(fitcircle)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gmt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - J.J. Green
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-09 00:00:00.000000000 Z
11
+ date: 2022-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler