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
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+
3
+ assert('Integer#chr') do
4
+ assert_equal("A", 65.chr)
5
+ assert_equal("B", 0x42.chr)
6
+ assert_equal("\xab", 171.chr)
7
+ assert_raise(RangeError) { -1.chr }
8
+ assert_raise(RangeError) { 256.chr }
9
+
10
+ assert_equal("A", 65.chr("ASCII-8BIT"))
11
+ assert_equal("B", 0x42.chr("BINARY"))
12
+ assert_equal("\xab", 171.chr("ascii-8bit"))
13
+ assert_raise(RangeError) { -1.chr("binary") }
14
+ assert_raise(RangeError) { 256.chr("Ascii-8bit") }
15
+ assert_raise(ArgumentError) { 65.chr("ASCII") }
16
+ assert_raise(ArgumentError) { 65.chr("ASCII-8BIT", 2) }
17
+ assert_raise(TypeError) { 65.chr(:BINARY) }
18
+
19
+ if __ENCODING__ == "ASCII-8BIT"
20
+ assert_raise(ArgumentError) { 65.chr("UTF-8") }
21
+ else
22
+ assert_equal("A", 65.chr("UTF-8"))
23
+ assert_equal("B", 0x42.chr("UTF-8"))
24
+ assert_equal("«", 171.chr("utf-8"))
25
+ assert_equal("あ", 12354.chr("Utf-8"))
26
+ assert_raise(RangeError) { -1.chr("utf-8") }
27
+ assert_raise(RangeError) { 0x110000.chr.chr("UTF-8") }
28
+ end
29
+ end
@@ -0,0 +1,26 @@
1
+ assert('Range#max') do
2
+ # returns the maximum value in the range when called with no arguments
3
+ assert_equal 'l', ('f'..'l').max
4
+ assert_equal 'e', ('a'...'f').max
5
+
6
+ # returns nil when the endpoint is less than the start point
7
+ assert_equal nil, ('z'..'l').max
8
+ end
9
+
10
+ assert('Range#max given a block') do
11
+ # returns nil when the endpoint is less than the start point
12
+ assert_equal nil, (('z'..'l').max { |x, y| x <=> y })
13
+ end
14
+
15
+ assert('Range#min') do
16
+ # returns the minimum value in the range when called with no arguments
17
+ assert_equal 'f', ('f'..'l').min
18
+
19
+ # returns nil when the start point is greater than the endpoint
20
+ assert_equal nil, ('z'..'l').min
21
+ end
22
+
23
+ assert('Range#min given a block') do
24
+ # returns nil when the start point is greater than the endpoint
25
+ assert_equal nil, (('z'..'l').min { |x, y| x <=> y })
26
+ end
@@ -2,39 +2,18 @@
2
2
  ##
3
3
  # String(Ext) Test
4
4
 
5
- UTF8STRING = ("\343\201\202".size == 1)
5
+ UTF8STRING = __ENCODING__ == "UTF-8"
6
6
 
7
- assert('String#getbyte') do
8
- str1 = "hello"
9
- bytes1 = [104, 101, 108, 108, 111]
10
- assert_equal bytes1[0], str1.getbyte(0)
11
- assert_equal bytes1[-1], str1.getbyte(-1)
12
- assert_equal bytes1[6], str1.getbyte(6)
13
-
14
- str2 = "\xFF"
15
- bytes2 = [0xFF]
16
- assert_equal bytes2[0], str2.getbyte(0)
17
- end
18
-
19
- assert('String#setbyte') do
20
- str1 = "hello"
21
- h = "H".getbyte(0)
22
- str1.setbyte(0, h)
23
- assert_equal(h, str1.getbyte(0))
24
- assert_equal("Hello", str1)
25
- end
26
-
27
- assert('String#byteslice') do
28
- str1 = "hello"
29
- assert_equal("e", str1.byteslice(1))
30
- assert_equal("o", str1.byteslice(-1))
31
- assert_equal("ell", str1.byteslice(1..3))
32
- assert_equal("el", str1.byteslice(1...3))
7
+ def assert_upto(exp, receiver, *args)
8
+ act = []
9
+ receiver.upto(*args) { |v| act << v }
10
+ assert_equal exp, act
33
11
  end
34
12
 
35
13
  assert('String#dump') do
36
14
  assert_equal("\"\\x00\"", "\0".dump)
37
15
  assert_equal("\"foo\"", "foo".dump)
16
+ assert_equal('"\xe3\x82\x8b"', "る".dump)
38
17
  assert_nothing_raised { ("\1" * 100).dump } # regress #1210
39
18
  end
40
19
 
