script_core 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (381) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.rubocop.yml +8 -6
  4. data/.ruby-version +1 -1
  5. data/Gemfile +2 -1
  6. data/bin/sandbox +1 -1
  7. data/ext/enterprise_script_service/Rakefile +1 -1
  8. data/ext/enterprise_script_service/flags.rb +5 -0
  9. data/ext/enterprise_script_service/libseccomp/CHANGELOG +15 -0
  10. data/ext/enterprise_script_service/libseccomp/CREDITS +3 -0
  11. data/ext/enterprise_script_service/libseccomp/Makefile.am +1 -1
  12. data/ext/enterprise_script_service/libseccomp/README.md +1 -1
  13. data/ext/enterprise_script_service/libseccomp/SECURITY.md +45 -0
  14. data/ext/enterprise_script_service/libseccomp/configure.ac +3 -3
  15. data/ext/enterprise_script_service/libseccomp/doc/admin/MAINTAINER_PROCESS.md +95 -0
  16. data/ext/enterprise_script_service/libseccomp/{RELEASE_PROCESS.md → doc/admin/RELEASE_PROCESS.md} +9 -1
  17. data/ext/enterprise_script_service/libseccomp/include/Makefile.am +1 -1
  18. data/ext/enterprise_script_service/libseccomp/include/seccomp-syscalls.h +2292 -0
  19. data/ext/enterprise_script_service/libseccomp/include/seccomp.h.in +3 -1065
  20. data/ext/enterprise_script_service/libseccomp/src/arch-aarch64-syscalls.c +35 -3
  21. data/ext/enterprise_script_service/libseccomp/src/arch-arm-syscalls.c +35 -3
  22. data/ext/enterprise_script_service/libseccomp/src/arch-mips-syscalls.c +43 -11
  23. data/ext/enterprise_script_service/libseccomp/src/arch-mips64-syscalls.c +33 -1
  24. data/ext/enterprise_script_service/libseccomp/src/arch-mips64n32-syscalls.c +33 -1
  25. data/ext/enterprise_script_service/libseccomp/src/arch-parisc-syscalls.c +34 -2
  26. data/ext/enterprise_script_service/libseccomp/src/arch-ppc-syscalls.c +43 -11
  27. data/ext/enterprise_script_service/libseccomp/src/arch-ppc64-syscalls.c +44 -12
  28. data/ext/enterprise_script_service/libseccomp/src/arch-s390-syscalls.c +46 -14
  29. data/ext/enterprise_script_service/libseccomp/src/arch-s390.c +142 -18
  30. data/ext/enterprise_script_service/libseccomp/src/arch-s390x-syscalls.c +47 -15
  31. data/ext/enterprise_script_service/libseccomp/src/arch-s390x.c +143 -17
  32. data/ext/enterprise_script_service/libseccomp/src/arch-x32-syscalls.c +33 -1
  33. data/ext/enterprise_script_service/libseccomp/src/arch-x86-syscalls.c +94 -12
  34. data/ext/enterprise_script_service/libseccomp/src/arch-x86.c +142 -19
  35. data/ext/enterprise_script_service/libseccomp/src/arch-x86_64-syscalls.c +33 -1
  36. data/ext/enterprise_script_service/libseccomp/src/db.c +1 -0
  37. data/ext/enterprise_script_service/libseccomp/src/gen_bpf.c +10 -3
  38. data/ext/enterprise_script_service/libseccomp/src/python/Makefile.am +4 -4
  39. data/ext/enterprise_script_service/libseccomp/src/python/seccomp.pyx +2 -0
  40. data/ext/enterprise_script_service/libseccomp/tests/.gitignore +1 -0
  41. data/ext/enterprise_script_service/libseccomp/tests/50-sim-hash_collision.c +98 -0
  42. data/ext/enterprise_script_service/libseccomp/tests/50-sim-hash_collision.py +61 -0
  43. data/ext/enterprise_script_service/libseccomp/tests/50-sim-hash_collision.tests +18 -0
  44. data/ext/enterprise_script_service/libseccomp/tests/Makefile.am +6 -3
  45. data/ext/enterprise_script_service/libseccomp/tools/Makefile.am +0 -2
  46. data/ext/enterprise_script_service/libseccomp/tools/check-syntax +1 -0
  47. data/ext/enterprise_script_service/libseccomp/tools/scmp_bpf_sim.c +2 -0
  48. data/ext/enterprise_script_service/mruby-mpdecimal/src/ext.c +1 -1
  49. data/ext/enterprise_script_service/mruby/.gitignore +2 -2
  50. data/ext/enterprise_script_service/mruby/CONTRIBUTING.md +10 -3
  51. data/ext/enterprise_script_service/mruby/Doxyfile +2408 -0
  52. data/ext/enterprise_script_service/mruby/README.md +21 -8
  53. data/ext/enterprise_script_service/mruby/Rakefile +4 -13
  54. data/ext/enterprise_script_service/mruby/appveyor_config.rb +1 -1
  55. data/ext/enterprise_script_service/mruby/build_config.rb +3 -3
  56. data/ext/enterprise_script_service/mruby/doc/guides/compile.md +42 -42
  57. data/ext/enterprise_script_service/mruby/doc/guides/debugger.md +1 -1
  58. data/ext/enterprise_script_service/mruby/doc/guides/mrbconf.md +45 -6
  59. data/ext/enterprise_script_service/mruby/doc/guides/mrbgems.md +5 -0
  60. data/ext/enterprise_script_service/mruby/doc/limitations.md +88 -38
  61. data/ext/enterprise_script_service/mruby/doc/mruby_logo_red_icon.png +0 -0
  62. data/ext/enterprise_script_service/mruby/doc/opcode.md +94 -94
  63. data/ext/enterprise_script_service/mruby/include/mrbconf.h +74 -11
  64. data/ext/enterprise_script_service/mruby/include/mruby.h +242 -146
  65. data/ext/enterprise_script_service/mruby/include/mruby/array.h +7 -7
  66. data/ext/enterprise_script_service/mruby/include/mruby/boxing_nan.h +2 -9
  67. data/ext/enterprise_script_service/mruby/include/mruby/boxing_no.h +11 -10
  68. data/ext/enterprise_script_service/mruby/include/mruby/boxing_word.h +104 -69
  69. data/ext/enterprise_script_service/mruby/include/mruby/class.h +7 -5
  70. data/ext/enterprise_script_service/mruby/include/mruby/common.h +9 -7
  71. data/ext/enterprise_script_service/mruby/include/mruby/compile.h +6 -6
  72. data/ext/enterprise_script_service/mruby/include/mruby/data.h +5 -5
  73. data/ext/enterprise_script_service/mruby/include/mruby/debug.h +2 -2
  74. data/ext/enterprise_script_service/mruby/include/mruby/dump.h +3 -7
  75. data/ext/enterprise_script_service/mruby/include/mruby/error.h +34 -6
  76. data/ext/enterprise_script_service/mruby/include/mruby/gc.h +2 -2
  77. data/ext/enterprise_script_service/mruby/include/mruby/hash.h +4 -11
  78. data/ext/enterprise_script_service/mruby/include/mruby/irep.h +16 -4
  79. data/ext/enterprise_script_service/mruby/include/mruby/istruct.h +4 -4
  80. data/ext/enterprise_script_service/mruby/include/mruby/khash.h +2 -2
  81. data/ext/enterprise_script_service/mruby/include/mruby/numeric.h +41 -7
  82. data/ext/enterprise_script_service/mruby/include/mruby/object.h +8 -9
  83. data/ext/enterprise_script_service/mruby/include/mruby/opcode.h +2 -2
  84. data/ext/enterprise_script_service/mruby/include/mruby/ops.h +6 -6
  85. data/ext/enterprise_script_service/mruby/include/mruby/proc.h +19 -13
  86. data/ext/enterprise_script_service/mruby/include/mruby/range.h +10 -4
  87. data/ext/enterprise_script_service/mruby/include/mruby/re.h +2 -2
  88. data/ext/enterprise_script_service/mruby/include/mruby/string.h +130 -107
  89. data/ext/enterprise_script_service/mruby/include/mruby/throw.h +2 -2
  90. data/ext/enterprise_script_service/mruby/include/mruby/value.h +137 -49
  91. data/ext/enterprise_script_service/mruby/include/mruby/variable.h +3 -5
  92. data/ext/enterprise_script_service/mruby/include/mruby/version.h +24 -10
  93. data/ext/enterprise_script_service/mruby/lib/mruby-core-ext.rb +2 -39
  94. data/ext/enterprise_script_service/mruby/lib/mruby/build.rb +32 -15
  95. data/ext/enterprise_script_service/mruby/lib/mruby/build/command.rb +63 -17
  96. data/ext/enterprise_script_service/mruby/lib/mruby/build/load_gems.rb +24 -10
  97. data/ext/enterprise_script_service/mruby/lib/mruby/gem.rb +11 -7
  98. data/ext/enterprise_script_service/mruby/lib/mruby/lockfile.rb +81 -0
  99. data/ext/enterprise_script_service/mruby/minirake +27 -11
  100. data/ext/enterprise_script_service/mruby/mrbgems/default.gembox +3 -0
  101. data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/mrbgem.rake +0 -1
  102. data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/mrblib/array.rb +47 -9
  103. data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/src/array.c +3 -3
  104. data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/test/array.rb +50 -29
  105. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.c +3 -3
  106. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/apiprint.c +2 -2
  107. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/cmdprint.c +3 -3
  108. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c +2 -2
  109. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.h +1 -1
  110. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdbconf.h +4 -0
  111. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c +28 -1
  112. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c +1 -2
  113. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mruby/bintest/mruby.rb +75 -8
  114. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c +134 -90
  115. data/ext/enterprise_script_service/mruby/mrbgems/mruby-class-ext/src/class.c +7 -8
  116. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/codegen.c +69 -46
  117. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/keywords +0 -3
  118. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/lex.def +51 -59
  119. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/parse.y +430 -241
  120. data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/mrbgem.rake +10 -0
  121. data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/mrblib/complex.rb +122 -0
  122. data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/src/complex.c +249 -0
  123. data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/test/complex.rb +153 -0
  124. data/ext/enterprise_script_service/mruby/mrbgems/mruby-enum-chain/mrblib/chain.rb +19 -17
  125. data/ext/enterprise_script_service/mruby/mrbgems/mruby-enum-chain/test/enum_chain.rb +41 -9
  126. data/ext/enterprise_script_service/mruby/mrbgems/mruby-enum-ext/mrblib/enum.rb +30 -4
  127. data/ext/enterprise_script_service/mruby/mrbgems/mruby-enum-ext/test/enum.rb +8 -3
  128. data/ext/enterprise_script_service/mruby/mrbgems/mruby-enumerator/mrbgem.rake +0 -1
  129. data/ext/enterprise_script_service/mruby/mrbgems/mruby-enumerator/mrblib/enumerator.rb +46 -14
  130. data/ext/enterprise_script_service/mruby/mrbgems/mruby-enumerator/test/enumerator.rb +51 -2
  131. data/ext/enterprise_script_service/mruby/mrbgems/mruby-error/src/exception.c +10 -0
  132. data/ext/enterprise_script_service/mruby/mrbgems/mruby-eval/src/eval.c +47 -44
  133. data/ext/enterprise_script_service/mruby/mrbgems/mruby-eval/test/eval.rb +2 -2
  134. data/ext/enterprise_script_service/mruby/mrbgems/mruby-exit/src/mruby-exit.c +9 -4
  135. data/ext/enterprise_script_service/mruby/mrbgems/mruby-fiber/src/fiber.c +16 -12
  136. data/ext/enterprise_script_service/mruby/mrbgems/mruby-fiber/test/fiber.rb +1 -1
  137. data/ext/enterprise_script_service/mruby/mrbgems/mruby-hash-ext/mrbgem.rake +0 -2
  138. data/ext/enterprise_script_service/mruby/mrbgems/mruby-hash-ext/mrblib/hash.rb +3 -0
  139. data/ext/enterprise_script_service/mruby/mrbgems/mruby-hash-ext/test/hash.rb +3 -7
  140. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/README.md +1 -3
  141. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrbgem.rake +1 -1
  142. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrblib/file.rb +0 -5
  143. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrblib/io.rb +24 -38
  144. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrblib/kernel.rb +16 -0
  145. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/file.c +19 -18
  146. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/file_test.c +5 -16
  147. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/io.c +54 -42
  148. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/file.rb +24 -20
  149. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/file_test.rb +4 -9
  150. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/io.rb +41 -35
  151. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/mruby_io_test.c +9 -36
  152. data/ext/enterprise_script_service/mruby/mrbgems/mruby-kernel-ext/mrbgem.rake +1 -1
  153. data/ext/enterprise_script_service/mruby/mrbgems/mruby-kernel-ext/src/kernel.c +9 -27
  154. data/ext/enterprise_script_service/mruby/mrbgems/mruby-kernel-ext/test/kernel.rb +2 -0
  155. data/ext/enterprise_script_service/mruby/mrbgems/mruby-math/src/math.c +5 -2
  156. data/ext/enterprise_script_service/mruby/mrbgems/mruby-metaprog/src/metaprog.c +39 -24
  157. data/ext/enterprise_script_service/mruby/mrbgems/mruby-metaprog/test/metaprog.rb +48 -17
  158. data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/mrblib/method.rb +0 -12
  159. data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/src/method.c +134 -101
  160. data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/test/method.rb +9 -1
  161. data/ext/enterprise_script_service/mruby/mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb +1 -5
  162. data/ext/enterprise_script_service/mruby/mrbgems/mruby-numeric-ext/src/numeric_ext.c +17 -37
  163. data/ext/enterprise_script_service/mruby/mrbgems/mruby-numeric-ext/test/numeric.rb +0 -8
  164. data/ext/enterprise_script_service/mruby/mrbgems/mruby-object-ext/mrbgem.rake +1 -1
  165. data/ext/enterprise_script_service/mruby/mrbgems/mruby-object-ext/mrblib/object.rb +15 -1
  166. data/ext/enterprise_script_service/mruby/mrbgems/mruby-object-ext/src/object.c +35 -6
  167. data/ext/enterprise_script_service/mruby/mrbgems/mruby-object-ext/test/nil.rb +4 -0
  168. data/ext/enterprise_script_service/mruby/mrbgems/mruby-objectspace/src/mruby_objectspace.c +1 -5
  169. data/ext/enterprise_script_service/mruby/mrbgems/mruby-objectspace/test/objectspace.rb +1 -1
  170. data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/src/pack.c +28 -23
  171. data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/test/pack.rb +43 -49
  172. data/ext/enterprise_script_service/mruby/mrbgems/mruby-print/mrblib/print.rb +3 -9
  173. data/ext/enterprise_script_service/mruby/mrbgems/mruby-proc-ext/src/proc.c +6 -9
  174. data/ext/enterprise_script_service/mruby/mrbgems/mruby-proc-ext/test/proc.rb +21 -5
  175. data/ext/enterprise_script_service/mruby/mrbgems/mruby-random/src/random.c +157 -124
  176. data/ext/enterprise_script_service/mruby/mrbgems/mruby-random/test/random.rb +72 -26
  177. data/ext/enterprise_script_service/mruby/mrbgems/mruby-range-ext/mrblib/range.rb +38 -0
  178. data/ext/enterprise_script_service/mruby/mrbgems/mruby-range-ext/src/range.c +26 -11
  179. data/ext/enterprise_script_service/mruby/mrbgems/mruby-range-ext/test/range.rb +111 -1
  180. data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/mrbgem.rake +5 -0
  181. data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/mrblib/rational.rb +117 -0
  182. data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/src/rational.c +209 -0
  183. data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/test/rational.rb +308 -0
  184. data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/README.md +1 -1
  185. data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/src/socket.c +10 -9
  186. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sprintf/src/kernel.c +2 -2
  187. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sprintf/src/sprintf.c +22 -24
  188. data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/mrbgem.rake +0 -1
  189. data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/mrblib/string.rb +8 -4
  190. data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/src/string.c +116 -117
  191. data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/test/numeric.rb +29 -0
  192. data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/test/range.rb +26 -0
  193. data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/test/string.rb +32 -50
  194. data/ext/enterprise_script_service/mruby/mrbgems/mruby-struct/mrblib/struct.rb +5 -7
  195. data/ext/enterprise_script_service/mruby/mrbgems/mruby-struct/src/struct.c +43 -57
  196. data/ext/enterprise_script_service/mruby/mrbgems/mruby-struct/test/struct.rb +16 -11
  197. data/ext/enterprise_script_service/mruby/mrbgems/mruby-symbol-ext/src/symbol.c +2 -2
  198. data/ext/enterprise_script_service/mruby/mrbgems/mruby-symbol-ext/test/symbol.rb +1 -1
  199. data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/driver.c +152 -1
  200. data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/mrbgem.rake +4 -3
  201. data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/vformat.c +200 -0
  202. data/ext/enterprise_script_service/mruby/mrbgems/mruby-time/include/mruby/time.h +2 -1
  203. data/ext/enterprise_script_service/mruby/mrbgems/mruby-time/src/time.c +199 -68
  204. data/ext/enterprise_script_service/mruby/mrbgems/mruby-time/test/time.rb +81 -46
  205. data/ext/enterprise_script_service/mruby/mrblib/array.rb +14 -16
  206. data/ext/enterprise_script_service/mruby/mrblib/enum.rb +13 -9
  207. data/ext/enterprise_script_service/mruby/mrblib/hash.rb +5 -7
  208. data/ext/enterprise_script_service/mruby/mrblib/kernel.rb +1 -1
  209. data/ext/enterprise_script_service/mruby/mrblib/numeric.rb +4 -4
  210. data/ext/enterprise_script_service/mruby/mrblib/range.rb +1 -1
  211. data/ext/enterprise_script_service/mruby/mrblib/string.rb +55 -112
  212. data/ext/enterprise_script_service/mruby/mruby-source.gemspec +1 -1
  213. data/ext/enterprise_script_service/mruby/oss-fuzz/config/mruby.dict +105 -0
  214. data/ext/enterprise_script_service/mruby/oss-fuzz/config/mruby_fuzzer.options +5 -0
  215. data/ext/enterprise_script_service/mruby/oss-fuzz/config/mruby_proto_fuzzer.options +4 -0
  216. data/ext/enterprise_script_service/mruby/oss-fuzz/mruby_fuzzer.c +18 -0
  217. data/ext/enterprise_script_service/mruby/oss-fuzz/mruby_proto_fuzzer.cpp +44 -0
  218. data/ext/enterprise_script_service/mruby/oss-fuzz/proto_to_ruby.cpp +455 -0
  219. data/ext/enterprise_script_service/mruby/oss-fuzz/proto_to_ruby.h +55 -0
  220. data/ext/enterprise_script_service/mruby/oss-fuzz/ruby.proto +201 -0
  221. data/ext/enterprise_script_service/mruby/src/array.c +95 -46
  222. data/ext/enterprise_script_service/mruby/src/backtrace.c +6 -8
  223. data/ext/enterprise_script_service/mruby/src/class.c +370 -278
  224. data/ext/enterprise_script_service/mruby/src/codedump.c +34 -34
  225. data/ext/enterprise_script_service/mruby/src/debug.c +2 -2
  226. data/ext/enterprise_script_service/mruby/src/dump.c +8 -6
  227. data/ext/enterprise_script_service/mruby/src/enum.c +1 -1
  228. data/ext/enterprise_script_service/mruby/src/error.c +157 -55
  229. data/ext/enterprise_script_service/mruby/src/etc.c +13 -46
  230. data/ext/enterprise_script_service/mruby/src/fmt_fp.c +2 -2
  231. data/ext/enterprise_script_service/mruby/src/gc.c +30 -11
  232. data/ext/enterprise_script_service/mruby/src/hash.c +23 -14
  233. data/ext/enterprise_script_service/mruby/src/kernel.c +16 -54
  234. data/ext/enterprise_script_service/mruby/src/load.c +40 -76
  235. data/ext/enterprise_script_service/mruby/src/numeric.c +164 -94
  236. data/ext/enterprise_script_service/mruby/src/object.c +16 -39
  237. data/ext/enterprise_script_service/mruby/src/pool.c +0 -2
  238. data/ext/enterprise_script_service/mruby/src/proc.c +47 -48
  239. data/ext/enterprise_script_service/mruby/src/range.c +22 -35
  240. data/ext/enterprise_script_service/mruby/src/state.c +5 -94
  241. data/ext/enterprise_script_service/mruby/src/string.c +874 -710
  242. data/ext/enterprise_script_service/mruby/src/symbol.c +73 -48
  243. data/ext/enterprise_script_service/mruby/src/variable.c +58 -38
  244. data/ext/enterprise_script_service/mruby/src/vm.c +133 -304
  245. data/ext/enterprise_script_service/mruby/tasks/doc.rake +48 -0
  246. data/ext/enterprise_script_service/mruby/tasks/toolchains/clang.rake +3 -4
  247. data/ext/enterprise_script_service/mruby/tasks/toolchains/gcc.rake +20 -19
  248. data/ext/enterprise_script_service/mruby/tasks/toolchains/visualcpp.rake +0 -12
  249. data/ext/enterprise_script_service/mruby/test/assert.rb +186 -25
  250. data/ext/enterprise_script_service/mruby/test/t/array.rb +34 -6
  251. data/ext/enterprise_script_service/mruby/test/t/class.rb +26 -0
  252. data/ext/enterprise_script_service/mruby/test/t/enumerable.rb +2 -2
  253. data/ext/enterprise_script_service/mruby/test/t/float.rb +17 -17
  254. data/ext/enterprise_script_service/mruby/test/t/hash.rb +2 -0
  255. data/ext/enterprise_script_service/mruby/test/t/integer.rb +14 -6
  256. data/ext/enterprise_script_service/mruby/test/t/kernel.rb +38 -19
  257. data/ext/enterprise_script_service/mruby/test/t/module.rb +87 -14
  258. data/ext/enterprise_script_service/mruby/test/t/numeric.rb +65 -23
  259. data/ext/enterprise_script_service/mruby/test/t/range.rb +4 -4
  260. data/ext/enterprise_script_service/mruby/test/t/string.rb +211 -49
  261. data/ext/enterprise_script_service/mruby/test/t/syntax.rb +19 -2
  262. data/ext/enterprise_script_service/mruby/test/t/vformat.rb +92 -0
  263. data/ext/enterprise_script_service/mruby/travis_config.rb +2 -2
  264. data/ext/enterprise_script_service/mruby_config.rb +10 -0
  265. data/ext/enterprise_script_service/mruby_engine.cpp +2 -2
  266. data/ext/enterprise_script_service/mruby_engine.gembox +1 -0
  267. data/ext/enterprise_script_service/msgpack/CHANGELOG.md +14 -0
  268. data/ext/enterprise_script_service/msgpack/Files.cmake +4 -0
  269. data/ext/enterprise_script_service/msgpack/README.md +1 -1
  270. data/ext/enterprise_script_service/msgpack/appveyor.yml +1 -1
  271. data/ext/enterprise_script_service/msgpack/erb/v1/cpp03_msgpack_tuple.hpp.erb +1 -1
  272. data/ext/enterprise_script_service/msgpack/erb/v1/cpp03_msgpack_tuple_decl.hpp.erb +1 -1
  273. data/ext/enterprise_script_service/msgpack/erb/v1/cpp03_zone.hpp.erb +3 -3
  274. data/ext/enterprise_script_service/msgpack/example/boost/asio_send_recv.cpp +1 -1
  275. data/ext/enterprise_script_service/msgpack/include/msgpack/adaptor/cpp11/timespec.hpp +16 -0
  276. data/ext/enterprise_script_service/msgpack/include/msgpack/adaptor/wstring.hpp +15 -0
  277. data/ext/enterprise_script_service/msgpack/include/msgpack/object.h +2 -0
  278. data/ext/enterprise_script_service/msgpack/include/msgpack/pack_template.h +17 -9
  279. data/ext/enterprise_script_service/msgpack/include/msgpack/sysdep.h +27 -16
  280. data/ext/enterprise_script_service/msgpack/include/msgpack/type.hpp +2 -0
  281. data/ext/enterprise_script_service/msgpack/include/msgpack/unpack_template.h +5 -0
  282. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/array_ref.hpp +0 -1
  283. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/check_container_size.hpp +1 -1
  284. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/cpp11/chrono.hpp +5 -5
  285. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/cpp11/timespec.hpp +140 -0
  286. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/detail/cpp03_msgpack_tuple.hpp +32 -32
  287. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/detail/cpp03_msgpack_tuple_decl.hpp +32 -32
  288. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/detail/cpp11_msgpack_tuple.hpp +6 -6
  289. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/detail/cpp11_msgpack_tuple_decl.hpp +10 -10
  290. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/ext.hpp +1 -1
  291. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/fixint.hpp +5 -4
  292. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/int.hpp +40 -13
  293. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/int_decl.hpp +3 -2
  294. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/wstring.hpp +121 -0
  295. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/detail/cpp03_zone.hpp +3 -3
  296. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/detail/cpp11_zone.hpp +3 -3
  297. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/object.hpp +6 -6
  298. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/object_fwd.hpp +1 -1
  299. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/pack.hpp +40 -5
  300. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/unpack.hpp +11 -11
  301. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/vrefbuffer.hpp +7 -7
  302. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/zbuffer.hpp +5 -5
  303. data/ext/enterprise_script_service/msgpack/include/msgpack/v2/adaptor/int_decl.hpp +1 -1
  304. data/ext/enterprise_script_service/msgpack/include/msgpack/v2/create_object_visitor.hpp +1 -1
  305. data/ext/enterprise_script_service/msgpack/include/msgpack/v2/parse.hpp +13 -13
  306. data/ext/enterprise_script_service/msgpack/include/msgpack/v2/x3_parse.hpp +28 -26
  307. data/ext/enterprise_script_service/msgpack/include/msgpack/v3/adaptor/int_decl.hpp +1 -1
  308. data/ext/enterprise_script_service/msgpack/include/msgpack/v3/parse.hpp +13 -13
  309. data/ext/enterprise_script_service/msgpack/include/msgpack/version_master.h +2 -2
  310. data/ext/enterprise_script_service/msgpack/include/msgpack/zbuffer.h +6 -6
  311. data/ext/enterprise_script_service/msgpack/include/msgpack/zone.h +1 -1
  312. data/ext/enterprise_script_service/msgpack/src/objectc.c +83 -148
  313. data/ext/enterprise_script_service/msgpack/src/unpack.c +73 -47
  314. data/ext/enterprise_script_service/msgpack/test/CMakeLists.txt +1 -1
  315. data/ext/enterprise_script_service/msgpack/test/array_ref.cpp +5 -0
  316. data/ext/enterprise_script_service/msgpack/test/boost_fusion.cpp +5 -0
  317. data/ext/enterprise_script_service/msgpack/test/boost_optional.cpp +7 -0
  318. data/ext/enterprise_script_service/msgpack/test/boost_string_ref.cpp +7 -0
  319. data/ext/enterprise_script_service/msgpack/test/boost_string_view.cpp +6 -0
  320. data/ext/enterprise_script_service/msgpack/test/boost_variant.cpp +15 -9
  321. data/ext/enterprise_script_service/msgpack/test/buffer.cpp +7 -0
  322. data/ext/enterprise_script_service/msgpack/test/carray.cpp +7 -0
  323. data/ext/enterprise_script_service/msgpack/test/cases.cpp +7 -1
  324. data/ext/enterprise_script_service/msgpack/test/convert.cpp +6 -0
  325. data/ext/enterprise_script_service/msgpack/test/fixint.cpp +7 -1
  326. data/ext/enterprise_script_service/msgpack/test/fixint_c.cpp +6 -1
  327. data/ext/enterprise_script_service/msgpack/test/fuzz_unpack_pack_fuzzer_cpp11.cpp +5 -0
  328. data/ext/enterprise_script_service/msgpack/test/iterator_cpp11.cpp +8 -2
  329. data/ext/enterprise_script_service/msgpack/test/json.cpp +6 -0
  330. data/ext/enterprise_script_service/msgpack/test/limit.cpp +7 -0
  331. data/ext/enterprise_script_service/msgpack/test/msgpack_basic.cpp +128 -6
  332. data/ext/enterprise_script_service/msgpack/test/msgpack_c.cpp +7 -2
  333. data/ext/enterprise_script_service/msgpack/test/msgpack_container.cpp +20 -3
  334. data/ext/enterprise_script_service/msgpack/test/msgpack_cpp11.cpp +159 -0
  335. data/ext/enterprise_script_service/msgpack/test/msgpack_cpp17.cpp +5 -0
  336. data/ext/enterprise_script_service/msgpack/test/msgpack_stream.cpp +8 -3
  337. data/ext/enterprise_script_service/msgpack/test/msgpack_tuple.cpp +6 -0
  338. data/ext/enterprise_script_service/msgpack/test/msgpack_vref.cpp +5 -0
  339. data/ext/enterprise_script_service/msgpack/test/msgpack_x3_parse.cpp +23 -18
  340. data/ext/enterprise_script_service/msgpack/test/object.cpp +77 -45
  341. data/ext/enterprise_script_service/msgpack/test/object_with_zone.cpp +28 -10
  342. data/ext/enterprise_script_service/msgpack/test/pack_unpack.cpp +25 -18
  343. data/ext/enterprise_script_service/msgpack/test/pack_unpack_c.cpp +7 -0
  344. data/ext/enterprise_script_service/msgpack/test/raw.cpp +17 -12
  345. data/ext/enterprise_script_service/msgpack/test/reference.cpp +6 -0
  346. data/ext/enterprise_script_service/msgpack/test/reference_cpp11.cpp +6 -0
  347. data/ext/enterprise_script_service/msgpack/test/reference_wrapper_cpp11.cpp +6 -0
  348. data/ext/enterprise_script_service/msgpack/test/shared_ptr_cpp11.cpp +6 -0
  349. data/ext/enterprise_script_service/msgpack/test/size_equal_only.cpp +6 -2
  350. data/ext/enterprise_script_service/msgpack/test/streaming.cpp +10 -3
  351. data/ext/enterprise_script_service/msgpack/test/streaming_c.cpp +7 -0
  352. data/ext/enterprise_script_service/msgpack/test/unique_ptr_cpp11.cpp +6 -0
  353. data/ext/enterprise_script_service/msgpack/test/user_class.cpp +5 -0
  354. data/ext/enterprise_script_service/msgpack/test/version.cpp +6 -0
  355. data/ext/enterprise_script_service/msgpack/test/visitor.cpp +7 -0
  356. data/ext/enterprise_script_service/msgpack/test/zone.cpp +6 -0
  357. data/lib/script_core/version.rb +1 -1
  358. data/lib/tasks/mruby/engine.gembox.example +1 -0
  359. data/lib/tasks/script_core.rake +21 -3
  360. data/spec/dummy/app/helpers/fields_helper.rb +2 -2
  361. data/spec/dummy/mruby/engine.gembox +1 -0
  362. data/spec/script_core_spec.rb +1 -1
  363. metadata +38 -22
  364. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/.gitignore +0 -1
  365. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/.travis.yml +0 -2
  366. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/run_test.rb +0 -26
  367. data/ext/enterprise_script_service/mruby/mrbgems/mruby-kernel-ext/mrblib/kernel.rb +0 -15
  368. data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/mrblib/unbound_method.rb +0 -9
  369. data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/.gitignore +0 -5
  370. data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/.travis.yml +0 -2
  371. data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/packtest.rb +0 -157
  372. data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/run_test.rb +0 -26
  373. data/ext/enterprise_script_service/mruby/mrbgems/mruby-random/src/mt19937ar.c +0 -224
  374. data/ext/enterprise_script_service/mruby/mrbgems/mruby-random/src/mt19937ar.h +0 -80
  375. data/ext/enterprise_script_service/mruby/mrbgems/mruby-random/src/random.h +0 -12
  376. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sleep/.gitignore +0 -4
  377. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sleep/.travis.yml +0 -29
  378. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sleep/.travis_build_config.rb +0 -6
  379. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sleep/Rakefile +0 -29
  380. data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/.travis.yml +0 -4
  381. data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/run_test.rb +0 -28
