ruby-termios 1.1.0 → 1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d67fe2e8d8fade0d9b3f6b80f99f7c75436c57f5e413a4c8461051cc6c0ad82
4
- data.tar.gz: f8519e70564bb6867d6412fc82f5eee6db50a9d24a6198c6679130cbbc89d430
3
+ metadata.gz: 1dd3722a4675c7b97d47759fefb3f86330039c77eaa6e2b4d50d928a9f5e969d
4
+ data.tar.gz: 6b1998adcc4ad1681f6aceb19e6596a658e16f56eb1eb989bd4c53e18fc93ad6
5
5
  SHA512:
6
- metadata.gz: 76c79841e46e8f3c8ac3adf7dcabe20ebe1b828836d01a69bf871c14490c27d30bd98acc0fd966752c17b59554c9c78db9ff4ad0aa7899bb8a42ca7ed14f9173
7
- data.tar.gz: e37fd4c83f68419b9c872f2dc134ba8894cdd5268fe1707c2eec817d4d62d05d84aa57b5c58416d38dc0adcf26b8315f14b5eea467207ed1827c206a6a21b7db
6
+ metadata.gz: 6f9e1773f55b831066a21cff41314195c6c1c64aad6af97e75fc7a2fa2c90acfe380f069bd71d12d70c36a2036d9e577df94d1d9041c91db67b0c434a83013d2
7
+ data.tar.gz: 8dc0d69adaa1c03c54d0d231a79dbeff5f51f7655c67571014ae4e3d842fc758d1377680f136511edc49eca20ace4dbc6adcb9c85e0b0ed5eced2e825e30b984
data/README.md CHANGED
@@ -43,4 +43,4 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/arika/
43
43
 
44
44
  ## License
45
45
 