@@ -116,8 +95,15 @@
116
95
  assert('String#concat') do
117
96
  assert_equal "Hello World!", "Hello " << "World" << 33
118
97
  assert_equal "Hello World!", "Hello ".concat("World").concat(33)
119
-
120
98
  assert_raise(TypeError) { "".concat(Object.new) }
99
+
100
+ if UTF8STRING
101
+ assert_equal "H«", "H" << 0xab
102
+ assert_equal "Hは", "H" << 12399
103
+ else
104
+ assert_equal "H\xab", "H" << 0xab
105
+ assert_raise(RangeError) { "H" << 12399 }
106
+ end
121
107
  end
122
108
 
123
109
  assert('String#casecmp') do
@@ -247,12 +233,6 @@
247
233
  assert_equal (-8), "-10".oct
248
234
  end
249
235
 
250
- assert('String#chr') do
251
- assert_equal "a", "abcde".chr
252
- # test Fixnum#chr as well
253
- assert_equal "a", 97.chr
254
- end
255
-
256
236
  assert('String#lines') do
257
237
  assert_equal ["Hel\n", "lo\n", "World!"], "Hel\nlo\nWorld!".lines
258
238
  assert_equal ["Hel\n", "lo\n", "World!\n"], "Hel\nlo\nWorld!\n".lines
@@ -539,16 +519,15 @@
539
519
  end
540
520
 
541
521
  assert('String#upto') do
542
- assert_equal %w(a8 a9 b0 b1 b2 b3 b4 b5 b6), "a8".upto("b6").to_a
543
- assert_equal ["9", "10", "11"], "9".upto("11").to_a
544
- assert_equal [], "25".upto("5").to_a
545
- assert_equal ["07", "08", "09", "10", "11"], "07".upto("11").to_a
546
-
547
- if UTF8STRING
548
- assert_equal ["あ", "ぃ", "い", "ぅ", "う", "ぇ", "え", "ぉ", "お"], "あ".upto("お").to_a
549
- end
550
-
551
- assert_equal ["9", ":", ";", "<", "=", ">", "?", "@", "A"], "9".upto("A").to_a
522
+ assert_upto %w(a8 a9 b0 b1 b2 b3 b4 b5 b6), "a8", "b6"
523
+ assert_upto ["9", "10", "11"], "9", "11"
524
+ assert_upto [], "25", "5"
525
+ assert_upto ["07", "08", "09", "10", "11"], "07", "11"
526
+ assert_upto ["9", ":", ";", "<", "=", ">", "?", "@", "A"], "9", "A"
527
+
528
+ if UTF8STRING
529
+ assert_upto %w(あ ぃ い ぅ う ぇ え ぉ お), "あ", "お"
530
+ end
552
531
 
553
532
  a = "aa"
554
533
  start = "aa"
@@ -630,8 +609,11 @@
630
609
  end if UTF8STRING
631
610
 
632
611
  assert('String#chr') do
612
+ assert_equal "a", "abcde".chr
633
613
  assert_equal "h", "hello!".chr
614
+ assert_equal "", "".chr
634
615
  end
616
+
635
617
  assert('String#chr(UTF-8)') do
636
618
  assert_equal "こ", "こんにちは世界!".chr
637
619
  end if UTF8STRING
@@ -657,19 +639,19 @@
657
639
  end if UTF8STRING
658
640
 
659
641
  assert('String#each_char') do
660
- s = ""
642
+ chars = []
661
643
  "hello!".each_char do |x|
662
- s += x
644
+ chars << x
663
645
  end
664
- assert_equal "hello!", s
646
+ assert_equal ["h", "e", "l", "l", "o", "!"], chars
665
647
  end
666
648
 
667
649
  assert('String#each_char(UTF-8)') do
668
- s = ""
650
+ chars = []
669
651
  "こんにちは世界!".each_char do |x|
670
- s += x
652
+ chars << x
671
653
  end
672
- assert_equal "こんにちは世界!", s
654
+ assert_equal ["", "ん", "に", "ち", "は", "世", "界", "!"], chars
673
655
  end if UTF8STRING
674
656
 
675
657
  assert('String#codepoints') do
@@ -46,7 +46,9 @@ def select(&block)
46
46
  ary
47
47
  end
48
48
 
49
- def _inspect
49
+ def _inspect(recur_list)
50
+ return "#<struct #{self.class}:...>" if recur_list[self.object_id]
51
+ recur_list[self.object_id] = true
50
52
  name = self.class.to_s
51
53
  if name[0] == "#"
52
54
  str = "#<struct "
@@ -55,7 +57,7 @@ def _inspect
55
57
  end
56
58
  buf = []