@@ -12,4 +12,20 @@ def open(file, *rest, &block)
12
12
  File.open(file, *rest, &block)
13
13
  end
14
14
  end
15
+
16
+ def print(*args)
17
+ $stdout.print(*args)
18
+ end
19
+
20
+ def puts(*args)
21
+ $stdout.puts(*args)
22
+ end
23
+
24
+ def printf(*args)
25
+ $stdout.printf(*args)
26
+ end
27
+
28
+ def gets(*args)
29
+ $stdin.gets(*args)
30
+ end
15
31
  end
@@ -116,7 +116,7 @@ mrb_file_s_unlink(mrb_state *mrb, mrb_value obj)
116
116
  for (i = 0; i < argc; i++) {
117
117
  const char *utf8_path;
118
118
  pathv = mrb_ensure_string_type(mrb, argv[i]);
119
- utf8_path = mrb_string_value_cstr(mrb, &pathv);
119
+ utf8_path = RSTRING_CSTR(mrb, pathv);
120
120
  path = mrb_locale_from_utf8(utf8_path, -1);
121
121
  if (UNLINK(path) < 0) {
122
122
  mrb_locale_free(path);
@@ -134,8 +134,8 @@ mrb_file_s_rename(mrb_state *mrb, mrb_value obj)
134
134
  char *src, *dst;
135
135
 
136
136
  mrb_get_args(mrb, "SS", &from, &to);
137
- src = mrb_locale_from_utf8(mrb_string_value_cstr(mrb, &from), -1);
138
- dst = mrb_locale_from_utf8(mrb_string_value_cstr(mrb, &to), -1);
137
+ src = mrb_locale_from_utf8(RSTRING_CSTR(mrb, from), -1);
138
+ dst = mrb_locale_from_utf8(RSTRING_CSTR(mrb, to), -1);
139
139
  if (rename(src, dst) < 0) {
140
140
  #if defined(_WIN32) || defined(_WIN64)
141
141
  if (CHMOD(dst, 0666) == 0 && UNLINK(dst) == 0 && rename(src, dst) == 0) {
@@ -146,7 +146,8 @@ mrb_file_s_rename(mrb_state *mrb, mrb_value obj)
146
146
  #endif
147
147
  mrb_locale_free(src);
148
148
  mrb_locale_free(dst);
149
- mrb_sys_fail(mrb, mrb_str_to_cstr(mrb, mrb_format(mrb, "(%S, %S)", from, to)));
149
+ mrb_sys_fail(mrb, RSTRING_CSTR(mrb, mrb_format(mrb, "(%v, %v)", from, to)));
150
+ return mrb_fixnum_value(-1); /* not reached */
150
151
  }
151
152
  mrb_locale_free(src);
152
153
  mrb_locale_free(dst);
@@ -159,12 +160,12 @@ mrb_file_dirname(mrb_state *mrb, mrb_value klass)
159
160
  #if defined(_WIN32) || defined(_WIN64)
160
161
  char dname[_MAX_DIR], vname[_MAX_DRIVE];
161
162
  char buffer[_MAX_DRIVE + _MAX_DIR];
163
+ const char *utf8_path;
162
164
  char *path;
163
165
  size_t ridx;
164
- mrb_value s;
165
- mrb_get_args(mrb, "S", &s);
166
- path = mrb_locale_from_utf8(mrb_str_to_cstr(mrb, s), -1);
167
- _splitpath((const char*)path, vname, dname, NULL, NULL);
166
+ mrb_get_args(mrb, "z", &utf8_path);
167
+ path = mrb_locale_from_utf8(utf8_path, -1);
168
+ _splitpath(path, vname, dname, NULL, NULL);
168
169
  snprintf(buffer, _MAX_DRIVE + _MAX_DIR, "%s%s", vname, dname);
169
170
  mrb_locale_free(path);
170
171
  ridx = strlen(buffer);
@@ -248,11 +249,12 @@ mrb_file_realpath(mrb_state *mrb, mrb_value klass)
248
249
  s = mrb_str_append(mrb, s, pathname);
249
250
  pathname = s;
250
251
  }
251
- cpath = mrb_locale_from_utf8(mrb_str_to_cstr(mrb, pathname), -1);
252
+ cpath = mrb_locale_from_utf8(RSTRING_CSTR(mrb, pathname), -1);
252
253
  result = mrb_str_buf_new(mrb, PATH_MAX);
253
254
  if (realpath(cpath, RSTRING_PTR(result)) == NULL) {
254
255
  mrb_locale_free(cpath);
255
256
  mrb_sys_fail(mrb, cpath);
257
+ return result; /* not reached */
256
258
  }
257
259
  mrb_locale_free(cpath);
258
260
  mrb_str_resize(mrb, result, strlen(RSTRING_PTR(result)));
@@ -300,14 +302,14 @@ mrb_file__gethome(mrb_state *mrb, mrb_value klass)
300
302
  mrb_raise(mrb, E_ARGUMENT_ERROR, "non-absolute home");
301
303
  }
302
304
  } else {
303
- const char *cuser = mrb_str_to_cstr(mrb, username);
305
+ const char *cuser = RSTRING_CSTR(mrb, username);
304
306
  struct passwd *pwd = getpwnam(cuser);
305
307
  if (pwd == NULL) {
306
308
  return mrb_nil_value();
307
309
  }
308
310
  home = pwd->pw_dir;
309
311
  if (!mrb_file_is_absolute_path(home)) {
310
- mrb_raisef(mrb, E_ARGUMENT_ERROR, "non-absolute home of ~%S", username);
312
+ mrb_raisef(mrb, E_ARGUMENT_ERROR, "non-absolute home of ~%v", username);
311
313
  }
312
314
  }
