script_core 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (191) hide show
  1. checksums.yaml +4 -4
  2. data/ext/enterprise_script_service/libseccomp/.travis.yml +21 -7
  3. data/ext/enterprise_script_service/libseccomp/CHANGELOG +22 -0
  4. data/ext/enterprise_script_service/libseccomp/CONTRIBUTING.md +37 -26
  5. data/ext/enterprise_script_service/libseccomp/CREDITS +8 -0
  6. data/ext/enterprise_script_service/libseccomp/README.md +3 -1
  7. data/ext/enterprise_script_service/libseccomp/configure.ac +13 -8
  8. data/ext/enterprise_script_service/libseccomp/doc/Makefile.am +6 -0
  9. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_api_get.3 +12 -2
  10. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_arch_add.3 +38 -6
  11. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_attr_set.3 +53 -2
  12. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_export_bpf.3 +20 -2
  13. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_init.3 +9 -2
  14. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_load.3 +32 -2
  15. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_merge.3 +16 -2
  16. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_alloc.3 +113 -0
  17. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_fd.3 +1 -0
  18. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_free.3 +1 -0
  19. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_id_valid.3 +1 -0
  20. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_receive.3 +1 -0
  21. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_respond.3 +1 -0
  22. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_rule_add.3 +64 -3
  23. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_syscall_priority.3 +18 -3
  24. data/ext/enterprise_script_service/libseccomp/include/seccomp-syscalls.h +12 -0
  25. data/ext/enterprise_script_service/libseccomp/include/seccomp.h.in +116 -0
  26. data/ext/enterprise_script_service/libseccomp/src/.gitignore +2 -0
  27. data/ext/enterprise_script_service/libseccomp/src/Makefile.am +31 -17
  28. data/ext/enterprise_script_service/libseccomp/src/api.c +254 -58
  29. data/ext/enterprise_script_service/libseccomp/src/arch-aarch64.h +1 -9
  30. data/ext/enterprise_script_service/libseccomp/src/arch-arm.c +47 -2
  31. data/ext/enterprise_script_service/libseccomp/src/arch-arm.h +1 -9
  32. data/ext/enterprise_script_service/libseccomp/src/arch-gperf-generate +40 -0
  33. data/ext/enterprise_script_service/libseccomp/src/arch-mips.c +41 -4
  34. data/ext/enterprise_script_service/libseccomp/src/arch-mips.h +2 -10
  35. data/ext/enterprise_script_service/libseccomp/src/arch-mips64.c +41 -4
  36. data/ext/enterprise_script_service/libseccomp/src/arch-mips64.h +3 -11
  37. data/ext/enterprise_script_service/libseccomp/src/arch-mips64n32.c +41 -4
  38. data/ext/enterprise_script_service/libseccomp/src/arch-mips64n32.h +2 -10
  39. data/ext/enterprise_script_service/libseccomp/src/arch-parisc.h +1 -10
  40. data/ext/enterprise_script_service/libseccomp/src/arch-parisc64.c +3 -3
  41. data/ext/enterprise_script_service/libseccomp/src/arch-parisc64.h +29 -0
  42. data/ext/enterprise_script_service/libseccomp/src/arch-ppc.h +1 -9
  43. data/ext/enterprise_script_service/libseccomp/src/arch-ppc64.c +606 -8
  44. data/ext/enterprise_script_service/libseccomp/src/arch-ppc64.h +2 -10
  45. data/ext/enterprise_script_service/libseccomp/src/arch-riscv64.c +31 -0
  46. data/ext/enterprise_script_service/libseccomp/src/arch-riscv64.h +22 -0
  47. data/ext/enterprise_script_service/libseccomp/src/arch-s390.c +171 -12
  48. data/ext/enterprise_script_service/libseccomp/src/arch-s390.h +1 -17
  49. data/ext/enterprise_script_service/libseccomp/src/arch-s390x.c +166 -10
  50. data/ext/enterprise_script_service/libseccomp/src/arch-s390x.h +1 -20
  51. data/ext/enterprise_script_service/libseccomp/src/arch-syscall-dump.c +8 -1
  52. data/ext/enterprise_script_service/libseccomp/src/arch-syscall-validate +359 -143
  53. data/ext/enterprise_script_service/libseccomp/src/arch-x32.c +36 -2
  54. data/ext/enterprise_script_service/libseccomp/src/arch-x32.h +2 -10
  55. data/ext/enterprise_script_service/libseccomp/src/arch-x86.c +172 -10
  56. data/ext/enterprise_script_service/libseccomp/src/arch-x86.h +1 -14
  57. data/ext/enterprise_script_service/libseccomp/src/arch-x86_64.h +1 -9
  58. data/ext/enterprise_script_service/libseccomp/src/arch.c +11 -3
  59. data/ext/enterprise_script_service/libseccomp/src/arch.h +7 -0
  60. data/ext/enterprise_script_service/libseccomp/src/db.c +268 -57
  61. data/ext/enterprise_script_service/libseccomp/src/db.h +16 -2
  62. data/ext/enterprise_script_service/libseccomp/src/gen_bpf.c +503 -148
  63. data/ext/enterprise_script_service/libseccomp/src/gen_bpf.h +2 -1
  64. data/ext/enterprise_script_service/libseccomp/src/gen_pfc.c +165 -37
  65. data/ext/enterprise_script_service/libseccomp/src/python/libseccomp.pxd +37 -1
  66. data/ext/enterprise_script_service/libseccomp/src/python/seccomp.pyx +295 -5
  67. data/ext/enterprise_script_service/libseccomp/src/syscalls.c +56 -0
  68. data/ext/enterprise_script_service/libseccomp/src/syscalls.csv +470 -0
  69. data/ext/enterprise_script_service/libseccomp/src/syscalls.h +62 -0
  70. data/ext/enterprise_script_service/libseccomp/src/syscalls.perf.template +82 -0
  71. data/ext/enterprise_script_service/libseccomp/src/system.c +196 -16
  72. data/ext/enterprise_script_service/libseccomp/src/system.h +68 -13
  73. data/ext/enterprise_script_service/libseccomp/tests/.gitignore +9 -2
  74. data/ext/enterprise_script_service/libseccomp/tests/06-sim-actions.tests +1 -1
  75. data/ext/enterprise_script_service/libseccomp/tests/11-basic-basic_errors.c +5 -5
  76. data/ext/enterprise_script_service/libseccomp/tests/13-basic-attrs.c +35 -1
  77. data/ext/enterprise_script_service/libseccomp/tests/13-basic-attrs.py +10 -1
  78. data/ext/enterprise_script_service/libseccomp/tests/15-basic-resolver.c +1 -0
  79. data/ext/enterprise_script_service/libseccomp/tests/16-sim-arch_basic.c +12 -0
  80. data/ext/enterprise_script_service/libseccomp/tests/16-sim-arch_basic.py +1 -0
  81. data/ext/enterprise_script_service/libseccomp/tests/{18-sim-basic_whitelist.c → 18-sim-basic_allowlist.c} +0 -0
  82. data/ext/enterprise_script_service/libseccomp/tests/{18-sim-basic_whitelist.py → 18-sim-basic_allowlist.py} +0 -0
  83. data/ext/enterprise_script_service/libseccomp/tests/18-sim-basic_allowlist.tests +32 -0
  84. data/ext/enterprise_script_service/libseccomp/tests/23-sim-arch_all_le_basic.c +3 -0
  85. data/ext/enterprise_script_service/libseccomp/tests/23-sim-arch_all_le_basic.py +1 -0
  86. data/ext/enterprise_script_service/libseccomp/tests/30-sim-socket_syscalls.c +3 -0
  87. data/ext/enterprise_script_service/libseccomp/tests/30-sim-socket_syscalls.py +1 -0
  88. data/ext/enterprise_script_service/libseccomp/tests/30-sim-socket_syscalls.tests +33 -17
  89. data/ext/enterprise_script_service/libseccomp/tests/{34-sim-basic_blacklist.c → 34-sim-basic_denylist.c} +0 -0
  90. data/ext/enterprise_script_service/libseccomp/tests/{34-sim-basic_blacklist.py → 34-sim-basic_denylist.py} +0 -0
  91. data/ext/enterprise_script_service/libseccomp/tests/34-sim-basic_denylist.tests +32 -0
  92. data/ext/enterprise_script_service/libseccomp/tests/36-sim-ipc_syscalls.c +3 -0
  93. data/ext/enterprise_script_service/libseccomp/tests/36-sim-ipc_syscalls.py +1 -0
  94. data/ext/enterprise_script_service/libseccomp/tests/36-sim-ipc_syscalls.tests +25 -25
  95. data/ext/enterprise_script_service/libseccomp/tests/39-basic-api_level.c +24 -3
  96. data/ext/enterprise_script_service/libseccomp/tests/39-basic-api_level.py +16 -1
  97. data/ext/enterprise_script_service/libseccomp/tests/47-live-kill_process.c +3 -3
  98. data/ext/enterprise_script_service/libseccomp/tests/51-live-user_notification.c +112 -0
  99. data/ext/enterprise_script_service/libseccomp/tests/51-live-user_notification.py +60 -0
  100. data/ext/enterprise_script_service/libseccomp/tests/51-live-user_notification.tests +11 -0
  101. data/ext/enterprise_script_service/libseccomp/tests/53-sim-binary_tree.c +156 -0
  102. data/ext/enterprise_script_service/libseccomp/tests/53-sim-binary_tree.py +95 -0
  103. data/ext/enterprise_script_service/libseccomp/tests/53-sim-binary_tree.tests +65 -0
  104. data/ext/enterprise_script_service/libseccomp/tests/54-live-binary_tree.c +128 -0
  105. data/ext/enterprise_script_service/libseccomp/tests/54-live-binary_tree.py +95 -0
  106. data/ext/enterprise_script_service/libseccomp/tests/54-live-binary_tree.tests +11 -0
  107. data/ext/enterprise_script_service/libseccomp/tests/55-basic-pfc_binary_tree.c +134 -0
  108. data/ext/enterprise_script_service/libseccomp/tests/55-basic-pfc_binary_tree.sh +46 -0
  109. data/ext/enterprise_script_service/libseccomp/tests/55-basic-pfc_binary_tree.tests +11 -0
  110. data/ext/enterprise_script_service/libseccomp/tests/56-basic-iterate_syscalls.c +90 -0
  111. data/ext/enterprise_script_service/libseccomp/tests/56-basic-iterate_syscalls.py +65 -0
  112. data/ext/enterprise_script_service/libseccomp/tests/56-basic-iterate_syscalls.tests +11 -0
  113. data/ext/enterprise_script_service/libseccomp/tests/57-basic-rawsysrc.c +64 -0
  114. data/ext/enterprise_script_service/libseccomp/tests/57-basic-rawsysrc.py +46 -0
  115. data/ext/enterprise_script_service/libseccomp/tests/57-basic-rawsysrc.tests +11 -0
  116. data/ext/enterprise_script_service/libseccomp/tests/58-live-tsync_notify.c +116 -0
  117. data/ext/enterprise_script_service/libseccomp/tests/58-live-tsync_notify.py +61 -0
  118. data/ext/enterprise_script_service/libseccomp/tests/58-live-tsync_notify.tests +11 -0
  119. data/ext/enterprise_script_service/libseccomp/tests/Makefile.am +31 -10
  120. data/ext/enterprise_script_service/libseccomp/tests/regression +6 -3
  121. data/ext/enterprise_script_service/libseccomp/tests/util.c +3 -3
  122. data/ext/enterprise_script_service/libseccomp/tools/check-syntax +1 -1
  123. data/ext/enterprise_script_service/libseccomp/tools/scmp_arch_detect.c +3 -0
  124. data/ext/enterprise_script_service/libseccomp/tools/scmp_bpf_disasm.c +4 -2
  125. data/ext/enterprise_script_service/libseccomp/tools/scmp_bpf_sim.c +2 -0
  126. data/ext/enterprise_script_service/libseccomp/tools/util.c +14 -12
  127. data/ext/enterprise_script_service/libseccomp/tools/util.h +7 -0
  128. data/ext/enterprise_script_service/mruby/.github/workflows/codeql-analysis.yml +51 -0
  129. data/ext/enterprise_script_service/mruby/Doxyfile +1 -1
  130. data/ext/enterprise_script_service/mruby/README.md +1 -1
  131. data/ext/enterprise_script_service/mruby/doc/guides/debugger.md +1 -1
  132. data/ext/enterprise_script_service/mruby/doc/limitations.md +10 -10
  133. data/ext/enterprise_script_service/mruby/include/mruby.h +13 -0
  134. data/ext/enterprise_script_service/mruby/include/mruby/boxing_word.h +0 -1
  135. data/ext/enterprise_script_service/mruby/include/mruby/proc.h +13 -8
  136. data/ext/enterprise_script_service/mruby/include/mruby/value.h +25 -29
  137. data/ext/enterprise_script_service/mruby/include/mruby/version.h +3 -3
  138. data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/src/array.c +5 -8
  139. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c +2 -2
  140. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c +17 -10
  141. data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/mrblib/complex.rb +1 -1
  142. data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/src/complex.c +1 -2
  143. data/ext/enterprise_script_service/mruby/mrbgems/mruby-eval/src/eval.c +1 -1
  144. data/ext/enterprise_script_service/mruby/mrbgems/mruby-fiber/src/fiber.c +1 -2
  145. data/ext/enterprise_script_service/mruby/mrbgems/mruby-inline-struct/test/inline.c +3 -4
  146. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/file.c +1 -2
  147. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/file_test.c +9 -26
  148. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/io.c +1 -2
  149. data/ext/enterprise_script_service/mruby/mrbgems/mruby-kernel-ext/src/kernel.c +6 -8
  150. data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/src/method.c +3 -4
  151. data/ext/enterprise_script_service/mruby/mrbgems/mruby-objectspace/src/mruby_objectspace.c +0 -1
  152. data/ext/enterprise_script_service/mruby/mrbgems/mruby-print/src/print.c +1 -2
  153. data/ext/enterprise_script_service/mruby/mrbgems/mruby-range-ext/src/range.c +1 -3
  154. data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/mrblib/rational.rb +1 -3
  155. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sprintf/src/sprintf.c +3 -3
  156. data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/src/string.c +1 -2
  157. data/ext/enterprise_script_service/mruby/mrbgems/mruby-struct/src/struct.c +5 -11
  158. data/ext/enterprise_script_service/mruby/mrbgems/mruby-time/src/time.c +5 -10
  159. data/ext/enterprise_script_service/mruby/mrblib/00class.rb +10 -0
  160. data/ext/enterprise_script_service/mruby/src/array.c +14 -11
  161. data/ext/enterprise_script_service/mruby/src/class.c +22 -21
  162. data/ext/enterprise_script_service/mruby/src/error.c +1 -2
  163. data/ext/enterprise_script_service/mruby/src/etc.c +0 -1
  164. data/ext/enterprise_script_service/mruby/src/gc.c +5 -5
  165. data/ext/enterprise_script_service/mruby/src/hash.c +8 -15
  166. data/ext/enterprise_script_service/mruby/src/kernel.c +4 -7
  167. data/ext/enterprise_script_service/mruby/src/numeric.c +28 -60
  168. data/ext/enterprise_script_service/mruby/src/object.c +11 -1
  169. data/ext/enterprise_script_service/mruby/src/proc.c +7 -8
  170. data/ext/enterprise_script_service/mruby/src/range.c +4 -12
  171. data/ext/enterprise_script_service/mruby/src/string.c +24 -21
  172. data/ext/enterprise_script_service/mruby/src/symbol.c +1 -2
  173. data/ext/enterprise_script_service/mruby/src/vm.c +28 -24
  174. data/ext/enterprise_script_service/mruby/test/t/kernel.rb +7 -0
  175. data/lib/script_core/version.rb +1 -1
  176. metadata +45 -21
  177. data/ext/enterprise_script_service/libseccomp/src/arch-aarch64-syscalls.c +0 -559
  178. data/ext/enterprise_script_service/libseccomp/src/arch-arm-syscalls.c +0 -570
  179. data/ext/enterprise_script_service/libseccomp/src/arch-mips-syscalls.c +0 -562
  180. data/ext/enterprise_script_service/libseccomp/src/arch-mips64-syscalls.c +0 -562
  181. data/ext/enterprise_script_service/libseccomp/src/arch-mips64n32-syscalls.c +0 -562
  182. data/ext/enterprise_script_service/libseccomp/src/arch-parisc-syscalls.c +0 -542
  183. data/ext/enterprise_script_service/libseccomp/src/arch-ppc-syscalls.c +0 -559
  184. data/ext/enterprise_script_service/libseccomp/src/arch-ppc64-syscalls.c +0 -559
  185. data/ext/enterprise_script_service/libseccomp/src/arch-s390-syscalls.c +0 -642
  186. data/ext/enterprise_script_service/libseccomp/src/arch-s390x-syscalls.c +0 -642
  187. data/ext/enterprise_script_service/libseccomp/src/arch-x32-syscalls.c +0 -558
  188. data/ext/enterprise_script_service/libseccomp/src/arch-x86-syscalls.c +0 -692
  189. data/ext/enterprise_script_service/libseccomp/src/arch-x86_64-syscalls.c +0 -559
  190. data/ext/enterprise_script_service/libseccomp/tests/18-sim-basic_whitelist.tests +0 -32
  191. data/ext/enterprise_script_service/libseccomp/tests/34-sim-basic_blacklist.tests +0 -32