57
59
  self.each_pair do |k,v|
58
- buf.push [k.to_s + "=" + v._inspect]
60
+ buf.push k.to_s + "=" + v._inspect(recur_list)
59
61
  end
60
62
  str + buf.join(", ") + ">"
61
63
  end
@@ -70,11 +72,7 @@ def _inspect
70
72
  # 15.2.18.4.10(x)
71
73
  #
72
74
  def inspect
73
- begin
74
- self._inspect
75
- rescue SystemStackError
76
- "#<struct #{self.class.to_s}:...>"
77
- end
75
+ self._inspect({})
78
76
  end
79
77
 
80
78
  ##
@@ -66,8 +66,8 @@ struct_members(mrb_state *mrb, mrb_value s)
66
66
  }
67
67
  else {
68
68
  mrb_raisef(mrb, E_TYPE_ERROR,
69
- "struct size differs (%S required %S given)",
70
- mrb_fixnum_value(RARRAY_LEN(members)), mrb_fixnum_value(RSTRUCT_LEN(s)));
69
+ "struct size differs (%i required %i given)",
70
+ RARRAY_LEN(members), RSTRUCT_LEN(s));
71
71
  }
72
72
  }
73
73
  return members;
@@ -87,10 +87,7 @@ mrb_struct_s_members_m(mrb_state *mrb, mrb_value klass)
87
87
  static void
88
88
  mrb_struct_modify(mrb_state *mrb, mrb_value strct)
89
89
  {
90
- if (MRB_FROZEN_P(mrb_basic_ptr(strct))) {
91
- mrb_raise(mrb, E_FROZEN_ERROR, "can't modify frozen struct");
92
- }
93
-
90
+ mrb_check_frozen(mrb, mrb_basic_ptr(strct));
94
91
  mrb_write_barrier(mrb, mrb_basic_ptr(strct));
95
92
  }
96
93
 
@@ -126,19 +123,29 @@ mrb_struct_ref(mrb_state *mrb, mrb_value obj)
126
123
  static mrb_sym
127
124
  mrb_id_attrset(mrb_state *mrb, mrb_sym id)
128
125
  {
126
+ #define ONSTACK_ALLOC_MAX 32
127
+ #define ONSTACK_STRLEN_MAX (ONSTACK_ALLOC_MAX - 1) /* '=' character */
128
+
129
129
  const char *name;
130
130
  char *buf;
131
131
  mrb_int len;
132
132
  mrb_sym mid;
133
+ char onstack[ONSTACK_ALLOC_MAX];
133
134
 
134
- name = mrb_sym2name_len(mrb, id, &len);
135
- buf = (char *)mrb_malloc(mrb, (size_t)len+2);
135
+ name = mrb_sym_name_len(mrb, id, &len);
136
+ if (len > ONSTACK_STRLEN_MAX) {
137
+ buf = (char *)mrb_malloc(mrb, (size_t)len+1);
138
+ }
139
+ else {
140
+ buf = onstack;
141
+ }
136
142
  memcpy(buf, name, (size_t)len);
137
143
  buf[len] = '=';
138
- buf[len+1] = '\0';
139
144
 
140
145
  mid = mrb_intern(mrb, buf, len+1);
141
- mrb_free(mrb, buf);
146
+ if (buf != onstack) {
147
+ mrb_free(mrb, buf);
148
+ }
142
149
  return mid;
143
150
  }
144
151
 
@@ -161,20 +168,6 @@ mrb_struct_set_m(mrb_state *mrb, mrb_value obj)
161
168
  return val;
162
169
  }
163
170
 
164
- static mrb_bool
165
- is_local_id(mrb_state *mrb, const char *name)
166
- {
167
- if (!name) return FALSE;
168
- return !ISUPPER(name[0]);
169
- }
170
-
171
- static mrb_bool
172
- is_const_id(mrb_state *mrb, const char *name)
173
- {
174
- if (!name) return FALSE;
175
- return ISUPPER(name[0]);
176
- }
177
-
178
171
  static void
179
172
  make_struct_define_accessors(mrb_state *mrb, mrb_value members, struct RClass *c)