313
315
  home = mrb_locale_from_utf8(home, -1);
@@ -393,13 +395,12 @@ mrb_file_s_symlink(mrb_state *mrb, mrb_value klass)
393
395
  int ai = mrb_gc_arena_save(mrb);
394
396
 
395
397
  mrb_get_args(mrb, "SS", &from, &to);
396
- src = mrb_locale_from_utf8(mrb_str_to_cstr(mrb, from), -1);
397
- dst = mrb_locale_from_utf8(mrb_str_to_cstr(mrb, to), -1);
398
-
398
+ src = mrb_locale_from_utf8(RSTRING_CSTR(mrb, from), -1);
399
+ dst = mrb_locale_from_utf8(RSTRING_CSTR(mrb, to), -1);
399
400
  if (symlink(src, dst) == -1) {
400
401
  mrb_locale_free(src);
401
402
  mrb_locale_free(dst);
402
- mrb_sys_fail(mrb, mrb_str_to_cstr(mrb, mrb_format(mrb, "(%S, %S)", from, to)));
403
+ mrb_sys_fail(mrb, RSTRING_CSTR(mrb, mrb_format(mrb, "(%v, %v)", from, to)));
403
404
  }
404
405
  mrb_locale_free(src);
405
406
  mrb_locale_free(dst);
