rice 2.1.3 → 2.2.0
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.
- checksums.yaml +4 -4
- data/extconf.rb +3 -6
- data/rice/detail/method_data.cpp +8 -2
- data/rice/detail/ruby_version_code.hpp +1 -1
- data/rice/to_from_ruby.ipp +124 -0
- data/ruby/lib/version.rb +1 -1
- data/test/test_To_From_Ruby.cpp +100 -0
- metadata +47 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfc3c808fd3b1c836e1788866f93b00cf739ea459b38f3db85304adcec9c3557
|
4
|
+
data.tar.gz: 5b61d235b4f964750929e825bcb18ab9e91fb12b85d8d29f19f8a886e0fdd204
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c2e7b10676fece41e12fca65ada008b87ca3faa6148771cf68bf07c75c01618b49d99df4ee8d11c3fd7d0b95d18367fd26923587bedf37ae677fefd090c6c44
|
7
|
+
data.tar.gz: bb1340b89738f90f222cfabf6c5bf9a1496154cf8eea2e607afba793c824fcb2497c2c2b141d11e97eae9e232eff755451b477ec568ecc4d7a98200a94856aaf
|
data/extconf.rb
CHANGED
@@ -23,12 +23,9 @@ if RbConfig::CONFIG["ENABLE_SHARED"] == "no"
|
|
23
23
|
Unfortunately Rice does not build against a staticly linked Ruby.
|
24
24
|
You'll need to rebuild Ruby with --enable-shared to use this library.
|
25
25
|
|
26
|
-
If you're on rvm:
|
27
|
-
If you're on rbenv:
|
28
|
-
|
29
|
-
If you are using Heroku, they use a own custom configured, staticly linked Ruby
|
30
|
-
for their stack and it unfortunately does not work with Rice. You will need to use
|
31
|
-
a custom Ruby build pack that builds and uses a non-static version of Ruby.
|
26
|
+
If you're on rvm: rvm reinstall [version] -- --enable-shared
|
27
|
+
If you're on rbenv: CONFIGURE_OPTS="--enable-shared" rbenv install [version]
|
28
|
+
If you're on Heroku: upgrade your stack to heroku-16 or later
|
32
29
|
EOC
|
33
30
|
end
|
34
31
|
|
data/rice/detail/method_data.cpp
CHANGED
@@ -31,6 +31,12 @@ method_data()
|
|
31
31
|
return (store == Qnil) ? Qnil : rb_ivar_get(store, id);
|
32
32
|
}
|
33
33
|
|
34
|
+
// Ruby 2.7 now includes a similarly named macro that uses templates to
|
35
|
+
// pick the right overload for the underlying function. That doesn't work
|
36
|
+
// for our cases because we are using this method dynamically and get a
|
37
|
+
// compilation error otherwise. This removes the macro and lets us fall
|
38
|
+
// back to the C-API underneath again.
|
39
|
+
#undef rb_define_method_id
|
34
40
|
|
35
41
|
// Define a method and attach data to it.
|
36
42
|
// The method looks to ruby like a normal aliased CFUNC, with a modified
|
@@ -75,9 +81,9 @@ define_method_with_data(
|
|
75
81
|
rb_ivar_set(store, id, data);
|
76
82
|
|
77
83
|
// Create the aliased method on the origin class
|
78
|
-
|
84
|
+
rb_define_method_id(
|
79
85
|
klass,
|
80
|
-
|
86
|
+
id,
|
81
87
|
cfunc,
|
82
88
|
arity);
|
83
89
|
|
data/rice/to_from_ruby.ipp
CHANGED
@@ -18,6 +18,37 @@ Rice::Object to_ruby<Rice::Object>(Rice::Object const & x)
|
|
18
18
|
return x;
|
19
19
|
}
|
20
20
|
|
21
|
+
// ---------------------------------------------------------------------
|
22
|
+
namespace Rice
|
23
|
+
{
|
24
|
+
namespace detail
|
25
|
+
{
|
26
|
+
inline short num2short(VALUE x)
|
27
|
+
{
|
28
|
+
return NUM2SHORT(x);
|
29
|
+
}
|
30
|
+
|
31
|
+
inline VALUE short2num(short x)
|
32
|
+
{
|
33
|
+
return INT2NUM(x);
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
template<>
|
39
|
+
inline
|
40
|
+
short from_ruby<short>(Rice::Object x)
|
41
|
+
{
|
42
|
+
return Rice::detail::num2short(x);
|
43
|
+
}
|
44
|
+
|
45
|
+
template<>
|
46
|
+
inline
|
47
|
+
Rice::Object to_ruby<short>(short const & x)
|
48
|
+
{
|
49
|
+
return Rice::protect(Rice::detail::short2num, x);
|
50
|
+
}
|
51
|
+
|
21
52
|
// ---------------------------------------------------------------------
|
22
53
|
namespace Rice
|
23
54
|
{
|
@@ -80,6 +111,68 @@ Rice::Object to_ruby<long>(long const & x)
|
|
80
111
|
return Rice::protect(Rice::detail::long2num, x);
|
81
112
|
}
|
82
113
|
|
114
|
+
// ---------------------------------------------------------------------
|
115
|
+
namespace Rice
|
116
|
+
{
|
117
|
+
namespace detail
|
118
|
+
{
|
119
|
+
inline long long num2longlong(VALUE x)
|
120
|
+
{
|
121
|
+
return NUM2LL(x);
|
122
|
+
}
|
123
|
+
|
124
|
+
inline VALUE longlong2num(long long x)
|
125
|
+
{
|
126
|
+
return LL2NUM(x);
|
127
|
+
}
|
128
|
+
}
|
129
|
+
}
|
130
|
+
|
131
|
+
template<>
|
132
|
+
inline
|
133
|
+
long long from_ruby<long long>(Rice::Object x)
|
134
|
+
{
|
135
|
+
return Rice::protect(Rice::detail::num2longlong, x);
|
136
|
+
}
|
137
|
+
|
138
|
+
template<>
|
139
|
+
inline
|
140
|
+
Rice::Object to_ruby<long long>(long long const & x)
|
141
|
+
{
|
142
|
+
return Rice::protect(Rice::detail::longlong2num, x);
|
143
|
+
}
|
144
|
+
|
145
|
+
// ---------------------------------------------------------------------
|
146
|
+
namespace Rice
|
147
|
+
{
|
148
|
+
namespace detail
|
149
|
+
{
|
150
|
+
inline unsigned short num2ushort(VALUE x)
|
151
|
+
{
|
152
|
+
return NUM2USHORT(x);
|
153
|
+
}
|
154
|
+
|
155
|
+
inline VALUE ushort2num(unsigned short x)
|
156
|
+
{
|
157
|
+
return UINT2NUM(x);
|
158
|
+
}
|
159
|
+
}
|
160
|
+
}
|
161
|
+
|
162
|
+
template<>
|
163
|
+
inline
|
164
|
+
unsigned short from_ruby<unsigned short>(Rice::Object x)
|
165
|
+
{
|
166
|
+
return Rice::detail::num2ushort(x);
|
167
|
+
}
|
168
|
+
|
169
|
+
template<>
|
170
|
+
inline
|
171
|
+
Rice::Object to_ruby<unsigned short>(unsigned short const & x)
|
172
|
+
{
|
173
|
+
return Rice::protect(Rice::detail::ushort2num, x);
|
174
|
+
}
|
175
|
+
|
83
176
|
// ---------------------------------------------------------------------
|
84
177
|
namespace Rice
|
85
178
|
{
|
@@ -142,6 +235,37 @@ Rice::Object to_ruby<unsigned long>(unsigned long const & x)
|
|
142
235
|
return Rice::protect(Rice::detail::ulong2num, x);
|
143
236
|
}
|
144
237
|
|
238
|
+
// ---------------------------------------------------------------------
|
239
|
+
namespace Rice
|
240
|
+
{
|
241
|
+
namespace detail
|
242
|
+
{
|
243
|
+
inline unsigned long long num2ulonglong(VALUE x)
|
244
|
+
{
|
245
|
+
return NUM2ULL(x);
|
246
|
+
}
|
247
|
+
|
248
|
+
inline VALUE ulonglong2num(unsigned long long x)
|
249
|
+
{
|
250
|
+
return ULL2NUM(x);
|
251
|
+
}
|
252
|
+
}
|
253
|
+
}
|
254
|
+
|
255
|
+
template<>
|
256
|
+
inline
|
257
|
+
unsigned long long from_ruby<unsigned long long>(Rice::Object x)
|
258
|
+
{
|
259
|
+
return Rice::protect(Rice::detail::num2ulonglong, x);
|
260
|
+
}
|
261
|
+
|
262
|
+
template<>
|
263
|
+
inline
|
264
|
+
Rice::Object to_ruby<unsigned long long>(unsigned long long const & x)
|
265
|
+
{
|
266
|
+
return Rice::protect(Rice::detail::ulonglong2num, x);
|
267
|
+
}
|
268
|
+
|
145
269
|
// ---------------------------------------------------------------------
|
146
270
|
template<>
|
147
271
|
inline
|
data/ruby/lib/version.rb
CHANGED
data/test/test_To_From_Ruby.cpp
CHANGED
@@ -27,6 +27,32 @@ TESTCASE(object_from_ruby)
|
|
27
27
|
ASSERT_EQUAL(o.value(), from_ruby<Object>(o).value());
|
28
28
|
}
|
29
29
|
|
30
|
+
TESTCASE(short_to_ruby)
|
31
|
+
{
|
32
|
+
ASSERT_EQUAL(INT2NUM(0), to_ruby((short)0).value());
|
33
|
+
ASSERT_EQUAL(INT2NUM(-1), to_ruby((short)-1).value());
|
34
|
+
ASSERT_EQUAL(INT2NUM(1), to_ruby((short)1).value());
|
35
|
+
ASSERT_EQUAL(
|
36
|
+
Object(INT2NUM(std::numeric_limits<short>::min())),
|
37
|
+
to_ruby(std::numeric_limits<short>::min()));
|
38
|
+
ASSERT_EQUAL(
|
39
|
+
Object(INT2NUM(std::numeric_limits<short>::max())),
|
40
|
+
to_ruby(std::numeric_limits<short>::max()));
|
41
|
+
}
|
42
|
+
|
43
|
+
TESTCASE(short_from_ruby)
|
44
|
+
{
|
45
|
+
ASSERT_EQUAL(0, from_ruby<short>(INT2NUM(0)));
|
46
|
+
ASSERT_EQUAL(-1, from_ruby<short>(INT2NUM(-1)));
|
47
|
+
ASSERT_EQUAL(1, from_ruby<short>(INT2NUM(1)));
|
48
|
+
ASSERT_EQUAL(
|
49
|
+
std::numeric_limits<short>::min(),
|
50
|
+
from_ruby<short>(INT2NUM(std::numeric_limits<short>::min())));
|
51
|
+
ASSERT_EQUAL(
|
52
|
+
std::numeric_limits<short>::max(),
|
53
|
+
from_ruby<short>(INT2NUM(std::numeric_limits<short>::max())));
|
54
|
+
}
|
55
|
+
|
30
56
|
TESTCASE(int_to_ruby)
|
31
57
|
{
|
32
58
|
ASSERT_EQUAL(INT2NUM(0), to_ruby((int)0).value());
|
@@ -91,6 +117,56 @@ TESTCASE(long_from_ruby)
|
|
91
117
|
from_ruby<long>(LONG2NUM(std::numeric_limits<long>::max())));
|
92
118
|
}
|
93
119
|
|
120
|
+
TESTCASE(long_long_to_ruby)
|
121
|
+
{
|
122
|
+
ASSERT_EQUAL(LL2NUM(0), to_ruby((long long)0).value());
|
123
|
+
ASSERT_EQUAL(LL2NUM(-1), to_ruby((long long)-1).value());
|
124
|
+
ASSERT_EQUAL(LL2NUM(1), to_ruby((long long)1).value());
|
125
|
+
ASSERT_EQUAL(
|
126
|
+
Object(LL2NUM(std::numeric_limits<long long>::min())),
|
127
|
+
to_ruby(std::numeric_limits<long long>::min()));
|
128
|
+
ASSERT_EQUAL(
|
129
|
+
Object(LL2NUM(std::numeric_limits<long long>::max())),
|
130
|
+
to_ruby(std::numeric_limits<long long>::max()));
|
131
|
+
}
|
132
|
+
|
133
|
+
TESTCASE(long_long_from_ruby)
|
134
|
+
{
|
135
|
+
ASSERT_EQUAL(0, from_ruby<long long>(LL2NUM(0)));
|
136
|
+
ASSERT_EQUAL(-1, from_ruby<long long>(LL2NUM(-1)));
|
137
|
+
ASSERT_EQUAL(1, from_ruby<long long>(LL2NUM(1)));
|
138
|
+
ASSERT_EQUAL(
|
139
|
+
std::numeric_limits<long long>::min(),
|
140
|
+
from_ruby<long long>(LL2NUM(std::numeric_limits<long long>::min())));
|
141
|
+
ASSERT_EQUAL(
|
142
|
+
std::numeric_limits<long long>::max(),
|
143
|
+
from_ruby<long long>(LL2NUM(std::numeric_limits<long long>::max())));
|
144
|
+
}
|
145
|
+
|
146
|
+
TESTCASE(unsigned_short_to_ruby)
|
147
|
+
{
|
148
|
+
ASSERT_EQUAL(UINT2NUM(0), to_ruby((unsigned short)0).value());
|
149
|
+
ASSERT_EQUAL(UINT2NUM(1), to_ruby((unsigned short)1).value());
|
150
|
+
ASSERT_EQUAL(
|
151
|
+
Object(UINT2NUM(std::numeric_limits<unsigned short>::min())),
|
152
|
+
to_ruby(std::numeric_limits<unsigned short>::min()));
|
153
|
+
ASSERT_EQUAL(
|
154
|
+
Object(UINT2NUM(std::numeric_limits<unsigned short>::max())),
|
155
|
+
to_ruby(std::numeric_limits<unsigned short>::max()));
|
156
|
+
}
|
157
|
+
|
158
|
+
TESTCASE(unsigned_short_from_ruby)
|
159
|
+
{
|
160
|
+
ASSERT_EQUAL(0u, from_ruby<unsigned short>(UINT2NUM(0)));
|
161
|
+
ASSERT_EQUAL(1u, from_ruby<unsigned short>(UINT2NUM(1)));
|
162
|
+
ASSERT_EQUAL(
|
163
|
+
std::numeric_limits<unsigned short>::min(),
|
164
|
+
from_ruby<unsigned short>(UINT2NUM(std::numeric_limits<unsigned short>::min())));
|
165
|
+
ASSERT_EQUAL(
|
166
|
+
std::numeric_limits<unsigned short>::max(),
|
167
|
+
from_ruby<unsigned short>(UINT2NUM(std::numeric_limits<unsigned short>::max())));
|
168
|
+
}
|
169
|
+
|
94
170
|
TESTCASE(unsigned_int_to_ruby)
|
95
171
|
{
|
96
172
|
ASSERT_EQUAL(UINT2NUM(0), to_ruby((unsigned int)0).value());
|
@@ -145,6 +221,30 @@ TESTCASE(unsigned_long_from_ruby)
|
|
145
221
|
from_ruby<unsigned long>(ULONG2NUM(std::numeric_limits<unsigned long>::max())));
|
146
222
|
}
|
147
223
|
|
224
|
+
TESTCASE(unsigned_long_long_to_ruby)
|
225
|
+
{
|
226
|
+
ASSERT_EQUAL(ULL2NUM(0), to_ruby((unsigned long long)0).value());
|
227
|
+
ASSERT_EQUAL(ULL2NUM(1), to_ruby((unsigned long long)1).value());
|
228
|
+
ASSERT_EQUAL(
|
229
|
+
Object(ULL2NUM(std::numeric_limits<unsigned long long>::min())),
|
230
|
+
to_ruby(std::numeric_limits<unsigned long long>::min()));
|
231
|
+
ASSERT_EQUAL(
|
232
|
+
Object(ULL2NUM(std::numeric_limits<unsigned long long>::max())),
|
233
|
+
to_ruby(std::numeric_limits<unsigned long long>::max()));
|
234
|
+
}
|
235
|
+
|
236
|
+
TESTCASE(unsigned_long_long_from_ruby)
|
237
|
+
{
|
238
|
+
ASSERT_EQUAL(0u, from_ruby<unsigned long>(ULL2NUM(0)));
|
239
|
+
ASSERT_EQUAL(1u, from_ruby<unsigned long>(ULL2NUM(1)));
|
240
|
+
ASSERT_EQUAL(
|
241
|
+
std::numeric_limits<unsigned long long>::min(),
|
242
|
+
from_ruby<unsigned long long>(ULL2NUM(std::numeric_limits<unsigned long long>::min())));
|
243
|
+
ASSERT_EQUAL(
|
244
|
+
std::numeric_limits<unsigned long long>::max(),
|
245
|
+
from_ruby<unsigned long long>(ULL2NUM(std::numeric_limits<unsigned long long>::max())));
|
246
|
+
}
|
247
|
+
|
148
248
|
TESTCASE(bool_to_ruby)
|
149
249
|
{
|
150
250
|
ASSERT_EQUAL(Qfalse, to_ruby(false).value());
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rice
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Brannan
|
@@ -9,8 +9,50 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
dependencies:
|
12
|
+
date: 2020-01-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: minitest
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
14
56
|
description: |
|
15
57
|
Rice is a C++ interface to Ruby's C API. It provides a type-safe and
|
16
58
|
exception-safe interface in order to make embedding Ruby and writing
|
@@ -230,15 +272,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
230
272
|
requirements:
|
231
273
|
- - ">="
|
232
274
|
- !ruby/object:Gem::Version
|
233
|
-
version: '
|
275
|
+
version: '2.4'
|
234
276
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
235
277
|
requirements:
|
236
278
|
- - ">="
|
237
279
|
- !ruby/object:Gem::Version
|
238
280
|
version: '0'
|
239
281
|
requirements: []
|
240
|
-
|
241
|
-
rubygems_version: 2.7.6
|
282
|
+
rubygems_version: 3.1.2
|
242
283
|
signing_key:
|
243
284
|
specification_version: 4
|
244
285
|
summary: Ruby Interface for C++ Extensions
|