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,6 +20,22 @@ typedef struct symbol_name {
20
20
  const char *name;
21
21
  } symbol_name;
22
22
 
23
+ #define SYMBOL_INLINE_BIT_POS 1
24
+ #define SYMBOL_INLINE_LOWER_BIT_POS 2
25
+ #define SYMBOL_INLINE (1 << (SYMBOL_INLINE_BIT_POS - 1))
26
+ #define SYMBOL_INLINE_LOWER (1 << (SYMBOL_INLINE_LOWER_BIT_POS - 1))
27
+ #define SYMBOL_NORMAL_SHIFT SYMBOL_INLINE_BIT_POS
28
+ #define SYMBOL_INLINE_SHIFT SYMBOL_INLINE_LOWER_BIT_POS
29
+ #ifdef MRB_ENABLE_ALL_SYMBOLS
30
+ # define SYMBOL_INLINE_P(sym) FALSE
31
+ # define SYMBOL_INLINE_LOWER_P(sym) FALSE
32
+ # define sym_inline_pack(name, len) 0
33
+ # define sym_inline_unpack(sym, buf, lenp) NULL
34
+ #else
35
+ # define SYMBOL_INLINE_P(sym) ((sym) & SYMBOL_INLINE)
36
+ # define SYMBOL_INLINE_LOWER_P(sym) ((sym) & SYMBOL_INLINE_LOWER)
37
+ #endif
38
+
23
39
  static void
24
40
  sym_validate_len(mrb_state *mrb, size_t len)
25
41
  {
@@ -34,14 +50,14 @@ static const char pack_table[] = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRS
34
50
  static mrb_sym
35
51
  sym_inline_pack(const char *name, uint16_t len)
36
52
  {
37
- const int lower_length_max = (MRB_SYMBOL_BITSIZE - 2) / 5;
38
- const int mix_length_max = (MRB_SYMBOL_BITSIZE - 2) / 6;
53
+ const int lower_length_max = (MRB_SYMBOL_BIT - 2) / 5;
54
+ const int mix_length_max = (MRB_SYMBOL_BIT - 2) / 6;
39
55
 
40
56
  char c;
41
57
  const char *p;
42
58
  int i;
43
59
  mrb_sym sym = 0;
44
- int lower = 1;
60
+ mrb_bool lower = TRUE;
45
61
 
46
62
  if (len > lower_length_max) return 0; /* too long */
47
63
  for (i=0; i<len; i++) {
@@ -52,9 +68,9 @@ sym_inline_pack(const char *name, uint16_t len)
52
68
  p = strchr(pack_table, (int)c);
53
69
  if (p == 0) return 0; /* non alnum char */
54
70
  bits = (uint32_t)(p - pack_table)+1;
55
- if (bits > 27) lower = 0;
71
+ if (bits > 27) lower = FALSE;
56
72
  if (i >= mix_length_max) break;
57
- sym |= bits<<(i*6+2);
73
+ sym |= bits<<(i*6+SYMBOL_INLINE_SHIFT);
58
74
  }
59
75
  if (lower) {
60
76
  sym = 0;
@@ -64,24 +80,24 @@ sym_inline_pack(const char *name, uint16_t len)
64
80
  c = name[i];
65
81
  p = strchr(pack_table, (int)c);
66
82
  bits = (uint32_t)(p - pack_table)+1;
67
- sym |= bits<<(i*5+2);
83
+ sym |= bits<<(i*5+SYMBOL_INLINE_SHIFT);
68
84
  }
69
- return sym | 3;
85
+ return sym | SYMBOL_INLINE | SYMBOL_INLINE_LOWER;
70
86
  }
71
87
  if (len > mix_length_max) return 0;
72
- return sym | 1;
88
+ return sym | SYMBOL_INLINE;
73
89
  }
74
90
 
75
91
  static const char*
76
92
  sym_inline_unpack(mrb_sym sym, char *buf, mrb_int *lenp)
