halton 0.2.1.5 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Cargo.lock +60 -36
- data/Cargo.toml +3 -0
- data/ext/halton/Cargo.toml +2 -3
- data/ext/halton/src/lib.rs +27 -20
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8818a9a7f4cf3ae86377e55d0ac217df57e1ee2adc7ae560673b3f388047a34
|
4
|
+
data.tar.gz: 5887f4a293d8e182c62f263ff605672d4ea4d1a05fdf1c84abc296914f272853
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2b05a5c6b4d9a1aeb80d757ca41e51681f91f4248395e9b4dac30b65ee857f234dc096935f626f5392028cb790e993c54808497381448b301f5073c7d3e238f
|
7
|
+
data.tar.gz: 4d03c2fe07a9d8b7a923b2a59f1893c00a4e541a63672741cca486ff7f0cff1763e09f2861631a70e395271d1df6f06233cab6b570b468243e73f74264d6b05a
|
data/Cargo.lock
CHANGED
@@ -4,18 +4,18 @@ version = 3
|
|
4
4
|
|
5
5
|
[[package]]
|
6
6
|
name = "aho-corasick"
|
7
|
-
version = "0.
|
7
|
+
version = "1.0.3"
|
8
8
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
9
|
-
checksum = "
|
9
|
+
checksum = "86b8f9420f797f2d9e935edf629310eb938a0d839f984e25327f3c7eed22300c"
|
10
10
|
dependencies = [
|
11
11
|
"memchr",
|
12
12
|
]
|
13
13
|
|
14
14
|
[[package]]
|
15
15
|
name = "bindgen"
|
16
|
-
version = "0.
|
16
|
+
version = "0.66.1"
|
17
17
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
18
|
-
checksum = "
|
18
|
+
checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7"
|
19
19
|
dependencies = [
|
20
20
|
"bitflags",
|
21
21
|
"cexpr",
|
@@ -28,13 +28,14 @@ dependencies = [
|
|
28
28
|
"regex",
|
29
29
|
"rustc-hash",
|
30
30
|
"shlex",
|
31
|
+
"syn",
|
31
32
|
]
|
32
33
|
|
33
34
|
[[package]]
|
34
35
|
name = "bitflags"
|
35
|
-
version = "
|
36
|
+
version = "2.3.3"
|
36
37
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
37
|
-
checksum = "
|
38
|
+
checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42"
|
38
39
|
|
39
40
|
[[package]]
|
40
41
|
name = "cexpr"
|
@@ -53,9 +54,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
|
53
54
|
|
54
55
|
[[package]]
|
55
56
|
name = "clang-sys"
|
56
|
-
version = "1.
|
57
|
+
version = "1.6.1"
|
57
58
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
58
|
-
checksum = "
|
59
|
+
checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f"
|
59
60
|
dependencies = [
|
60
61
|
"glob",
|
61
62
|
"libc",
|
@@ -64,9 +65,9 @@ dependencies = [
|
|
64
65
|
|
65
66
|
[[package]]
|
66
67
|
name = "glob"
|
67
|
-
version = "0.3.
|
68
|
+
version = "0.3.1"
|
68
69
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
69
|
-
checksum = "
|
70
|
+
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
|
70
71
|
|
71
72
|
[[package]]
|
72
73
|
name = "halton"
|
@@ -96,9 +97,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
|
96
97
|
|
97
98
|
[[package]]
|
98
99
|
name = "libc"
|
99
|
-
version = "0.2.
|
100
|
+
version = "0.2.147"
|
100
101
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
101
|
-
checksum = "
|
102
|
+
checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3"
|
102
103
|
|
103
104
|
[[package]]
|
104
105
|
name = "libloading"
|
@@ -112,20 +113,21 @@ dependencies = [
|
|
112
113
|
|
113
114
|
[[package]]
|
114
115
|
name = "magnus"
|
115
|
-
version = "0.
|
116
|
+
version = "0.6.0"
|
116
117
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
117
|
-
checksum = "
|
118
|
+
checksum = "68e9585bfe236e88e6b10b6d8eb5349bd0e0009f3f9dff8d2e99a82601b33743"
|
118
119
|
dependencies = [
|
119
120
|
"magnus-macros",
|
120
121
|
"rb-sys",
|
121
122
|
"rb-sys-env",
|
123
|
+
"seq-macro",
|
122
124
|
]
|
123
125
|
|
124
126
|
[[package]]
|
125
127
|
name = "magnus-macros"
|
126
|
-
version = "0.
|
128
|
+
version = "0.6.0"
|
127
129
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
128
|
-
checksum = "
|
130
|
+
checksum = "5968c820e2960565f647819f5928a42d6e874551cab9d88d75e3e0660d7f71e3"
|
129
131
|
dependencies = [
|
130
132
|
"proc-macro2",
|
131
133
|
"quote",
|
@@ -146,9 +148,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
|
146
148
|
|
147
149
|
[[package]]
|
148
150
|
name = "nom"
|
149
|
-
version = "7.1.
|
151
|
+
version = "7.1.3"
|
150
152
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
151
|
-
checksum = "
|
153
|
+
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
|
152
154
|
dependencies = [
|
153
155
|
"memchr",
|
154
156
|
"minimal-lexical",
|
@@ -162,53 +164,69 @@ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
|
|
162
164
|
|
163
165
|
[[package]]
|
164
166
|
name = "proc-macro2"
|
165
|
-
version = "1.0.
|
167
|
+
version = "1.0.66"
|
166
168
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
167
|
-
checksum = "
|
169
|
+
checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9"
|
168
170
|
dependencies = [
|
169
171
|
"unicode-ident",
|
170
172
|
]
|
171
173
|
|
172
174
|
[[package]]
|
173
175
|
name = "quote"
|
174
|
-
version = "1.0.
|
176
|
+
version = "1.0.32"
|
175
177
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
176
|
-
checksum = "
|
178
|
+
checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965"
|
177
179
|
dependencies = [
|
178
180
|
"proc-macro2",
|
179
181
|
]
|
180
182
|
|
181
183
|
[[package]]
|
182
184
|
name = "rb-sys"
|
183
|
-
version = "0.9.
|
185
|
+
version = "0.9.81"
|
184
186
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
185
|
-
checksum = "
|
187
|
+
checksum = "a57240b308b155b09dce81e32829966a99f52d1088b45957e4283e526c5317a1"
|
186
188
|
dependencies = [
|
187
189
|
"rb-sys-build",
|
188
190
|
]
|
189
191
|
|
190
192
|
[[package]]
|
191
193
|
name = "rb-sys-build"
|
192
|
-
version = "0.9.
|
194
|
+
version = "0.9.81"
|
193
195
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
194
|
-
checksum = "
|
196
|
+
checksum = "f24ce877a4c5d07f06f6aa6fec3ac95e4b357b9f73b0f5445d8cbb7266d410e8"
|
195
197
|
dependencies = [
|
196
198
|
"bindgen",
|
199
|
+
"lazy_static",
|
200
|
+
"proc-macro2",
|
201
|
+
"quote",
|
197
202
|
"regex",
|
198
203
|
"shell-words",
|
204
|
+
"syn",
|
199
205
|
]
|
200
206
|
|
201
207
|
[[package]]
|
202
208
|
name = "rb-sys-env"
|
203
|
-
version = "0.1.
|
209
|
+
version = "0.1.2"
|
204
210
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
205
|
-
checksum = "
|
211
|
+
checksum = "a35802679f07360454b418a5d1735c89716bde01d35b1560fc953c1415a0b3bb"
|
206
212
|
|
207
213
|
[[package]]
|
208
214
|
name = "regex"
|
209
|
-
version = "1.
|
215
|
+
version = "1.9.3"
|
210
216
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
211
|
-
checksum = "
|
217
|
+
checksum = "81bc1d4caf89fac26a70747fe603c130093b53c773888797a6329091246d651a"
|
218
|
+
dependencies = [
|
219
|
+
"aho-corasick",
|
220
|
+
"memchr",
|
221
|
+
"regex-automata",
|
222
|
+
"regex-syntax",
|
223
|
+
]
|
224
|
+
|
225
|
+
[[package]]
|
226
|
+
name = "regex-automata"
|
227
|
+
version = "0.3.6"
|
228
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
229
|
+
checksum = "fed1ceff11a1dddaee50c9dc8e4938bd106e9d89ae372f192311e7da498e3b69"
|
212
230
|
dependencies = [
|
213
231
|
"aho-corasick",
|
214
232
|
"memchr",
|
@@ -217,9 +235,9 @@ dependencies = [
|
|
217
235
|
|
218
236
|
[[package]]
|
219
237
|
name = "regex-syntax"
|
220
|
-
version = "0.
|
238
|
+
version = "0.7.4"
|
221
239
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
222
|
-
checksum = "
|
240
|
+
checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2"
|
223
241
|
|
224
242
|
[[package]]
|
225
243
|
name = "rustc-hash"
|
@@ -227,6 +245,12 @@ version = "1.1.0"
|
|
227
245
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
228
246
|
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
229
247
|
|
248
|
+
[[package]]
|
249
|
+
name = "seq-macro"
|
250
|
+
version = "0.3.5"
|
251
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
252
|
+
checksum = "a3f0bf26fd526d2a95683cd0f87bf103b8539e2ca1ef48ce002d67aad59aa0b4"
|
253
|
+
|
230
254
|
[[package]]
|
231
255
|
name = "shell-words"
|
232
256
|
version = "1.1.0"
|
@@ -241,9 +265,9 @@ checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
|
|
241
265
|
|
242
266
|
[[package]]
|
243
267
|
name = "syn"
|
244
|
-
version = "
|
268
|
+
version = "2.0.28"
|
245
269
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
246
|
-
checksum = "
|
270
|
+
checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567"
|
247
271
|
dependencies = [
|
248
272
|
"proc-macro2",
|
249
273
|
"quote",
|
@@ -252,9 +276,9 @@ dependencies = [
|
|
252
276
|
|
253
277
|
[[package]]
|
254
278
|
name = "unicode-ident"
|
255
|
-
version = "1.0.
|
279
|
+
version = "1.0.11"
|
256
280
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
257
|
-
checksum = "
|
281
|
+
checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
|
258
282
|
|
259
283
|
[[package]]
|
260
284
|
name = "winapi"
|
data/Cargo.toml
CHANGED
data/ext/halton/Cargo.toml
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
[package]
|
2
2
|
name = "halton"
|
3
3
|
version = "0.1.0"
|
4
|
-
|
5
|
-
edition = "2018"
|
4
|
+
edition = "2021"
|
6
5
|
|
7
6
|
[lib]
|
8
7
|
crate-type = ["cdylib"]
|
9
8
|
|
10
9
|
[dependencies]
|
11
10
|
halton = "0.2.1"
|
12
|
-
magnus = "0.
|
11
|
+
magnus = { version = "0.6", default_features = false }
|
data/ext/halton/src/lib.rs
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
use std::cell::RefCell;
|
2
2
|
|
3
3
|
use magnus::{
|
4
|
-
block::{
|
5
|
-
|
4
|
+
block::{Yield, YieldSplat, YieldValues},
|
5
|
+
function, method,
|
6
6
|
prelude::*,
|
7
|
-
|
8
|
-
Error, RArray, Value,
|
7
|
+
Error, RArray, Value, Ruby
|
9
8
|
};
|
10
9
|
|
11
|
-
#[magnus::wrap(class = "Halton::Sequence",
|
10
|
+
#[magnus::wrap(class = "Halton::Sequence", free_immediately, size)]
|
12
11
|
struct Sequence(RefCell<halton::Sequence>);
|
13
12
|
|
14
13
|
impl Sequence {
|
@@ -16,11 +15,11 @@ impl Sequence {
|
|
16
15
|
Self(RefCell::new(halton::Sequence::new(base)))
|
17
16
|
}
|
18
17
|
|
19
|
-
fn next(&
|
20
|
-
match
|
18
|
+
fn next(ruby: &Ruby, rb_self: &Sequence) -> Result<f64, Error> {
|
19
|
+
match rb_self.0.try_borrow_mut().unwrap().next() {
|
21
20
|
Some(f) => Ok(f),
|
22
21
|
None => Err(Error::new(
|
23
|
-
|
22
|
+
ruby.exception_stop_iteration(),
|
24
23
|
"iteration reached an end",
|
25
24
|
)),
|
26
25
|
}
|
@@ -33,21 +32,26 @@ impl Sequence {
|
|
33
32
|
fn remaining(&self) -> Option<usize> {
|
34
33
|
self.0.try_borrow().unwrap().size_hint().1
|
35
34
|
}
|
35
|
+
|
36
|
+
fn take(ruby: &Ruby, rb_self: &Sequence, n: usize) -> RArray {
|
37
|
+
ruby.ary_from_iter(rb_self.0.try_borrow_mut().unwrap().clone().take(n))
|
38
|
+
}
|
36
39
|
}
|
37
40
|
|
38
|
-
fn each_one(rb_self: Value, base: u8) -> Yield<impl Iterator<Item = f64>> {
|
39
|
-
if !block_given() {
|
41
|
+
fn each_one(ruby: &Ruby, rb_self: Value, base: u8) -> Yield<impl Iterator<Item = f64>> {
|
42
|
+
if !ruby.block_given() {
|
40
43
|
return Yield::Enumerator(rb_self.enumeratorize("each_one", (base,)));
|
41
44
|
}
|
42
45
|
Yield::Iter(halton::Sequence::new(base))
|
43
46
|
}
|
44
47
|
|
45
48
|
fn each_pair(
|
49
|
+
ruby: &Ruby,
|
46
50
|
rb_self: Value,
|
47
51
|
x_base: u8,
|
48
52
|
y_base: u8,
|
49
53
|
) -> YieldValues<impl Iterator<Item = (f64, f64)>> {
|
50
|
-
if !block_given() {
|
54
|
+
if !ruby.block_given() {
|
51
55
|
return YieldValues::Enumerator(rb_self.enumeratorize("each_pair", (x_base, y_base)));
|
52
56
|
}
|
53
57
|
let seq_x = halton::Sequence::new(x_base);
|
@@ -56,12 +60,13 @@ fn each_pair(
|
|
56
60
|
}
|
57
61
|
|
58
62
|
fn each_triple(
|
63
|
+
ruby: &Ruby,
|
59
64
|
rb_self: Value,
|
60
65
|
x_base: u8,
|
61
66
|
y_base: u8,
|
62
67
|
z_base: u8,
|
63
68
|
) -> YieldValues<impl Iterator<Item = (f64, f64, f64)>> {
|
64
|
-
if !block_given() {
|
69
|
+
if !ruby.block_given() {
|
65
70
|
return YieldValues::Enumerator(
|
66
71
|
rb_self.enumeratorize("each_triple", (x_base, y_base, z_base)),
|
67
72
|
);
|
@@ -76,13 +81,14 @@ fn each_many(
|
|
76
81
|
rb_self: Value,
|
77
82
|
args: &[Value],
|
78
83
|
) -> Result<YieldSplat<impl Iterator<Item = RArray>>, Error> {
|
79
|
-
|
84
|
+
let ruby = unsafe { Ruby::get_unchecked() };
|
85
|
+
ruby.check_arity(args.len(), 1..)?;
|
80
86
|
let bases = args
|
81
87
|
.iter()
|
82
|
-
.map(|v|
|
88
|
+
.map(|v| u8::try_convert(*v))
|
83
89
|
.collect::<Result<Vec<u8>, _>>()?;
|
84
90
|
|
85
|
-
if !block_given() {
|
91
|
+
if !ruby.block_given() {
|
86
92
|
return Ok(YieldSplat::Enumerator(
|
87
93
|
rb_self.enumeratorize("each_many", args),
|
88
94
|
));
|
@@ -96,27 +102,28 @@ fn each_many(
|
|
96
102
|
buffer.clear();
|
97
103
|
for seq in &mut seqs {
|
98
104
|
if let Some(v) = seq.next() {
|
99
|
-
buffer.push(
|
105
|
+
buffer.push(ruby.into_value(v));
|
100
106
|
} else {
|
101
107
|
return None;
|
102
108
|
}
|
103
109
|
}
|
104
|
-
Some(
|
110
|
+
Some(ruby.ary_new_from_values(&buffer))
|
105
111
|
})))
|
106
112
|
}
|
107
113
|
|
108
114
|
#[magnus::init]
|
109
|
-
fn init() -> Result<(), Error> {
|
110
|
-
let module = define_module("Halton")?;
|
115
|
+
fn init(ruby: &Ruby) -> Result<(), Error> {
|
116
|
+
let module = ruby.define_module("Halton")?;
|
111
117
|
module.define_singleton_method("number", function!(halton::number, 2))?;
|
112
118
|
module.define_singleton_method("each_one", method!(each_one, 1))?;
|
113
119
|
module.define_singleton_method("each_pair", method!(each_pair, 2))?;
|
114
120
|
module.define_singleton_method("each_triple", method!(each_triple, 3))?;
|
115
121
|
module.define_singleton_method("each_many", method!(each_many, -1))?;
|
116
|
-
let class = module.define_class("Sequence",
|
122
|
+
let class = module.define_class("Sequence", ruby.class_object())?;
|
117
123
|
class.define_singleton_method("new", function!(Sequence::new, 1))?;
|
118
124
|
class.define_method("next", method!(Sequence::next, 0))?;
|
119
125
|
class.define_method("skip", method!(Sequence::skip, 1))?;
|
120
126
|
class.define_method("remaining", method!(Sequence::remaining, 0))?;
|
127
|
+
class.define_method("take", method!(Sequence::take, 1))?;
|
121
128
|
Ok(())
|
122
129
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: halton
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mat Sadler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -101,15 +101,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
101
101
|
requirements:
|
102
102
|
- - ">="
|
103
103
|
- !ruby/object:Gem::Version
|
104
|
-
version: 2.
|
104
|
+
version: 2.7.0
|
105
105
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
107
|
- - ">="
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: 3.3.26
|
110
110
|
requirements:
|
111
|
-
- Rust >= 1.
|
112
|
-
rubygems_version: 3.
|
111
|
+
- Rust >= 1.61
|
112
|
+
rubygems_version: 3.5.0.dev
|
113
113
|
signing_key:
|
114
114
|
specification_version: 4
|
115
115
|
summary: A module for generating Halton sequences
|