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
@@ -102,25 +102,28 @@ patch_irep(mrb_state *mrb, mrb_irep *irep, int bnest, mrb_irep *top)
102
102
  uint8_t c;
103
103
  mrb_code insn;
104
104
  int argc = irep_argc(irep);
105
+ mrb_code *iseq = (mrb_code *)irep->iseq;
106
+
107
+ mrb_assert((irep->flags & MRB_ISEQ_NO_FREE) == 0);
105
108
 
106
109
  for (i = 0; i < irep->ilen; ) {
107
- insn = irep->iseq[i];
110
+ insn = iseq[i];
108
111
  switch(insn){
109
112
  case OP_EPUSH:
110
- b = PEEK_S(irep->iseq+i+1);
111
- patch_irep(mrb, irep->reps[b], bnest + 1, top);
113
+ a = PEEK_B(iseq+i+1);
114
+ patch_irep(mrb, irep->reps[a], bnest + 1, top);
112
115
  break;
113
116
 
114
117
  case OP_LAMBDA:
115
118
  case OP_BLOCK:
116
- a = PEEK_B(irep->iseq+i+1);
117
- b = PEEK_B(irep->iseq+i+2);
119
+ a = PEEK_B(iseq+i+1);
120
+ b = PEEK_B(iseq+i+2);
118
121
  patch_irep(mrb, irep->reps[b], bnest + 1, top);
119
122
  break;
120
123
 
121
124
  case OP_SEND:
122
- b = PEEK_B(irep->iseq+i+2);
123
- c = PEEK_B(irep->iseq+i+3);
125
+ b = PEEK_B(iseq+i+2);
126
+ c = PEEK_B(iseq+i+3);
124
127
  if (c != 0) {
125
128
  break;
126
129
  }
@@ -128,24 +131,24 @@ patch_irep(mrb_state *mrb, mrb_irep *irep, int bnest, mrb_irep *top)
128
131
  uint16_t arg = search_variable(mrb, irep->syms[b], bnest);
129
132
  if (arg != 0) {
130
133
  /* must replace */
131
- irep->iseq[i] = OP_GETUPVAR;
132
- irep->iseq[i+2] = arg >> 8;
133
- irep->iseq[i+3] = arg & 0xff;
134
+ iseq[i] = OP_GETUPVAR;
135
+ iseq[i+2] = arg >> 8;
136
+ iseq[i+3] = arg & 0xff;
134
137
  }
135
138
  }
136
139
  break;
137
140
 
138
141
  case OP_MOVE:
139
- a = PEEK_B(irep->iseq+i+1);
140
- b = PEEK_B(irep->iseq+i+2);
142
+ a = PEEK_B(iseq+i+1);
143
+ b = PEEK_B(iseq+i+2);
141
144
  /* src part */
142
145
  if (potential_upvar_p(irep->lv, b, argc, irep->nlocals)) {
143
146
  uint16_t arg = search_variable(mrb, irep->lv[b - 1].name, bnest);
144
147
  if (arg != 0) {
145
148
  /* must replace */
146
- irep->iseq[i] = insn = OP_GETUPVAR;
147
- irep->iseq[i+2] = arg >> 8;
148
- irep->iseq[i+3] = arg & 0xff;
149
+ iseq[i] = insn = OP_GETUPVAR;
150
+ iseq[i+2] = arg >> 8;
151
+ iseq[i+3] = arg & 0xff;
149
152
  }
150
153
  }
151
154
  /* dst part */
@@ -153,18 +156,18 @@ patch_irep(mrb_state *mrb, mrb_irep *irep, int bnest, mrb_irep *top)
153
156
  uint16_t arg = search_variable(mrb, irep->lv[a - 1].name, bnest);
154
157
  if (arg != 0) {
155
158
  /* must replace */
156
- irep->iseq[i] = insn = OP_SETUPVAR;
157
- irep->iseq[i+1] = (mrb_code)b;
158
- irep->iseq[i+2] = arg >> 8;
159
- irep->iseq[i+3] = arg & 0xff;
159
+ iseq[i] = insn = OP_SETUPVAR;
160
+ iseq[i+1] = (mrb_code)b;
161
+ iseq[i+2] = arg >> 8;
162
+ iseq[i+3] = arg & 0xff;
160
163
  }
161
164
  }
