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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7ed27356a6e2a2f658747ba007d3d5f295049e425512a7996e8d31679fa10964
4
- data.tar.gz: c368b48acb7bfc73fde7d347de2c9667224daaa7c1b085e170ab9eab60cb26cc
3
+ metadata.gz: a8818a9a7f4cf3ae86377e55d0ac217df57e1ee2adc7ae560673b3f388047a34
4
+ data.tar.gz: 5887f4a293d8e182c62f263ff605672d4ea4d1a05fdf1c84abc296914f272853
5
5
  SHA512:
6
- metadata.gz: 4ade7dfefe049433feb6fef115461f55fb043953444e33b83efd11c62db37f6c46ec554e4f9094a80caa6309f2e9391e8f13b3abf0f6285cd1e6a4aa3927ae9b
7
- data.tar.gz: 658632d67fb5ab6e7478067aa8dff286e1d130754bb7f8995b3a47ab1ba854bab8e7f0809da951c82023593c66b3061afc24272456df7210826df354098d20c2
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.20"
7
+ version = "1.0.3"
8
8
  source = "registry+https://github.com/rust-lang/crates.io-index"
9
- checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac"
9
+ checksum = "86b8f9420f797f2d9e935edf629310eb938a0d839f984e25327f3c7eed22300c"
10
10
  dependencies = [
11
11
  "memchr",
12
12
  ]
13
13
 
14
14
  [[package]]
15
15
  name = "bindgen"
16
- version = "0.60.1"
16
+ version = "0.66.1"
17
17
  source = "registry+https://github.com/rust-lang/crates.io-index"
18
- checksum = "062dddbc1ba4aca46de6338e2bf87771414c335f7b2f2036e8f3e9befebf88e6"
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 = "1.3.2"
36
+ version = "2.3.3"
36
37
  source = "registry+https://github.com/rust-lang/crates.io-index"
37
- checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
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.4.0"
57
+ version = "1.6.1"
57
58
  source = "registry+https://github.com/rust-lang/crates.io-index"
58
- checksum = "fa2e27ae6ab525c3d369ded447057bca5438d86dc3a68f6faafb8269ba82ebf3"
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.0"
68
+ version = "0.3.1"
68
69
  source = "registry+https://github.com/rust-lang/crates.io-index"
69
- checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
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.139"
100
+ version = "0.2.147"
100
101
  source = "registry+https://github.com/rust-lang/crates.io-index"
101
- checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79"
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.4.4"
116
+ version = "0.6.0"
116
117
  source = "registry+https://github.com/rust-lang/crates.io-index"
117
- checksum = "fc87660cd7daa49fddbfd524c836de54d5c927d520cd163f43700c5087c57d6c"
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.3.0"
128
+ version = "0.6.0"
127
129
  source = "registry+https://github.com/rust-lang/crates.io-index"
128
- checksum = "206cb23bfeea05180c97522ef6a3e52a4eb17b0ed2f30ee3ca9c4f994d2378ae"
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.1"
151
+ version = "7.1.3"
150
152
  source = "registry+https://github.com/rust-lang/crates.io-index"
151
- checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36"
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.49"
167
+ version = "1.0.66"
166
168
  source = "registry+https://github.com/rust-lang/crates.io-index"
167
- checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5"
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.23"
176
+ version = "1.0.32"
175
177
  source = "registry+https://github.com/rust-lang/crates.io-index"
176
- checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b"
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.53"
185
+ version = "0.9.81"
184
186
  source = "registry+https://github.com/rust-lang/crates.io-index"
185
- checksum = "aa291f69bcc44f8e96597a3f39e9933fde6977b825415cfaa670ac49b8ab7c99"
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.53"
194
+ version = "0.9.81"
193
195
  source = "registry+https://github.com/rust-lang/crates.io-index"
194
- checksum = "d998fd6ef588471d6d7cca24c4da88eda5e6757b6885c55760e856ecdb254c3d"
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.1"
209
+ version = "0.1.2"
204
210
  source = "registry+https://github.com/rust-lang/crates.io-index"
205
- checksum = "74c38752410925faeb82c400c06ba2fd9ee6aa8f719dd33994c9e53f5242d25f"
211
+ checksum = "a35802679f07360454b418a5d1735c89716bde01d35b1560fc953c1415a0b3bb"
206
212
 
207
213
  [[package]]
208
214
  name = "regex"
209
- version = "1.7.0"
215
+ version = "1.9.3"
210
216
  source = "registry+https://github.com/rust-lang/crates.io-index"
211
- checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a"
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.6.28"
238
+ version = "0.7.4"
221
239
  source = "registry+https://github.com/rust-lang/crates.io-index"
222
- checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848"
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 = "1.0.107"
268
+ version = "2.0.28"
245
269
  source = "registry+https://github.com/rust-lang/crates.io-index"
246
- checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5"
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.6"
279
+ version = "1.0.11"
256
280
  source = "registry+https://github.com/rust-lang/crates.io-index"
257
- checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc"
281
+ checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
258
282
 
259
283
  [[package]]
260
284
  name = "winapi"
data/Cargo.toml CHANGED
@@ -1,2 +1,5 @@
1
1
  [workspace]
2
2
  members = ["ext/halton"]
3
+
4
+ [profile.release]
5
+ debug = true
@@ -1,12 +1,11 @@
1
1
  [package]
2
2
  name = "halton"
3
3
  version = "0.1.0"
4
- authors = ["Mat Sadler <mat@sourcetagsandcodes.com>"]
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.4.4"
11
+ magnus = { version = "0.6", default_features = false }
@@ -1,14 +1,13 @@
1
1
  use std::cell::RefCell;
2
2
 
3
3
  use magnus::{
4
- block::{block_given, Yield, YieldSplat, YieldValues},
5
- define_module, exception, function, method,
4
+ block::{Yield, YieldSplat, YieldValues},
5
+ function, method,
6
6
  prelude::*,
7
- scan_args::check_arity,
8
- Error, RArray, Value,
7
+ Error, RArray, Value, Ruby
9
8
  };
10
9
 
11
- #[magnus::wrap(class = "Halton::Sequence", free_immediatly, size)]
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(&self) -> Result<f64, Error> {
20
- match self.0.try_borrow_mut().unwrap().next() {
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
- exception::stop_iteration(),
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
- check_arity(args.len(), 1..)?;
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| v.try_convert())
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(v.into());
105
+ buffer.push(ruby.into_value(v));
100
106
  } else {
101
107
  return None;
102
108
  }
103
109
  }
104
- Some(RArray::from_slice(&buffer))
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", Default::default())?;
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.2.1.5
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-02-01 00:00:00.000000000 Z
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.6.0
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.51.0
112
- rubygems_version: 3.4.6
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