77
93
  {
78
- int bit_per_char = sym&2 ? 5 : 6; /* all lower case if `sym&2` is true */
94
+ int bit_per_char = SYMBOL_INLINE_LOWER_P(sym) ? 5 : 6;
79
95
  int i;
80
96
 
81
- mrb_assert(sym&1);
97
+ mrb_assert(SYMBOL_INLINE_P(sym));
82
98
 
83
99
  for (i=0; i<30/bit_per_char; i++) {
84
- uint32_t bits = sym>>(i*bit_per_char+2) & ((1<<bit_per_char)-1);
100
+ uint32_t bits = sym>>(i*bit_per_char+SYMBOL_INLINE_SHIFT) & ((1<<bit_per_char)-1);
85
101
  if (bits == 0) break;
86
102
  buf[i] = pack_table[bits-1];;
87
103
  }
@@ -91,7 +107,7 @@ sym_inline_unpack(mrb_sym sym, char *buf, mrb_int *lenp)
91
107
  }
92
108
  #endif
93
109
 
94
- uint8_t
110
+ static uint8_t
95
111
  symhash(const char *key, size_t len)
96
112
  {
97
113
  uint32_t hash, i;
@@ -108,30 +124,32 @@ symhash(const char *key, size_t len)
108
124
  }
109
125
 
110
126
  static mrb_sym
111
- find_symbol(mrb_state *mrb, const char *name, uint16_t len, uint8_t hash)
127
+ find_symbol(mrb_state *mrb, const char *name, uint16_t len, uint8_t *hashp)
112
128
  {
113
129
  mrb_sym i;
114
130
  symbol_name *sname;
131
+ uint8_t hash;
115
132
 
116
- #ifndef MRB_ENABLE_ALL_SYMBOLS
117
133
  /* inline symbol */
118
134
  i = sym_inline_pack(name, len);
119
135
  if (i > 0) return i;
120
- #endif
136
+
137
+ hash = symhash(name, len);
138
+ if (hashp) *hashp = hash;
121
139
 
122
140
  i = mrb->symhash[hash];
123
141
  if (i == 0) return 0;
124
142
  do {
125
143
  sname = &mrb->symtbl[i];
126
144
  if (sname->len == len && memcmp(sname->name, name, len) == 0) {
127
- return i<<1;
145
+ return i<<SYMBOL_NORMAL_SHIFT;
128
146
  }
129
147
  if (sname->prev == 0xff) {
130
148
  i -= 0xff;
131
149
  sname = &mrb->symtbl[i];
132
150
  while (mrb->symtbl < sname) {
133
151
  if (sname->len == len && memcmp(sname->name, name, len) == 0) {
134
- return (mrb_sym)(sname - mrb->symtbl)<<1;
152
+ return (mrb_sym)(sname - mrb->symtbl)<<SYMBOL_NORMAL_SHIFT;
135
153
  }
136
154
  sname--;
137
155
  }
@@ -150,8 +168,7 @@ sym_intern(mrb_state *mrb, const char *name, size_t len, mrb_bool lit)
150
168
  uint8_t hash;
151
169
 
152
170
  sym_validate_len(mrb, len);
153
- hash = symhash(name, len);
154
- sym = find_symbol(mrb, name, len, hash);
171
+ sym = find_symbol(mrb, name, len, &hash);
155
172
  if (sym > 0) return sym;
156
173
 
157
174
  /* registering a new symbol */
@@ -186,7 +203,7 @@ sym_intern(mrb_state *mrb, const char *name, size_t len, mrb_bool lit)
186
203
  }
187
204
  mrb->symhash[hash] = sym;
188
205
 
189
- return sym<<1;
206
+ return sym<<SYMBOL_NORMAL_SHIFT;
190
207
  }
191
208
 
192
209
  MRB_API mrb_sym
@@ -219,7 +236,7 @@ mrb_check_intern(mrb_state *mrb, const char *name, size_t len)
219
236
  mrb_sym sym;
220
237
 
221
238
  sym_validate_len(mrb, len);
222
- sym = find_symbol(mrb, name, len, symhash(name, len));
239
+ sym = find_symbol(mrb, name, len, NULL);
223
240
  if (sym > 0) return mrb_symbol_value(sym);
224
241
  return mrb_nil_value();
225
242
  }
@@ -239,13 +256,9 @@ mrb_check_intern_str(mrb_state *mrb, mrb_value str)
239
256
  static const char*
240
257
  sym2name_len(mrb_state *mrb, mrb_sym sym, char *buf, mrb_int *lenp)