@@ -417,16 +418,16 @@ mrb_file_s_chmod(mrb_state *mrb, mrb_value klass) {
417
418
 
418
419
  mrb_get_args(mrb, "i*", &mode, &filenames, &argc);
419
420
  for (i = 0; i < argc; i++) {
420
- const char *utf8_path = mrb_str_to_cstr(mrb, filenames[i]);
421
+ const char *utf8_path = RSTRING_CSTR(mrb, filenames[i]);
421
422
  char *path = mrb_locale_from_utf8(utf8_path, -1);
422
423
  if (CHMOD(path, mode) == -1) {
423
424
  mrb_locale_free(path);
424
425
  mrb_sys_fail(mrb, utf8_path);
425
426
  }
426
427
  mrb_locale_free(path);
428
+ mrb_gc_arena_restore(mrb, ai);
427
429
  }
428
430
 
429
- mrb_gc_arena_restore(mrb, ai);
430
431
  return mrb_fixnum_value(argc);
431
432
  }
432
433
 
@@ -473,7 +474,7 @@ mrb_init_file(mrb_state *mrb)
473
474
  io = mrb_class_get(mrb, "IO");
474
475
  file = mrb_define_class(mrb, "File", io);
475
476
  MRB_SET_INSTANCE_TT(file, MRB_TT_DATA);