180
173
  {
@@ -185,19 +178,15 @@ make_struct_define_accessors(mrb_state *mrb, mrb_value members, struct RClass *c
185
178
 
186
179
  for (i=0; i<len; i++) {
187
180
  mrb_sym id = mrb_symbol(ptr_members[i]);
188
- const char *name = mrb_sym2name_len(mrb, id, NULL);
189
-
190
- if (is_local_id(mrb, name) || is_const_id(mrb, name)) {
191
- mrb_method_t m;
192
- mrb_value at = mrb_fixnum_value(i);
193
- struct RProc *aref = mrb_proc_new_cfunc_with_env(mrb, mrb_struct_ref, 1, &at);
194
- struct RProc *aset = mrb_proc_new_cfunc_with_env(mrb, mrb_struct_set_m, 1, &at);
195
- MRB_METHOD_FROM_PROC(m, aref);
196
- mrb_define_method_raw(mrb, c, id, m);
197
- MRB_METHOD_FROM_PROC(m, aset);
198
- mrb_define_method_raw(mrb, c, mrb_id_attrset(mrb, id), m);
199
- mrb_gc_arena_restore(mrb, ai);
200
- }
181
+ mrb_method_t m;
182
+ mrb_value at = mrb_fixnum_value(i);
183
+ struct RProc *aref = mrb_proc_new_cfunc_with_env(mrb, mrb_struct_ref, 1, &at);
184
+ struct RProc *aset = mrb_proc_new_cfunc_with_env(mrb, mrb_struct_set_m, 1, &at);
185
+ MRB_METHOD_FROM_PROC(m, aref);
186
+ mrb_define_method_raw(mrb, c, id, m);
187
+ MRB_METHOD_FROM_PROC(m, aset);
188
+ mrb_define_method_raw(mrb, c, mrb_id_attrset(mrb, id), m);
189
+ mrb_gc_arena_restore(mrb, ai);
201
190
  }
202
191
  }
203
192
 
@@ -215,11 +204,11 @@ make_struct(mrb_state *mrb, mrb_value name, mrb_value members, struct RClass *kl
215
204
  /* old style: should we warn? */
216
205
  mrb_to_str(mrb, name);
217
206
  id = mrb_obj_to_sym(mrb, name);
218
- if (!is_const_id(mrb, mrb_sym2name_len(mrb, id, NULL))) {
219
- mrb_name_error(mrb, id, "identifier %S needs to be constant", name);
207
+ if (!mrb_const_name_p(mrb, RSTRING_PTR(name), RSTRING_LEN(name))) {
208
+ mrb_name_error(mrb, id, "identifier %v needs to be constant", name);
220
209
  }
221
210
  if (mrb_const_defined_at(mrb, mrb_obj_value(klass), id)) {
222
- mrb_warn(mrb, "redefining constant Struct::%S", name);
211
+ mrb_warn(mrb, "redefining constant Struct::%v", name);
223
212
  mrb_const_remove(mrb, mrb_obj_value(klass), id);
224
213
  }
225
214
  c = mrb_define_class_under(mrb, klass, RSTRING_PTR(name), klass);
@@ -399,23 +388,22 @@ struct_aref_sym(mrb_state *mrb, mrb_value obj, mrb_sym id)
399
388
  return ptr[i];
400
389
  }
401
390
  }
402
- mrb_name_error(mrb, id, "no member '%S' in struct", mrb_sym2str(mrb, id));
391
+ mrb_name_error(mrb, id, "no member '%n' in struct", id);
403
392
  return mrb_nil_value(); /* not reached */
404
393
  }
405
394
 
406
395
  static mrb_value
407
396
  struct_aref_int(mrb_state *mrb, mrb_value s, mrb_int i)
408
397
  {
409
- if (i < 0) i = RSTRUCT_LEN(s) + i;
410
- if (i < 0)
411
- mrb_raisef(mrb, E_INDEX_ERROR,
412
- "offset %S too small for struct(size:%S)",
413
- mrb_fixnum_value(i), mrb_fixnum_value(RSTRUCT_LEN(s)));
414
- if (RSTRUCT_LEN(s) <= i)
398
+ mrb_int idx = i < 0 ? RSTRUCT_LEN(s) + i : i;
399
+
400
+ if (idx < 0)
401
+ mrb_raisef(mrb, E_INDEX_ERROR,
402
+ "offset %i too small for struct(size:%i)", i, RSTRUCT_LEN(s));
403
+ if (RSTRUCT_LEN(s) <= idx)
415
404
  mrb_raisef(mrb, E_INDEX_ERROR,
416
- "offset %S too large for struct(size:%S)",
417
- mrb_fixnum_value(i), mrb_fixnum_value(RSTRUCT_LEN(s)));
418
- return RSTRUCT_PTR(s)[i];
405
+ "offset %i too large for struct(size:%i)", i, RSTRUCT_LEN(s));
406
+ return RSTRUCT_PTR(s)[idx];
419
407
  }
420
408
 
421
409
  /* 15.2.18.4.2 */
@@ -447,7 +435,7 @@ mrb_struct_aref(mrb_state *mrb, mrb_value s)
447
435
  mrb_value sym = mrb_check_intern_str(mrb, idx);