241
258
  {
242
- #ifndef MRB_ENABLE_ALL_SYMBOLS
243
- if (sym & 1) { /* inline packed symbol */
244
- return sym_inline_unpack(sym, buf, lenp);
245
- }
246
- #endif
259
+ if (SYMBOL_INLINE_P(sym)) return sym_inline_unpack(sym, buf, lenp);
247
260
 
248
- sym >>= 1;
261
+ sym >>= SYMBOL_NORMAL_SHIFT;
249
262
  if (sym == 0 || mrb->symidx < sym) {
250
263
  if (lenp) *lenp = 0;
251
264
  return NULL;
@@ -256,7 +269,7 @@ sym2name_len(mrb_state *mrb, mrb_sym sym, char *buf, mrb_int *lenp)
256
269
  }
257
270
 
258
271
  MRB_API const char*
259
- mrb_sym2name_len(mrb_state *mrb, mrb_sym sym, mrb_int *lenp)
272
+ mrb_sym_name_len(mrb_state *mrb, mrb_sym sym, mrb_int *lenp)
260
273
  {
261
274
  return sym2name_len(mrb, sym, mrb->symbuf, lenp);
262
275
  }
@@ -326,7 +339,7 @@ mrb_init_symtbl(mrb_state *mrb)
326
339
  static mrb_value
327
340
  sym_to_s(mrb_state *mrb, mrb_value sym)
328
341
  {
329
- return mrb_sym2str(mrb, mrb_symbol(sym));
342
+ return mrb_sym_str(mrb, mrb_symbol(sym));
330
343
  }
331
344
 
332
345
  /* 15.2.11.3.4 */
@@ -481,57 +494,69 @@ sym_inspect(mrb_state *mrb, mrb_value sym)
481
494
  mrb_sym id = mrb_symbol(sym);
482
495
  char *sp;
483
496
 
484
- name = mrb_sym2name_len(mrb, id, &len);
497
+ name = mrb_sym_name_len(mrb, id, &len);
485
498
  str = mrb_str_new(mrb, 0, len+1);
486
499
  sp = RSTRING_PTR(str);
487
- RSTRING_PTR(str)[0] = ':';
500
+ sp[0] = ':';
488
501
  memcpy(sp+1, name, len);
489
502
  mrb_assert_int_fit(mrb_int, len, size_t, SIZE_MAX);
490
503
  if (!symname_p(name) || strlen(name) != (size_t)len) {
491
- str = mrb_str_dump(mrb, str);
504
+ str = mrb_str_inspect(mrb, str);
492
505
  sp = RSTRING_PTR(str);
493
506
  sp[0] = ':';
494
507
  sp[1] = '"';
495
508
  }
509
+ #ifdef MRB_UTF8_STRING
510
+ if (SYMBOL_INLINE_P(id)) RSTR_SET_ASCII_FLAG(mrb_str_ptr(str));
511
+ #endif
496
512
  return str;
497
513
  }
498
514
 
499
515
  MRB_API mrb_value