476
- mrb_define_class_method(mrb, file, "umask", mrb_file_s_umask, MRB_ARGS_REQ(1));
477
+ mrb_define_class_method(mrb, file, "umask", mrb_file_s_umask, MRB_ARGS_OPT(1));
477
478
  mrb_define_class_method(mrb, file, "delete", mrb_file_s_unlink, MRB_ARGS_ANY());
478
479
  mrb_define_class_method(mrb, file, "unlink", mrb_file_s_unlink, MRB_ARGS_ANY());
479
480
  mrb_define_class_method(mrb, file, "rename", mrb_file_s_rename, MRB_ARGS_REQ(2));
@@ -1,5 +1,5 @@
1
1
  /*
2
- ** file.c - File class
2
+ ** file_test.c - FileTest class
3
3
  */
4
4
 
5
5
  #include "mruby.h"
@@ -42,16 +42,9 @@ extern struct mrb_data_type mrb_io_type;
42
42
  static int
43
43
  mrb_stat0(mrb_state *mrb, mrb_value obj, struct stat *st, int do_lstat)
44
44
  {
45
- mrb_value tmp;
46
- mrb_value io_klass, str_klass;
47
-
48
- io_klass = mrb_obj_value(mrb_class_get(mrb, "IO"));
49
- str_klass = mrb_obj_value(mrb_class_get(mrb, "String"));
50
-
51
- tmp = mrb_funcall(mrb, obj, "is_a?", 1, io_klass);
52
- if (mrb_test(tmp)) {
45
+ if (mrb_obj_is_kind_of(mrb, obj, mrb_class_get(mrb, "IO"))) {
53
46
  struct mrb_io *fptr;
54
- fptr = (struct mrb_io *)mrb_get_datatype(mrb, obj, &mrb_io_type);
47
+ fptr = (struct mrb_io *)mrb_data_get_ptr(mrb, obj, &mrb_io_type);
55
48
 
56
49
  if (fptr && fptr->fd >= 0) {
57
50
  return fstat(fptr->fd, st);
@@ -60,10 +53,8 @@ mrb_stat0(mrb_state *mrb, mrb_value obj, struct stat *st, int do_lstat)
60
53
  mrb_raise(mrb, E_IO_ERROR, "closed stream");
61
54
  return -1;
62
55
  }
63
-
64
- tmp = mrb_funcall(mrb, obj, "is_a?", 1, str_klass);
65
- if (mrb_test(tmp)) {
66
- char *path = mrb_locale_from_utf8(mrb_str_to_cstr(mrb, obj), -1);
56
+ else {
57
+ char *path = mrb_locale_from_utf8(RSTRING_CSTR(mrb, obj), -1);
67
58
  int ret;
68
59
  if (do_lstat) {
69
60
  ret = LSTAT(path, st);
@@ -73,8 +64,6 @@ mrb_stat0(mrb_state *mrb, mrb_value obj, struct stat *st, int do_lstat)
73
64
  mrb_locale_free(path);
74
65
  return ret;
75
66
  }
76
-
77
- return -1;
78
67
  }
79
68
 
80
69
  static int
@@ -79,7 +79,7 @@ io_get_open_fptr(mrb_state *mrb, mrb_value self)
79
79
  {
80
80
  struct mrb_io *fptr;
81
81
 
82
- fptr = (struct mrb_io *)mrb_get_datatype(mrb, self, &mrb_io_type);
82
+ fptr = (struct mrb_io *)mrb_data_get_ptr(mrb, self, &mrb_io_type);
83
83
  if (fptr == NULL) {
84
84
  mrb_raise(mrb, E_IO_ERROR, "uninitialized stream.");
85
85
  }
@@ -127,7 +127,7 @@ mrb_io_modestr_to_flags(mrb_state *mrb, const char *mode)
127
127
  flags |= FMODE_WRITABLE | FMODE_APPEND | FMODE_CREATE;
128
128
  break;
129
129
  default:
130
- mrb_raisef(mrb, E_ARGUMENT_ERROR, "illegal access mode %S", mrb_str_new_cstr(mrb, mode));
130
+ mrb_raisef(mrb, E_ARGUMENT_ERROR, "illegal access mode %s", mode);
131
131
  }
132
132
 
133
133
  while (*m) {
@@ -141,7 +141,7 @@ mrb_io_modestr_to_flags(mrb_state *mrb, const char *mode)
141
141
  case ':':
142
142
  /* XXX: PASSTHROUGH*/
143
143
  default:
144
- mrb_raisef(mrb, E_ARGUMENT_ERROR, "illegal access mode %S", mrb_str_new_cstr(mrb, mode));
144
+ mrb_raisef(mrb, E_ARGUMENT_ERROR, "illegal access mode %s", mode);
145
145
  }
146
146
  }
147
147
 
@@ -191,8 +191,7 @@ mrb_fd_cloexec(mrb_state *mrb, int fd)
191
191
 
192
192
  flags = fcntl(fd, F_GETFD);
193
193
  if (flags == -1) {
194
- mrb_bug(mrb, "mrb_fd_cloexec: fcntl(%S, F_GETFD) failed: %S",
195
- mrb_fixnum_value(fd), mrb_fixnum_value(errno));
194
+ mrb_bug(mrb, "mrb_fd_cloexec: fcntl(%d, F_GETFD) failed: %d", fd, errno);
196
195
  }
197
196
  if (fd <= 2) {
198
197
  flags2 = flags & ~FD_CLOEXEC; /* Clear CLOEXEC for standard file descriptors: 0, 1, 2. */
@@ -202,8 +201,7 @@ mrb_fd_cloexec(mrb_state *mrb, int fd)
202
201
  }
203
202
  if (flags != flags2) {
204
203
  if (fcntl(fd, F_SETFD, flags2) == -1) {
205
- mrb_bug(mrb, "mrb_fd_cloexec: fcntl(%S, F_SETFD, %S) failed: %S",
206
- mrb_fixnum_value(fd), mrb_fixnum_value(flags2), mrb_fixnum_value(errno));
204
+ mrb_bug(mrb, "mrb_fd_cloexec: fcntl(%d, F_SETFD, %d) failed: %d", fd, flags2, errno);
207
205
  }
208
206
  }
209
207
  #endif
@@ -286,12 +284,13 @@ mrb_io_alloc(mrb_state *mrb)
286
284
  #endif
287
285
 
288
286
  static int
289
- option_to_fd(mrb_state *mrb, mrb_value obj, const char *key)
287
+ option_to_fd(mrb_state *mrb, mrb_value hash, const char *key)
290
288
  {
291
- mrb_value opt = mrb_funcall(mrb, obj, "[]", 1, mrb_symbol_value(mrb_intern_static(mrb, key, strlen(key))));
292
- if (mrb_nil_p(opt)) {
293
- return -1;
294
- }
289
+ mrb_value opt;
290
+
291
+ if (!mrb_hash_p(hash)) return -1;
292
+ opt = mrb_hash_fetch(mrb, hash, mrb_symbol_value(mrb_intern_static(mrb, key, strlen(key))), mrb_nil_value());
293
+ if (mrb_nil_p(opt)) return -1;
295
294
 
296
295
  switch (mrb_type(opt)) {
297
296
  case MRB_TT_DATA: /* IO */
@@ -334,8 +333,8 @@ mrb_io_s_popen(mrb_state *mrb, mrb_value klass)
334
333
  mrb_get_args(mrb, "S|SH", &cmd, &mode, &opt);
335
334
  io = mrb_obj_value(mrb_data_object_alloc(mrb, mrb_class_ptr(klass), NULL, &mrb_io_type));
336
335
 
337
- pname = mrb_string_value_cstr(mrb, &cmd);
338
- flags = mrb_io_modestr_to_flags(mrb, mrb_string_value_cstr(mrb, &mode));
336
+ pname = RSTRING_CSTR(mrb, cmd);
337
+ flags = mrb_io_modestr_to_flags(mrb, RSTRING_CSTR(mrb, mode));
339
338
 
340
339
  doexec = (strcmp("-", pname) != 0);
341
340
  opt_in = option_to_fd(mrb, opt, "in");
@@ -381,7 +380,7 @@ mrb_io_s_popen(mrb_state *mrb, mrb_value klass)
381
380
  CloseHandle(ifd[1]);
382
381
  CloseHandle(ofd[0]);
383
382
  CloseHandle(ofd[1]);
384
- mrb_raisef(mrb, E_IO_ERROR, "command not found: %S", cmd);
383
+ mrb_raisef(mrb, E_IO_ERROR, "command not found: %v", cmd);
385
384
  }
386
385
  CloseHandle(pi.hThread);
387
386
  CloseHandle(ifd[0]);
@@ -430,8 +429,8 @@ mrb_io_s_popen(mrb_state *mrb, mrb_value klass)
430
429
  mrb_get_args(mrb, "S|SH", &cmd, &mode, &opt);
431
430
  io = mrb_obj_value(mrb_data_object_alloc(mrb, mrb_class_ptr(klass), NULL, &mrb_io_type));
432
431
 
433
- pname = mrb_string_value_cstr(mrb, &cmd);
434
- flags = mrb_io_modestr_to_flags(mrb, mrb_string_value_cstr(mrb, &mode));
432
+ pname = RSTRING_CSTR(mrb, cmd);
433
+ flags = mrb_io_modestr_to_flags(mrb, RSTRING_CSTR(mrb, mode));
435
434
 
436
435
  doexec = (strcmp("-", pname) != 0);
437
436
  opt_in = option_to_fd(mrb, opt, "in");
@@ -494,7 +493,7 @@ mrb_io_s_popen(mrb_state *mrb, mrb_value klass)
494
493
  close(fd);
495
494
  }
496
495
  mrb_proc_exec(pname);
497
- mrb_raisef(mrb, E_IO_ERROR, "command not found: %S", cmd);
496
+ mrb_raisef(mrb, E_IO_ERROR, "command not found: %v", cmd);
498
497
  _exit(127);
499
498
  }
500
499
  result = mrb_nil_value();
@@ -628,7 +627,7 @@ mrb_io_initialize(mrb_state *mrb, mrb_value io)
628
627
  opt = mrb_hash_new(mrb);
629
628
  }
630
629
 
631
- flags = mrb_io_modestr_to_flags(mrb, mrb_string_value_cstr(mrb, &mode));
630
+ flags = mrb_io_modestr_to_flags(mrb, RSTRING_CSTR(mrb, mode));
632
631
 
633
632
  mrb_iv_set(mrb, io, mrb_intern_cstr(mrb, "@buf"), mrb_str_new_cstr(mrb, ""));
634
633
 
@@ -760,7 +759,6 @@ mrb_io_s_sysclose(mrb_state *mrb, mrb_value klass)
760
759
  int
761
760
  mrb_cloexec_open(mrb_state *mrb, const char *pathname, mrb_int flags, mrb_int mode)
762
761
  {
763
- mrb_value emsg;
764
762
  int fd, retry = FALSE;
765
763
  char* fname = mrb_locale_from_utf8(pathname, -1);
766
764
 
@@ -783,9 +781,7 @@ reopen:
783
781
  }
784
782
  }
