gmt 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/gmt/gmt.c +18 -14
- data/ext/gmt/option.c +4 -4
- data/ext/gmt/option.h +2 -2
- data/lib/gmt.rb +12 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ad7de33d11e4ab6419c28a78a14ba7ae9d5e0418485ab794060f8ca7a5a6f21
|
4
|
+
data.tar.gz: 11e72187266c674aad88d7597f2f50a2b714c2443820564a470bef2a180a5fdf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 921660bab096dd80e3908914ceca695090c83c9a7a644be6b594dc51c448c03ae1d6d33de02f5f02dc028ea32496bd672d8ac3ff980d98ee1ec7ed0170788f35
|
7
|
+
data.tar.gz: ffc9d3d9a51563c4e0295ccf7c621053db09fb5c302639dcabe0e516a01c09415670e8eab9f012857b0d4ecfe119a4a38a85c6962b178dc90451951a35a027a3
|
data/ext/gmt/gmt.c
CHANGED
@@ -4,6 +4,8 @@
|
|
4
4
|
#include <gmt.h>
|
5
5
|
#include <gmt_version.h>
|
6
6
|
|
7
|
+
#include <errno.h>
|
8
|
+
|
7
9
|
#include "option.h"
|
8
10
|
|
9
11
|
#define API_VER(major, minor, release) (10000 * major + 100 * minor + release)
|
@@ -17,18 +19,6 @@ typedef struct
|
|
17
19
|
|
18
20
|
/* helpers */
|
19
21
|
|
20
|
-
static void raise_unless_class_data(gmt_t *gmt)
|
21
|
-
{
|
22
|
-
if (gmt == NULL)
|
23
|
-
rb_raise(rb_eRuntimeError, "failed fetch of GMT class data");
|
24
|
-
}
|
25
|
-
|
26
|
-
static void raise_if_error(int err, const char *module)
|
27
|
-
{
|
28
|
-
if (err)
|
29
|
-
rb_raise(rb_eRuntimeError, "failed call to GMT module %s", module);
|
30
|
-
}
|
31
|
-
|
32
22
|
static void gmt_free(void*);
|
33
23
|
|
34
24
|
static rb_data_type_t data_type = {
|
@@ -117,7 +107,9 @@ static VALUE gmt_simple(const char *name, int argc, VALUE *argv, VALUE self)
|
|
117
107
|
|
118
108
|
gmt_t *gmt;
|
119
109
|
TypedData_Get_Struct(self, gmt_t, &data_type, gmt);
|
120
|
-
|
110
|
+
|
111
|
+
if (gmt == NULL)
|
112
|
+
rb_raise(rb_eRuntimeError, "failed fetch of GMT class data");
|
121
113
|
|
122
114
|
void *session = gmt->session;
|
123
115
|
|
@@ -125,10 +117,22 @@ static VALUE gmt_simple(const char *name, int argc, VALUE *argv, VALUE self)
|
|
125
117
|
gmt_opts = ruby_array_to_gmt_options(opts, session);
|
126
118
|
gmt_opts = append_inputs_to_gmt_options(files, gmt_opts, session);
|
127
119
|
|
120
|
+
errno = 0;
|
128
121
|
int err = GMT_Call_Module(session, name, -1, gmt_opts);
|
122
|
+
int gmt_errno = errno;
|
129
123
|
|
130
124
|
GMT_Destroy_Options(session, &gmt_opts);
|
131
|
-
|
125
|
+
|
126
|
+
if (err != 0)
|
127
|
+
{
|
128
|
+
VALUE gmt_syserr;
|
129
|
+
|
130
|
+
if ((gmt_errno != 0) &&
|
131
|
+
((gmt_syserr = rb_syserr_new(gmt_errno, NULL)) != 0))
|
132
|
+
rb_exc_raise(gmt_syserr);
|
133
|
+
else
|
134
|
+
rb_raise(rb_eRuntimeError, "failed call to GMT module %s", name);
|
135
|
+
}
|
132
136
|
|
133
137
|
return Qtrue;
|
134
138
|
}
|
data/ext/gmt/option.c
CHANGED
@@ -32,7 +32,7 @@ static gmt_option_t* append_option(void *session,
|
|
32
32
|
return GMT_Append_Option(session, gmt_opt, gmt_opts);
|
33
33
|
}
|
34
34
|
|
35
|
-
|
35
|
+
gmt_option_t* ruby_array_to_gmt_options(VALUE opts, void *session)
|
36
36
|
{
|
37
37
|
if (TYPE(opts) != T_ARRAY)
|
38
38
|
rb_raise(rb_eArgError, "options should be an array");
|
@@ -74,9 +74,9 @@ extern gmt_option_t* ruby_array_to_gmt_options(VALUE opts, void *session)
|
|
74
74
|
return gmt_opts;
|
75
75
|
}
|
76
76
|
|
77
|
-
|
78
|
-
|
79
|
-
|
77
|
+
gmt_option_t* append_inputs_to_gmt_options(VALUE files,
|
78
|
+
gmt_option_t *gmt_opts,
|
79
|
+
void *session)
|
80
80
|
{
|
81
81
|
if (TYPE(files) != T_ARRAY)
|
82
82
|
rb_raise(rb_eArgError, "inputs should be an array");
|
data/ext/gmt/option.h
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
|
15
15
|
typedef struct GMT_OPTION gmt_option_t;
|
16
16
|
|
17
|
-
|
18
|
-
|
17
|
+
gmt_option_t* ruby_array_to_gmt_options(VALUE, void*);
|
18
|
+
gmt_option_t* append_inputs_to_gmt_options(VALUE, gmt_option_t*, void*);
|
19
19
|
|
20
20
|
#endif
|
data/lib/gmt.rb
CHANGED
@@ -66,6 +66,18 @@
|
|
66
66
|
#
|
67
67
|
# using this format.
|
68
68
|
#
|
69
|
+
# One occasionally has need for multiple calls to the same option: the
|
70
|
+
# <code>-B</code> option being the usual culprit. In this case, use a single
|
71
|
+
# <code>:B</code> key and an array of the arguments:
|
72
|
+
#
|
73
|
+
# B: [
|
74
|
+
# 'xa%g+l%s' % [dx, x_label],
|
75
|
+
# 'ya%g+l%s' % [dy, y_label],
|
76
|
+
# 'nWeS'
|
77
|
+
# ], ...
|
78
|
+
#
|
79
|
+
# for example.
|
80
|
+
#
|
69
81
|
# == PostScript functions
|
70
82
|
#
|
71
83
|
# When creating complex PostScript plots one needs to make several calls to
|
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.
|
4
|
+
version: 0.2.5
|
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:
|
11
|
+
date: 2024-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -131,7 +131,7 @@ requirements:
|
|
131
131
|
- GMT5/6 development libraries (compile)
|
132
132
|
- GMT5/6 installation (test)
|
133
133
|
- ghostscript (test)
|
134
|
-
rubygems_version: 3.
|
134
|
+
rubygems_version: 3.2.3
|
135
135
|
signing_key:
|
136
136
|
specification_version: 4
|
137
137
|
summary: Generic Mapping Tools (GMT)
|