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
@@ -20,7 +20,7 @@ Date: Tue, 21 May 2013 04:31:30 GMT
20
20
  ```
21
21
 
22
22
  ## Requirement
23
- - [iij/mruby-io](https://github.com/iij/mruby-io) mrbgem
23
+ - [mruby-io](https://github.com/mruby/mruby/tree/master/mrbgems/mruby-io) mrbgem
24
24
  - [iij/mruby-mtest](https://github.com/iij/mruby-mtest) mrgbem to run tests
25
25
  - system must have RFC3493 basic socket interface
26
26
  - and some POSIX API...
@@ -38,9 +38,10 @@
38
38
  #include "mruby/array.h"
39
39
  #include "mruby/class.h"
40
40
  #include "mruby/data.h"
41
+ #include "mruby/numeric.h"
41
42
  #include "mruby/string.h"
42
43
  #include "mruby/variable.h"
43
- #include "error.h"
44
+ #include "mruby/error.h"
44
45
 
45
46
  #include "mruby/ext/io.h"
46
47
 
@@ -130,7 +131,7 @@ mrb_addrinfo_getaddrinfo(mrb_state *mrb, mrb_value klass)
130
131
  mrb_get_args(mrb, "oo|oooi", &nodename, &service, &family, &socktype, &protocol, &flags);
131
132
 
132
133
  if (mrb_string_p(nodename)) {
133
- hostname = mrb_str_to_cstr(mrb, nodename);
134
+ hostname = RSTRING_CSTR(mrb, nodename);
134
135
  } else if (mrb_nil_p(nodename)) {
135
136
  hostname = NULL;
136
137
  } else {
@@ -138,9 +139,9 @@ mrb_addrinfo_getaddrinfo(mrb_state *mrb, mrb_value klass)
138
139
  }
139
140
 
140
141
  if (mrb_string_p(service)) {
141
- servname = mrb_str_to_cstr(mrb, service);
142
+ servname = RSTRING_CSTR(mrb, service);
142
143
  } else if (mrb_fixnum_p(service)) {
143
- servname = mrb_str_to_cstr(mrb, mrb_funcall(mrb, service, "to_s", 0));
144
+ servname = RSTRING_PTR(mrb_fixnum_to_str(mrb, service, 10));
144
145
  } else if (mrb_nil_p(service)) {
145
146
  servname = NULL;
146
147
  } else {
@@ -170,7 +171,7 @@ mrb_addrinfo_getaddrinfo(mrb_state *mrb, mrb_value klass)
170
171
 
171
172
  error = getaddrinfo(hostname, servname, &hints, &res0);
172
173
  if (error) {
173
- mrb_raisef(mrb, E_SOCKET_ERROR, "getaddrinfo: %S", mrb_str_new_cstr(mrb, gai_strerror(error)));
174
+ mrb_raisef(mrb, E_SOCKET_ERROR, "getaddrinfo: %s", gai_strerror(error));
174
175
  }
175
176
  mrb_cv_set(mrb, klass, mrb_intern_lit(mrb, "_lastai"), mrb_cptr_value(mrb, res0));
176
177
 
@@ -205,7 +206,7 @@ mrb_addrinfo_getnameinfo(mrb_state *mrb, mrb_value self)
205
206
  }
206
207
  error = getnameinfo((struct sockaddr *)RSTRING_PTR(sastr), (socklen_t)RSTRING_LEN(sastr), RSTRING_PTR(host), NI_MAXHOST, RSTRING_PTR(serv), NI_MAXSERV, (int)flags);
207
208
  if (error) {
208
- mrb_raisef(mrb, E_SOCKET_ERROR, "getnameinfo: %S", mrb_str_new_cstr(mrb, gai_strerror(error)));
209
+ mrb_raisef(mrb, E_SOCKET_ERROR, "getnameinfo: %s", gai_strerror(error));
209
210
  }
210
211
  ary = mrb_ary_new_capa(mrb, 2);
211
212
  mrb_str_resize(mrb, host, strlen(RSTRING_PTR(host)));
@@ -454,7 +455,7 @@ mrb_basicsocket_setsockopt(mrb_state *mrb, mrb_value self)
454
455
  level = mrb_fixnum(so);
455
456
  if (mrb_string_p(optval)) {
456
457
  /* that's good */
457
- } else if (mrb_type(optval) == MRB_TT_TRUE || mrb_type(optval) == MRB_TT_FALSE) {
458
+ } else if (mrb_true_p(optval) || mrb_false_p(optval)) {
458
459
  mrb_int i = mrb_test(optval) ? 1 : 0;
459
460
  optval = mrb_str_new(mrb, (char*)&i, sizeof(i));
460
461
  } else if (mrb_fixnum_p(optval)) {
@@ -475,7 +476,7 @@ mrb_basicsocket_setsockopt(mrb_state *mrb, mrb_value self)
475
476
  optname = mrb_fixnum(mrb_funcall(mrb, so, "optname", 0));
476
477
  optval = mrb_funcall(mrb, so, "data", 0);
477
478
  } else {
478
- mrb_raisef(mrb, E_ARGUMENT_ERROR, "wrong number of arguments (%S for 3)", mrb_fixnum_value(argc));
479
+ mrb_raisef(mrb, E_ARGUMENT_ERROR, "wrong number of arguments (%i for 3)", argc);
479
480
  }
480
481
 
481
482
  s = socket_fd(mrb, self);
@@ -701,7 +702,7 @@ mrb_socket_sockaddr_un(mrb_state *mrb, mrb_value klass)
701
702
 
702
703
  mrb_get_args(mrb, "S", &path);
703
704
  if ((size_t)RSTRING_LEN(path) > sizeof(sunp->sun_path) - 1) {
704
- mrb_raisef(mrb, E_ARGUMENT_ERROR, "too long unix socket path (max: %S bytes)", mrb_fixnum_value(sizeof(sunp->sun_path) - 1));
705
+ mrb_raisef(mrb, E_ARGUMENT_ERROR, "too long unix socket path (max: %d bytes)", (int)sizeof(sunp->sun_path) - 1);
705
706
  }
706
707
  s = mrb_str_buf_new(mrb, sizeof(struct sockaddr_un));
707
708
  sunp = (struct sockaddr_un *)RSTRING_PTR(s);
@@ -18,8 +18,8 @@ mrb_mruby_sprintf_gem_init(mrb_state* mrb)
18
18
  }
19
19
  krn = mrb->kernel_module;
20
20
 
21
- mrb_define_method(mrb, krn, "sprintf", mrb_f_sprintf, MRB_ARGS_ANY());
22
- mrb_define_method(mrb, krn, "format", mrb_f_sprintf, MRB_ARGS_ANY());
21
+ mrb_define_method(mrb, krn, "sprintf", mrb_f_sprintf, MRB_ARGS_REQ(1)|MRB_ARGS_REST());
22
+ mrb_define_method(mrb, krn, "format", mrb_f_sprintf, MRB_ARGS_REQ(1)|MRB_ARGS_REST());
23
23
  }
24
24
 
25
25
  void
@@ -81,7 +81,7 @@ mrb_fix2binstr(mrb_state *mrb, mrb_value x, int base)
81
81
  char d;
82
82
 
83
83
  if (base != 2) {
84
- mrb_raisef(mrb, E_ARGUMENT_ERROR, "invalid radix %S", mrb_fixnum_value(base));
84
+ mrb_raisef(mrb, E_ARGUMENT_ERROR, "invalid radix %d", base);
85
85
  }
86
86
  if (val == 0) {
87
87
  return mrb_str_new_lit(mrb, "0");
@@ -144,10 +144,10 @@ check_next_arg(mrb_state *mrb, int posarg, int nextarg)
144
144
  {
145
145
  switch (posarg) {
146
146
  case -1:
147
- mrb_raisef(mrb, E_ARGUMENT_ERROR, "unnumbered(%S) mixed with numbered", mrb_fixnum_value(nextarg));
147
+ mrb_raisef(mrb, E_ARGUMENT_ERROR, "unnumbered(%d) mixed with numbered", nextarg);
148
148
  break;
149
149
  case -2:
150
- mrb_raisef(mrb, E_ARGUMENT_ERROR, "unnumbered(%S) mixed with named", mrb_fixnum_value(nextarg));
150
+ mrb_raisef(mrb, E_ARGUMENT_ERROR, "unnumbered(%d) mixed with named", nextarg);
151
151
  break;
152
152
  default:
153
153
  break;
@@ -155,29 +155,29 @@ check_next_arg(mrb_state *mrb, int posarg, int nextarg)
155
155
  }
156
156
 
157
157
  static void
158
- check_pos_arg(mrb_state *mrb, mrb_int posarg, mrb_int n)
158
+ check_pos_arg(mrb_state *mrb, int posarg, mrb_int n)
159
159
  {
160
160
  if (posarg > 0) {
161
- mrb_raisef(mrb, E_ARGUMENT_ERROR, "numbered(%S) after unnumbered(%S)",
162
- mrb_fixnum_value(n), mrb_fixnum_value(posarg));
161
+ mrb_raisef(mrb, E_ARGUMENT_ERROR, "numbered(%i) after unnumbered(%d)",
162
+ n, posarg);
163
163
  }
164
164
  if (posarg == -2) {
165
- mrb_raisef(mrb, E_ARGUMENT_ERROR, "numbered(%S) after named", mrb_fixnum_value(n));
165
+ mrb_raisef(mrb, E_ARGUMENT_ERROR, "numbered(%i) after named", n);
166
166
  }
167
167
  if (n < 1) {
168
- mrb_raisef(mrb, E_ARGUMENT_ERROR, "invalid index - %S$", mrb_fixnum_value(n));
168
+ mrb_raisef(mrb, E_ARGUMENT_ERROR, "invalid index - %i$", n);
169
169
  }
170
170
  }
171
171
 
172
172
  static void
173
- check_name_arg(mrb_state *mrb, int posarg, const char *name, mrb_int len)
173
+ check_name_arg(mrb_state *mrb, int posarg, const char *name, size_t len)
174
174
  {
175
175
  if (posarg > 0) {
176
- mrb_raisef(mrb, E_ARGUMENT_ERROR, "named%S after unnumbered(%S)",
177
- mrb_str_new(mrb, (name), (len)), mrb_fixnum_value(posarg));
176
+ mrb_raisef(mrb, E_ARGUMENT_ERROR, "named%l after unnumbered(%d)",
177
+ name, len, posarg);
178
178
  }
179
179
  if (posarg == -1) {
180
- mrb_raisef(mrb, E_ARGUMENT_ERROR, "named%S after numbered", mrb_str_new(mrb, (name), (len)));
180
+ mrb_raisef(mrb, E_ARGUMENT_ERROR, "named%l after numbered", name, len);
181
181
  }
182
182
  }
183
183
 
@@ -580,7 +580,7 @@ mrb_str_format(mrb_state *mrb, mrb_int argc, const mrb_value *argv, mrb_value fm
580
580
  retry:
581
581
  switch (*p) {
582
582
  default:
583
- mrb_raisef(mrb, E_ARGUMENT_ERROR, "malformed format string - \\%%S", mrb_str_new(mrb, p, 1));
583
+ mrb_raisef(mrb, E_ARGUMENT_ERROR, "malformed format string - %%%c", *p);
584
584
  break;
585
585
 
586
586
  case ' ':
@@ -619,7 +619,7 @@ retry:
619
619
  GETNUM(n, width);
620
620
  if (*p == '$') {
621
621
  if (!mrb_undef_p(nextvalue)) {
622
- mrb_raisef(mrb, E_ARGUMENT_ERROR, "value given twice - %S$", mrb_fixnum_value(n));
622
+ mrb_raisef(mrb, E_ARGUMENT_ERROR, "value given twice - %i$", n);
623
623
  }
624
624
  nextvalue = GETPOSARG(n);
625
625
  p++;
@@ -639,14 +639,14 @@ retry:
639
639
  for (; p < end && *p != term; )
640
640
  p++;
641
641
  if (id) {
642
- mrb_raisef(mrb, E_ARGUMENT_ERROR, "name%S after <%S>",
643
- mrb_str_new(mrb, start, p - start + 1), mrb_sym2str(mrb, id));
642
+ mrb_raisef(mrb, E_ARGUMENT_ERROR, "name%l after <%n>",
643
+ start, p - start + 1, id);
644
644
  }
645
645
  symname = mrb_str_new(mrb, start + 1, p - start - 1);
646
646
  id = mrb_intern_str(mrb, symname);
647
- nextvalue = GETNAMEARG(mrb_symbol_value(id), start, (mrb_int)(p - start + 1));
647
+ nextvalue = GETNAMEARG(mrb_symbol_value(id), start, p - start + 1);
648
648
  if (mrb_undef_p(nextvalue)) {
649
- mrb_raisef(mrb, E_KEY_ERROR, "key%S not found", mrb_str_new(mrb, start, p - start + 1));
649
+ mrb_raisef(mrb, E_KEY_ERROR, "key%l not found", start, p - start + 1);
650
650
  }
651
651
  if (term == '}') goto format_s;
652
652
  p++;
@@ -845,6 +845,7 @@ retry:
845
845
  case 'd':
846
846
  case 'i':
847
847
  sign = 1;
848
+ /* fall through */
848
849
  default:
849
850
  base = 10; break;
850
851
  }
@@ -1003,10 +1004,8 @@ retry:
1003
1004
  case 'A': {
1004
1005
  mrb_value val = GETARG();
1005
1006
  double fval;
1006
- mrb_int i;
1007
1007
  mrb_int need = 6;
1008
1008
  char fbuf[32];
1009
- int frexp_result;
1010
1009
 
1011
1010
  fval = mrb_float(mrb_Float(mrb, val));
1012
1011
  if (!isfinite(fval)) {
@@ -1050,9 +1049,8 @@ retry:
1050
1049
  fmt_setup(fbuf, sizeof(fbuf), *p, flags, width, prec);
1051
1050
  need = 0;
1052
1051
  if (*p != 'e' && *p != 'E') {
1053
- i = INT_MIN;
1054
- frexp(fval, &frexp_result);
1055
- i = (mrb_int)frexp_result;
1052
+ int i;
1053
+ frexp(fval, &i);
1056
1054
  if (i > 0)
1057
1055
  need = BIT_DIGITS(i);
1058
1056
  }
@@ -1089,7 +1087,7 @@ retry:
1089
1087
  if (posarg >= 0 && nextarg < argc) {
1090
1088
  const char *mesg = "too many arguments for format string";
1091
1089
  if (mrb_test(ruby_debug)) mrb_raise(mrb, E_ARGUMENT_ERROR, mesg);
1092
- if (mrb_test(ruby_verbose)) mrb_warn(mrb, "%S", mrb_str_new_cstr(mrb, mesg));
1090
+ if (mrb_test(ruby_verbose)) mrb_warn(mrb, "%s", mesg);
1093
1091
  }
1094
1092
  #endif
1095
1093
  mrb_str_resize(mrb, result, blen);
@@ -2,5 +2,4 @@
2
2
  spec.license = 'MIT'
3
3
  spec.author = 'mruby developers'
4
4
  spec.summary = 'String class extension'
5
- spec.add_test_dependency 'mruby-enumerator', core: 'mruby-enumerator'
6
5
  end
@@ -310,11 +310,15 @@ def chars(&block)
310
310
  end
311
311
  end
312
312
 
313
+ ##
314
+ # Call the given block for each character of
315
+ # +self+.
313
316
  def each_char(&block)
314
317
  return to_enum :each_char unless block
315
-
316
- split('').each do |i|
317
- block.call(i)
318
+ pos = 0
319
+ while pos < self.size
320
+ block.call(self[pos])
321
+ pos += 1
318
322
  end
319
323
  self
320
324
  end
@@ -410,7 +414,7 @@ def upto(max, exclusive=false, &block)
410
414
  e = max.ord
411
415
  while c <= e
412
416
  break if exclusive and c == e
413
- yield c.chr
417
+ yield c.chr(__ENCODING__)
414
418
  c += 1
415
419
  end
416
420
  return self
@@ -5,82 +5,90 @@
5
5
  #include <mruby/string.h>
6
6
  #include <mruby/range.h>
7
7
 
8
- static mrb_value
9
- mrb_str_getbyte(mrb_state *mrb, mrb_value str)
10
- {
11
- mrb_int pos;
12
- mrb_get_args(mrb, "i", &pos);
8
+ #define ENC_ASCII_8BIT "ASCII-8BIT"
9
+ #define ENC_BINARY "BINARY"
10
+ #define ENC_UTF8 "UTF-8"
13
11
 
14
- if (pos < 0)
15
- pos += RSTRING_LEN(str);
16
- if (pos < 0 || RSTRING_LEN(str) <= pos)
17
- return mrb_nil_value();
12
+ #define ENC_COMP_P(enc, enc_lit) \
13
+ str_casecmp_p(RSTRING_PTR(enc), RSTRING_LEN(enc), enc_lit, sizeof(enc_lit"")-1)
14
+
15
+ #ifdef MRB_WITHOUT_FLOAT
16
+ # define mrb_float_p(o) FALSE
17
+ #endif
18
18
 
19
- return mrb_fixnum_value((unsigned char)RSTRING_PTR(str)[pos]);
19
+ static mrb_bool
20
+ str_casecmp_p(const char *s1, mrb_int len1, const char *s2, mrb_int len2)
21
+ {
22
+ const char *e1, *e2;
23
+
24
+ if (len1 != len2) return FALSE;
25
+ e1 = s1 + len1;
26
+ e2 = s2 + len2;
27
+ while (s1 < e1 && s2 < e2) {
28
+ if (*s1 != *s2 && TOUPPER(*s1) != TOUPPER(*s2)) return FALSE;
29
+ ++s1;
30
+ ++s2;
31
+ }
32
+ return TRUE;
20
33
  }
21
34
 
22
35
  static mrb_value
23
- mrb_str_setbyte(mrb_state *mrb, mrb_value str)
36
+ int_chr_binary(mrb_state *mrb, mrb_value num)
24
37
  {
25
- mrb_int pos, byte;
26
- mrb_int len;
27
-
28
- mrb_get_args(mrb, "ii", &pos, &byte);
29
-
30
- len = RSTRING_LEN(str);
31
- if (pos < -len || len <= pos)
32
- mrb_raisef(mrb, E_INDEX_ERROR, "index %S is out of array", mrb_fixnum_value(pos));
33
- if (pos < 0)
34
- pos += len;
38
+ mrb_int cp = mrb_int(mrb, num);
39
+ char c;
40
+ mrb_value str;
35
41
 
36
- mrb_str_modify(mrb, mrb_str_ptr(str));
37
- byte &= 0xff;
38
- RSTRING_PTR(str)[pos] = (unsigned char)byte;
39
- return mrb_fixnum_value((unsigned char)byte);
42
+ if (cp < 0 || 0xff < cp) {
43
+ mrb_raisef(mrb, E_RANGE_ERROR, "%v out of char range", num);
44
+ }
45
+ c = (char)cp;
46
+ str = mrb_str_new(mrb, &c, 1);
47
+ RSTR_SET_ASCII_FLAG(mrb_str_ptr(str));
48
+ return str;
40
49
  }
41
50
 
51
+ #ifdef MRB_UTF8_STRING
42
52
  static mrb_value
43
- mrb_str_byteslice(mrb_state *mrb, mrb_value str)
53
+ int_chr_utf8(mrb_state *mrb, mrb_value num)
44
54
  {
45
- mrb_value a1;
55
+ mrb_int cp = mrb_int(mrb, num);
56
+ char utf8[4];
46
57
  mrb_int len;
58
+ mrb_value str;
59
+ uint32_t ascii_flag = 0;
47
60
 
48
- if (mrb_get_argc(mrb) == 2) {
49
- mrb_int pos;
50
- mrb_get_args(mrb, "ii", &pos, &len);
51
- return mrb_str_substr(mrb, str, pos, len);
61
+ if (cp < 0 || 0x10FFFF < cp) {
62
+ mrb_raisef(mrb, E_RANGE_ERROR, "%v out of char range", num);
52
63
  }
53
- mrb_get_args(mrb, "o|i", &a1, &len);
54
- switch (mrb_type(a1)) {
55
- case MRB_TT_RANGE:
56
- {
57
- mrb_int beg;
58
-
59
- len = RSTRING_LEN(str);
60
- switch (mrb_range_beg_len(mrb, a1, &beg, &len, len, TRUE)) {
61
- case 0: /* not range */
62
- break;
63
- case 1: /* range */
64
- return mrb_str_substr(mrb, str, beg, len);
65
- case 2: /* out of range */
66
- mrb_raisef(mrb, E_RANGE_ERROR, "%S out of range", a1);
67
- break;
68
- }
69
- return mrb_nil_value();
70
- }
71
- #ifndef MRB_WITHOUT_FLOAT
72
- case MRB_TT_FLOAT:
73
- a1 = mrb_fixnum_value((mrb_int)mrb_float(a1));
74
- /* fall through */
75
- #endif
76
- case MRB_TT_FIXNUM:
77
- return mrb_str_substr(mrb, str, mrb_fixnum(a1), 1);
78
- default:
79
- mrb_raise(mrb, E_TYPE_ERROR, "wrong type of argument");
64
+ if (cp < 0x80) {
65
+ utf8[0] = (char)cp;
66
+ len = 1;
67
+ ascii_flag = MRB_STR_ASCII;
80
68
  }
81
- /* not reached */
82
- return mrb_nil_value();
69
+ else if (cp < 0x800) {
70
+ utf8[0] = (char)(0xC0 | (cp >> 6));
71
+ utf8[1] = (char)(0x80 | (cp & 0x3F));
72
+ len = 2;
73
+ }
74
+ else if (cp < 0x10000) {
75
+ utf8[0] = (char)(0xE0 | (cp >> 12));
76
+ utf8[1] = (char)(0x80 | ((cp >> 6) & 0x3F));
77
+ utf8[2] = (char)(0x80 | ( cp & 0x3F));
78
+ len = 3;
79
+ }
80
+ else {
81
+ utf8[0] = (char)(0xF0 | (cp >> 18));
82
+ utf8[1] = (char)(0x80 | ((cp >> 12) & 0x3F));
83
+ utf8[2] = (char)(0x80 | ((cp >> 6) & 0x3F));
84
+ utf8[3] = (char)(0x80 | ( cp & 0x3F));
85
+ len = 4;
86
+ }
87
+ str = mrb_str_new(mrb, utf8, len);
88
+ mrb_str_ptr(str)->flags |= ascii_flag;
89
+ return str;
83
90
  }
91
+ #endif
84
92
 
85
93
  /*
86
94
  * call-seq:
@@ -137,8 +145,6 @@ mrb_str_swapcase(mrb_state *mrb, mrb_value self)
137
145
  return str;
138
146
  }
139
147
 
140
- static mrb_value mrb_fixnum_chr(mrb_state *mrb, mrb_value num);
141
-
142
148
  /*
143
149
  * call-seq:
144
150
  * str << integer -> str
@@ -148,7 +154,8 @@ static mrb_value mrb_fixnum_chr(mrb_state *mrb, mrb_value num);
148
154
  *
149
155
  * Append---Concatenates the given object to <i>str</i>. If the object is a
150
156
  * <code>Integer</code>, it is considered as a codepoint, and is converted
151
- * to a character before concatenation.
157
+ * to a character before concatenation
158
+ * (equivalent to <code>str.concat(integer.chr(__ENCODING__))</code>).
152
159
  *
153
160
  * a = "hello "
154
161
  * a << "world" #=> "hello world"
@@ -160,11 +167,15 @@ mrb_str_concat_m(mrb_state *mrb, mrb_value self)
160
167
  mrb_value str;
161
168
 
162
169
  mrb_get_args(mrb, "o", &str);
163
- if (mrb_fixnum_p(str))
164
- str = mrb_fixnum_chr(mrb, str);
170
+ if (mrb_fixnum_p(str) || mrb_float_p(str))
171
+ #ifdef MRB_UTF8_STRING
172
+ str = int_chr_utf8(mrb, str);
173
+ #else
174
+ str = int_chr_binary(mrb, str);
175
+ #endif
165
176
  else
166
- str = mrb_ensure_string_type(mrb, str);
167
- mrb_str_concat(mrb, self, str);
177
+ mrb_ensure_string_type(mrb, str);
178
+ mrb_str_cat_str(mrb, self, str);
168
179
  return self;
169
180
  }
170
181
 
@@ -507,8 +518,7 @@ str_tr(mrb_state *mrb, mrb_value str, mrb_value p1, mrb_value p2, mrb_bool squee
507
518
  continue;
508
519
  }
509
520
  if (c > 0x80) {
510
- mrb_raisef(mrb, E_ARGUMENT_ERROR, "character (%S) out of range",
511
- mrb_fixnum_value((mrb_int)c));
521
+ mrb_raisef(mrb, E_ARGUMENT_ERROR, "character (%i) out of range", c);
512
522
  }
513
523
  lastch = c;
514
524
  s[i] = (char)c;
@@ -812,7 +822,7 @@ mrb_str_count(mrb_state *mrb, mrb_value str)
812
822
  tr_parse_pattern(mrb, &pat, v_pat, TRUE);
813
823
  tr_compile_pattern(&pat, v_pat, bitmap);
814
824
  tr_free_pattern(mrb, &pat);
815
-
825
+
816
826
  s = RSTRING_PTR(str);
817
827
  len = RSTRING_LEN(str);
818
828
  for (i = 0; i < len; i++) {
@@ -848,49 +858,42 @@ mrb_str_chr(mrb_state *mrb, mrb_value self)
848
858
  return mrb_str_substr(mrb, self, 0, 1);
849
859
  }
850
860
 
861
+ /*
862
+ * call-seq:
863
+ * int.chr([encoding]) -> string
864
+ *
865
+ * Returns a string containing the character represented by the +int+'s value
866
+ * according to +encoding+. +"ASCII-8BIT"+ (+"BINARY"+) and +"UTF-8"+ (only
867
+ * with +MRB_UTF8_STRING+) can be specified as +encoding+ (default is
868
+ * +"ASCII-8BIT"+).
869
+ *
870
+ * 65.chr #=> "A"
871
+ * 230.chr #=> "\xE6"
872
+ * 230.chr("ASCII-8BIT") #=> "\xE6"
873
+ * 230.chr("UTF-8") #=> "\u00E6"
874
+ */
851
875
  static mrb_value
852
- mrb_fixnum_chr(mrb_state *mrb, mrb_value num)
876
+ mrb_int_chr(mrb_state *mrb, mrb_value num)
853
877
  {
854
- mrb_int cp = mrb_fixnum(num);
855
- #ifdef MRB_UTF8_STRING
856
- char utf8[4];
857
- mrb_int len;
858
-
859
- if (cp < 0 || 0x10FFFF < cp) {
860
- mrb_raisef(mrb, E_RANGE_ERROR, "%S out of char range", num);
861
- }
862
- if (cp < 0x80) {
863
- utf8[0] = (char)cp;
864
- len = 1;
878
+ mrb_value enc;
879
+ mrb_bool enc_given;
880
+
881
+ mrb_get_args(mrb, "|S?", &enc, &enc_given);
882
+ if (!enc_given ||
883
+ ENC_COMP_P(enc, ENC_ASCII_8BIT) ||
884
+ ENC_COMP_P(enc, ENC_BINARY)) {
885
+ return int_chr_binary(mrb, num);
865
886
  }
866
- else if (cp < 0x800) {
867
- utf8[0] = (char)(0xC0 | (cp >> 6));
868
- utf8[1] = (char)(0x80 | (cp & 0x3F));
869
- len = 2;
870
- }
871
- else if (cp < 0x10000) {
872
- utf8[0] = (char)(0xE0 | (cp >> 12));
873
- utf8[1] = (char)(0x80 | ((cp >> 6) & 0x3F));
874
- utf8[2] = (char)(0x80 | ( cp & 0x3F));
875
- len = 3;
887
+ #ifdef MRB_UTF8_STRING
888
+ else if (ENC_COMP_P(enc, ENC_UTF8)) {
889
+ return int_chr_utf8(mrb, num);
876
890
  }
891
+ #endif
877
892
  else {
878
- utf8[0] = (char)(0xF0 | (cp >> 18));
879
- utf8[1] = (char)(0x80 | ((cp >> 12) & 0x3F));
880
- utf8[2] = (char)(0x80 | ((cp >> 6) & 0x3F));
881
- utf8[3] = (char)(0x80 | ( cp & 0x3F));
882
- len = 4;
883
- }
884
- return mrb_str_new(mrb, utf8, len);
885
- #else
886
- char c;
887
-
888
- if (cp < 0 || 0xff < cp) {
889
- mrb_raisef(mrb, E_RANGE_ERROR, "%S out of char range", num);
893
+ mrb_raisef(mrb, E_ARGUMENT_ERROR, "unknown encoding name - %v", enc);
890
894
  }
891
- c = (char)cp;
892
- return mrb_str_new(mrb, &c, 1);
893
- #endif
895
+ /* not reached */
896
+ return mrb_nil_value();
894
897
  }
895
898
 
896
899
  /*
@@ -1078,7 +1081,7 @@ mrb_str_del_prefix_bang(mrb_state *mrb, mrb_value self)
1078
1081
  if (plen > slen) return mrb_nil_value();
1079
1082
  s = RSTR_PTR(str);
1080
1083
  if (memcmp(s, ptr, plen) != 0) return mrb_nil_value();
1081
- if (!MRB_FROZEN_P(str) && (RSTR_SHARED_P(str) || RSTR_FSHARED_P(str))) {
1084
+ if (!mrb_frozen_p(str) && (RSTR_SHARED_P(str) || RSTR_FSHARED_P(str))) {
1082
1085
  str->as.heap.ptr += plen;
1083
1086
  }
1084
1087
  else {
@@ -1135,7 +1138,7 @@ mrb_str_del_suffix_bang(mrb_state *mrb, mrb_value self)
1135
1138
  if (plen > slen) return mrb_nil_value();
1136
1139
  s = RSTR_PTR(str);
1137
1140
  if (memcmp(s+slen-plen, ptr, plen) != 0) return mrb_nil_value();
1138
- if (!MRB_FROZEN_P(str) && (RSTR_SHARED_P(str) || RSTR_FSHARED_P(str))) {
1141
+ if (!mrb_frozen_p(str) && (RSTR_SHARED_P(str) || RSTR_FSHARED_P(str))) {
1139
1142
  /* no need to modify string */
1140
1143
  }
1141
1144
  else {
@@ -1178,8 +1181,6 @@ mrb_str_lines(mrb_state *mrb, mrb_value self)
1178
1181
  char *p = b, *t;
1179
1182
  char *e = b + RSTRING_LEN(self);
1180
1183
 
1181
- mrb_get_args(mrb, "");
1182
-
1183
1184
  result = mrb_ary_new(mrb);
1184
1185
  ai = mrb_gc_arena_save(mrb);
1185
1186
  while (p < e) {
@@ -1199,9 +1200,6 @@ mrb_mruby_string_ext_gem_init(mrb_state* mrb)
1199
1200
  struct RClass * s = mrb->string_class;
1200
1201
 
1201
1202
  mrb_define_method(mrb, s, "dump", mrb_str_dump, MRB_ARGS_NONE());
1202
- mrb_define_method(mrb, s, "getbyte", mrb_str_getbyte, MRB_ARGS_REQ(1));
1203
- mrb_define_method(mrb, s, "setbyte", mrb_str_setbyte, MRB_ARGS_REQ(2));
1204
- mrb_define_method(mrb, s, "byteslice", mrb_str_byteslice, MRB_ARGS_REQ(1)|MRB_ARGS_OPT(1));
1205
1203
  mrb_define_method(mrb, s, "swapcase!", mrb_str_swapcase_bang, MRB_ARGS_NONE());
1206
1204
  mrb_define_method(mrb, s, "swapcase", mrb_str_swapcase, MRB_ARGS_NONE());
1207
1205
  mrb_define_method(mrb, s, "concat", mrb_str_concat_m, MRB_ARGS_REQ(1));
@@ -1222,8 +1220,8 @@ mrb_mruby_string_ext_gem_init(mrb_state* mrb)
1222
1220
  mrb_define_method(mrb, s, "chr", mrb_str_chr, MRB_ARGS_NONE());
1223
1221
  mrb_define_method(mrb, s, "succ", mrb_str_succ, MRB_ARGS_NONE());
1224
1222
  mrb_define_method(mrb, s, "succ!", mrb_str_succ_bang, MRB_ARGS_NONE());
1225
- mrb_define_alias(mrb, s, "next", "succ");
1226
- mrb_define_alias(mrb, s, "next!", "succ!");
1223
+ mrb_define_method(mrb, s, "next", mrb_str_succ, MRB_ARGS_NONE());
1224
+ mrb_define_method(mrb, s, "next!", mrb_str_succ_bang, MRB_ARGS_NONE());
1227
1225
  mrb_define_method(mrb, s, "ord", mrb_str_ord, MRB_ARGS_NONE());
1228
1226
  mrb_define_method(mrb, s, "delete_prefix!", mrb_str_del_prefix_bang, MRB_ARGS_REQ(1));
1229
1227
  mrb_define_method(mrb, s, "delete_prefix", mrb_str_del_prefix, MRB_ARGS_REQ(1));
@@ -1231,7 +1229,8 @@ mrb_mruby_string_ext_gem_init(mrb_state* mrb)
1231
1229
  mrb_define_method(mrb, s, "delete_suffix", mrb_str_del_suffix, MRB_ARGS_REQ(1));
1232
1230
 
1233
1231
  mrb_define_method(mrb, s, "__lines", mrb_str_lines, MRB_ARGS_NONE());
1234
- mrb_define_method(mrb, mrb->fixnum_class, "chr", mrb_fixnum_chr, MRB_ARGS_NONE());
1232
+
1233
+ mrb_define_method(mrb, mrb_module_get(mrb, "Integral"), "chr", mrb_int_chr, MRB_ARGS_OPT(1));
1235
1234
  }
1236
1235
 
1237
1236
  void