785
783
 
786
- emsg = mrb_format(mrb, "open %S", mrb_str_new_cstr(mrb, pathname));
787
- mrb_str_modify(mrb, mrb_str_ptr(emsg));
788
- mrb_sys_fail(mrb, RSTRING_PTR(emsg));
784
+ mrb_sys_fail(mrb, RSTRING_CSTR(mrb, mrb_format(mrb, "open %s", pathname)));
789
785
  }
790
786
  mrb_locale_free(fname);
791
787
 
@@ -812,8 +808,8 @@ mrb_io_s_sysopen(mrb_state *mrb, mrb_value klass)
812
808
  perm = 0666;
813
809
  }
814
810
 
815
- pat = mrb_string_value_cstr(mrb, &path);
816
- flags = mrb_io_modestr_to_flags(mrb, mrb_string_value_cstr(mrb, &mode));
811
+ pat = RSTRING_CSTR(mrb, path);
812
+ flags = mrb_io_modestr_to_flags(mrb, RSTRING_CSTR(mrb, mode));
817
813
  modenum = mrb_io_flags_to_modenum(mrb, flags);
818
814
  fd = mrb_cloexec_open(mrb, pat, modenum, perm);
819
815
  return mrb_fixnum_value(fd);
@@ -912,11 +908,7 @@ mrb_io_syswrite(mrb_state *mrb, mrb_value io)
912
908
  }