448
436
 
449
437
  if (mrb_nil_p(sym)) {
450
- mrb_name_error(mrb, mrb_intern_str(mrb, idx), "no member '%S' in struct", idx);
438
+ mrb_name_error(mrb, mrb_intern_str(mrb, idx), "no member '%v' in struct", idx);
451
439
  }
452
440
  idx = sym;
453
441
  }
@@ -475,7 +463,7 @@ mrb_struct_aset_sym(mrb_state *mrb, mrb_value s, mrb_sym id, mrb_value val)
475
463
  return val;
476
464
  }
477
465
  }
478
- mrb_name_error(mrb, id, "no member '%S' in struct", mrb_sym2str(mrb, id));
466
+ mrb_name_error(mrb, id, "no member '%n' in struct", id);
479
467
  return val; /* not reach */
480
468
  }
481
469
 
@@ -514,7 +502,7 @@ mrb_struct_aset(mrb_state *mrb, mrb_value s)
514
502
  mrb_value sym = mrb_check_intern_str(mrb, idx);
515
503
 
516
504
  if (mrb_nil_p(sym)) {
517
- mrb_name_error(mrb, mrb_intern_str(mrb, idx), "no member '%S' in struct", idx);
505
+ mrb_name_error(mrb, mrb_intern_str(mrb, idx), "no member '%v' in struct", idx);
518
506
  }
519
507
  idx = sym;
520
508
  }
@@ -526,13 +514,11 @@ mrb_struct_aset(mrb_state *mrb, mrb_value s)
526
514
  if (i < 0) i = RSTRUCT_LEN(s) + i;
527
515
  if (i < 0) {
528
516
  mrb_raisef(mrb, E_INDEX_ERROR,
529
- "offset %S too small for struct(size:%S)",
530
- mrb_fixnum_value(i), mrb_fixnum_value(RSTRUCT_LEN(s)));
517
+ "offset %i too small for struct(size:%i)", i, RSTRUCT_LEN(s));
531
518
  }
532
519
  if (RSTRUCT_LEN(s) <= i) {
533
520
  mrb_raisef(mrb, E_INDEX_ERROR,
534
- "offset %S too large for struct(size:%S)",
535
- mrb_fixnum_value(i), mrb_fixnum_value(RSTRUCT_LEN(s)));
521
+ "offset %i too large for struct(size:%i)", i, RSTRUCT_LEN(s));
536
522
  }
537
523
  mrb_struct_modify(mrb, s);
538
524
  return RSTRUCT_PTR(s)[i] = val;
@@ -116,9 +116,10 @@
116
116
  end
117
117
 
118
118
  assert('struct inspect') do
119
- c = Struct.new(:m1, :m2, :m3, :m4, :m5)
120
- cc = c.new(1,2,3,4,5)
121
- assert_equal "#<struct m1=1, m2=2, m3=3, m4=4, m5=5>", cc.inspect
119
+ c = Struct.new(:m1, :m2, :m3, :m4, :m5, :recur)
120
+ cc = c.new(1,2,3,4,5,nil)
121
+ cc.recur = cc
122
+ assert_equal "#<struct m1=1, m2=2, m3=3, m4=4, m5=5, recur=#<struct #{cc.class}:...>>", cc.inspect
122
123
  end
123
124
 
124
125
  assert('Struct#length, Struct#size') do
@@ -152,14 +153,14 @@
152
153
  assert_equal 1, a.dig(1, 0)
153
154
  end
154
155
 
155
- assert("Struct.new removes existing constant") do
156
- skip "redefining Struct with same name cause warnings"
157
- begin
158
- assert_not_equal Struct.new("Test", :a), Struct.new("Test", :a, :b)
159
- ensure
160
- Struct.remove_const :Test
161
- end
162
- end
156
+ # TODO: suppress redefining Struct warning during test
157
+ # assert("Struct.new removes existing constant") do
158
+ # begin
159
+ # assert_not_equal Struct.new("Test", :a), Struct.new("Test", :a, :b)
160
+ # ensure
161
+ # Struct.remove_const :Test
162
+ # end
163
+ # end
163
164
 
164
165
  assert("Struct#initialize_copy requires struct to be the same type") do
165
166
  begin
@@ -181,6 +182,10 @@
181
182
  end
182
183
  end
183
184
 
185
+ assert("Struct.new does not allow invalid class name") do
186
+ assert_raise(NameError) { Struct.new("Test-", :a) }
187
+ end
188
+
184
189
  assert("Struct.new generates subclass of Struct") do
185
190
  begin
186
191
  original_struct = Struct