@@ -599,13 +599,12 @@ mrb_dup(mrb_state *mrb, int fd, mrb_bool *failed)
599
599
  static mrb_value
600
600
  mrb_io_initialize_copy(mrb_state *mrb, mrb_value copy)
601
601
  {
602
- mrb_value orig;
602
+ mrb_value orig = mrb_get_arg1(mrb);
603
603
  mrb_value buf;
604
604
  struct mrb_io *fptr_copy;
605
605
  struct mrb_io *fptr_orig;
606
606
  mrb_bool failed = TRUE;
607
607
 
608
- mrb_get_args(mrb, "o", &orig);
609
608
  fptr_orig = io_get_open_fptr(mrb, orig);
610
609
  fptr_copy = (struct mrb_io *)DATA_PTR(copy);
611
610
  if (fptr_orig == fptr_copy) return copy;
@@ -128,9 +128,8 @@ mrb_f_integer(mrb_state *mrb, mrb_value self)
128
128
  static mrb_value
129
129
  mrb_f_float(mrb_state *mrb, mrb_value self)
130
130
  {
131
- mrb_value arg;
131
+ mrb_value arg = mrb_get_arg1(mrb);
132
132
 
133
- mrb_get_args(mrb, "o", &arg);
134
133
  return mrb_Float(mrb, arg);
135
134
  }
136
135
  #endif
@@ -149,9 +148,9 @@ mrb_f_float(mrb_state *mrb, mrb_value self)
149
148
  static mrb_value
150
149
  mrb_f_string(mrb_state *mrb, mrb_value self)
151
150
  {
152
- mrb_value arg, tmp;
151
+ mrb_value arg = mrb_get_arg1(mrb);
152
+ mrb_value tmp;
153
153
 
154
- mrb_get_args(mrb, "o", &arg);
155
154
  tmp = mrb_convert_type(mrb, arg, MRB_TT_STRING, "String", "to_s");
156
155
  return tmp;
157
156
  }
@@ -168,9 +167,9 @@ mrb_f_string(mrb_state *mrb, mrb_value self)
168
167
  static mrb_value
169
168
  mrb_f_array(mrb_state *mrb, mrb_value self)
170
169
  {
171
- mrb_value arg, tmp;
170
+ mrb_value arg = mrb_get_arg1(mrb);
171
+ mrb_value tmp;
172
172
 
173
- mrb_get_args(mrb, "o", &arg);
174
173
  tmp = mrb_check_convert_type(mrb, arg, MRB_TT_ARRAY, "Array", "to_a");
175
174
  if (mrb_nil_p(tmp)) {
176
175
  return mrb_ary_new_from_values(mrb, 1, &arg);
@@ -196,9 +195,8 @@ mrb_f_array(mrb_state *mrb, mrb_value self)
196
195
  static mrb_value
197
196
  mrb_f_hash(mrb_state *mrb, mrb_value self)
198
197
  {
199
- mrb_value arg;
198
+ mrb_value arg = mrb_get_arg1(mrb);
200
199
 
201
- mrb_get_args(mrb, "o", &arg);
202
200
  if (mrb_nil_p(arg) || (mrb_array_p(arg) && RARRAY_LEN(arg) == 0)) {
203
201
  return mrb_hash_new(mrb);
204
202
  }
@@ -33,9 +33,8 @@ unbound_method_bind(mrb_state *mrb, mrb_value self)
33
33
  mrb_value name = mrb_iv_get(mrb, self, mrb_intern_lit(mrb, "_name"));
34
34
  mrb_value proc = mrb_iv_get(mrb, self, mrb_intern_lit(mrb, "_proc"));
35
35
  mrb_value klass = mrb_iv_get(mrb, self, mrb_intern_lit(mrb, "_klass"));
36
- mrb_value recv;
36
+ mrb_value recv = mrb_get_arg1(mrb);
37
37
 
38
- mrb_get_args(mrb, "o", &recv);
39
38
  bind_check(mrb, recv, owner);
40
39
  me = method_object_alloc(mrb, mrb_class_get(mrb, "Method"));
41
40
  mrb_obj_iv_set(mrb, me, mrb_intern_lit(mrb, "_owner"), owner);
@@ -51,11 +50,11 @@ unbound_method_bind(mrb_state *mrb, mrb_value self)
51
50
  static mrb_value
52
51
  method_eql(mrb_state *mrb, mrb_value self)
53
52
  {
54
- mrb_value other, receiver, orig_proc, other_proc;
53
+ mrb_value other = mrb_get_arg1(mrb);
54
+ mrb_value receiver, orig_proc, other_proc;
55
55
  struct RClass *owner, *klass;
56
56
  struct RProc *orig_rproc, *other_rproc;
57
57
 
58
- mrb_get_args(mrb, "o", &other);
59
58
  if (!mrb_obj_is_instance_of(mrb, other, mrb_class(mrb, self)))
60
59
  return mrb_false_value();
61
60
 
@@ -89,7 +89,6 @@ os_count_objects(mrb_state *mrb, mrb_value self)
89
89
  COUNT_TYPE(T_STRING);
90
90
  COUNT_TYPE(T_RANGE);
91
91
  COUNT_TYPE(T_EXCEPTION);
92
- COUNT_TYPE(T_FILE);
93
92
  COUNT_TYPE(T_ENV);
94
93
  COUNT_TYPE(T_DATA);
95
94
  COUNT_TYPE(T_FIBER);
@@ -45,9 +45,8 @@ printstr(mrb_state *mrb, mrb_value obj)
45
45
  mrb_value
46
46
  mrb_printstr(mrb_state *mrb, mrb_value self)
47
47
  {
48
- mrb_value argv;
48
+ mrb_value argv = mrb_get_arg1(mrb);
49
49
 
50
- mrb_get_args(mrb, "o", &argv);
51
50
  printstr(mrb, argv);
52
51
 
53
52
  return argv;
@@ -34,12 +34,10 @@ r_lt(mrb_state *mrb, mrb_value a, mrb_value b)
34
34
  static mrb_value
35
35
  range_cover(mrb_state *mrb, mrb_value range)
36
36
  {
37
- mrb_value val;
38
37
  struct RRange *r = mrb_range_ptr(mrb, range);
38
+ mrb_value val = mrb_get_arg1(mrb);
39
39
  mrb_value beg, end;
40
40
 
41
- mrb_get_args(mrb, "o", &val);
42
-
43
41
  beg = RANGE_BEG(r);
44
42
  end = RANGE_END(r);
45
43
 
@@ -91,8 +91,8 @@ def Rational(numerator, denominator = 1)
91
91
  end
92
92
 
93
93
  [:+, :-, :*, :/, :<=>, :==, :<, :<=, :>, :>=].each do |op|
94
+ original_operator_name = :"__original_operator_#{op}_rational"
94
95
  Fixnum.instance_eval do
95
- original_operator_name = "__original_operator_#{op}_rational"
96
96
  alias_method original_operator_name, op
97
97
  define_method op do |rhs|
98
98
  if rhs.is_a? Rational
@@ -103,7 +103,6 @@ def Rational(numerator, denominator = 1)
103
103
  end
104
104
  end
105
105
  Float.instance_eval do
106
- original_operator_name = "__original_operator_#{op}_rational"
107
106
  alias_method original_operator_name, op
108
107
  define_method op do |rhs|
109
108
  if rhs.is_a? Rational
@@ -114,4 +113,3 @@ def Rational(numerator, denominator = 1)
114
113
  end if Object.const_defined?(:Float)
115
114
  end
116
115
  end
117
-
@@ -842,7 +842,7 @@ retry:
842
842
  case 'B':
843
843
  case 'u': {
844
844
  mrb_value val = GETARG();
845
- char nbuf[68], *s;
845
+ char nbuf[69], *s;
846
846
  const char *prefix = NULL;
847
847
  int sign = 0, dots = 0;
848
848
  char sc = 0;
@@ -914,7 +914,7 @@ retry:
914
914
  width--;
915
915
  }
916
916
  mrb_assert(base == 10);
917
- mrb_int2str(nbuf, sizeof(nbuf), v);
917
+ mrb_int2str(nbuf, sizeof(nbuf)-1, v);
918
918
  s = nbuf;
919
919
  if (v < 0) s++; /* skip minus sign */
920
920
  }
@@ -927,7 +927,7 @@ retry:
927
927
  else {
928
928
  val = mrb_fixnum_to_str(mrb, mrb_fixnum_value(v), base);
929
929
  }
930
- strncpy(++s, RSTRING_PTR(val), sizeof(nbuf)-1);
930
+ strncpy(++s, RSTRING_PTR(val), sizeof(nbuf)-2);
931
931
  if (v < 0) {
932
932
  char d;
933
933
 
@@ -164,9 +164,8 @@ mrb_str_swapcase(mrb_state *mrb, mrb_value self)
164
164
  static mrb_value
165
165
  mrb_str_concat_m(mrb_state *mrb, mrb_value self)
166
166
  {
167
- mrb_value str;
167
+ mrb_value str = mrb_get_arg1(mrb);
168
168
 
169
- mrb_get_args(mrb, "o", &str);
170
169
  if (mrb_fixnum_p(str) || mrb_float_p(str))
171
170
  #ifdef MRB_UTF8_STRING
172
171
  str = int_chr_utf8(mrb, str);
@@ -154,9 +154,8 @@ mrb_struct_set_m(mrb_state *mrb, mrb_value obj)
154
154
  {
155
155
  mrb_int i = mrb_fixnum(mrb_proc_cfunc_env_get(mrb, 0));
156
156
  mrb_value *ptr;
157
- mrb_value val;
157
+ mrb_value val = mrb_get_arg1(mrb);
158
158
 
159
- mrb_get_args(mrb, "o", &val);
160
159
  mrb_struct_modify(mrb, obj);
161
160
  ptr = RSTRUCT_PTR(obj);
162
161
  if (ptr == NULL || i >= RSTRUCT_LEN(obj)) {
@@ -356,9 +355,7 @@ mrb_struct_initialize(mrb_state *mrb, mrb_value self)
356
355
  static mrb_value
357
356
  mrb_struct_init_copy(mrb_state *mrb, mrb_value copy)
358
357
  {
359
- mrb_value s;
360
-
361
- mrb_get_args(mrb, "o", &s);
358
+ mrb_value s = mrb_get_arg1(mrb);
362
359
 
363
360
  if (mrb_obj_equal(mrb, copy, s)) return copy;
364
361
  if (!mrb_obj_is_instance_of(mrb, s, mrb_obj_class(mrb, copy))) {
@@ -428,9 +425,8 @@ struct_aref_int(mrb_state *mrb, mrb_value s, mrb_int i)
428
425
  static mrb_value
429
426
  mrb_struct_aref(mrb_state *mrb, mrb_value s)
430
427
  {
431
- mrb_value idx;
428
+ mrb_value idx = mrb_get_arg1(mrb);
432
429
 
433
- mrb_get_args(mrb, "o", &idx);
434
430
  if (mrb_string_p(idx)) {
435
431
  mrb_value sym = mrb_check_intern_str(mrb, idx);
436
432
 
@@ -545,11 +541,10 @@ mrb_struct_aset(mrb_state *mrb, mrb_value s)
545
541
  static mrb_value
546
542
  mrb_struct_equal(mrb_state *mrb, mrb_value s)
547
543
  {
548
- mrb_value s2;
544
+ mrb_value s2 = mrb_get_arg1(mrb);
549
545
  mrb_value *ptr, *ptr2;
550
546
  mrb_int i, len;
551
547
 
552
- mrb_get_args(mrb, "o", &s2);
553
548
  if (mrb_obj_equal(mrb, s, s2)) {
554
549
  return mrb_true_value();
555
550
  }
@@ -582,11 +577,10 @@ mrb_struct_equal(mrb_state *mrb, mrb_value s)
582
577
  static mrb_value
583
578
  mrb_struct_eql(mrb_state *mrb, mrb_value s)
584
579
  {
585
- mrb_value s2;
580
+ mrb_value s2 = mrb_get_arg1(mrb);
586
581
  mrb_value *ptr, *ptr2;
587
582
  mrb_int i, len;
588
583
 
589
- mrb_get_args(mrb, "o", &s2);
590
584
  if (mrb_obj_equal(mrb, s, s2)) {
591
585
  return mrb_true_value();
592
586
  }
@@ -515,11 +515,10 @@ time_get_ptr(mrb_state *mrb, mrb_value time)
515
515
  static mrb_value
516
516
  mrb_time_eq(mrb_state *mrb, mrb_value self)
517
517
  {
518
- mrb_value other;
518
+ mrb_value other = mrb_get_arg1(mrb);
519
519
  struct mrb_time *tm1, *tm2;
520
520
  mrb_bool eq_p;
521
521
 
522
- mrb_get_args(mrb, "o", &other);
523
522
  tm1 = DATA_GET_PTR(mrb, self, &mrb_time_type, struct mrb_time);
524
523
  tm2 = DATA_CHECK_GET_PTR(mrb, other, &mrb_time_type, struct mrb_time);
525
524
  eq_p = tm1 && tm2 && tm1->sec == tm2->sec && tm1->usec == tm2->usec;
@@ -530,10 +529,9 @@ mrb_time_eq(mrb_state *mrb, mrb_value self)
530
529
  static mrb_value
531
530
  mrb_time_cmp(mrb_state *mrb, mrb_value self)
532
531
  {
533
- mrb_value other;
532
+ mrb_value other = mrb_get_arg1(mrb);
534
533
  struct mrb_time *tm1, *tm2;
535
534
 
536
- mrb_get_args(mrb, "o", &other);
537
535
  tm1 = DATA_GET_PTR(mrb, self, &mrb_time_type, struct mrb_time);
538
536
  tm2 = DATA_CHECK_GET_PTR(mrb, other, &mrb_time_type, struct mrb_time);
539
537
  if (!tm1 || !tm2) return mrb_nil_value();
@@ -556,11 +554,10 @@ mrb_time_cmp(mrb_state *mrb, mrb_value self)
556
554
  static mrb_value
557
555
  mrb_time_plus(mrb_state *mrb, mrb_value self)
558
556
  {
559
- mrb_value o;
557
+ mrb_value o = mrb_get_arg1(mrb);
560
558
  struct mrb_time *tm;
561
559
  time_t sec, usec;
562
560
 
563
- mrb_get_args(mrb, "o", &o);
564
561
  tm = time_get_ptr(mrb, self);
565
562
  sec = mrb_to_time_t(mrb, o, &usec);
566
563
  return mrb_time_make_time(mrb, mrb_obj_class(mrb, self), tm->sec+sec, tm->usec+usec, tm->timezone);
@@ -569,10 +566,9 @@ mrb_time_plus(mrb_state *mrb, mrb_value self)
569
566
  static mrb_value
570
567
  mrb_time_minus(mrb_state *mrb, mrb_value self)
571
568
  {
572
- mrb_value other;
569
+ mrb_value other = mrb_get_arg1(mrb);
573
570
  struct mrb_time *tm, *tm2;
574
571
 
575
- mrb_get_args(mrb, "o", &other);
576
572
  tm = time_get_ptr(mrb, self);
577
573
  tm2 = DATA_CHECK_GET_PTR(mrb, other, &mrb_time_type, struct mrb_time);
578
574
  if (tm2) {
@@ -770,10 +766,9 @@ mrb_time_initialize(mrb_state *mrb, mrb_value self)
770
766
  static mrb_value
771
767
  mrb_time_initialize_copy(mrb_state *mrb, mrb_value copy)
772
768
  {
773
- mrb_value src;
769
+ mrb_value src = mrb_get_arg1(mrb);
774
770
  struct mrb_time *t1, *t2;
775
771
 
776
- mrb_get_args(mrb, "o", &src);
777
772
  if (mrb_obj_equal(mrb, copy, src)) return copy;
778
773
  if (!mrb_obj_is_instance_of(mrb, src, mrb_obj_class(mrb, copy))) {
779
774
  mrb_raise(mrb, E_TYPE_ERROR, "wrong argument class");
@@ -1,3 +1,13 @@
1
+ class BasicObject
2
+ def !=(other)
3
+ if self == other
4
+ false
5
+ else
6
+ true
7
+ end
8
+ end
9
+ end
10
+
1
11
  class Module
2
12
  # 15.2.2.4.12
3
13
  def attr_accessor(*names)
@@ -866,10 +866,12 @@ static mrb_value
866
866
  mrb_ary_aget(mrb_state *mrb, mrb_value self)
867
867
  {
868
868
  struct RArray *a = mrb_ary_ptr(self);
869
- mrb_int i, len, alen;
869
+ mrb_int i;
870
+ mrb_int len, alen;
870
871
  mrb_value index;
871
872
 
872
- if (mrb_get_args(mrb, "o|i", &index, &len) == 1) {
873
+ if (mrb_get_argc(mrb) == 1) {
874
+ index = mrb_get_arg1(mrb);
873
875
  switch (mrb_type(index)) {
874
876
  /* a[n..m] */
875
877
  case MRB_TT_RANGE:
@@ -886,6 +888,7 @@ mrb_ary_aget(mrb_state *mrb, mrb_value self)
886
888
  }
887
889
  }
888
890
 
891
+ mrb_get_args(mrb, "oi", &index, &len);
889
892
  i = aget_index(mrb, index);
890
893
  alen = ARY_LEN(a);
891
894
  if (i < 0) i += alen;
@@ -939,7 +942,10 @@ mrb_ary_aset(mrb_state *mrb, mrb_value self)
939
942
  mrb_int i, len;
940
943
 
941
944
  mrb_ary_modify(mrb, mrb_ary_ptr(self));
942
- if (mrb_get_args(mrb, "oo|o", &v1, &v2, &v3) == 2) {
945
+ if (mrb_get_argc(mrb) == 2) {
946
+ mrb_value *vs = mrb_get_argv(mrb);
947
+ v1 = vs[0]; v2 = vs[1];
948
+
943
949
  /* a[n..m] = v */
944
950
  switch (mrb_range_beg_len(mrb, v1, &i, &len, RARRAY_LEN(self), FALSE)) {
945
951
  case MRB_RANGE_TYPE_MISMATCH:
@@ -955,6 +961,7 @@ mrb_ary_aset(mrb_state *mrb, mrb_value self)
955
961
  return v2;
956
962
  }
957
963
 
964
+ mrb_get_args(mrb, "ooo", &v1, &v2, &v3);
958
965
  /* a[n,m] = v */
959
966
  mrb_ary_splice(mrb, self, aget_index(mrb, v1), aget_index(mrb, v2), v3);
960
967
  return v3;
@@ -1038,10 +1045,9 @@ mrb_ary_last(mrb_state *mrb, mrb_value self)
1038
1045
  static mrb_value
1039
1046
  mrb_ary_index_m(mrb_state *mrb, mrb_value self)
1040
1047
  {
1041
- mrb_value obj;
1048
+ mrb_value obj = mrb_get_arg1(mrb);
1042
1049
  mrb_int i;
1043
1050
 
1044
- mrb_get_args(mrb, "o", &obj);
1045
1051
  for (i = 0; i < RARRAY_LEN(self); i++) {
1046
1052
  if (mrb_equal(mrb, RARRAY_PTR(self)[i], obj)) {
1047
1053
  return mrb_fixnum_value(i);
@@ -1053,10 +1059,9 @@ mrb_ary_index_m(mrb_state *mrb, mrb_value self)
1053
1059
  static mrb_value
1054
1060
  mrb_ary_rindex_m(mrb_state *mrb, mrb_value self)
1055
1061
  {
1056
- mrb_value obj;
1062
+ mrb_value obj = mrb_get_arg1(mrb);
1057
1063
  mrb_int i, len;
1058
1064
 
1059
- mrb_get_args(mrb, "o", &obj);
1060
1065
  for (i = RARRAY_LEN(self) - 1; i >= 0; i--) {
1061
1066
  if (mrb_equal(mrb, RARRAY_PTR(self)[i], obj)) {
1062
1067
  return mrb_fixnum_value(i);
@@ -1230,9 +1235,8 @@ mrb_ary_join_m(mrb_state *mrb, mrb_value ary)
1230
1235
  static mrb_value
1231
1236
  mrb_ary_eq(mrb_state *mrb, mrb_value ary1)
1232
1237
  {
1233
- mrb_value ary2;
1238
+ mrb_value ary2 = mrb_get_arg1(mrb);
1234
1239
 
1235
- mrb_get_args(mrb, "o", &ary2);
1236
1240
  if (mrb_obj_equal(mrb, ary1, ary2)) return mrb_true_value();
1237
1241
  if (!mrb_array_p(ary2)) {
1238
1242
  return mrb_false_value();
@@ -1245,9 +1249,8 @@ mrb_ary_eq(mrb_state *mrb, mrb_value ary1)
1245
1249
  static mrb_value
1246
1250
  mrb_ary_cmp(mrb_state *mrb, mrb_value ary1)
1247
1251
  {
1248
- mrb_value ary2;
1252
+ mrb_value ary2 = mrb_get_arg1(mrb);
1249
1253
 
1250
- mrb_get_args(mrb, "o", &ary2);
1251
1254
  if (mrb_obj_equal(mrb, ary1, ary2)) return mrb_fixnum_value(0);
1252
1255
  if (!mrb_array_p(ary2)) {
1253
1256
  return mrb_nil_value();
@@ -549,6 +549,23 @@ mrb_get_argv(mrb_state *mrb)
549
549
  return array_argv;
550
550
  }
551
551
 
552
+ MRB_API mrb_value
553
+ mrb_get_arg1(mrb_state *mrb)
554
+ {
555
+ mrb_int argc = mrb->c->ci->argc;
556
+ mrb_value *array_argv = mrb->c->stack + 1;
557
+ if (argc < 0) {
558
+ struct RArray *a = mrb_ary_ptr(*array_argv);
559
+
560
+ argc = ARY_LEN(a);
561
+ array_argv = ARY_PTR(a);
562
+ }
563
+ if (argc != 1) {
564
+ mrb_raise(mrb, E_ARGUMENT_ERROR, "wrong number of arguments");
565
+ }
566
+ return array_argv[0];
567
+ }
568
+
552
569
  void mrb_hash_check_kdict(mrb_state *mrb, mrb_value self);
553
570
 
554
571
  /*
@@ -1212,10 +1229,9 @@ mrb_mod_ancestors(mrb_state *mrb, mrb_value self)
1212
1229
  static mrb_value
1213
1230
  mrb_mod_extend_object(mrb_state *mrb, mrb_value mod)
1214
1231
  {
1215
- mrb_value obj;
1232
+ mrb_value obj = mrb_get_arg1(mrb);
1216
1233
 
1217
1234
  mrb_check_type(mrb, mod, MRB_TT_MODULE);
1218
- mrb_get_args(mrb, "o", &obj);
1219
1235
  mrb_include_module(mrb, mrb_class_ptr(mrb_singleton_class(mrb, obj)), mrb_class_ptr(mod));
1220
1236
  return mod;
1221
1237
  }
@@ -1493,9 +1509,8 @@ static mrb_value
1493
1509
  attr_writer(mrb_state *mrb, mrb_value obj)
1494
1510
  {
1495
1511
  mrb_value name = mrb_proc_cfunc_env_get(mrb, 0);
1496
- mrb_value val;
1512
+ mrb_value val = mrb_get_arg1(mrb);
1497
1513
 
1498
- mrb_get_args(mrb, "o", &val);
1499
1514
  mrb_iv_set(mrb, obj, to_sym(mrb, name), val);
1500
1515
  return val;
1501
1516
  }
@@ -1663,21 +1678,11 @@ mrb_bob_not(mrb_state *mrb, mrb_value cv)
1663
1678
  mrb_value
1664
1679
  mrb_obj_equal_m(mrb_state *mrb, mrb_value self)
1665
1680
  {
1666
- mrb_value arg;
1681
+ mrb_value arg = mrb_get_arg1(mrb);
1667
1682
 
1668
- mrb_get_args(mrb, "o", &arg);
1669
1683
  return mrb_bool_value(mrb_obj_equal(mrb, self, arg));
1670
1684
  }
1671
1685
 
1672
- static mrb_value
1673
- mrb_obj_not_equal_m(mrb_state *mrb, mrb_value self)
1674
- {
1675
- mrb_value arg;
1676
-
1677
- mrb_get_args(mrb, "o", &arg);
1678
- return mrb_bool_value(!mrb_equal(mrb, self, arg));
1679
- }
1680
-
1681
1686
  MRB_API mrb_bool
1682
1687
  mrb_obj_respond_to(mrb_state *mrb, struct RClass* c, mrb_sym mid)
1683
1688
  {
@@ -1975,13 +1980,11 @@ mrb_const_get_sym(mrb_state *mrb, mrb_value mod, mrb_sym id)
1975
1980
  static mrb_value
1976
1981
  mrb_mod_const_get(mrb_state *mrb, mrb_value mod)
1977
1982
  {
1978
- mrb_value path;
1983
+ mrb_value path = mrb_get_arg1(mrb);
1979
1984
  mrb_sym id;
1980
1985
  char *ptr;
1981
1986
  mrb_int off, end, len;
1982
1987
 
1983
- mrb_get_args(mrb, "o", &path);
1984
-
1985
1988
  if (mrb_symbol_p(path)) {
1986
1989
  /* const get with symbol */
1987
1990
  id = mrb_symbol(path);
@@ -2134,10 +2137,9 @@ top_define_method(mrb_state *mrb, mrb_value self)
2134
2137
  static mrb_value
2135
2138
  mrb_mod_eqq(mrb_state *mrb, mrb_value mod)
2136
2139
  {
2137
- mrb_value obj;
2140
+ mrb_value obj = mrb_get_arg1(mrb);
2138
2141
  mrb_bool eqq;
2139
2142
 
2140
- mrb_get_args(mrb, "o", &obj);
2141
2143
  eqq = mrb_obj_is_kind_of(mrb, obj, mrb_class_ptr(mod));
2142
2144
 
2143
2145
  return mrb_bool_value(eqq);
@@ -2272,7 +2274,6 @@ mrb_init_class(mrb_state *mrb)
2272
2274
  mrb_define_method(mrb, bob, "initialize", mrb_bob_init, MRB_ARGS_NONE());
2273
2275
  mrb_define_method(mrb, bob, "!", mrb_bob_not, MRB_ARGS_NONE());
2274
2276
  mrb_define_method(mrb, bob, "==", mrb_obj_equal_m, MRB_ARGS_REQ(1)); /* 15.3.1.3.1 */
2275
- mrb_define_method(mrb, bob, "!=", mrb_obj_not_equal_m, MRB_ARGS_REQ(1));
2276
2277
  mrb_define_method(mrb, bob, "__id__", mrb_obj_id_m, MRB_ARGS_NONE()); /* 15.3.1.3.4 */
2277
2278
  mrb_define_method(mrb, bob, "__send__", mrb_f_send, MRB_ARGS_REQ(1)|MRB_ARGS_REST()|MRB_ARGS_BLOCK()); /* 15.3.1.3.5 */
2278
2279
  mrb_define_method(mrb, bob, "equal?", mrb_obj_equal_m, MRB_ARGS_REQ(1)); /* 15.3.1.3.11 */