913
909
 
914
910
  mrb_get_args(mrb, "S", &str);
915
- if (mrb_type(str) != MRB_TT_STRING) {
916
- buf = mrb_funcall(mrb, str, "to_s", 0);
917
- } else {
918
- buf = str;
919
- }
911
+ buf = str;
920
912
 
921
913
  if (fptr->fd2 == -1) {
922
914
  fd = fptr->fd;
@@ -955,7 +947,7 @@ mrb_value
955
947
  mrb_io_closed(mrb_state *mrb, mrb_value io)
956
948
  {
957
949
  struct mrb_io *fptr;
958
- fptr = (struct mrb_io *)mrb_get_datatype(mrb, io, &mrb_io_type);
950
+ fptr = (struct mrb_io *)mrb_data_get_ptr(mrb, io, &mrb_io_type);
959
951
  if (fptr == NULL || fptr->fd >= 0) {
960
952
  return mrb_false_value();
961
953
  }
@@ -1005,7 +997,7 @@ static int
1005
997
  mrb_io_read_data_pending(mrb_state *mrb, mrb_value io)
1006
998
  {
1007
999
  mrb_value buf = mrb_iv_get(mrb, io, mrb_intern_cstr(mrb, "@buf"));
1008
- if (mrb_type(buf) == MRB_TT_STRING && RSTRING_LEN(buf) > 0) {
1000
+ if (mrb_string_p(buf) && RSTRING_LEN(buf) > 0) {
1009
1001
  return 1;
1010
1002
  }
1011
1003
  return 0;
@@ -1068,7 +1060,7 @@ mrb_io_s_select(mrb_state *mrb, mrb_value klass)
1068
1060
  mrb_get_args(mrb, "*", &argv, &argc);
1069
1061
 
1070
1062
  if (argc < 1 || argc > 4) {
1071
- mrb_raisef(mrb, E_ARGUMENT_ERROR, "wrong number of arguments (%S for 1..4)", mrb_fixnum_value(argc));
1063
+ mrb_raisef(mrb, E_ARGUMENT_ERROR, "wrong number of arguments (%i for 1..4)", argc);
1072
1064
  }
1073
1065
 
1074
1066
  timeout = mrb_nil_value();
@@ -1299,6 +1291,27 @@ mrb_io_sync(mrb_state *mrb, mrb_value self)
1299
1291
  return mrb_bool_value(fptr->sync);
1300
1292
  }
1301
1293
 
1294
+ static mrb_value
1295
+ io_bufread(mrb_state *mrb, mrb_value self)
1296
+ {
1297
+ mrb_value str, str2;
1298
+ mrb_int len, newlen;
1299
+ struct RString *s;
1300
+ char *p;
1301
+
1302
+ mrb_get_args(mrb, "Si", &str, &len);
1303
+ s = RSTRING(str);
1304
+ mrb_str_modify(mrb, s);
1305
+ p = RSTR_PTR(s);
1306
+ str2 = mrb_str_new(mrb, p, len);
1307
+ newlen = RSTR_LEN(s)-len;
1308
+ memmove(p, p+len, newlen);
1309
+ p[newlen] = '\0';
1310
+ RSTR_SET_LEN(s, newlen);
1311
+
1312
+ return str2;
1313
+ }
1314
+
1302
1315
  void
1303
1316
  mrb_init_io(mrb_state *mrb)
1304
1317
  {
@@ -1308,23 +1321,23 @@ mrb_init_io(mrb_state *mrb)
1308
1321
  MRB_SET_INSTANCE_TT(io, MRB_TT_DATA);
1309
1322
 
1310
1323
  mrb_include_module(mrb, io, mrb_module_get(mrb, "Enumerable")); /* 15.2.20.3 */
1311
- mrb_define_class_method(mrb, io, "_popen", mrb_io_s_popen, MRB_ARGS_ANY());
1324
+ mrb_define_class_method(mrb, io, "_popen", mrb_io_s_popen, MRB_ARGS_ARG(1,2));
1312
1325
  mrb_define_class_method(mrb, io, "_sysclose", mrb_io_s_sysclose, MRB_ARGS_REQ(1));
1313
- mrb_define_class_method(mrb, io, "for_fd", mrb_io_s_for_fd, MRB_ARGS_ANY());
1314
- mrb_define_class_method(mrb, io, "select", mrb_io_s_select, MRB_ARGS_ANY());
1315
- mrb_define_class_method(mrb, io, "sysopen", mrb_io_s_sysopen, MRB_ARGS_ANY());
1326
+ mrb_define_class_method(mrb, io, "for_fd", mrb_io_s_for_fd, MRB_ARGS_ARG(1,2));
1327
+ mrb_define_class_method(mrb, io, "select", mrb_io_s_select, MRB_ARGS_ARG(1,3));
1328
+ mrb_define_class_method(mrb, io, "sysopen", mrb_io_s_sysopen, MRB_ARGS_ARG(1,2));
1316
1329
  #if !defined(_WIN32) && !(defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE)
1317
1330
  mrb_define_class_method(mrb, io, "_pipe", mrb_io_s_pipe, MRB_ARGS_NONE());
1318
1331
  #endif
1319
1332
 
1320
- mrb_define_method(mrb, io, "initialize", mrb_io_initialize, MRB_ARGS_ANY()); /* 15.2.20.5.21 (x)*/
1333
+ mrb_define_method(mrb, io, "initialize", mrb_io_initialize, MRB_ARGS_ARG(1,2)); /* 15.2.20.5.21 (x)*/
1321
1334
  mrb_define_method(mrb, io, "initialize_copy", mrb_io_initialize_copy, MRB_ARGS_REQ(1));
1322
1335
  mrb_define_method(mrb, io, "_check_readable", mrb_io_check_readable, MRB_ARGS_NONE());
1323
1336
  mrb_define_method(mrb, io, "isatty", mrb_io_isatty, MRB_ARGS_NONE());
1324
1337
  mrb_define_method(mrb, io, "sync", mrb_io_sync, MRB_ARGS_NONE());
1325
1338
  mrb_define_method(mrb, io, "sync=", mrb_io_set_sync, MRB_ARGS_REQ(1));
1326
- mrb_define_method(mrb, io, "sysread", mrb_io_sysread, MRB_ARGS_ANY());
1327
- mrb_define_method(mrb, io, "sysseek", mrb_io_sysseek, MRB_ARGS_REQ(1));
1339
+ mrb_define_method(mrb, io, "sysread", mrb_io_sysread, MRB_ARGS_ARG(1,1));
1340
+ mrb_define_method(mrb, io, "sysseek", mrb_io_sysseek, MRB_ARGS_ARG(1,1));
1328
1341
  mrb_define_method(mrb, io, "syswrite", mrb_io_syswrite, MRB_ARGS_REQ(1));
1329
1342
  mrb_define_method(mrb, io, "close", mrb_io_close, MRB_ARGS_NONE()); /* 15.2.20.5.1 */
1330
1343
  mrb_define_method(mrb, io, "close_write", mrb_io_close_write, MRB_ARGS_NONE());
@@ -1334,6 +1347,5 @@ mrb_init_io(mrb_state *mrb)
1334
1347
  mrb_define_method(mrb, io, "pid", mrb_io_pid, MRB_ARGS_NONE()); /* 15.2.20.5.2 */
1335
1348
  mrb_define_method(mrb, io, "fileno", mrb_io_fileno, MRB_ARGS_NONE());
1336
1349
 
1337
-
1338
- mrb_gv_set(mrb, mrb_intern_cstr(mrb, "$/"), mrb_str_new_cstr(mrb, "\n"));
1350
+ mrb_define_class_method(mrb, io, "_bufread", io_bufread, MRB_ARGS_REQ(2));
1339
1351
  }
@@ -1,15 +1,13 @@
1
1
  ##
2
2
  # File Test
3
3
 
4
- assert('File TEST SETUP') do
5
- MRubyIOTestUtil.io_test_setup
6
- end
4
+ MRubyIOTestUtil.io_test_setup
7
5
 
8
- assert('File', '15.2.21') do
6
+ assert('File.class', '15.2.21') do
9
7
  assert_equal Class, File.class
10
8
  end
11
9
 
12
- assert('File', '15.2.21.2') do
10
+ assert('File.superclass', '15.2.21.2') do
13
11
  assert_equal IO, File.superclass
14
12
  end
15
13
 
@@ -35,6 +33,7 @@
35
33
  assert_equal 'a', File.basename('/a/')
36
34
  assert_equal 'b', File.basename('/a/b')
37
35
  assert_equal 'b', File.basename('../a/b')
36
+ assert_raise(ArgumentError) { File.basename("/a/b\0") }
38
37
  end
39
38
 
40
39
  assert('File.dirname') do
@@ -108,6 +107,8 @@
108
107
  MRubyIOTestUtil.rmdir dir
109
108
  end
110
109
  end
110
+
111
+ assert_raise(ArgumentError) { File.realpath("TO\0DO") }
111
112
  end
112
113
 
113
114
  assert("File.readlink") do
@@ -178,20 +179,25 @@
178
179
 
179
180
  assert('File.symlink') do
180
181
  target_name = "/usr/bin"
181
- symlink_name = "test-bin-dummy"
182
182
  if !File.exist?(target_name)
183
183
  skip("target directory of File.symlink is not found")
184
- else
185
- begin
186
- assert_equal 0, File.symlink(target_name, symlink_name)
187
- begin
188
- assert_equal true, File.symlink?(symlink_name)
189
- ensure
190
- File.delete symlink_name
191
- end
192
- rescue NotImplementedError => e
193
- skip e.message
194
- end
184
+ end
185
+
186
+ begin
187
+ tmpdir = MRubyIOTestUtil.mkdtemp("mruby-io-test.XXXXXX")
188
+ rescue => e
189
+ skip e.message
190
+ end
191
+
192
+ symlink_name = "#{tmpdir}/test-bin-dummy"
193
+ begin
194
+ assert_equal 0, File.symlink(target_name, symlink_name)
195
+ assert_equal true, File.symlink?(symlink_name)
196
+ rescue NotImplementedError => e
197
+ skip e.message
198
+ ensure
199
+ File.delete symlink_name rescue nil
200
+ MRubyIOTestUtil.rmdir tmpdir rescue nil
195
201
  end
196
202
  end
197
203
 
@@ -204,6 +210,4 @@
204
210
  end
205
211
  end
206
212
 
207
- assert('File TEST CLEANUP') do
208
- assert_nil MRubyIOTestUtil.io_test_cleanup
209
- end
213
+ MRubyIOTestUtil.io_test_cleanup