162
165
  break;
163
166
 
164
167
  case OP_GETUPVAR:
165
- a = PEEK_B(irep->iseq+i+1);
166
- b = PEEK_B(irep->iseq+i+2);
167
- c = PEEK_B(irep->iseq+i+3);
168
+ a = PEEK_B(iseq+i+1);
169
+ b = PEEK_B(iseq+i+2);
170
+ c = PEEK_B(iseq+i+3);
168
171
  {
169
172
  int lev = c+1;
170
173
  mrb_irep *tmp = search_irep(top, bnest, lev, irep);
@@ -172,18 +175,18 @@ patch_irep(mrb_state *mrb, mrb_irep *irep, int bnest, mrb_irep *top)
172
175
  uint16_t arg = search_variable(mrb, tmp->lv[b-1].name, bnest);
173
176
  if (arg != 0) {
174
177
  /* must replace */
175
- irep->iseq[i] = OP_GETUPVAR;
176
- irep->iseq[i+2] = arg >> 8;
177
- irep->iseq[i+3] = arg & 0xff;
178
+ iseq[i] = OP_GETUPVAR;
179
+ iseq[i+2] = arg >> 8;
180
+ iseq[i+3] = arg & 0xff;
178
181
  }
179
182
  }
180
183
  }
181
184
  break;
182
185
 
183
186
  case OP_SETUPVAR:
184
- a = PEEK_B(irep->iseq+i+1);
185
- b = PEEK_B(irep->iseq+i+2);
186
- c = PEEK_B(irep->iseq+i+3);
187
+ a = PEEK_B(iseq+i+1);
188
+ b = PEEK_B(iseq+i+2);
189
+ c = PEEK_B(iseq+i+3);
187
190
  {
188
191
  int lev = c+1;
189
192
  mrb_irep *tmp = search_irep(top, bnest, lev, irep);
@@ -191,25 +194,25 @@ patch_irep(mrb_state *mrb, mrb_irep *irep, int bnest, mrb_irep *top)
191
194
  uint16_t arg = search_variable(mrb, tmp->lv[b-1].name, bnest);
192
195
  if (arg != 0) {
193
196
  /* must replace */
194
- irep->iseq[i] = OP_SETUPVAR;
195
- irep->iseq[i+1] = a;
196
- irep->iseq[i+2] = arg >> 8;
197
- irep->iseq[i+3] = arg & 0xff;
197
+ iseq[i] = OP_SETUPVAR;
198
+ iseq[i+1] = a;
199
+ iseq[i+2] = arg >> 8;
200
+ iseq[i+3] = arg & 0xff;
198
201
  }
199
202
  }
200
203
  }
201
204
  break;
202
205
 
203
206
  case OP_EXT1:
204
- insn = PEEK_B(irep->iseq+i+1);
207
+ insn = PEEK_B(iseq+i+1);
205
208
  i += mrb_insn_size1[insn]+1;
206
209
  continue;
207
210
  case OP_EXT2:
208
- insn = PEEK_B(irep->iseq+i+1);
211
+ insn = PEEK_B(iseq+i+1);
209
212
  i += mrb_insn_size2[insn]+1;
210
213
  continue;
211
214
  case OP_EXT3:
212
- insn = PEEK_B(irep->iseq+i+1);
215
+ insn = PEEK_B(iseq+i+1);
213
216
  i += mrb_insn_size3[insn]+1;
214
217
  continue;
215
218
  }
@@ -235,7 +238,7 @@ create_proc_from_string(mrb_state *mrb, char *s, mrb_int len, mrb_value binding,
235
238
  }
236
239
 
237
240
  cxt = mrbc_context_new(mrb);
238
- cxt->lineno = (short)line;
241
+ cxt->lineno = (uint16_t)line;
239
242
 
240
243
  mrbc_filename(mrb, cxt, file ? file : "(eval)");
241
244
  cxt->capture_errors = TRUE;