500
- mrb_sym2str(mrb_state *mrb, mrb_sym sym)
516
+ mrb_sym_str(mrb_state *mrb, mrb_sym sym)
501
517
  {
502
518
  mrb_int len;
503
- const char *name = mrb_sym2name_len(mrb, sym, &len);
519
+ const char *name = mrb_sym_name_len(mrb, sym, &len);
504
520
 
505
521
  if (!name) return mrb_undef_value(); /* can't happen */
506
- if (sym&1) { /* inline symbol */
507
- return mrb_str_new(mrb, name, len);
522
+ if (SYMBOL_INLINE_P(sym)) {
523
+ mrb_value str = mrb_str_new(mrb, name, len);
524
+ RSTR_SET_ASCII_FLAG(mrb_str_ptr(str));
525
+ return str;
508
526
  }
509
527
  return mrb_str_new_static(mrb, name, len);
510
528
  }
511
529
 
512
- MRB_API const char*
513
- mrb_sym2name(mrb_state *mrb, mrb_sym sym)
530
+ static const char*
531
+ sym_name(mrb_state *mrb, mrb_sym sym, mrb_bool dump)
514
532
  {
515
533
  mrb_int len;
516
- const char *name = mrb_sym2name_len(mrb, sym, &len);
534
+ const char *name = mrb_sym_name_len(mrb, sym, &len);
517
535
 
518
536
  if (!name) return NULL;
519
- if (symname_p(name) && strlen(name) == (size_t)len) {
537
+ if (strlen(name) == (size_t)len && (!dump || symname_p(name))) {
520
538
  return name;
521
539
  }
522
540
  else {
523
- mrb_value str;
524
- if (sym&1) { /* inline symbol */
525
- str = mrb_str_new(mrb, name, len);
526
- }
527
- else {
528
- str = mrb_str_new_static(mrb, name, len);
529
- }
541
+ mrb_value str = SYMBOL_INLINE_P(sym) ?
542
+ mrb_str_new(mrb, name, len) : mrb_str_new_static(mrb, name, len);
530
543
  str = mrb_str_dump(mrb, str);
531
544
  return RSTRING_PTR(str);
532
545
  }
533
546
  }
534
547
 
548
+ MRB_API const char*
549
+ mrb_sym_name(mrb_state *mrb, mrb_sym sym)
550
+ {
551
+ return sym_name(mrb, sym, FALSE);
552
+ }
553
+
554
+ MRB_API const char*
555
+ mrb_sym_dump(mrb_state *mrb, mrb_sym sym)
556
+ {
557
+ return sym_name(mrb, sym, TRUE);
558
+ }
559
+
535
560
  #define lesser(a,b) (((a)>(b))?(b):(a))
536
561
 
537
562
  static mrb_value
@@ -541,7 +566,7 @@ sym_cmp(mrb_state *mrb, mrb_value s1)
541
566
  mrb_sym sym1, sym2;
542
567
 
543
568
  mrb_get_args(mrb, "o", &s2);
544
- if (mrb_type(s2) != MRB_TT_SYMBOL) return mrb_nil_value();
569
+ if (!mrb_symbol_p(s2)) return mrb_nil_value();
545
570
  sym1 = mrb_symbol(s1);
546
571
  sym2 = mrb_symbol(s2);
547
572
  if (sym1 == sym2) return mrb_fixnum_value(0);
@@ -79,19 +79,19 @@ iv_put(mrb_state *mrb, iv_tbl *t, mrb_sym sym, mrb_value val)
79
79
  }
80
80
 
81
81
  /* Not found */
82
- t->size++;
83
82
  if (matched_seg) {
84
83
  matched_seg->key[matched_idx] = sym;
85
84
  matched_seg->val[matched_idx] = val;
85
+ t->size++;
86
86
  return;
87
87
  }
88
88
 
89
89
  seg = (segment*)mrb_malloc(mrb, sizeof(segment));
90
- if (!seg) return;
91
90
  seg->next = NULL;
92
91
  seg->key[0] = sym;
93
92
  seg->val[0] = val;
94
93
  t->last_len = 1;
94
+ t->size++;
95
95
  if (prev) {
96
96
  prev->next = seg;
97
97
  }
@@ -341,23 +341,24 @@ mrb_iv_get(mrb_state *mrb, mrb_value obj, mrb_sym sym)
341
341
 
342
342
  static inline void assign_class_name(mrb_state *mrb, struct RObject *obj, mrb_sym sym, mrb_value v);
343
343
 
344
- MRB_API void
345
- mrb_obj_iv_set(mrb_state *mrb, struct RObject *obj, mrb_sym sym, mrb_value v)
344
+ void
345
+ mrb_obj_iv_set_force(mrb_state *mrb, struct RObject *obj, mrb_sym sym, mrb_value v)
346
346
  {
347
- iv_tbl *t;
348
-
349
- if (MRB_FROZEN_P(obj)) {
350
- mrb_raisef(mrb, E_FROZEN_ERROR, "can't modify frozen %S", mrb_obj_value(obj));
351
- }
352
347
  assign_class_name(mrb, obj, sym, v);
353
348
  if (!obj->iv) {
354
349
  obj->iv = iv_new(mrb);
355
350
  }
356
- t = obj->iv;
357
- iv_put(mrb, t, sym, v);
351
+ iv_put(mrb, obj->iv, sym, v);
358
352
  mrb_write_barrier(mrb, (struct RBasic*)obj);
359
353
  }
360
354
 
355
+ MRB_API void
356
+ mrb_obj_iv_set(mrb_state *mrb, struct RObject *obj, mrb_sym sym, mrb_value v)
357
+ {
358
+ mrb_check_frozen(mrb, obj);
359
+ mrb_obj_iv_set_force(mrb, obj, sym, v);
360
+ }
361
+
361
362
  /* Iterates over the instance variable table. */
362
363
  MRB_API void
363
364
  mrb_iv_foreach(mrb_state *mrb, mrb_value obj, mrb_iv_foreach_func *func, void *p)
@@ -377,7 +378,7 @@ assign_class_name(mrb_state *mrb, struct RObject *obj, mrb_sym sym, mrb_value v)
377
378
  {
378
379
  if (namespace_p(obj->tt) && namespace_p(mrb_type(v))) {
379
380
  struct RObject *c = mrb_obj_ptr(v);
380
- if (obj != c && ISUPPER(mrb_sym2name(mrb, sym)[0])) {
381
+ if (obj != c && ISUPPER(mrb_sym_name_len(mrb, sym, NULL)[0])) {
381
382
  mrb_sym id_classname = mrb_intern_lit(mrb, "__classname__");
382
383
  mrb_value o = mrb_obj_iv_get(mrb, c, id_classname);
383
384
 
@@ -387,10 +388,10 @@ assign_class_name(mrb_state *mrb, struct RObject *obj, mrb_sym sym, mrb_value v)
387
388
 
388
389
  if (mrb_nil_p(o)) {
389
390
  if ((struct RClass *)obj == mrb->object_class) {
390
- mrb_obj_iv_set(mrb, c, id_classname, mrb_symbol_value(sym));
391
+ mrb_obj_iv_set_force(mrb, c, id_classname, mrb_symbol_value(sym));
391
392
  }
392
393
  else {
393
- mrb_obj_iv_set(mrb, c, id_outer, mrb_obj_value(obj));
394
+ mrb_obj_iv_set_force(mrb, c, id_outer, mrb_obj_value(obj));
394
395
  }
395
396
  }
396
397
  }
@@ -434,7 +435,7 @@ mrb_iv_name_sym_p(mrb_state *mrb, mrb_sym iv_name)
434
435
  const char *s;
435
436
  mrb_int len;
436
437
 
437
- s = mrb_sym2name_len(mrb, iv_name, &len);
438
+ s = mrb_sym_name_len(mrb, iv_name, &len);
438
439
  if (len < 2) return FALSE;
439
440
  if (s[0] != '@') return FALSE;
440
441
  if (ISDIGIT(s[1])) return FALSE;
@@ -445,7 +446,7 @@ MRB_API void
445
446
  mrb_iv_name_sym_check(mrb_state *mrb, mrb_sym iv_name)
446
447
  {
447
448
  if (!mrb_iv_name_sym_p(mrb, iv_name)) {
448
- mrb_name_error(mrb, iv_name, "'%S' is not allowed as an instance variable name", mrb_sym2str(mrb, iv_name));
449
+ mrb_name_error(mrb, iv_name, "'%n' is not allowed as an instance variable name", iv_name);
449
450
  }
450
451
  }
451
452
 
@@ -482,10 +483,10 @@ inspect_i(mrb_state *mrb, mrb_sym sym, mrb_value v, void *p)
482
483
  else {
483
484
  mrb_str_cat_lit(mrb, str, ", ");
484
485
  }
485
- s = mrb_sym2name_len(mrb, sym, &len);
486
+ s = mrb_sym_name_len(mrb, sym, &len);
486
487
  mrb_str_cat(mrb, str, s, len);
487
488
  mrb_str_cat_lit(mrb, str, "=");
488
- if (mrb_type(v) == MRB_TT_OBJECT) {
489
+ if (mrb_object_p(v)) {
489
490
  ins = mrb_any_to_s(mrb, v);
490
491
  }
491
492
  else {
@@ -508,7 +509,7 @@ mrb_obj_iv_inspect(mrb_state *mrb, struct RObject *obj)
508
509
  mrb_str_cat_lit(mrb, str, "-<");
509
510
  mrb_str_cat_cstr(mrb, str, cn);
510
511
  mrb_str_cat_lit(mrb, str, ":");
511
- mrb_str_concat(mrb, str, mrb_ptr_to_str(mrb, obj));
512
+ mrb_str_cat_str(mrb, str, mrb_ptr_to_str(mrb, obj));
512
513
 
513
514
  iv_foreach(mrb, t, inspect_i, &str);
514
515
  mrb_str_cat_lit(mrb, str, ">");
@@ -524,6 +525,7 @@ mrb_iv_remove(mrb_state *mrb, mrb_value obj, mrb_sym sym)
524
525
  iv_tbl *t = mrb_obj_ptr(obj)->iv;
525
526
  mrb_value val;
526
527
 
528
+ mrb_check_frozen(mrb, mrb_obj_ptr(obj));
527
529
  if (iv_del(mrb, t, sym, &val)) {
528
530
  return val;
529
531
  }
@@ -539,7 +541,7 @@ iv_i(mrb_state *mrb, mrb_sym sym, mrb_value v, void *p)
539
541
  mrb_int len;
540
542
 
541
543
  ary = *(mrb_value*)p;
542
- s = mrb_sym2name_len(mrb, sym, &len);
544
+ s = mrb_sym_name_len(mrb, sym, &len);
543
545
  if (len > 1 && s[0] == '@' && s[1] != '@') {
544
546
  mrb_ary_push(mrb, ary, mrb_symbol_value(sym));
545
547
  }
@@ -583,7 +585,7 @@ cv_i(mrb_state *mrb, mrb_sym sym, mrb_value v, void *p)
583
585
  mrb_int len;
584
586
 
585
587
  ary = *(mrb_value*)p;
586
- s = mrb_sym2name_len(mrb, sym, &len);
588
+ s = mrb_sym_name_len(mrb, sym, &len);
587
589
  if (len > 2 && s[0] == '@' && s[1] == '@') {
588
590
  mrb_ary_push(mrb, ary, mrb_symbol_value(sym));
589
591
  }
@@ -593,7 +595,7 @@ cv_i(mrb_state *mrb, mrb_sym sym, mrb_value v, void *p)
593
595
  /* 15.2.2.4.19 */
594
596
  /*
595
597
  * call-seq:
596
- * mod.class_variables -> array
598
+ * mod.class_variables(inherit=true) -> array
597
599
  *
598
600
  * Returns an array of the names of class variables in <i>mod</i>.
599
601
  *
@@ -611,11 +613,14 @@ mrb_mod_class_variables(mrb_state *mrb, mrb_value mod)
611
613
  {
612
614
  mrb_value ary;
613
615
  struct RClass *c;
616
+ mrb_bool inherit = TRUE;
614
617
 
618
+ mrb_get_args(mrb, "|b", &inherit);
615
619
  ary = mrb_ary_new(mrb);
616
620
  c = mrb_class_ptr(mod);
617
621
  while (c) {
618
622
  iv_foreach(mrb, c->iv, cv_i, &ary);
623
+ if (!inherit) break;
619
624
  c = c->super;
620
625
  }
621
626
  return ary;
@@ -652,8 +657,7 @@ mrb_mod_cv_get(mrb_state *mrb, struct RClass *c, mrb_sym sym)
652
657
  if (given) return v;
653
658
  }
654
659
  }
655
- mrb_name_error(mrb, sym, "uninitialized class variable %S in %S",
656
- mrb_sym2str(mrb, sym), mrb_obj_value(cls));
660
+ mrb_name_error(mrb, sym, "uninitialized class variable %n in %C", sym, cls);
657
661
  /* not reached */
658
662
  return mrb_nil_value();
659
663
  }
@@ -673,6 +677,7 @@ mrb_mod_cv_set(mrb_state *mrb, struct RClass *c, mrb_sym sym, mrb_value v)
673
677
  iv_tbl *t = c->iv;
674
678
 
675
679
  if (iv_get(mrb, t, sym, NULL)) {
680
+ mrb_check_frozen(mrb, c);
676
681
  iv_put(mrb, t, sym, v);
677
682
  mrb_write_barrier(mrb, (struct RBasic*)c);
678
683
  return;
@@ -700,6 +705,7 @@ mrb_mod_cv_set(mrb_state *mrb, struct RClass *c, mrb_sym sym, mrb_value v)
700
705
  c = cls;
701
706
  }
702
707
 
708
+ mrb_check_frozen(mrb, c);
703
709
  if (!c->iv) {
704
710
  c->iv = iv_new(mrb);
705
711
  }
@@ -737,7 +743,13 @@ mrb_vm_cv_get(mrb_state *mrb, mrb_sym sym)
737
743
  {
738
744
  struct RClass *c;
739
745
 
740
- c = MRB_PROC_TARGET_CLASS(mrb->c->ci->proc);
746
+ struct RProc *p = mrb->c->ci->proc;
747
+
748
+ for (;;) {
749
+ c = MRB_PROC_TARGET_CLASS(p);
750
+ if (c->tt != MRB_TT_SCLASS) break;
751
+ p = p->upper;
752
+ }
741
753
  return mrb_mod_cv_get(mrb, c, sym);
742
754
  }
743
755
 
@@ -745,8 +757,13 @@ void
745
757
  mrb_vm_cv_set(mrb_state *mrb, mrb_sym sym, mrb_value v)
746
758
  {
747
759
  struct RClass *c;
760
+ struct RProc *p = mrb->c->ci->proc;
748
761
 
749
- c = MRB_PROC_TARGET_CLASS(mrb->c->ci->proc);
762
+ for (;;) {
763
+ c = MRB_PROC_TARGET_CLASS(p);
764
+ if (c->tt != MRB_TT_SCLASS) break;
765
+ p = p->upper;
766
+ }
750
767
  mrb_mod_cv_set(mrb, c, sym, v);
751
768
  }
752
769
 
@@ -877,9 +894,17 @@ const_i(mrb_state *mrb, mrb_sym sym, mrb_value v, void *p)
877
894
  mrb_int len;
878
895
 
879
896
  ary = *(mrb_value*)p;
880
- s = mrb_sym2name_len(mrb, sym, &len);
897
+ s = mrb_sym_name_len(mrb, sym, &len);
881
898
  if (len >= 1 && ISUPPER(s[0])) {
882
- mrb_ary_push(mrb, ary, mrb_symbol_value(sym));
899
+ mrb_int i, alen = RARRAY_LEN(ary);
900
+
901
+ for (i=0; i<alen; i++) {
902
+ if (mrb_symbol(RARRAY_PTR(ary)[i]) == sym)
903
+ break;
904
+ }
905
+ if (i==alen) {
906
+ mrb_ary_push(mrb, ary, mrb_symbol_value(sym));
907
+ }
883
908
  }
884
909
  return 0;
885
910
  }
@@ -962,16 +987,8 @@ mrb_f_global_variables(mrb_state *mrb, mrb_value self)
962
987
  {
963
988
  iv_tbl *t = mrb->globals;
964
989
  mrb_value ary = mrb_ary_new(mrb);
965
- size_t i;
966
- char buf[3];
967
990
 
968
991
  iv_foreach(mrb, t, gv_i, &ary);
969
- buf[0] = '$';
970
- buf[2] = 0;
971
- for (i = 1; i <= 9; ++i) {
972
- buf[1] = (char)(i + '0');
973
- mrb_ary_push(mrb, ary, mrb_symbol_value(mrb_intern(mrb, buf, 2)));
974
- }
975
992
  return ary;
976
993
  }
977
994
 
@@ -1100,12 +1117,13 @@ mrb_class_find_path(mrb_state *mrb, struct RClass *c)
1100
1117
  mrb_str_cat_cstr(mrb, path, str);
1101
1118
  mrb_str_cat_cstr(mrb, path, "::");
1102
1119
 
1103
- str = mrb_sym2name_len(mrb, name, &len);
1120
+ str = mrb_sym_name_len(mrb, name, &len);
1104
1121
  mrb_str_cat(mrb, path, str, len);
1105
1122
  if (RSTRING_PTR(path)[0] != '#') {
1106
1123
  iv_del(mrb, c->iv, mrb_intern_lit(mrb, "__outer__"), NULL);
1107
1124
  iv_put(mrb, c->iv, mrb_intern_lit(mrb, "__classname__"), path);
1108
1125
  mrb_field_write_barrier_value(mrb, (struct RBasic*)c, path);
1126
+ path = mrb_str_dup(mrb, path);
1109
1127
  }
1110
1128
  return path;
1111
1129
  }
@@ -1115,7 +1133,9 @@ mrb_class_find_path(mrb_state *mrb, struct RClass *c)
1115
1133
  mrb_bool
1116
1134
  mrb_ident_p(const char *s, mrb_int len)
1117
1135
  {
1118
- for (mrb_int i = 0; i < len; i++) {
1136
+ mrb_int i;
1137
+
1138
+ for (i = 0; i < len; i++) {
1119
1139
  if (!identchar(s[i])) return FALSE;
1120
1140
  }
1121
1141
  return TRUE;