46
- The gem is available as open source under the terms of the [Ruby's Licens](https://www.ruby-lang.org/en/about/license.txt).
46
+ The gem is available as open source under the terms of the [Ruby's License](https://www.ruby-lang.org/en/about/license.txt).
data/ext/extconf.rb CHANGED
@@ -1,28 +1,7 @@
1
1
  require 'mkmf'
2
2
 
3
- Dir.glob('./lib/**/*.rb') do |f|
4
- $INSTALLFILES << [f, '$(RUBYLIBDIR)', 'lib']
5
- end
3
+ abort 'termios.h is required' unless have_header('termios.h')
4
+ abort 'unistd.h is required' unless have_header('unistd.h')
5
+ have_header('sys/ioctl.h')
6
6
 
7
- if have_header('termios.h') &&
8
- have_header('unistd.h')
9
- have_header('sys/ioctl.h')
10
-
11
- if RUBY_VERSION >= '1.7'
12
- if have_header('ruby/io.h')
13
- have_type("rb_io_t", ["ruby/io.h"])
14
- have_struct_member("rb_io_t", "fd", ["ruby/io.h"])
15
- else
16
- if have_type("rb_io_t", ["ruby.h", "rubyio.h"])
17
- have_struct_member("rb_io_t", "fd", ["ruby.h", "rubyio.h"])
18
- else
19
- have_struct_member("OpenFile", "fd", ["ruby.h", "rubyio.h"])
20
- end
21
- if have_macro("OpenFile", ["ruby.h", "rubyio.h"])
22
- $defs.push("-DHAVE_MACRO_OPENFILE")
23
- end
24
- end
25
- end
26
-
27
- create_makefile('termios')
28
- end
7
+ create_makefile('termios')
data/ext/termios.c CHANGED
@@ -6,28 +6,15 @@
6
6
  */
7
7
 
8
8
  #include "ruby.h"
9
- #if defined(HAVE_RUBY_IO_H)
10
9
  #include "ruby/io.h"
11
- #else
12
- #include "rubyio.h"
13
- #endif
10
+ #include "ruby/ractor.h"
14
11
  #include <termios.h>
15
- #include <sys/ioctl.h>
16
- #if defined(HAVE_SYS_IOCTL_H)
17
12
  #include <unistd.h>
13
+ #if defined(HAVE_SYS_IOCTL_H)
14
+ #include <sys/ioctl.h>
18
15
  #endif
19
16
  #include <string.h>
20
17
 
21
- #if defined(HAVE_TYPE_RB_IO_T) && !defined(HAVE_MACRO_OPENFILE)
22
- typedef rb_io_t OpenFile;
23
- #endif
24
-
25
- #if defined(HAVE_ST_FD)
26
- #define FILENO(fptr) (fptr->fd)
27
- #else
28
- #define FILENO(fptr) fileno(fptr->f)
29
- #endif
30
-
31
18
  #define validate_ulong(v) ULONG2NUM(NUM2ULONG(v))
32
19
 
33
20
  static VALUE mTermios;
@@ -50,8 +37,7 @@ static ID id_iflag, id_oflag, id_cflag, id_lflag, id_cc, id_ispeed, id_ospeed;
50
37
  * Updates input modes of the object.
51
38
  */
52
39
  static VALUE
53
- termios_set_iflag(self, value)
54
- VALUE self, value;
40
+ termios_set_iflag(VALUE self, VALUE value)
55
41
  {
56
42
  rb_ivar_set(self, id_iflag, validate_ulong(value));
57
43
 
@@ -65,8 +51,7 @@ termios_set_iflag(self, value)
65
51
  * Updates output modes of the object.
66
52
  */
67
53
  static VALUE
68
- termios_set_oflag(self, value)
69
- VALUE self, value;
54
+ termios_set_oflag(VALUE self, VALUE value)
70
55
  {
71
56
  rb_ivar_set(self, id_oflag, validate_ulong(value));
72
57
 
@@ -80,8 +65,7 @@ termios_set_oflag(self, value)
80
65
  * Updates control modes of the object.
81
66
  */
82
67
  static VALUE
83
- termios_set_cflag(self, value)
84
- VALUE self, value;
68
+ termios_set_cflag(VALUE self, VALUE value)
85
69
  {
86
70
  rb_ivar_set(self, id_cflag, validate_ulong(value));
87
71
 
@@ -95,8 +79,7 @@ termios_set_cflag(self, value)
95
79
  * Updates local modes of the object.
96
80
  */
97
81
  static VALUE
98
- termios_set_lflag(self, value)
99
- VALUE self, value;
82
+ termios_set_lflag(VALUE self, VALUE value)
100
83
  {
101
84
  rb_ivar_set(self, id_lflag, validate_ulong(value));
102
85
 
@@ -110,8 +93,7 @@ termios_set_lflag(self, value)
110
93
  * Updates control characters of the object.
111
94
  */
112
95
  static VALUE
113
- termios_set_cc(self, value)
114
- VALUE self, value;
96
+ termios_set_cc(VALUE self, VALUE value)
115
97
  {
116
98
  Check_Type(value, T_ARRAY);
117
99
  rb_ivar_set(self, id_cc, value);
@@ -126,8 +108,7 @@ termios_set_cc(self, value)
126
108
  * Updates input baud rate of the object.
127
109
  */
128
110
  static VALUE
129
- termios_set_ispeed(self, value)
130
- VALUE self, value;
111
+ termios_set_ispeed(VALUE self, VALUE value)
131
112
  {
132
113
  rb_ivar_set(self, id_ispeed, validate_ulong(value));
133
114
 
@@ -141,8 +122,7 @@ termios_set_ispeed(self, value)
141
122
  * Updates output baud rate of the object.
142
123
  */
143
124
  static VALUE
144
- termios_set_ospeed(self, value)
145
- VALUE self, value;
125
+ termios_set_ospeed(VALUE self, VALUE value)
146
126
  {
147
127
  rb_ivar_set(self, id_ospeed, validate_ulong(value));
148
128
 
@@ -156,16 +136,13 @@ termios_set_ospeed(self, value)
156
136
  * Returns new Termios::Termios object.
157
137
  */
158
138
  static VALUE
159
- termios_initialize(argc, argv, self)
160
- int argc;
161
- VALUE *argv;
162
- VALUE self;
139
+ termios_initialize(int argc, VALUE *argv, VALUE self)
163
140
  {
164
141
  VALUE c_iflag, c_oflag, c_cflag, c_lflag, c_cc, c_ispeed, c_ospeed;
165
142
  VALUE cc_ary;
166
143
  int i;
167
144
 
168
- cc_ary = rb_ary_new2(NCCS);
145
+ cc_ary = rb_ary_new_capa(NCCS);
169
146
  for (i = 0; i < NCCS; i++) {
170
147
  rb_ary_store(cc_ary, i, INT2FIX(0));
171
148
  }
@@ -178,8 +155,8 @@ termios_initialize(argc, argv, self)
178
155
  rb_ivar_set(self, id_ispeed, INT2FIX(0));
179
156
  rb_ivar_set(self, id_ospeed, INT2FIX(0));
180
157
 
181
- rb_scan_args(argc, argv, "07",
182
- &c_iflag, &c_oflag, &c_cflag, &c_lflag,
158
+ rb_scan_args(argc, argv, "07",
159
+ &c_iflag, &c_oflag, &c_cflag, &c_lflag,
183
160
  &c_cc, &c_ispeed, &c_ospeed);
184
161
 
185
162
  if (!NIL_P(c_iflag))
@@ -201,7 +178,7 @@ termios_initialize(argc, argv, self)
201
178
  termios_set_ispeed(self, c_ispeed);
202
179
 
203
180
  if (!NIL_P(c_ospeed))
204
- termios_set_ispeed(self, c_ospeed);
181
+ termios_set_ospeed(self, c_ospeed);
205
182
 
206
183
  return self;
207
184
  }
@@ -236,20 +213,19 @@ termios_initialize(argc, argv, self)
236
213
  */
237
214
 
238
215
  static VALUE
239
- termios_to_Termios(t)
240
- struct termios *t;
216
+ termios_to_Termios(struct termios *t)
241
217
  {
242
218
  int i;
243
219
  VALUE obj, cc_ary;
244
220
 
245
- obj = rb_funcall(cTermios, rb_intern("new"), 0);
221
+ obj = rb_class_new_instance(0, NULL, cTermios);
246
222
 
247
223
  termios_set_iflag(obj, ULONG2NUM(t->c_iflag));
248
224
  termios_set_oflag(obj, ULONG2NUM(t->c_oflag));
249
225
  termios_set_cflag(obj, ULONG2NUM(t->c_cflag));
250
226
  termios_set_lflag(obj, ULONG2NUM(t->c_lflag));
251
227
 
252
- cc_ary = rb_ary_new2(NCCS);
228
+ cc_ary = rb_ary_new_capa(NCCS);
253
229
  for (i = 0; i < NCCS; i++) {
254
230
  rb_ary_store(cc_ary, i, CHR2FIX(t->c_cc[i]));
255
231
  }
@@ -262,17 +238,15 @@ termios_to_Termios(t)
262
238
  }
263
239
 
264
240
  static void
265
- Termios_to_termios(obj, t)
266
- VALUE obj;
267
- struct termios *t;
241
+ Termios_to_termios(VALUE obj, struct termios *t)
268
242
  {
269
243
  int i;
270
244
  VALUE cc_ary;
271
245
 
272
- t->c_iflag = NUM2ULONG(rb_ivar_get(obj, id_iflag));
273
- t->c_oflag = NUM2ULONG(rb_ivar_get(obj, id_oflag));
274
- t->c_cflag = NUM2ULONG(rb_ivar_get(obj, id_cflag));
275
- t->c_lflag = NUM2ULONG(rb_ivar_get(obj, id_lflag));
246
+ t->c_iflag = (tcflag_t)NUM2ULONG(rb_ivar_get(obj, id_iflag));
247
+ t->c_oflag = (tcflag_t)NUM2ULONG(rb_ivar_get(obj, id_oflag));
248
+ t->c_cflag = (tcflag_t)NUM2ULONG(rb_ivar_get(obj, id_cflag));
249
+ t->c_lflag = (tcflag_t)NUM2ULONG(rb_ivar_get(obj, id_lflag));
276
250
 
277
251
  cc_ary = rb_ivar_get(obj, id_cc);
278
252
  for (i = 0; i < NCCS; i++) {
@@ -280,8 +254,8 @@ Termios_to_termios(obj, t)
280
254
  t->c_cc[i] = NUM2CHR(elt);
281
255
  }
282
256
 
283
- cfsetispeed(t, NUM2ULONG(rb_ivar_get(obj, id_ispeed)));
284
- cfsetospeed(t, NUM2ULONG(rb_ivar_get(obj, id_ospeed)));
257
+ cfsetispeed(t, (speed_t)NUM2ULONG(rb_ivar_get(obj, id_ispeed)));
258
+ cfsetospeed(t, (speed_t)NUM2ULONG(rb_ivar_get(obj, id_ospeed)));
285
259
  }
286
260
 
287
261
  /*
@@ -304,15 +278,12 @@ Termios_to_termios(obj, t)
304
278
  * See also: tcgetattr(3)
305
279
  */
306
280
  static VALUE
307
- termios_tcgetattr(io)
308
- VALUE io;
281
+ termios_tcgetattr(VALUE io)
309
282
  {
310
283
  struct termios t;
311
- OpenFile *fptr;
312
284
 
313
285
  Check_Type(io, T_FILE);
314
- GetOpenFile(io, fptr);
315
- if (tcgetattr(FILENO(fptr), &t) < 0) {
286
+ if (tcgetattr(rb_io_descriptor(io), &t) < 0) {
316
287
  rb_sys_fail("tcgetattr");
317
288
  }
318
289
 
@@ -320,8 +291,7 @@ termios_tcgetattr(io)
320
291
  }
321
292
 
322
293
  static VALUE
323
- termios_s_tcgetattr(obj, io)
324
- VALUE obj, io;
294
+ termios_s_tcgetattr(VALUE obj, VALUE io)
325
295
  {
326
296
  return termios_tcgetattr(io);
327
297
  }
@@ -359,33 +329,29 @@ termios_s_tcgetattr(obj, io)
359
329
  * See also: tcsetattr(3)
360
330
  */
361
331
  static VALUE
362
- termios_tcsetattr(io, opt, param)
363
- VALUE io, opt, param;
332
+ termios_tcsetattr(VALUE io, VALUE opt, VALUE param)
364
333
  {
365
334
  VALUE old;
366
- OpenFile *fptr;
367
335
  struct termios t;
368
336
  int tcsetattr_option;
369
337
 
370
338
  Check_Type(io, T_FILE);
371
339
  Check_Type(opt, T_FIXNUM);
372
340
  if (CLASS_OF(param) != cTermios) {
373
- const char *type = rb_class2name(CLASS_OF(param));
374
- rb_raise(rb_eTypeError,
375
- "wrong argument type %s (expected Termios::Termios)",
376
- type);
341
+ rb_raise(rb_eTypeError,
342
+ "wrong argument type %"PRIsVALUE" (expected Termios::Termios)",
343
+ rb_obj_class(param));
377
344
  }
378
345
 
379
346
  tcsetattr_option = FIX2INT(opt);
380
347
  if (rb_ary_includes(tcsetattr_opt, opt) != Qtrue) {
381
- rb_raise(rb_eArgError,
348
+ rb_raise(rb_eArgError,
382
349
  "wrong option value %d", tcsetattr_option);
383
350
  }
384
351
 
385
352
  old = termios_tcgetattr(io);
386
- GetOpenFile(io, fptr);
387
353
  Termios_to_termios(param, &t);
388
- if (tcsetattr(FILENO(fptr), tcsetattr_option, &t) < 0) {
354
+ if (tcsetattr(rb_io_descriptor(io), tcsetattr_option, &t) < 0) {
389
355
  rb_sys_fail("tcsetattr");
390
356
  }
391
357
 
@@ -393,8 +359,7 @@ termios_tcsetattr(io, opt, param)
393
359
  }
394
360
 
395
361
  static VALUE
396
- termios_s_tcsetattr(obj, io, opt, param)
397
- VALUE obj, io, opt, param;
362
+ termios_s_tcsetattr(VALUE obj, VALUE io, VALUE opt, VALUE param)
398
363
  {
399
364
  return termios_tcsetattr(io, opt, param);
400
365
  }
@@ -409,16 +374,12 @@ termios_s_tcsetattr(obj, io, opt, param)
409
374
  * See also: tcsendbreak(3)
410
375
  */
411
376
  static VALUE
412
- termios_tcsendbreak(io, duration)
413
- VALUE io, duration;
377
+ termios_tcsendbreak(VALUE io, VALUE duration)
414
378
  {
415
- OpenFile *fptr;
416
-
417
379
  Check_Type(io, T_FILE);
418
380
  Check_Type(duration, T_FIXNUM);
419
381
 
420
- GetOpenFile(io, fptr);
421
- if (tcsendbreak(FILENO(fptr), FIX2INT(duration)) < 0) {
382
+ if (tcsendbreak(rb_io_descriptor(io), FIX2INT(duration)) < 0) {
422
383
  rb_sys_fail("tcsendbreak");
423
384
  }
424
385
 
@@ -426,8 +387,7 @@ termios_tcsendbreak(io, duration)
426
387
  }
427
388
 
428
389
  static VALUE
429
- termios_s_tcsendbreak(obj, io, duration)
430
- VALUE obj, io, duration;
390
+ termios_s_tcsendbreak(VALUE obj, VALUE io, VALUE duration)
431
391
  {
432
392
  return termios_tcsendbreak(io, duration);
433
393
  }
@@ -442,15 +402,11 @@ termios_s_tcsendbreak(obj, io, duration)
442
402
  * See also: tcdrain(3)
443
403
  */
444
404
  static VALUE
445
- termios_tcdrain(io)
446
- VALUE io;
405
+ termios_tcdrain(VALUE io)
447
406
  {
448
- OpenFile *fptr;
449
-
450
407
  Check_Type(io, T_FILE);
451
408
 
452
- GetOpenFile(io, fptr);
453
- if (tcdrain(FILENO(fptr)) < 0) {
409
+ if (tcdrain(rb_io_descriptor(io)) < 0) {
454
410
  rb_sys_fail("tcdrain");
455
411
  }
456
412
 
@@ -458,8 +414,7 @@ termios_tcdrain(io)
458
414
  }
459
415
 
460
416
  static VALUE
461
- termios_s_tcdrain(obj, io)
462
- VALUE obj, io;
417
+ termios_s_tcdrain(VALUE obj, VALUE io)
463
418
  {
464
419
  return termios_tcdrain(io);
465
420
  }
@@ -475,22 +430,19 @@ termios_s_tcdrain(obj, io)
475
430
  * See also: tcflush(3)
476
431
  */
477
432
  static VALUE
478
- termios_tcflush(io, qs)
479
- VALUE io, qs;
433
+ termios_tcflush(VALUE io, VALUE qs)
480
434
  {
481
- OpenFile *fptr;
482
435
  int queue_selector;
483
436
 
484
437
  Check_Type(io, T_FILE);
485
438
  Check_Type(qs, T_FIXNUM);
486
439
  queue_selector = FIX2INT(qs);
487
440
  if (rb_ary_includes(tcflush_qs, qs) != Qtrue) {
488
- rb_raise(rb_eArgError,
441
+ rb_raise(rb_eArgError,
489
442
  "wrong queue-selector value %d", queue_selector);
490
443
  }
491
444
 
492
- GetOpenFile(io, fptr);
493
- if (tcflush(FILENO(fptr), queue_selector) < 0) {
445
+ if (tcflush(rb_io_descriptor(io), queue_selector) < 0) {
494
446
  rb_sys_fail("tcflush");
495
447
  }
496
448
 
@@ -498,8 +450,7 @@ termios_tcflush(io, qs)
498
450
  }
499
451
 
500
452
  static VALUE
501
- termios_s_tcflush(obj, io, qs)
502
- VALUE obj, io, qs;
453
+ termios_s_tcflush(VALUE obj, VALUE io, VALUE qs)
503
454
  {
504
455
  return termios_tcflush(io, qs);
505
456
  }
@@ -514,22 +465,19 @@ termios_s_tcflush(obj, io, qs)
514
465
  * See also: tcflow(3)
515
466
  */
516
467
  static VALUE
517
- termios_tcflow(io, act)
518
- VALUE io, act;
468
+ termios_tcflow(VALUE io, VALUE act)
519
469
  {
520
- OpenFile *fptr;
521
470
  int action;
522
471
 
523
472
  Check_Type(io, T_FILE);
524
473
  Check_Type(act, T_FIXNUM);
525
474
  action = FIX2INT(act);
526
475
  if (rb_ary_includes(tcflow_act, act) != Qtrue) {
527
- rb_raise(rb_eArgError,
476
+ rb_raise(rb_eArgError,
528
477
  "wrong action value %d", action);
529
478
  }
530
479
 
531
- GetOpenFile(io, fptr);
532
- if (tcflow(FILENO(fptr), action) < 0) {
480
+ if (tcflow(rb_io_descriptor(io), action) < 0) {
533
481
  rb_sys_fail("tcflow");
534
482
  }
535
483
 
@@ -537,8 +485,7 @@ termios_tcflow(io, act)
537
485
  }
538
486
 
539
487
  static VALUE
540
- termios_s_tcflow(obj, io, act)
541
- VALUE obj, io, act;
488
+ termios_s_tcflow(VALUE obj, VALUE io, VALUE act)
542
489
  {
543
490
  return termios_tcflow(io, act);
544
491
  }
@@ -554,24 +501,20 @@ termios_s_tcflow(obj, io, act)
554
501
  * See also: tcgetpgrp(3)
555
502
  */
556
503
  static VALUE
557
- termios_tcgetpgrp(io)
558
- VALUE io;
504
+ termios_tcgetpgrp(VALUE io)
559
505
  {
560
- OpenFile *fptr;
561
506
  pid_t pid;
562
507
 
563
508
  Check_Type(io, T_FILE);
564
- GetOpenFile(io, fptr);
565
- if ((pid = tcgetpgrp(FILENO(fptr))) < 0) {
509
+ if ((pid = tcgetpgrp(rb_io_descriptor(io))) < 0) {
566
510
  rb_sys_fail("tcgetpgrp");
567
511
  }
568
512
 
569
- return LONG2NUM(pid);
513
+ return PIDT2NUM(pid);
570
514
  }
571
515
 
572
516
  static VALUE
573
- termios_s_tcgetpgrp(obj, io)
574
- VALUE obj, io;
517
+ termios_s_tcgetpgrp(VALUE obj, VALUE io)
575
518
  {
576
519
  return termios_tcgetpgrp(io);
577
520
  }
@@ -587,17 +530,14 @@ termios_s_tcgetpgrp(obj, io)
587
530
  * See also: tcsetpgrp(3)
588
531
  */
589
532
  static VALUE
590
- termios_tcsetpgrp(io, pgrpid)
591
- VALUE io, pgrpid;
533
+ termios_tcsetpgrp(VALUE io, VALUE pgrpid)
592
534
  {
593
- OpenFile *fptr;
594
535
  pid_t pgrp;
595
536
 
596
537
  Check_Type(io, T_FILE);
597
- pgrp = NUM2LONG(pgrpid);
538
+ pgrp = NUM2PIDT(pgrpid);
598
539
 
599
- GetOpenFile(io, fptr);
600
- if (tcsetpgrp(FILENO(fptr), pgrp) < 0) {
540
+ if (tcsetpgrp(rb_io_descriptor(io), pgrp) < 0) {
601
541
  rb_sys_fail("tcsetpgrp");
602
542
  }
603
543
 
@@ -605,8 +545,7 @@ termios_tcsetpgrp(io, pgrpid)
605
545
  }
606
546
 
607
547
  static VALUE
608
- termios_s_tcsetpgrp(obj, io, pgrpid)
609
- VALUE obj, io, pgrpid;
548
+ termios_s_tcsetpgrp(VALUE obj, VALUE io, VALUE pgrpid)
610
549
  {
611
550
  return termios_tcsetpgrp(io, pgrpid);
612
551
  }
@@ -618,12 +557,9 @@ termios_s_tcsetpgrp(obj, io, pgrpid)
618
557
  * Returns new Termios::Termios object.
619
558
  */
620
559
  static VALUE
621
- termios_s_newtermios(argc, argv, klass)
622
- int argc;
623
- VALUE *argv;
624
- VALUE klass;
560
+ termios_s_newtermios(int argc, VALUE *argv, VALUE klass)
625
561
  {
626
- return rb_funcall2(cTermios, rb_intern("new"), argc, argv);
562
+ return rb_class_new_instance(argc, argv, cTermios);
627
563
  }
628
564
 
629
565
  /*
@@ -633,8 +569,7 @@ termios_s_newtermios(argc, argv, klass)
633
569
  * Produces a shallow copy of the object.
634
570
  */
635
571
  static VALUE
636
- termios_dup(self)
637
- VALUE self;
572
+ termios_dup(VALUE self)
638
573
  {
639
574
  VALUE result;
640
575
  VALUE cc_ary;
@@ -646,8 +581,8 @@ termios_dup(self)
646
581
  return result;
647
582
  }
648
583
 
649
- void
650
- Init_termios()
584
+ RUBY_FUNC_EXPORTED void
585
+ Init_termios(void)
651
586
  {
652
587
  VALUE ccindex, ccindex_names;
653
588
  VALUE iflags, iflags_names;
@@ -660,6 +595,8 @@ Init_termios()
660
595
  VALUE pty_pkt_options, pty_pkt_options_names;
661
596
  VALUE line_disciplines, line_disciplines_names;
662
597
 
598
+ rb_ext_ractor_safe(true);
599
+
663
600
  /* module Termios */
664
601
 
665
602
  mTermios = rb_define_module("Termios");
@@ -1534,4 +1471,31 @@ Init_termios()
1534
1471
  #ifdef PPPDISC
1535
1472
  define_flag(line_disciplines, PPPDISC)
1536
1473
  #endif
1474
+
1475
+ /* make the lookup tables shareable so that they can be used from any Ractor */
1476
+ rb_ractor_make_shareable(ccindex);
1477
+ rb_ractor_make_shareable(ccindex_names);
1478
+ rb_ractor_make_shareable(iflags);
1479
+ rb_ractor_make_shareable(iflags_names);
1480
+ rb_ractor_make_shareable(oflags);
1481
+ rb_ractor_make_shareable(oflags_names);
1482
+ rb_ractor_make_shareable(oflags_choices);
1483
+ rb_ractor_make_shareable(cflags);
1484
+ rb_ractor_make_shareable(cflags_names);
1485
+ rb_ractor_make_shareable(cflags_choices);
1486
+ rb_ractor_make_shareable(lflags);
1487
+ rb_ractor_make_shareable(lflags_names);
1488
+ rb_ractor_make_shareable(bauds);
1489
+ rb_ractor_make_shareable(bauds_names);
1490
+ rb_ractor_make_shareable(tcsetattr_opt);
1491
+ rb_ractor_make_shareable(tcflush_qs);
1492
+ rb_ractor_make_shareable(tcflow_act);
1493
+ rb_ractor_make_shareable(ioctl_commands);
1494
+ rb_ractor_make_shareable(ioctl_commands_names);
1495
+ rb_ractor_make_shareable(modem_signals);
1496
+ rb_ractor_make_shareable(modem_signals_names);
1497
+ rb_ractor_make_shareable(pty_pkt_options);
1498
+ rb_ractor_make_shareable(pty_pkt_options_names);
1499
+ rb_ractor_make_shareable(line_disciplines);
1500
+ rb_ractor_make_shareable(line_disciplines_names);
1537
1501
  }
@@ -1,3 +1,3 @@
1
1
  module Termios
2
- VERSION = '1.1.0'
2
+ VERSION = '1.2.0'
3
3
  end
data/lib/termios.rb CHANGED
@@ -41,6 +41,7 @@ module Termios
41
41
  }
42
42
  VISIBLE_CHAR[POSIX_VDISABLE] = "<undef>"
43
43
  VISIBLE_CHAR[[POSIX_VDISABLE].pack("C")] = "<undef>"
44
+ Ractor.make_shareable(VISIBLE_CHAR)
44
45
 
45
46
  class Termios
46
47
  def inspect
metadata CHANGED
@@ -1,19 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-termios
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - akira yamada
8
- autorequire:
9
- bindir: exe
8
+ bindir: bin
10
9
  cert_chain: []
11
- date: 2020-12-15 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies: []
13
- description: |2
14
- Termios module is simple wrapper of termios(3).
15
- It can be included into IO-family classes and can extend IO-family objects.
16
- In addition, the methods can use as module function.
12
+ description: |
13
+ Termios module is simple wrapper of termios(3).
14
+ It can be included into IO-family classes and can extend IO-family objects.
15
+ In addition, the methods can use as module function.
17
16
  email:
18
17
  - akira@arika.org
19
18
  executables: []
@@ -21,12 +20,8 @@ extensions:
21
20
  - ext/extconf.rb
22
21
  extra_rdoc_files: []
23
22
  files:
24
- - ".gitignore"
25
- - Gemfile
26
23
  - README.md
27
24
  - Rakefile
28
- - bin/console
29
- - bin/setup
30
25
  - examples/modem_check0.rb
31
26
  - examples/modem_check1.rb
32
27
  - examples/modem_check2.rb
@@ -36,16 +31,14 @@ files:
36
31
  - ext/termios.c
37
32
  - lib/termios.rb
38
33
  - lib/termios/version.rb
39
- - ruby-termios.gemspec
40
34
  - termios.rd
41
35
  homepage: https://github.com/arika/ruby-termios
42
36
  licenses:
43
- - Ruby's
37
+ - Ruby
44
38
  metadata:
45
- homepage_uri: https://github.com/arika/ruby-termios
46
- source_code_ri: https://github.com/arika/ruby-termios
39
+ source_code_uri: https://github.com/arika/ruby-termios
47
40
  bug_tracker_uri: https://github.com/arika/ruby-termios/issues
48
- post_install_message:
41
+ rubygems_mfa_required: 'true'
49
42
  rdoc_options: []
50
43
  require_paths:
51
44
  - lib
@@ -53,15 +46,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
53
46
  requirements:
54
47
  - - ">="
55
48
  - !ruby/object:Gem::Version
56
- version: 2.3.0
49
+ version: 3.2.0
57
50
  required_rubygems_version: !ruby/object:Gem::Requirement
58
51
  requirements:
59
52
  - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  requirements: []
63
- rubygems_version: 3.2.0
64
- signing_key:
56
+ rubygems_version: 4.0.20
65
57
  specification_version: 4
66
58
  summary: a simple wrapper of termios(3)
67
59
  test_files: []
data/.gitignore DELETED
@@ -1,99 +0,0 @@
1
- # Created by https://www.gitignore.io/api/ruby,osx,vim
2
-
3
- ### Ruby ###
4
- *.gem
5
- *.rbc
6
- *.so
7
- *.o
8
- *.bundle
9
- /.config
10
- /coverage/
11
- /InstalledFiles
12
- /pkg/
13
- /spec/reports/
14
- /spec/examples.txt
15
- /test/tmp/
16
- /test/version_tmp/
17
- /tmp/
18
- /Makefile
19
- /mkmf.log
20
-
21
- # Used by dotenv library to load environment variables.
22
- # .env
23
-
24
- ## Specific to RubyMotion:
25
- .dat*
26
- .repl_history
27
- build/
28
- *.bridgesupport
29
- build-iPhoneOS/
30
- build-iPhoneSimulator/
31
-
32
- ## Specific to RubyMotion (use of CocoaPods):
33
- #
34
- # We recommend against adding the Pods directory to your .gitignore. However
35
- # you should judge for yourself, the pros and cons are mentioned at:
36
- # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
37
- #
38
- # vendor/Pods/
39
-
40
- ## Documentation cache and generated files:
41
- /.yardoc/
42
- /_yardoc/
43
- /doc/
44
- /rdoc/
45
-
46
- ## Environment normalization:
47
- /.bundle/
48
- /vendor/bundle
49
- /lib/bundler/man/
50
-
51
- # for a library or gem, you might want to ignore these files since the code is
52
- # intended to run in multiple environments; otherwise, check them in:
53
- Gemfile.lock
54
- .ruby-version
55
- .ruby-gemset
56
-
57
- # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
58
- .rvmrc
59
-
60
-
61
- ### OSX ###
62
- *.DS_Store
63
- .AppleDouble
64
- .LSOverride
65
-
66
- # Icon must end with two \r
67
- Icon
68
-
69
- # Thumbnails
70
- ._*
71
-
72
- # Files that might appear in the root of a volume
73
- .DocumentRevisions-V100
74
- .fseventsd
75
- .Spotlight-V100
76
- .TemporaryItems
77
- .Trashes
78
- .VolumeIcon.icns
79
- .com.apple.timemachine.donotpresent
80
-
81
- # Directories potentially created on remote AFP share
82
- .AppleDB
83
- .AppleDesktop
84
- Network Trash Folder
85
- Temporary Items
86
- .apdisk
87
-
88
-
89
- ### Vim ###
90
- # swap
91
- [._]*.s[a-w][a-z]
92
- [._]s[a-w][a-z]
93
- # session
94
- Session.vim
95
- # temporary
96
- .netrwhist
97
- *~
98
- # auto-generated tag files
99
- tags
data/Gemfile DELETED
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- # Specify your gem's dependencies in termios.gemspec
6
- gemspec
7
-
8
- gem 'rake', '~> 13.0'
9
-
10
- gem 'rake-compiler'
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'bundler/setup'
4
- require 'termios'
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require 'pry'
11
- # Pry.start
12
-
13
- require 'irb'
14
- IRB.start
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
data/ruby-termios.gemspec DELETED
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'lib/termios/version'
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = 'ruby-termios'
7
- spec.version = Termios::VERSION
8
- spec.authors = ['akira yamada']
9
- spec.email = ['akira@arika.org']
10
-
11
- spec.summary = 'a simple wrapper of termios(3)'
12
- spec.description = <<-E
13
- Termios module is simple wrapper of termios(3).
14
- It can be included into IO-family classes and can extend IO-family objects.
15
- In addition, the methods can use as module function.
16
- E
17
- spec.homepage = 'https://github.com/arika/ruby-termios'
18
- spec.license = "Ruby's"
19
- spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
20
-
21
- spec.metadata['homepage_uri'] = spec.homepage
22
- spec.metadata['source_code_ri'] = spec.homepage
23
- spec.metadata['bug_tracker_uri'] = spec.homepage + '/issues'
24
-
25
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
27
- end
28
- spec.bindir = 'exe'
29
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
- spec.require_paths = ['lib']
31
- spec.extensions = ['ext/extconf.rb']
32
- end