@@ -254,15 +257,15 @@ create_proc_from_string(mrb_state *mrb, char *s, mrb_int len, mrb_value binding,
254
257
  mrb_value str;
255
258
 
256
259
  if (file) {
257
- str = mrb_format(mrb, " file %S line %S: %S",
258
- mrb_str_new_cstr(mrb, file),
259
- mrb_fixnum_value(p->error_buffer[0].lineno),
260
- mrb_str_new_cstr(mrb, p->error_buffer[0].message));
260
+ str = mrb_format(mrb, "file %s line %d: %s",
261
+ file,
262
+ p->error_buffer[0].lineno,
263
+ p->error_buffer[0].message);
261
264
  }
262
265
  else {
263
- str = mrb_format(mrb, " line %S: %S",
264
- mrb_fixnum_value(p->error_buffer[0].lineno),
265
- mrb_str_new_cstr(mrb, p->error_buffer[0].message));
266
+ str = mrb_format(mrb, "line %d: %s",
267
+ p->error_buffer[0].lineno,
268
+ p->error_buffer[0].message);
266
269
  }
267
270
  mrb_parser_free(p);
268
271
  mrbc_context_free(mrb, cxt);
@@ -387,7 +390,7 @@ void
387
390
  mrb_mruby_eval_gem_init(mrb_state* mrb)
388
391
  {
389
392
  mrb_define_module_function(mrb, mrb->kernel_module, "eval", f_eval, MRB_ARGS_ARG(1, 3));
390
- mrb_define_method(mrb, mrb->kernel_module, "instance_eval", f_instance_eval, MRB_ARGS_ARG(1, 2));
393
+ mrb_define_method(mrb, mrb_class_get(mrb, "BasicObject"), "instance_eval", f_instance_eval, MRB_ARGS_OPT(3)|MRB_ARGS_BLOCK());
391
394
  }
392
395
 
393
396
  void
@@ -80,7 +80,7 @@ def const_string
80
80
  assert_equal('class') { obj.const_string }
81
81
  end
82
82
 
83
- assert('Object#instance_eval with begin-rescue-ensure execution order') do
83
+ assert('BasicObject#instance_eval with begin-rescue-ensure execution order') do
84
84
  class HellRaiser
85
85
  def raise_hell
86
86
  order = [:enter_raise_hell]
@@ -100,7 +100,7 @@ def raise_hell
100
100
  assert_equal([:enter_raise_hell, :begin, :rescue, :ensure], hell_raiser.raise_hell)
101
101
  end
102
102
 
103
- assert('Kernel#instance_eval() to define singleton methods Issue #3141') do
103
+ assert('BasicObject#instance_eval to define singleton methods Issue #3141') do
104
104
  foo_class = Class.new do
105
105
  def bar(x)
106
106
  instance_eval "def baz; #{x}; end"
@@ -4,12 +4,17 @@
4
4
  static mrb_value
5
5
  f_exit(mrb_state *mrb, mrb_value self)
6
6
  {
7
- mrb_int i = EXIT_SUCCESS;
7
+ mrb_value status = mrb_true_value();
8
+ int istatus;
9
+
10
+ mrb_get_args(mrb, "|o", &status);
11
+ istatus = mrb_true_p(status) ? EXIT_SUCCESS :
12
+ mrb_false_p(status) ? EXIT_FAILURE :
13
+ (int)mrb_int(mrb, status);
14
+ exit(istatus);
8
15
 
9
- mrb_get_args(mrb, "|i", &i);
10
- exit((int)i);
11
16
  /* not reached */
12
- return mrb_nil_value();
17
+ return status;
13
18
  }
14
19
 
15
20
  void
@@ -72,14 +72,11 @@ fiber_init(mrb_state *mrb, mrb_value self)
72
72
  mrb_value blk;
73
73
  size_t slen;
74
74
 
75
- mrb_get_args(mrb, "&", &blk);
75
+ mrb_get_args(mrb, "&!", &blk);
76
76
 
77
77
  if (f->cxt) {
78
78
  mrb_raise(mrb, E_RUNTIME_ERROR, "cannot initialize twice");
79
79
  }
80
- if (mrb_nil_p(blk)) {
81
- mrb_raise(mrb, E_ARGUMENT_ERROR, "tried to create Fiber object without a block");
82
- }
83
80
  p = mrb_proc_ptr(blk);
84
81
  if (MRB_PROC_CFUNC_P(p)) {
85
82
  mrb_raise(mrb, E_FIBER_ERROR, "tried to create Fiber from C defined method");
@@ -191,14 +188,21 @@ fiber_switch(mrb_state *mrb, mrb_value self, mrb_int len, const mrb_value *a, mr
191
188
 
192
189
  fiber_check_cfunc(mrb, c);
193
190
  status = c->status;
194
- if (resume && status == MRB_FIBER_TRANSFERRED) {
195
- mrb_raise(mrb, E_FIBER_ERROR, "resuming transferred fiber");
196
- }
197
- if (status == MRB_FIBER_RUNNING || status == MRB_FIBER_RESUMED) {
191
+ switch (status) {
192
+ case MRB_FIBER_TRANSFERRED:
193
+ if (resume) {
194
+ mrb_raise(mrb, E_FIBER_ERROR, "resuming transferred fiber");
195
+ }
196
+ break;
197
+ case MRB_FIBER_RUNNING:
198
+ case MRB_FIBER_RESUMED:
198
199
  mrb_raise(mrb, E_FIBER_ERROR, "double resume");
199
- }
200
- if (status == MRB_FIBER_TERMINATED) {
200
+ break;
201
+ case MRB_FIBER_TERMINATED:
201
202
  mrb_raise(mrb, E_FIBER_ERROR, "resuming dead fiber");
203
+ break;
204
+ default:
205
+ break;
202
206
  }
203
207
  old_c->status = resume ? MRB_FIBER_RESUMED : MRB_FIBER_TRANSFERRED;
204
208
  c->prev = resume ? mrb->c : (c->prev ? c->prev : mrb->root_c);
@@ -290,7 +294,7 @@ fiber_eq(mrb_state *mrb, mrb_value self)
290
294
  mrb_value other;
291
295
  mrb_get_args(mrb, "o", &other);
292
296
 
293
- if (mrb_type(other) != MRB_TT_FIBER) {
297
+ if (!mrb_fiber_p(other)) {
294
298
  return mrb_false_value();
295
299
  }
296
300
  return mrb_bool_value(fiber_ptr(self) == fiber_ptr(other));
@@ -405,7 +409,7 @@ mrb_mruby_fiber_gem_init(mrb_state* mrb)
405
409
  c = mrb_define_class(mrb, "Fiber", mrb->object_class);
406
410
  MRB_SET_INSTANCE_TT(c, MRB_TT_FIBER);
407
411
 
408
- mrb_define_method(mrb, c, "initialize", fiber_init, MRB_ARGS_NONE());
412
+ mrb_define_method(mrb, c, "initialize", fiber_init, MRB_ARGS_NONE()|MRB_ARGS_BLOCK());
409
413
  mrb_define_method(mrb, c, "resume", fiber_resume, MRB_ARGS_ANY());
410
414
  mrb_define_method(mrb, c, "transfer", fiber_transfer, MRB_ARGS_ANY());
411
415
  mrb_define_method(mrb, c, "alive?", fiber_alive_p, MRB_ARGS_NONE());
@@ -76,7 +76,7 @@
76
76
  end
77
77
 
78
78
  assert('Fiber with splat in the block argument list') {
79
- Fiber.new{|*x|x}.resume(1) == [1]
79
+ assert_equal([1], Fiber.new{|*x|x}.resume(1))
80
80
  }
81
81
 
82
82
  assert('Fiber raises on resume when dead') do
@@ -2,7 +2,5 @@
2
2
  spec.license = 'MIT'
3
3
  spec.author = 'mruby developers'
4
4
  spec.summary = 'Hash class extension'
5
- spec.add_dependency 'mruby-enum-ext', core: 'mruby-enum-ext'
6
5
  spec.add_dependency 'mruby-array-ext', core: 'mruby-array-ext'
7
- spec.add_test_dependency 'mruby-enumerator', core: 'mruby-enumerator'
8
6
  end
@@ -494,4 +494,7 @@ def fetch_values(*keys, &block)
494
494
  self.fetch(k, &block)
495
495
  end
496
496
  end
497
+
498
+ alias filter select
499
+ alias filter! select!
497
500
  end
@@ -269,10 +269,8 @@
269
269
  h.transform_keys{|k| k+"!"})
270
270
  assert_equal({1 => 100, 2 => 200},
271
271
  h.transform_keys{|k|k.to_i})
272
- assert_equal({"1.0" => 100, "2.1" => 200},
273
- h.transform_keys.with_index{|k, i| "#{k}.#{i}"})
274
- assert_equal(h, h.transform_keys!{|k|k.to_i})
275
- assert_equal(h, {1 => 100, 2 => 200})
272
+ assert_same(h, h.transform_keys!{|k|k.to_i})
273
+ assert_equal({1 => 100, 2 => 200}, h)
276
274
  end
277
275
 
278
276
  assert("Hash#transform_values") do
@@ -281,9 +279,7 @@
281
279
  h.transform_values{|v| v * v + 1})
282
280
  assert_equal({a: "1", b: "2", c: "3"},
283
281
  h.transform_values{|v|v.to_s})
284
- assert_equal({a: "1.0", b: "2.1", c: "3.2"},
285
- h.transform_values.with_index{|v, i| "#{v}.#{i}"})
286
- assert_equal(h, h.transform_values!{|v|v.to_s})
282
+ assert_same(h, h.transform_values!{|v|v.to_s})
287
283
  assert_equal({a: "1", b: "2", c: "3"}, h)
288
284
  end
289
285
 
@@ -1,7 +1,5 @@
1
1
  mruby-io
2
2
  ========
3
- [![Build Status](https://travis-ci.org/iij/mruby-io.svg?branch=master)](https://travis-ci.org/iij/mruby-io)
4
-
5
3
 
6
4
  `IO` and `File` classes for mruby
7
5
 
@@ -9,7 +7,7 @@ mruby-io
9
7
  Add the line below to your `build_config.rb`:
10
8
 
11
9
  ```
12
- conf.gem :github => 'iij/mruby-io'
10
+ conf.gem core: 'mruby-io'
13
11
  ```
14
12
 
15
13
  ## Implemented methods
@@ -6,7 +6,7 @@
6
6
  spec.cc.include_paths << "#{build.root}/src"
7
7
 
8
8
  case RUBY_PLATFORM
9
- when /mingw|mswin/
9
+ when /mingw|mswin|msys/
10
10
  spec.linker.libraries += ['Ws2_32']
11
11
  #spec.cc.include_paths += ["C:/Windows/system/include"]
12
12
  spec.linker.library_paths += ["C:/Windows/system"]
@@ -1,9 +1,4 @@
1
1
  class File < IO
2
- class FileError < Exception; end
3
- class NoFileError < FileError; end
4
- class UnableToStat < FileError; end
5
- class PermissionError < FileError; end
6
-
7
2
  attr_accessor :path
8
3
 
9
4
  def initialize(fd_or_path, mode = "r", perm = 0666)
@@ -123,8 +123,8 @@ def hash
123
123
 
124
124
  def write(string)
125
125
  str = string.is_a?(String) ? string : string.to_s
126
- return str.size unless str.size > 0
127
- if 0 < @buf.length
126
+ return 0 if str.empty?
127
+ unless @buf.empty?
128
128
  # reset real pos ignore buf
129
129
  seek(pos, SEEK_SET)
130
130
  end
@@ -140,8 +140,8 @@ def <<(str)
140
140
  def eof?
141
141
  _check_readable
142
142
  begin
143
- buf = _read_buf
144
- return buf.size == 0
143
+ _read_buf
144
+ return @buf.empty?
145
145
  rescue EOFError
146
146
  return true
147
147
  end
@@ -150,7 +150,7 @@ def eof?
150
150
 
151
151
  def pos
152
152
  raise IOError if closed?
153
- sysseek(0, SEEK_CUR) - @buf.length
153
+ sysseek(0, SEEK_CUR) - @buf.bytesize
154
154
  end
155
155
  alias_method :tell, :pos
156
156
 
@@ -170,8 +170,13 @@ def seek(i, whence = SEEK_SET)
170
170
  end
171
171
 
172
172
  def _read_buf
173
- return @buf if @buf && @buf.size > 0
174
- @buf = sysread(BUF_SIZE)
173
+ return @buf if @buf && @buf.bytesize >= 4 # maximum UTF-8 character is 4 bytes
174
+ @buf ||= ""
175
+ begin
176
+ @buf += sysread(BUF_SIZE)
177
+ rescue EOFError => e
178
+ raise e if @buf.empty?
179
+ end
175
180
  end
176
181
 
177
182
  def ungetc(substr)
@@ -207,9 +212,8 @@ def read(length = nil, outbuf = "")
207
212
  end
208
213
 
209
214
  if length
210
- consume = (length <= @buf.size) ? length : @buf.size
211
- array.push @buf[0, consume]
212
- @buf = @buf[consume, @buf.size - consume]
215
+ consume = (length <= @buf.bytesize) ? length : @buf.bytesize
216
+ array.push IO._bufread(@buf, consume)
213
217
  length -= consume
214
218
  break if length == 0
215
219
  else
@@ -226,12 +230,12 @@ def read(length = nil, outbuf = "")
226
230
  end
227
231
  end
228
232
 
229
- def readline(arg = $/, limit = nil)
233
+ def readline(arg = "\n", limit = nil)
230
234
  case arg
231
235
  when String
232
236
  rs = arg
233
237
  when Fixnum
234
- rs = $/
238
+ rs = "\n"
235
239
  limit = arg
236
240
  else
237
241
  raise ArgumentError
@@ -242,7 +246,7 @@ def readline(arg = $/, limit = nil)
242
246
  end
243
247
 
244
248
  if rs == ""
245
- rs = $/ + $/
249
+ rs = "\n\n"
246
250
  end
247
251
 
248
252
  array = []
@@ -256,12 +260,12 @@ def readline(arg = $/, limit = nil)
256
260
 
257
261
  if limit && limit <= @buf.size
258
262
  array.push @buf[0, limit]
259
- @buf = @buf[limit, @buf.size - limit]
263
+ @buf[0, limit] = ""
260
264
  break
261
265
  elsif idx = @buf.index(rs)
262
266
  len = idx + rs.size
263
267
  array.push @buf[0, len]
264
- @buf = @buf[len, @buf.size - len]
268
+ @buf[0, len] = ""
265
269
  break
266
270
  else
267
271
  array.push @buf
@@ -285,7 +289,7 @@ def gets(*args)
285
289
  def readchar
286
290
  _read_buf
287
291
  c = @buf[0]
288
- @buf = @buf[1, @buf.size]
292
+ @buf[0] = ""
289
293
  c
290
294
  end
291
295
 
@@ -299,6 +303,8 @@ def getc
299
303
 
300
304
  # 15.2.20.5.3
301
305
  def each(&block)
306
+ return to_enum unless block
307
+
302
308
  while line = self.gets
303
309
  block.call(line)
304
310
  end
@@ -307,6 +313,8 @@ def each(&block)
307
313
 
308
314
  # 15.2.20.5.4
309
315
  def each_byte(&block)
316
+ return to_enum(:each_byte) unless block
317
+
310
318
  while char = self.getc
311
319
  block.call(char)
312
320
  end
@@ -364,25 +372,3 @@ def printf(*args)
364
372
  $stdin = STDIN
365
373
  $stdout = STDOUT
366
374
  $stderr = STDERR
367
-
368
- module Kernel
369
- def print(*args)
370
- $stdout.print(*args)
371
- end
372
-
373
- def puts(*args)
374
- $stdout.puts(*args)
375
- end
376
-
377
- def printf(*args)
378
- $stdout.printf(*args)
379
- end
380
-
381
- def gets(*args)
382
- $stdin.gets(*args)
383
- end
384
-
385
- def getc(*args)
386
- $stdin.getc(*args)
387
- end
388
- end