rust_ruby_example 0.1.0-x86_64-linux → 0.1.1-x86_64-linux

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: 323ee7cc0d28d0171d14277b03d4ec6b87b8a07a787a5b99390f96c6c599f265
4
- data.tar.gz: bf889dce29ddc3bfb12e2d27daf3bbb965897f99fe59173c124cb565afd06121
3
+ metadata.gz: d77d5fe9eb2f15d3da4e8d9863b2dde5fb0960b9a3e77582dbf5f670b802fc32
4
+ data.tar.gz: f572df3ef73d2847c3cd13630a50b1fb991461b047590bf57a9396d3655b43ef
5
5
  SHA512:
6
- metadata.gz: e9756e9c9f07fa12dc953b0ffe7e85e35d09fe8058e94916cc8353a2c43eb0d00b0c876b2bd841032e2c91f204b6204ad84cdfe4d1f11bb8f171d2a24f9f7a96
7
- data.tar.gz: 638da7e8bd4fdfd1117c6fee59fb842b9f07b42c4ac57b10cba5084f34bd02ac4b22c07f046fbaad63671348ccb55a47dd98c0a4cb15a6a4e421ad963365bdf8
6
+ metadata.gz: 55e007340bb8e97012a980ce7facc8a393a0863b66b89541696d12f22973081613b206ad05b2dc70d8091eb4328f57029580316ed7338a58f5e195e4f50c3246
7
+ data.tar.gz: 85e818958478fa338aabf0f5aec3b5dbb4df3911e0bcb2d5dc6179db299238b36516e6f10ec5c93dab7d5f473d473144f919ecb60e4873d6275c2d2d26905a21
data/Cargo.lock ADDED
@@ -0,0 +1,374 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 3
4
+
5
+ [[package]]
6
+ name = "aho-corasick"
7
+ version = "0.7.18"
8
+ source = "registry+https://github.com/rust-lang/crates.io-index"
9
+ checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
10
+ dependencies = [
11
+ "memchr",
12
+ ]
13
+
14
+ [[package]]
15
+ name = "atty"
16
+ version = "0.2.14"
17
+ source = "registry+https://github.com/rust-lang/crates.io-index"
18
+ checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
19
+ dependencies = [
20
+ "hermit-abi",
21
+ "libc",
22
+ "winapi",
23
+ ]
24
+
25
+ [[package]]
26
+ name = "autocfg"
27
+ version = "1.1.0"
28
+ source = "registry+https://github.com/rust-lang/crates.io-index"
29
+ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
30
+
31
+ [[package]]
32
+ name = "bindgen"
33
+ version = "0.59.2"
34
+ source = "git+https://github.com/rust-lang/rust-bindgen?rev=f34e4103f304500c96d332f5cecc9067c980d0f9#f34e4103f304500c96d332f5cecc9067c980d0f9"
35
+ dependencies = [
36
+ "bitflags",
37
+ "cexpr",
38
+ "clang-sys",
39
+ "clap",
40
+ "env_logger",
41
+ "lazy_static",
42
+ "lazycell",
43
+ "log",
44
+ "peeking_take_while",
45
+ "proc-macro2",
46
+ "quote",
47
+ "regex",
48
+ "rustc-hash",
49
+ "shlex",
50
+ "which",
51
+ ]
52
+
53
+ [[package]]
54
+ name = "bitflags"
55
+ version = "1.3.2"
56
+ source = "registry+https://github.com/rust-lang/crates.io-index"
57
+ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
58
+
59
+ [[package]]
60
+ name = "cexpr"
61
+ version = "0.6.0"
62
+ source = "registry+https://github.com/rust-lang/crates.io-index"
63
+ checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
64
+ dependencies = [
65
+ "nom",
66
+ ]
67
+
68
+ [[package]]
69
+ name = "cfg-if"
70
+ version = "1.0.0"
71
+ source = "registry+https://github.com/rust-lang/crates.io-index"
72
+ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
73
+
74
+ [[package]]
75
+ name = "clang-sys"
76
+ version = "1.3.1"
77
+ source = "registry+https://github.com/rust-lang/crates.io-index"
78
+ checksum = "4cc00842eed744b858222c4c9faf7243aafc6d33f92f96935263ef4d8a41ce21"
79
+ dependencies = [
80
+ "glob",
81
+ "libc",
82
+ "libloading",
83
+ ]
84
+
85
+ [[package]]
86
+ name = "clap"
87
+ version = "3.1.5"
88
+ source = "registry+https://github.com/rust-lang/crates.io-index"
89
+ checksum = "ced1892c55c910c1219e98d6fc8d71f6bddba7905866ce740066d8bfea859312"
90
+ dependencies = [
91
+ "atty",
92
+ "bitflags",
93
+ "indexmap",
94
+ "os_str_bytes",
95
+ "strsim",
96
+ "termcolor",
97
+ "textwrap",
98
+ ]
99
+
100
+ [[package]]
101
+ name = "either"
102
+ version = "1.6.1"
103
+ source = "registry+https://github.com/rust-lang/crates.io-index"
104
+ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
105
+
106
+ [[package]]
107
+ name = "env_logger"
108
+ version = "0.9.0"
109
+ source = "registry+https://github.com/rust-lang/crates.io-index"
110
+ checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3"
111
+ dependencies = [
112
+ "atty",
113
+ "humantime",
114
+ "log",
115
+ "regex",
116
+ "termcolor",
117
+ ]
118
+
119
+ [[package]]
120
+ name = "glob"
121
+ version = "0.3.0"
122
+ source = "registry+https://github.com/rust-lang/crates.io-index"
123
+ checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
124
+
125
+ [[package]]
126
+ name = "hashbrown"
127
+ version = "0.11.2"
128
+ source = "registry+https://github.com/rust-lang/crates.io-index"
129
+ checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
130
+
131
+ [[package]]
132
+ name = "hermit-abi"
133
+ version = "0.1.19"
134
+ source = "registry+https://github.com/rust-lang/crates.io-index"
135
+ checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
136
+ dependencies = [
137
+ "libc",
138
+ ]
139
+
140
+ [[package]]
141
+ name = "humantime"
142
+ version = "2.1.0"
143
+ source = "registry+https://github.com/rust-lang/crates.io-index"
144
+ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
145
+
146
+ [[package]]
147
+ name = "indexmap"
148
+ version = "1.8.0"
149
+ source = "registry+https://github.com/rust-lang/crates.io-index"
150
+ checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223"
151
+ dependencies = [
152
+ "autocfg",
153
+ "hashbrown",
154
+ ]
155
+
156
+ [[package]]
157
+ name = "lazy_static"
158
+ version = "1.4.0"
159
+ source = "registry+https://github.com/rust-lang/crates.io-index"
160
+ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
161
+
162
+ [[package]]
163
+ name = "lazycell"
164
+ version = "1.3.0"
165
+ source = "registry+https://github.com/rust-lang/crates.io-index"
166
+ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
167
+
168
+ [[package]]
169
+ name = "libc"
170
+ version = "0.2.119"
171
+ source = "registry+https://github.com/rust-lang/crates.io-index"
172
+ checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4"
173
+
174
+ [[package]]
175
+ name = "libloading"
176
+ version = "0.7.3"
177
+ source = "registry+https://github.com/rust-lang/crates.io-index"
178
+ checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd"
179
+ dependencies = [
180
+ "cfg-if",
181
+ "winapi",
182
+ ]
183
+
184
+ [[package]]
185
+ name = "log"
186
+ version = "0.4.14"
187
+ source = "registry+https://github.com/rust-lang/crates.io-index"
188
+ checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
189
+ dependencies = [
190
+ "cfg-if",
191
+ ]
192
+
193
+ [[package]]
194
+ name = "memchr"
195
+ version = "2.4.1"
196
+ source = "registry+https://github.com/rust-lang/crates.io-index"
197
+ checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
198
+
199
+ [[package]]
200
+ name = "minimal-lexical"
201
+ version = "0.2.1"
202
+ source = "registry+https://github.com/rust-lang/crates.io-index"
203
+ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
204
+
205
+ [[package]]
206
+ name = "nom"
207
+ version = "7.1.0"
208
+ source = "registry+https://github.com/rust-lang/crates.io-index"
209
+ checksum = "1b1d11e1ef389c76fe5b81bcaf2ea32cf88b62bc494e19f493d0b30e7a930109"
210
+ dependencies = [
211
+ "memchr",
212
+ "minimal-lexical",
213
+ "version_check",
214
+ ]
215
+
216
+ [[package]]
217
+ name = "os_str_bytes"
218
+ version = "6.0.0"
219
+ source = "registry+https://github.com/rust-lang/crates.io-index"
220
+ checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64"
221
+ dependencies = [
222
+ "memchr",
223
+ ]
224
+
225
+ [[package]]
226
+ name = "peeking_take_while"
227
+ version = "0.1.2"
228
+ source = "registry+https://github.com/rust-lang/crates.io-index"
229
+ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
230
+
231
+ [[package]]
232
+ name = "pkg-config"
233
+ version = "0.3.24"
234
+ source = "registry+https://github.com/rust-lang/crates.io-index"
235
+ checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe"
236
+
237
+ [[package]]
238
+ name = "proc-macro2"
239
+ version = "1.0.36"
240
+ source = "registry+https://github.com/rust-lang/crates.io-index"
241
+ checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029"
242
+ dependencies = [
243
+ "unicode-xid",
244
+ ]
245
+
246
+ [[package]]
247
+ name = "quote"
248
+ version = "1.0.15"
249
+ source = "registry+https://github.com/rust-lang/crates.io-index"
250
+ checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145"
251
+ dependencies = [
252
+ "proc-macro2",
253
+ ]
254
+
255
+ [[package]]
256
+ name = "rb-sys"
257
+ version = "0.6.2"
258
+ source = "git+https://github.com/ianks/rb-sys?tag=v0.6.2#f8c0e5b77f20af59f34edb9a5e2f4e7fba3c7fd9"
259
+ dependencies = [
260
+ "bindgen",
261
+ "libc",
262
+ "pkg-config",
263
+ ]
264
+
265
+ [[package]]
266
+ name = "regex"
267
+ version = "1.5.4"
268
+ source = "registry+https://github.com/rust-lang/crates.io-index"
269
+ checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
270
+ dependencies = [
271
+ "aho-corasick",
272
+ "memchr",
273
+ "regex-syntax",
274
+ ]
275
+
276
+ [[package]]
277
+ name = "regex-syntax"
278
+ version = "0.6.25"
279
+ source = "registry+https://github.com/rust-lang/crates.io-index"
280
+ checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
281
+
282
+ [[package]]
283
+ name = "rust_ruby_example"
284
+ version = "0.1.0"
285
+ dependencies = [
286
+ "rb-sys",
287
+ ]
288
+
289
+ [[package]]
290
+ name = "rustc-hash"
291
+ version = "1.1.0"
292
+ source = "registry+https://github.com/rust-lang/crates.io-index"
293
+ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
294
+
295
+ [[package]]
296
+ name = "shlex"
297
+ version = "1.1.0"
298
+ source = "registry+https://github.com/rust-lang/crates.io-index"
299
+ checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
300
+
301
+ [[package]]
302
+ name = "strsim"
303
+ version = "0.10.0"
304
+ source = "registry+https://github.com/rust-lang/crates.io-index"
305
+ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
306
+
307
+ [[package]]
308
+ name = "termcolor"
309
+ version = "1.1.3"
310
+ source = "registry+https://github.com/rust-lang/crates.io-index"
311
+ checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
312
+ dependencies = [
313
+ "winapi-util",
314
+ ]
315
+
316
+ [[package]]
317
+ name = "textwrap"
318
+ version = "0.15.0"
319
+ source = "registry+https://github.com/rust-lang/crates.io-index"
320
+ checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb"
321
+
322
+ [[package]]
323
+ name = "unicode-xid"
324
+ version = "0.2.2"
325
+ source = "registry+https://github.com/rust-lang/crates.io-index"
326
+ checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
327
+
328
+ [[package]]
329
+ name = "version_check"
330
+ version = "0.9.4"
331
+ source = "registry+https://github.com/rust-lang/crates.io-index"
332
+ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
333
+
334
+ [[package]]
335
+ name = "which"
336
+ version = "4.2.4"
337
+ source = "registry+https://github.com/rust-lang/crates.io-index"
338
+ checksum = "2a5a7e487e921cf220206864a94a89b6c6905bfc19f1057fa26a4cb360e5c1d2"
339
+ dependencies = [
340
+ "either",
341
+ "lazy_static",
342
+ "libc",
343
+ ]
344
+
345
+ [[package]]
346
+ name = "winapi"
347
+ version = "0.3.9"
348
+ source = "registry+https://github.com/rust-lang/crates.io-index"
349
+ checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
350
+ dependencies = [
351
+ "winapi-i686-pc-windows-gnu",
352
+ "winapi-x86_64-pc-windows-gnu",
353
+ ]
354
+
355
+ [[package]]
356
+ name = "winapi-i686-pc-windows-gnu"
357
+ version = "0.4.0"
358
+ source = "registry+https://github.com/rust-lang/crates.io-index"
359
+ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
360
+
361
+ [[package]]
362
+ name = "winapi-util"
363
+ version = "0.1.5"
364
+ source = "registry+https://github.com/rust-lang/crates.io-index"
365
+ checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
366
+ dependencies = [
367
+ "winapi",
368
+ ]
369
+
370
+ [[package]]
371
+ name = "winapi-x86_64-pc-windows-gnu"
372
+ version = "0.4.0"
373
+ source = "registry+https://github.com/rust-lang/crates.io-index"
374
+ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
data/Cargo.toml ADDED
@@ -0,0 +1,10 @@
1
+ [package]
2
+ name = "rust_ruby_example"
3
+ version = "0.1.0"
4
+
5
+ [lib]
6
+ crate-type = ["cdylib"]
7
+
8
+ [dependencies]
9
+ # Needed until bindgen has the `allowlist_file` feature
10
+ rb-sys = { git = "https://github.com/ianks/rb-sys", tag = "v0.6.2" }
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ RUBY_VERSION =~ /(\d+\.\d+)/
5
+ require "#{$1}/rust_ruby_example"
6
+ rescue LoadError
7
+ require "rust_ruby_example"
8
+ end
data/src/lib.rs ADDED
@@ -0,0 +1,42 @@
1
+ #[macro_use]
2
+ extern crate rb_sys;
3
+
4
+ use rb_sys::{
5
+ rb_define_module, rb_define_module_function, rb_string_value_cstr, rb_utf8_str_new, VALUE,
6
+ };
7
+ use std::ffi::{CStr, CString};
8
+ use std::os::raw::{c_char, c_long};
9
+
10
+ ruby_extension!();
11
+
12
+ #[inline]
13
+ unsafe fn cstr_to_string(str: *const c_char) -> String {
14
+ CStr::from_ptr(str).to_string_lossy().into_owned()
15
+ }
16
+
17
+ #[no_mangle]
18
+ unsafe extern "C" fn pub_reverse(_klass: VALUE, mut input: VALUE) -> VALUE {
19
+ let ruby_string = cstr_to_string(rb_string_value_cstr(&mut input));
20
+ let reversed = ruby_string.to_string().chars().rev().collect::<String>();
21
+ let reversed_cstring = CString::new(reversed).unwrap();
22
+ let size = ruby_string.len() as c_long;
23
+
24
+ rb_utf8_str_new(reversed_cstring.as_ptr(), size)
25
+ }
26
+
27
+ #[allow(non_snake_case)]
28
+ #[no_mangle]
29
+ pub extern "C" fn Init_rust_ruby_example() {
30
+ let name = CString::new("RustRubyExample").unwrap();
31
+ let function_name = CString::new("reverse").unwrap();
32
+ // bindgen does not properly detect the arity of the ruby callback function, so we have to transmute
33
+ let callback = unsafe {
34
+ std::mem::transmute::<
35
+ unsafe extern "C" fn(VALUE, VALUE) -> VALUE,
36
+ unsafe extern "C" fn() -> VALUE,
37
+ >(pub_reverse)
38
+ };
39
+ let klass = unsafe { rb_define_module(name.as_ptr()) };
40
+
41
+ unsafe { rb_define_module_function(klass, function_name.as_ptr(), Some(callback), 1) }
42
+ }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rust_ruby_example
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - Ian Ker-Seymer
@@ -16,6 +16,8 @@ executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
+ - Cargo.lock
20
+ - Cargo.toml
19
21
  - ext/rust_ruby_example/extconf.rb
20
22
  - lib/2.4/rust_ruby_example.so
21
23
  - lib/2.5/rust_ruby_example.so
@@ -23,6 +25,8 @@ files:
23
25
  - lib/2.7/rust_ruby_example.so
24
26
  - lib/3.0/rust_ruby_example.so
25
27
  - lib/3.1/rust_ruby_example.so
28
+ - lib/rust_ruby_example.rb
29
+ - src/lib.rs
26
30
  homepage:
27
31
  licenses: []
28
32
  metadata:
@@ -48,5 +52,5 @@ requirements: []
48
52
  rubygems_version: 3.4.0.dev
49
53
  signing_key:
50
54
  specification_version: 4
51
- summary: Testing
55
+ summary: A Rust extension for Ruby
52
56
  test_files: []