script_core 0.2.7 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (283) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/Gemfile +2 -2
  4. data/ext/enterprise_script_service/Rakefile +1 -1
  5. data/ext/enterprise_script_service/mruby/.github/workflows/build.yml +117 -74
  6. data/ext/enterprise_script_service/mruby/.github/workflows/codeql-analysis.yml +41 -37
  7. data/ext/enterprise_script_service/mruby/.github/workflows/lint.yml +23 -0
  8. data/ext/enterprise_script_service/mruby/.github/workflows/oss-fuzz.yml +27 -0
  9. data/ext/enterprise_script_service/mruby/.github/workflows/spell-checker.yml +17 -0
  10. data/ext/enterprise_script_service/mruby/.gitlab-ci.yml +3 -3
  11. data/ext/enterprise_script_service/mruby/.markdownlint.yml +16 -0
  12. data/ext/enterprise_script_service/mruby/.travis.yml +2 -2
  13. data/ext/enterprise_script_service/mruby/.yamllint +8 -0
  14. data/ext/enterprise_script_service/mruby/AUTHORS +3 -0
  15. data/ext/enterprise_script_service/mruby/CODEOWNERS +1 -0
  16. data/ext/enterprise_script_service/mruby/CONTRIBUTING.md +6 -13
  17. data/ext/enterprise_script_service/mruby/Doxyfile +4 -4
  18. data/ext/enterprise_script_service/mruby/LICENSE +1 -1
  19. data/ext/enterprise_script_service/mruby/Makefile +1 -1
  20. data/ext/enterprise_script_service/mruby/README.md +4 -14
  21. data/ext/enterprise_script_service/mruby/Rakefile +18 -108
  22. data/ext/enterprise_script_service/mruby/TODO.md +17 -0
  23. data/ext/enterprise_script_service/mruby/appveyor.yml +31 -25
  24. data/ext/enterprise_script_service/mruby/benchmark/bm_ao_render.rb +1 -1
  25. data/ext/enterprise_script_service/mruby/build_config.rb +9 -152
  26. data/ext/enterprise_script_service/mruby/{examples/targets/build_config_ArduinoDue.rb → build_config/ArduinoDue.rb} +2 -19
  27. data/ext/enterprise_script_service/mruby/{examples/targets/build_config_IntelEdison.rb → build_config/IntelEdison.rb} +2 -2
  28. data/ext/enterprise_script_service/mruby/{examples/targets/build_config_IntelGalileo.rb → build_config/IntelGalileo.rb} +1 -18
  29. data/ext/enterprise_script_service/mruby/{examples/targets/build_config_RX630.rb → build_config/RX630.rb} +2 -19
  30. data/ext/enterprise_script_service/mruby/build_config/android_arm64-v8a.rb +11 -0
  31. data/ext/enterprise_script_service/mruby/build_config/android_armeabi.rb +11 -0
  32. data/ext/enterprise_script_service/mruby/{examples/targets/build_config_android_armeabi_v7a_neon_hard.rb → build_config/android_armeabi_v7a_neon_hard.rb} +0 -15
  33. data/ext/enterprise_script_service/mruby/build_config/bench.rb +11 -0
  34. data/ext/enterprise_script_service/mruby/build_config/boxing.rb +21 -0
  35. data/ext/enterprise_script_service/mruby/{examples/targets/build_config_chipKITMax32.rb → build_config/chipKITMax32.rb} +2 -19
  36. data/ext/enterprise_script_service/mruby/{travis_config.rb → build_config/ci/gcc-clang.rb} +10 -10
  37. data/ext/enterprise_script_service/mruby/build_config/ci/msvc.rb +20 -0
  38. data/ext/enterprise_script_service/mruby/build_config/clang-asan.rb +11 -0
  39. data/ext/enterprise_script_service/mruby/build_config/cross-32bit.rb +14 -0
  40. data/ext/enterprise_script_service/mruby/build_config/default.rb +80 -0
  41. data/ext/enterprise_script_service/mruby/{examples/targets/build_config_dreamcast_shelf.rb → build_config/dreamcast_shelf.rb} +5 -19
  42. data/ext/enterprise_script_service/mruby/build_config/gameboyadvance.rb +73 -0
  43. data/ext/enterprise_script_service/mruby/build_config/host-cxx.rb +12 -0
  44. data/ext/enterprise_script_service/mruby/build_config/host-debug.rb +20 -0
  45. data/ext/enterprise_script_service/mruby/build_config/host-gprof.rb +14 -0
  46. data/ext/enterprise_script_service/mruby/build_config/host-m32.rb +15 -0
  47. data/ext/enterprise_script_service/mruby/build_config/host-shared.rb +36 -0
  48. data/ext/enterprise_script_service/mruby/build_config/mrbc.rb +11 -0
  49. data/ext/enterprise_script_service/mruby/build_config/no-float.rb +17 -0
  50. data/ext/enterprise_script_service/mruby/doc/guides/compile.md +138 -49
  51. data/ext/enterprise_script_service/mruby/doc/guides/debugger.md +5 -4
  52. data/ext/enterprise_script_service/mruby/doc/guides/gc-arena-howto.md +1 -1
  53. data/ext/enterprise_script_service/mruby/doc/guides/mrbconf.md +49 -22
  54. data/ext/enterprise_script_service/mruby/doc/guides/mrbgems.md +31 -14
  55. data/ext/enterprise_script_service/mruby/doc/guides/symbol.md +83 -0
  56. data/ext/enterprise_script_service/mruby/doc/limitations.md +35 -36
  57. data/ext/enterprise_script_service/mruby/doc/mruby3.md +163 -0
  58. data/ext/enterprise_script_service/mruby/doc/opcode.md +93 -107
  59. data/ext/enterprise_script_service/mruby/examples/mrbgems/c_and_ruby_extension_example/mrblib/example.rb +1 -1
  60. data/ext/enterprise_script_service/mruby/examples/mrbgems/c_and_ruby_extension_example/src/example.c +5 -1
  61. data/ext/enterprise_script_service/mruby/examples/mrbgems/c_extension_example/src/example.c +5 -1
  62. data/ext/enterprise_script_service/mruby/examples/mrbgems/ruby_extension_example/mrblib/example.rb +1 -1
  63. data/ext/enterprise_script_service/mruby/include/mrbconf.h +81 -62
  64. data/ext/enterprise_script_service/mruby/include/mruby.h +137 -96
  65. data/ext/enterprise_script_service/mruby/include/mruby/array.h +23 -6
  66. data/ext/enterprise_script_service/mruby/include/mruby/boxing_nan.h +73 -48
  67. data/ext/enterprise_script_service/mruby/include/mruby/boxing_no.h +8 -8
  68. data/ext/enterprise_script_service/mruby/include/mruby/boxing_word.h +79 -48
  69. data/ext/enterprise_script_service/mruby/include/mruby/class.h +10 -8
  70. data/ext/enterprise_script_service/mruby/include/mruby/common.h +4 -1
  71. data/ext/enterprise_script_service/mruby/include/mruby/compile.h +13 -7
  72. data/ext/enterprise_script_service/mruby/include/mruby/debug.h +2 -2
  73. data/ext/enterprise_script_service/mruby/include/mruby/dump.h +17 -35
  74. data/ext/enterprise_script_service/mruby/include/mruby/endian.h +44 -0
  75. data/ext/enterprise_script_service/mruby/include/mruby/error.h +39 -5
  76. data/ext/enterprise_script_service/mruby/include/mruby/gc.h +1 -0
  77. data/ext/enterprise_script_service/mruby/include/mruby/hash.h +33 -13
  78. data/ext/enterprise_script_service/mruby/include/mruby/irep.h +64 -14
  79. data/ext/enterprise_script_service/mruby/include/mruby/khash.h +6 -14
  80. data/ext/enterprise_script_service/mruby/include/mruby/numeric.h +36 -63
  81. data/ext/enterprise_script_service/mruby/include/mruby/opcode.h +1 -27
  82. data/ext/enterprise_script_service/mruby/include/mruby/ops.h +27 -23
  83. data/ext/enterprise_script_service/mruby/include/mruby/presym.h +40 -0
  84. data/ext/enterprise_script_service/mruby/include/mruby/presym/disable.h +70 -0
  85. data/ext/enterprise_script_service/mruby/include/mruby/presym/enable.h +37 -0
  86. data/ext/enterprise_script_service/mruby/include/mruby/presym/scanning.h +73 -0
  87. data/ext/enterprise_script_service/mruby/include/mruby/proc.h +80 -13
  88. data/ext/enterprise_script_service/mruby/include/mruby/string.h +10 -15
  89. data/ext/enterprise_script_service/mruby/include/mruby/throw.h +14 -3
  90. data/ext/enterprise_script_service/mruby/include/mruby/value.h +29 -19
  91. data/ext/enterprise_script_service/mruby/include/mruby/variable.h +1 -0
  92. data/ext/enterprise_script_service/mruby/include/mruby/version.h +26 -7
  93. data/ext/enterprise_script_service/mruby/lib/mruby/build.rb +198 -44
  94. data/ext/enterprise_script_service/mruby/lib/mruby/build/command.rb +55 -37
  95. data/ext/enterprise_script_service/mruby/lib/mruby/build/load_gems.rb +12 -10
  96. data/ext/enterprise_script_service/mruby/lib/{mruby-core-ext.rb → mruby/core_ext.rb} +10 -3
  97. data/ext/enterprise_script_service/mruby/lib/mruby/gem.rb +75 -32
  98. data/ext/enterprise_script_service/mruby/lib/mruby/lockfile.rb +1 -1
  99. data/ext/enterprise_script_service/mruby/lib/mruby/presym.rb +132 -0
  100. data/ext/enterprise_script_service/mruby/mrbgems/default-no-fpu.gembox +3 -0
  101. data/ext/enterprise_script_service/mruby/mrbgems/default-no-stdio.gembox +4 -0
  102. data/ext/enterprise_script_service/mruby/mrbgems/default.gembox +9 -88
  103. data/ext/enterprise_script_service/mruby/mrbgems/full-core.gembox +1 -4
  104. data/ext/enterprise_script_service/mruby/mrbgems/math.gembox +10 -0
  105. data/ext/enterprise_script_service/mruby/mrbgems/metaprog.gembox +15 -0
  106. data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/mrblib/array.rb +1 -1
  107. data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/src/array.c +5 -4
  108. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-config/mrbgem.rake +28 -19
  109. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-config/mruby-config +18 -8
  110. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/bintest/mrdb.rb +3 -6
  111. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/bintest/print.rb +10 -10
  112. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.c +14 -9
  113. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/apiprint.c +3 -2
  114. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c +4 -3
  115. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.h +2 -6
  116. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdbconf.h +4 -4
  117. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mirb/bintest/mirb.rb +23 -5
  118. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mirb/mrbgem.rake +11 -2
  119. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c +41 -34
  120. data/ext/enterprise_script_service/mruby/mrbgems/{mruby-compiler → mruby-bin-mrbc}/bintest/mrbc.rb +0 -0
  121. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mrbc/mrbgem.rake +3 -4
  122. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c +19 -9
  123. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mruby/bintest/mruby.rb +25 -4
  124. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mruby/mrbgem.rake +1 -1
  125. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c +22 -6
  126. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-strip/bintest/mruby-strip.rb +1 -1
  127. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-strip/tools/mruby-strip/mruby-strip.c +2 -2
  128. data/ext/enterprise_script_service/mruby/mrbgems/mruby-catch/mrbgem.rake +5 -0
  129. data/ext/enterprise_script_service/mruby/mrbgems/mruby-catch/mrblib/catch.rb +27 -0
  130. data/ext/enterprise_script_service/mruby/mrbgems/mruby-class-ext/src/class.c +2 -1
  131. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/codegen.c +430 -399
  132. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/keywords +5 -0
  133. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/lex.def +49 -44
  134. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/parse.y +559 -217
  135. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/y.tab.c +4774 -4193
  136. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/mrbgem.rake +18 -19
  137. data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/mrblib/complex.rb +1 -1
  138. data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/src/complex.c +8 -7
  139. data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/test/complex.rb +4 -4
  140. data/ext/enterprise_script_service/mruby/mrbgems/mruby-enumerator/mrblib/enumerator.rb +1 -0
  141. data/ext/enterprise_script_service/mruby/mrbgems/mruby-enumerator/test/enumerator.rb +2 -2
  142. data/ext/enterprise_script_service/mruby/mrbgems/mruby-error/mrbgem.rake +2 -2
  143. data/ext/enterprise_script_service/mruby/mrbgems/mruby-eval/src/eval.c +17 -25
  144. data/ext/enterprise_script_service/mruby/mrbgems/mruby-fiber/src/fiber.c +18 -13
  145. data/ext/enterprise_script_service/mruby/mrbgems/mruby-hash-ext/src/hash-ext.c +30 -2
  146. data/ext/enterprise_script_service/mruby/mrbgems/mruby-hash-ext/test/hash.rb +7 -0
  147. data/ext/enterprise_script_service/mruby/mrbgems/mruby-inline-struct/test/inline.c +2 -2
  148. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/README.md +18 -16
  149. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/include/mruby/ext/io.h +2 -2
  150. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrblib/file.rb +9 -4
  151. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrblib/io.rb +2 -2
  152. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/file.c +55 -52
  153. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/file_test.c +4 -2
  154. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/io.c +99 -87
  155. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/file.rb +2 -0
  156. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/io.rb +2 -3
  157. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/mruby_io_test.c +1 -1
  158. data/ext/enterprise_script_service/mruby/mrbgems/mruby-kernel-ext/src/kernel.c +7 -6
  159. data/ext/enterprise_script_service/mruby/mrbgems/mruby-math/src/math.c +13 -12
  160. data/ext/enterprise_script_service/mruby/mrbgems/mruby-math/test/math.rb +5 -4
  161. data/ext/enterprise_script_service/mruby/mrbgems/mruby-metaprog/src/metaprog.c +43 -58
  162. data/ext/enterprise_script_service/mruby/mrbgems/mruby-metaprog/test/metaprog.rb +4 -4
  163. data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/README.md +4 -3
  164. data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/src/method.c +77 -74
  165. data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/test/method.rb +4 -4
  166. data/ext/enterprise_script_service/mruby/mrbgems/mruby-numeric-ext/src/numeric_ext.c +14 -13
  167. data/ext/enterprise_script_service/mruby/mrbgems/mruby-object-ext/src/object.c +5 -4
  168. data/ext/enterprise_script_service/mruby/mrbgems/mruby-objectspace/src/mruby_objectspace.c +18 -12
  169. data/ext/enterprise_script_service/mruby/mrbgems/mruby-os-memsize/mrbgem.rake +10 -0
  170. data/ext/enterprise_script_service/mruby/mrbgems/mruby-os-memsize/src/memsize.c +231 -0
  171. data/ext/enterprise_script_service/mruby/mrbgems/mruby-os-memsize/test/memsize.rb +63 -0
  172. data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/README.md +15 -18
  173. data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/src/pack.c +38 -88
  174. data/ext/enterprise_script_service/mruby/mrbgems/mruby-print/mrblib/print.rb +1 -30
  175. data/ext/enterprise_script_service/mruby/mrbgems/mruby-print/src/print.c +62 -26
  176. data/ext/enterprise_script_service/mruby/mrbgems/mruby-proc-ext/src/proc.c +32 -19
  177. data/ext/enterprise_script_service/mruby/mrbgems/mruby-proc-ext/test/proc.c +1 -1
  178. data/ext/enterprise_script_service/mruby/mrbgems/mruby-random/src/random.c +98 -43
  179. data/ext/enterprise_script_service/mruby/mrbgems/mruby-random/test/random.rb +2 -2
  180. data/ext/enterprise_script_service/mruby/mrbgems/mruby-range-ext/mrblib/range.rb +39 -6
  181. data/ext/enterprise_script_service/mruby/mrbgems/mruby-range-ext/src/range.c +20 -40
  182. data/ext/enterprise_script_service/mruby/mrbgems/mruby-range-ext/test/range.rb +27 -3
  183. data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/mrblib/rational.rb +11 -17
  184. data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/src/rational.c +216 -38
  185. data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/test/rational.rb +6 -6
  186. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sleep/README.md +6 -4
  187. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sleep/src/mrb_sleep.c +4 -4
  188. data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/README.md +3 -2
  189. data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/src/socket.c +47 -45
  190. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sprintf/src/sprintf.c +102 -71
  191. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sprintf/test/sprintf.rb +4 -2
  192. data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/mrblib/string.rb +23 -1
  193. data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/src/string.c +13 -9
  194. data/ext/enterprise_script_service/mruby/mrbgems/mruby-struct/mrblib/struct.rb +1 -1
  195. data/ext/enterprise_script_service/mruby/mrbgems/mruby-struct/src/struct.c +18 -25
  196. data/ext/enterprise_script_service/mruby/mrbgems/mruby-symbol-ext/src/symbol.c +6 -5
  197. data/ext/enterprise_script_service/mruby/mrbgems/mruby-symbol-ext/test/symbol.rb +1 -1
  198. data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/README.md +0 -1
  199. data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/driver.c +5 -5
  200. data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/mrbgem.rake +16 -44
  201. data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/vformat.c +4 -4
  202. data/ext/enterprise_script_service/mruby/mrbgems/mruby-time/src/time.c +27 -27
  203. data/ext/enterprise_script_service/mruby/mrbgems/stdlib-ext.gembox +18 -0
  204. data/ext/enterprise_script_service/mruby/mrbgems/stdlib-io.gembox +12 -0
  205. data/ext/enterprise_script_service/mruby/mrbgems/stdlib.gembox +54 -0
  206. data/ext/enterprise_script_service/mruby/mrblib/10error.rb +4 -0
  207. data/ext/enterprise_script_service/mruby/mrblib/array.rb +17 -9
  208. data/ext/enterprise_script_service/mruby/mrblib/enum.rb +1 -1
  209. data/ext/enterprise_script_service/mruby/mrblib/hash.rb +0 -20
  210. data/ext/enterprise_script_service/mruby/mrblib/init_mrblib.c +0 -11
  211. data/ext/enterprise_script_service/mruby/mrblib/numeric.rb +36 -11
  212. data/ext/enterprise_script_service/mruby/mrblib/range.rb +25 -3
  213. data/ext/enterprise_script_service/mruby/oss-fuzz/mruby_proto_fuzzer.cpp +2 -2
  214. data/ext/enterprise_script_service/mruby/oss-fuzz/proto_to_ruby.h +1 -1
  215. data/ext/enterprise_script_service/mruby/src/array.c +43 -80
  216. data/ext/enterprise_script_service/mruby/src/backtrace.c +16 -17
  217. data/ext/enterprise_script_service/mruby/src/class.c +774 -182
  218. data/ext/enterprise_script_service/mruby/src/codedump.c +223 -198
  219. data/ext/enterprise_script_service/mruby/src/debug.c +6 -6
  220. data/ext/enterprise_script_service/mruby/src/dump.c +466 -141
  221. data/ext/enterprise_script_service/mruby/src/enum.c +1 -1
  222. data/ext/enterprise_script_service/mruby/src/error.c +36 -13
  223. data/ext/enterprise_script_service/mruby/src/etc.c +43 -34
  224. data/ext/enterprise_script_service/mruby/src/fmt_fp.c +5 -6
  225. data/ext/enterprise_script_service/mruby/src/gc.c +73 -71
  226. data/ext/enterprise_script_service/mruby/src/hash.c +1050 -707
  227. data/ext/enterprise_script_service/mruby/src/kernel.c +75 -220
  228. data/ext/enterprise_script_service/mruby/src/load.c +196 -166
  229. data/ext/enterprise_script_service/mruby/src/numeric.c +352 -314
  230. data/ext/enterprise_script_service/mruby/src/object.c +97 -90
  231. data/ext/enterprise_script_service/mruby/src/print.c +4 -3
  232. data/ext/enterprise_script_service/mruby/src/proc.c +48 -56
  233. data/ext/enterprise_script_service/mruby/src/range.c +45 -21
  234. data/ext/enterprise_script_service/mruby/src/state.c +25 -32
  235. data/ext/enterprise_script_service/mruby/src/string.c +59 -101
  236. data/ext/enterprise_script_service/mruby/src/symbol.c +121 -56
  237. data/ext/enterprise_script_service/mruby/src/value_array.h +1 -0
  238. data/ext/enterprise_script_service/mruby/src/variable.c +158 -158
  239. data/ext/enterprise_script_service/mruby/src/vm.c +617 -602
  240. data/ext/enterprise_script_service/mruby/tasks/benchmark.rake +6 -6
  241. data/ext/enterprise_script_service/mruby/tasks/bin.rake +23 -0
  242. data/ext/enterprise_script_service/mruby/tasks/core.rake +12 -0
  243. data/ext/enterprise_script_service/mruby/tasks/doc.rake +50 -38
  244. data/ext/enterprise_script_service/mruby/tasks/gitlab.rake +83 -77
  245. data/ext/enterprise_script_service/mruby/tasks/libmruby.rake +10 -1
  246. data/ext/enterprise_script_service/mruby/tasks/mrbgems.rake +13 -1
  247. data/ext/enterprise_script_service/mruby/tasks/mrblib.rake +40 -0
  248. data/ext/enterprise_script_service/mruby/tasks/presym.rake +44 -0
  249. data/ext/enterprise_script_service/mruby/tasks/test.rake +68 -0
  250. data/ext/enterprise_script_service/mruby/tasks/toolchains/gcc.rake +6 -5
  251. data/ext/enterprise_script_service/mruby/tasks/toolchains/openwrt.rake +10 -14
  252. data/ext/enterprise_script_service/mruby/tasks/toolchains/visualcpp.rake +17 -21
  253. data/ext/enterprise_script_service/mruby/test/bintest.rb +5 -5
  254. data/ext/enterprise_script_service/mruby/test/t/argumenterror.rb +16 -0
  255. data/ext/enterprise_script_service/mruby/test/t/array.rb +7 -3
  256. data/ext/enterprise_script_service/mruby/test/t/bs_literal.rb +1 -1
  257. data/ext/enterprise_script_service/mruby/test/t/float.rb +18 -8
  258. data/ext/enterprise_script_service/mruby/test/t/hash.rb +903 -281
  259. data/ext/enterprise_script_service/mruby/test/t/integer.rb +10 -38
  260. data/ext/enterprise_script_service/mruby/test/t/kernel.rb +1 -1
  261. data/ext/enterprise_script_service/mruby/test/t/literals.rb +50 -0
  262. data/ext/enterprise_script_service/mruby/test/t/module.rb +2 -2
  263. data/ext/enterprise_script_service/mruby/test/t/numeric.rb +1 -1
  264. data/ext/enterprise_script_service/mruby/test/t/range.rb +83 -1
  265. data/ext/enterprise_script_service/mruby/test/t/string.rb +4 -0
  266. data/ext/enterprise_script_service/mruby/test/t/superclass.rb +10 -10
  267. data/ext/enterprise_script_service/mruby/test/t/syntax.rb +24 -0
  268. data/ext/enterprise_script_service/mruby/test/t/vformat.rb +3 -3
  269. data/ext/enterprise_script_service/mruby_config.rb +2 -5
  270. data/ext/enterprise_script_service/mruby_engine.cpp +1 -1
  271. data/lib/script_core/version.rb +1 -1
  272. data/spec/script_core_spec.rb +13 -0
  273. metadata +61 -23
  274. data/ext/enterprise_script_service/mruby/.github/workflows/main.yml +0 -24
  275. data/ext/enterprise_script_service/mruby/TODO +0 -8
  276. data/ext/enterprise_script_service/mruby/appveyor_config.rb +0 -46
  277. data/ext/enterprise_script_service/mruby/benchmark/build_config_boxing.rb +0 -28
  278. data/ext/enterprise_script_service/mruby/examples/targets/build_config_android_arm64-v8a.rb +0 -26
  279. data/ext/enterprise_script_service/mruby/examples/targets/build_config_android_armeabi.rb +0 -26
  280. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sprintf/src/kernel.c +0 -30
  281. data/ext/enterprise_script_service/mruby/mrblib/mrblib.rake +0 -18
  282. data/ext/enterprise_script_service/mruby/src/crc.c +0 -39
  283. data/ext/enterprise_script_service/mruby/src/mruby_core.rake +0 -19
@@ -143,7 +143,7 @@ def assert_cmp(exp, o1, o2)
143
143
  assert_equal_rational(false, 1r, ComplexLikeNumeric.new(2))
144
144
  end
145
145
 
146
- assert 'Fixnum#==(Rational), Fixnum#!=(Rational)' do
146
+ assert 'Integer#==(Rational), Integer#!=(Rational)' do
147
147
  assert_equal_rational(true, 2, Rational(4,2))
148
148
  assert_equal_rational(true, -2, Rational(-4,2))
149
149
  assert_equal_rational(true, -2, Rational(4,-2))
@@ -186,7 +186,7 @@ def assert_cmp(exp, o1, o2)
186
186
  assert_raise(NoMethodError) { 1r <=> ComplexLikeNumeric.new(2) }
187
187
  end
188
188
 
189
- assert 'Fixnum#<=>(Rational)' do
189
+ assert 'Integer#<=>(Rational)' do
190
190
  assert_cmp(-1, -2, Rational(-9,5))
191
191
  assert_cmp(0, 5, 5r)
192
192
  assert_cmp(1, 3, Rational(8,3))
@@ -210,7 +210,7 @@ def assert_cmp(exp, o1, o2)
210
210
  assert_raise(ArgumentError) { 1r < "2" }
211
211
  end
212
212
 
213
- assert 'Fixnum#<(Rational)' do
213
+ assert 'Integer#<(Rational)' do
214
214
  assert_not_operator(1, :<, Rational(2,3))
215
215
  assert_not_operator(2, :<, 2r)
216
216
  assert_operator(-3, :<, Rational(2,3))
@@ -234,7 +234,7 @@ def assert_cmp(exp, o1, o2)
234
234
  assert_raise(ArgumentError) { 1r <= "2" }
235
235
  end
236
236
 
237
- assert 'Fixnum#<=(Rational)' do
237
+ assert 'Integer#<=(Rational)' do
238
238
  assert_not_operator(1, :<=, Rational(2,3))
239
239
  assert_operator(2, :<=, 2r)
240
240
  assert_operator(-3, :<=, Rational(2,3))
@@ -258,7 +258,7 @@ def assert_cmp(exp, o1, o2)
258
258
  assert_raise(ArgumentError) { 1r > "2" }
259
259
  end
260
260
 
261
- assert 'Fixnum#>(Rational)' do
261
+ assert 'Integer#>(Rational)' do
262
262
  assert_operator(1, :>, Rational(2,3))
263
263
  assert_not_operator(2, :>, 2r)
264
264
  assert_not_operator(-3, :>, Rational(2,3))
@@ -282,7 +282,7 @@ def assert_cmp(exp, o1, o2)
282
282
  assert_raise(ArgumentError) { 1r >= "2" }
283
283
  end
284
284
 
285
- assert 'Fixnum#>=(Rational)' do
285
+ assert 'Integer#>=(Rational)' do
286
286
  assert_operator(1, :>=, Rational(2,3))
287
287
  assert_operator(2, :>=, 2r)
288
288
  assert_not_operator(-3, :>=, Rational(2,3))
@@ -1,8 +1,11 @@
1
1
  # Sleep Module for mruby
2
+
2
3
  mruby sleep module
3
4
 
4
5
  ## install by mrbgems
5
- - add conf.gem line to `build_config.rb`
6
+
7
+ - add conf.gem line to your build configuration.
8
+
6
9
  ```ruby
7
10
  MRuby::Build.new do |conf|
8
11
 
@@ -20,8 +23,7 @@ usleep(10000)
20
23
  ```
21
24
 
22
25
  # License
23
- under the MIT License:
24
-
25
- * http://www.opensource.org/licenses/mit-license.php
26
26
 
27
+ under the MIT License:
27
28
 
29
+ * https://www.opensource.org/licenses/mit-license.php
@@ -23,7 +23,7 @@
23
23
  ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24
24
  ** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
25
  **
26
- ** [ MIT license: http://www.opensource.org/licenses/mit-license.php ]
26
+ ** [ MIT license: https://www.opensource.org/licenses/mit-license.php ]
27
27
  */
28
28
 
29
29
  #include <time.h>
@@ -44,7 +44,7 @@ mrb_f_sleep(mrb_state *mrb, mrb_value self)
44
44
  {
45
45
  time_t beg = time(0);
46
46
  time_t end;
47
- #ifndef MRB_WITHOUT_FLOAT
47
+ #ifndef MRB_NO_FLOAT
48
48
  mrb_float sec;
49
49
 
50
50
  mrb_get_args(mrb, "f", &sec);
@@ -66,7 +66,7 @@ mrb_f_sleep(mrb_state *mrb, mrb_value self)
66
66
  #endif
67
67
  end = time(0) - beg;
68
68
 
69
- return mrb_fixnum_value(end);
69
+ return mrb_fixnum_value((mrb_int)end);
70
70
  }
71
71
 
72
72
  /* mruby special; needed for mruby without float numbers */
@@ -120,7 +120,7 @@ mrb_f_usleep(mrb_state *mrb, mrb_value self)
120
120
  }
121
121
  #endif
122
122
 
123
- return mrb_fixnum_value(slp_tm);
123
+ return mrb_fixnum_value((mrb_int)slp_tm);
124
124
  }
125
125
 
126
126
  void
@@ -4,8 +4,8 @@ mruby-socket
4
4
  "mruby-socket" mrbgem provides BSD socket interface for mruby.
5
5
  API is compatible with CRuby's "socket" library.
6
6
 
7
-
8
7
  ## Example
8
+
9
9
  ```sh
10
10
  % vi kame.rb
11
11
  s = TCPSocket.open("www.kame.net", 80)
@@ -20,18 +20,19 @@ Date: Tue, 21 May 2013 04:31:30 GMT
20
20
  ```
21
21
 
22
22
  ## Requirement
23
+
23
24
  - [mruby-io](https://github.com/mruby/mruby/tree/master/mrbgems/mruby-io) mrbgem
24
25
  - [iij/mruby-mtest](https://github.com/iij/mruby-mtest) mrgbem to run tests
25
26
  - system must have RFC3493 basic socket interface
26
27
  - and some POSIX API...
27
28
 
28
29
  ## TODO
30
+
29
31
  - add missing methods
30
32
  - write more tests
31
33
  - fix possible descriptor leakage (see XXX comments)
32
34
  - `UNIXSocket#recv_io` `UNIXSocket#send_io`
33
35
 
34
-
35
36
  ## License
36
37
 
37
38
  Copyright (c) 2013 Internet Initiative Japan Inc.
@@ -42,6 +42,7 @@
42
42
  #include "mruby/string.h"
43
43
  #include "mruby/variable.h"
44
44
  #include "mruby/error.h"
45
+ #include "mruby/presym.h"
45
46
 
46
47
  #include "mruby/ext/io.h"
47
48
 
@@ -53,7 +54,7 @@
53
54
  #endif
54
55
  #endif
55
56
 
56
- #define E_SOCKET_ERROR (mrb_class_get(mrb, "SocketError"))
57
+ #define E_SOCKET_ERROR mrb_class_get_id(mrb, MRB_SYM(SocketError))
57
58
 
58
59
  #if !defined(mrb_cptr)
59
60
  #define mrb_cptr_value(m,p) mrb_voidp_value((m),(p))
@@ -140,50 +141,50 @@ mrb_addrinfo_getaddrinfo(mrb_state *mrb, mrb_value klass)
140
141
 
141
142
  if (mrb_string_p(service)) {
142
143
  servname = RSTRING_CSTR(mrb, service);
143
- } else if (mrb_fixnum_p(service)) {
144
+ } else if (mrb_integer_p(service)) {
144
145
  servname = RSTRING_PTR(mrb_fixnum_to_str(mrb, service, 10));
145
146
  } else if (mrb_nil_p(service)) {
146
147
  servname = NULL;
147
148
  } else {
148
- mrb_raise(mrb, E_TYPE_ERROR, "service must be String, Fixnum, or nil");
149
+ mrb_raise(mrb, E_TYPE_ERROR, "service must be String, Integer, or nil");
149
150
  }
150
151
 
151
152
  memset(&hints, 0, sizeof(hints));
152
153
  hints.ai_flags = (int)flags;
153
154
 
154
- if (mrb_fixnum_p(family)) {
155
- hints.ai_family = (int)mrb_fixnum(family);
155
+ if (mrb_integer_p(family)) {
156
+ hints.ai_family = (int)mrb_integer(family);
156
157
  }
157
158
 
158
- if (mrb_fixnum_p(socktype)) {
159
- hints.ai_socktype = (int)mrb_fixnum(socktype);
159
+ if (mrb_integer_p(socktype)) {
160
+ hints.ai_socktype = (int)mrb_integer(socktype);
160
161
  }
161
162
 
162
- if (mrb_fixnum_p(protocol)) {
163
- hints.ai_protocol = (int)mrb_fixnum(protocol);
163
+ if (mrb_integer_p(protocol)) {
164
+ hints.ai_protocol = (int)mrb_integer(protocol);
164
165
  }
165
166
 
166
- lastai = mrb_cv_get(mrb, klass, mrb_intern_lit(mrb, "_lastai"));
167
+ lastai = mrb_cv_get(mrb, klass, MRB_SYM(_lastai));
167
168
  if (mrb_cptr_p(lastai)) {
168
169
  freeaddrinfo((struct addrinfo*)mrb_cptr(lastai));
169
- mrb_cv_set(mrb, klass, mrb_intern_lit(mrb, "_lastai"), mrb_nil_value());
170
+ mrb_cv_set(mrb, klass, MRB_SYM(_lastai), mrb_nil_value());
170
171
  }
171
172
 
172
173
  error = getaddrinfo(hostname, servname, &hints, &res0);
173
174
  if (error) {
174
175
  mrb_raisef(mrb, E_SOCKET_ERROR, "getaddrinfo: %s", gai_strerror(error));
175
176
  }
176
- mrb_cv_set(mrb, klass, mrb_intern_lit(mrb, "_lastai"), mrb_cptr_value(mrb, res0));
177
+ mrb_cv_set(mrb, klass, MRB_SYM(_lastai), mrb_cptr_value(mrb, res0));
177
178
 
178
179
  for (res = res0; res != NULL; res = res->ai_next) {
179
180
  sa = mrb_str_new(mrb, (char*)res->ai_addr, res->ai_addrlen);
180
- ai = mrb_funcall(mrb, klass, "new", 4, sa, mrb_fixnum_value(res->ai_family), mrb_fixnum_value(res->ai_socktype), mrb_fixnum_value(res->ai_protocol));
181
+ ai = mrb_funcall_id(mrb, klass, MRB_SYM(new), 4, sa, mrb_fixnum_value(res->ai_family), mrb_fixnum_value(res->ai_socktype), mrb_fixnum_value(res->ai_protocol));
181
182
  mrb_ary_push(mrb, ary, ai);
182
183
  mrb_gc_arena_restore(mrb, arena_idx);
183
184
  }
184
185
 
185
186
  freeaddrinfo(res0);
186
- mrb_cv_set(mrb, klass, mrb_intern_lit(mrb, "_lastai"), mrb_nil_value());
187
+ mrb_cv_set(mrb, klass, MRB_SYM(_lastai), mrb_nil_value());
187
188
 
188
189
  return ary;
189
190
  }
@@ -197,10 +198,10 @@ mrb_addrinfo_getnameinfo(mrb_state *mrb, mrb_value self)
197
198
 
198
199
  flags = 0;
199
200
  mrb_get_args(mrb, "|i", &flags);
200
- host = mrb_str_buf_new(mrb, NI_MAXHOST);
201
- serv = mrb_str_buf_new(mrb, NI_MAXSERV);
201
+ host = mrb_str_new_capa(mrb, NI_MAXHOST);
202
+ serv = mrb_str_new_capa(mrb, NI_MAXSERV);
202
203
 
203
- sastr = mrb_iv_get(mrb, self, mrb_intern_lit(mrb, "@sockaddr"));
204
+ sastr = mrb_iv_get(mrb, self, MRB_IVSYM(sockaddr));
204
205
  if (!mrb_string_p(sastr)) {
205
206
  mrb_raise(mrb, E_SOCKET_ERROR, "invalid sockaddr");
206
207
  }
@@ -222,7 +223,7 @@ mrb_addrinfo_unix_path(mrb_state *mrb, mrb_value self)
222
223
  {
223
224
  mrb_value sastr;
224
225
 
225
- sastr = mrb_iv_get(mrb, self, mrb_intern_lit(mrb, "@sockaddr"));
226
+ sastr = mrb_iv_get(mrb, self, MRB_IVSYM(sockaddr));
226
227
  if (((struct sockaddr *)RSTRING_PTR(sastr))->sa_family != AF_UNIX)
227
228
  mrb_raise(mrb, E_SOCKET_ERROR, "need AF_UNIX address");
228
229
  if (RSTRING_LEN(sastr) < (mrb_int)offsetof(struct sockaddr_un, sun_path) + 1) {
@@ -254,7 +255,7 @@ sa2addrlist(mrb_state *mrb, const struct sockaddr *sa, socklen_t salen)
254
255
  return mrb_nil_value();
255
256
  }
256
257
  port = ntohs(port);
257
- host = mrb_str_buf_new(mrb, NI_MAXHOST);
258
+ host = mrb_str_new_capa(mrb, NI_MAXHOST);
258
259
  if (getnameinfo(sa, salen, RSTRING_PTR(host), NI_MAXHOST, NULL, 0, NI_NUMERICHOST) == -1)
259
260
  mrb_sys_fail(mrb, "getnameinfo");
260
261
  mrb_str_resize(mrb, host, strlen(RSTRING_PTR(host)));
@@ -269,7 +270,7 @@ sa2addrlist(mrb_state *mrb, const struct sockaddr *sa, socklen_t salen)
269
270
  static int
270
271
  socket_fd(mrb_state *mrb, mrb_value sock)
271
272
  {
272
- return (int)mrb_fixnum(mrb_funcall(mrb, sock, "fileno", 0));
273
+ return (int)mrb_integer(mrb_funcall_id(mrb, sock, MRB_SYM(fileno), 0));
273
274
  }
274
275
 
275
276
  static int
@@ -347,10 +348,10 @@ mrb_basicsocket_getsockopt(mrb_state *mrb, mrb_value self)
347
348
  optlen = sizeof(opt);
348
349
  if (getsockopt(s, (int)level, (int)optname, opt, &optlen) == -1)
349
350
  mrb_sys_fail(mrb, "getsockopt");
350
- c = mrb_const_get(mrb, mrb_obj_value(mrb_class_get(mrb, "Socket")), mrb_intern_lit(mrb, "Option"));
351
+ c = mrb_const_get(mrb, mrb_obj_value(mrb_class_get_id(mrb, MRB_SYM(Socket))), MRB_SYM(Option));
351
352
  family = socket_family(s);
352
353
  data = mrb_str_new(mrb, opt, optlen);
353
- return mrb_funcall(mrb, c, "new", 4, mrb_fixnum_value(family), mrb_fixnum_value(level), mrb_fixnum_value(optname), data);
354
+ return mrb_funcall_id(mrb, c, MRB_SYM(new), 4, mrb_fixnum_value(family), mrb_fixnum_value(level), mrb_fixnum_value(optname), data);
354
355
  }
355
356
 
356
357
  static mrb_value
@@ -361,7 +362,7 @@ mrb_basicsocket_recv(mrb_state *mrb, mrb_value self)
361
362
  mrb_value buf;
362
363
 
363
364
  mrb_get_args(mrb, "i|i", &maxlen, &flags);
364
- buf = mrb_str_buf_new(mrb, maxlen);
365
+ buf = mrb_str_new_capa(mrb, maxlen);
365
366
  n = recv(socket_fd(mrb, self), RSTRING_PTR(buf), (fsize_t)maxlen, (int)flags);
366
367
  if (n == -1)
367
368
  mrb_sys_fail(mrb, "recv");
@@ -378,9 +379,9 @@ mrb_basicsocket_recvfrom(mrb_state *mrb, mrb_value self)
378
379
  socklen_t socklen;
379
380
 
380
381
  mrb_get_args(mrb, "i|i", &maxlen, &flags);
381
- buf = mrb_str_buf_new(mrb, maxlen);
382
+ buf = mrb_str_new_capa(mrb, maxlen);
382
383
  socklen = sizeof(struct sockaddr_storage);
383
- sa = mrb_str_buf_new(mrb, socklen);
384
+ sa = mrb_str_new_capa(mrb, socklen);
384
385
  n = recvfrom(socket_fd(mrb, self), RSTRING_PTR(buf), (fsize_t)maxlen, (int)flags, (struct sockaddr *)RSTRING_PTR(sa), &socklen);
385
386
  if (n == -1)
386
387
  mrb_sys_fail(mrb, "recvfrom");
@@ -449,21 +450,21 @@ mrb_basicsocket_setsockopt(mrb_state *mrb, mrb_value self)
449
450
 
450
451
  argc = mrb_get_args(mrb, "o|io", &so, &optname, &optval);
451
452
  if (argc == 3) {
452
- if (!mrb_fixnum_p(so)) {
453
+ if (!mrb_integer_p(so)) {
453
454
  mrb_raise(mrb, E_ARGUMENT_ERROR, "level is not an integer");
454
455
  }
455
- level = mrb_fixnum(so);
456
+ level = mrb_integer(so);
456
457
  if (mrb_string_p(optval)) {
457
458
  /* that's good */
458
459
  } else if (mrb_true_p(optval) || mrb_false_p(optval)) {
459
460
  mrb_int i = mrb_test(optval) ? 1 : 0;
460
461
  optval = mrb_str_new(mrb, (char*)&i, sizeof(i));
461
- } else if (mrb_fixnum_p(optval)) {
462
+ } else if (mrb_integer_p(optval)) {
462
463
  if (optname == IP_MULTICAST_TTL || optname == IP_MULTICAST_LOOP) {
463
- char uc = (char)mrb_fixnum(optval);
464
+ char uc = (char)mrb_integer(optval);
464
465
  optval = mrb_str_new(mrb, &uc, sizeof(uc));
465
466
  } else {
466
- mrb_int i = mrb_fixnum(optval);
467
+ mrb_int i = mrb_integer(optval);
467
468
  optval = mrb_str_new(mrb, (char*)&i, sizeof(i));
468
469
  }
469
470
  } else {
@@ -472,9 +473,9 @@ mrb_basicsocket_setsockopt(mrb_state *mrb, mrb_value self)
472
473
  } else if (argc == 1) {
473
474
  if (strcmp(mrb_obj_classname(mrb, so), "Socket::Option") != 0)
474
475
  mrb_raise(mrb, E_ARGUMENT_ERROR, "not an instance of Socket::Option");
475
- level = mrb_fixnum(mrb_funcall(mrb, so, "level", 0));
476
- optname = mrb_fixnum(mrb_funcall(mrb, so, "optname", 0));
477
- optval = mrb_funcall(mrb, so, "data", 0);
476
+ level = mrb_integer(mrb_funcall_id(mrb, so, MRB_SYM(level), 0));
477
+ optname = mrb_integer(mrb_funcall_id(mrb, so, MRB_SYM(optname), 0));
478
+ optval = mrb_funcall_id(mrb, so, MRB_SYM(data), 0);
478
479
  } else {
479
480
  mrb_argnum_error(mrb, argc, 3, 3);
480
481
  }
@@ -515,7 +516,8 @@ static mrb_value
515
516
  mrb_ipsocket_ntop(mrb_state *mrb, mrb_value klass)
516
517
  {
517
518
  mrb_int af, n;
518
- char *addr, buf[50];
519
+ const char *addr;
520
+ char buf[50];
519
521
 
520
522
  mrb_get_args(mrb, "is", &af, &addr, &n);
521
523
  if ((af == AF_INET && n != 4) || (af == AF_INET6 && n != 16))
@@ -529,7 +531,8 @@ static mrb_value
529
531
  mrb_ipsocket_pton(mrb_state *mrb, mrb_value klass)
530
532
  {
531
533
  mrb_int af, n;
532
- char *bp, buf[50];
534
+ const char *bp;
535
+ char buf[50];
533
536
 
534
537
  mrb_get_args(mrb, "is", &af, &bp, &n);
535
538
  if ((size_t)n > sizeof(buf) - 1)
@@ -568,7 +571,7 @@ mrb_ipsocket_recvfrom(mrb_state *mrb, mrb_value self)
568
571
  fd = socket_fd(mrb, self);
569
572
  flags = 0;
570
573
  mrb_get_args(mrb, "i|i", &maxlen, &flags);
571
- buf = mrb_str_buf_new(mrb, maxlen);
574
+ buf = mrb_str_new_capa(mrb, maxlen);
572
575
  socklen = sizeof(ss);
573
576
  n = recvfrom(fd, RSTRING_PTR(buf), (fsize_t)maxlen, (int)flags,
574
577
  (struct sockaddr *)&ss, &socklen);
@@ -594,7 +597,7 @@ mrb_socket_gethostname(mrb_state *mrb, mrb_value cls)
594
597
  #else
595
598
  bufsize = 256;
596
599
  #endif
597
- buf = mrb_str_buf_new(mrb, (mrb_int)bufsize);
600
+ buf = mrb_str_new_capa(mrb, (mrb_int)bufsize);
598
601
  if (gethostname(RSTRING_PTR(buf), (fsize_t)bufsize) != 0)
599
602
  mrb_sys_fail(mrb, "gethostname");
600
603
  mrb_str_resize(mrb, buf, (mrb_int)strlen(RSTRING_PTR(buf)));
@@ -625,7 +628,7 @@ mrb_socket_accept2(mrb_state *mrb, mrb_value klass)
625
628
 
626
629
  mrb_get_args(mrb, "i", &s0);
627
630
  socklen = sizeof(struct sockaddr_storage);
628
- sastr = mrb_str_buf_new(mrb, socklen);
631
+ sastr = mrb_str_new_capa(mrb, socklen);
629
632
  s1 = (int)accept(s0, (struct sockaddr *)RSTRING_PTR(sastr), &socklen);
630
633
  if (s1 == -1) {
631
634
  mrb_sys_fail(mrb, "accept");
@@ -704,7 +707,7 @@ mrb_socket_sockaddr_un(mrb_state *mrb, mrb_value klass)
704
707
  if ((size_t)RSTRING_LEN(path) > sizeof(sunp->sun_path) - 1) {
705
708
  mrb_raisef(mrb, E_ARGUMENT_ERROR, "too long unix socket path (max: %d bytes)", (int)sizeof(sunp->sun_path) - 1);
706
709
  }
707
- s = mrb_str_buf_new(mrb, sizeof(struct sockaddr_un));
710
+ s = mrb_str_new_capa(mrb, sizeof(struct sockaddr_un));
708
711
  sunp = (struct sockaddr_un *)RSTRING_PTR(s);
709
712
  #if HAVE_SA_LEN
710
713
  sunp->sun_len = sizeof(struct sockaddr_un);
@@ -778,7 +781,6 @@ mrb_win32_basicsocket_close(mrb_state *mrb, mrb_value self)
778
781
  return mrb_nil_value();
779
782
  }
780
783
 
781
- #define E_EOF_ERROR (mrb_class_get(mrb, "EOFError"))
782
784
  static mrb_value
783
785
  mrb_win32_basicsocket_sysread(mrb_state *mrb, mrb_value self)
784
786
  {
@@ -841,7 +843,7 @@ mrb_win32_basicsocket_syswrite(mrb_state *mrb, mrb_value self)
841
843
  n = send(sd, RSTRING_PTR(str), (int)RSTRING_LEN(str), 0);
842
844
  if (n == SOCKET_ERROR)
843
845
  mrb_sys_fail(mrb, "send");
844
- return mrb_fixnum_value(n);
846
+ return mrb_int_value(mrb, n);
845
847
  }
846
848
 
847
849
  #endif
@@ -861,14 +863,14 @@ mrb_mruby_socket_gem_init(mrb_state* mrb)
861
863
  #endif
862
864
 
863
865
  ai = mrb_define_class(mrb, "Addrinfo", mrb->object_class);
864
- mrb_mod_cv_set(mrb, ai, mrb_intern_lit(mrb, "_lastai"), mrb_nil_value());
866
+ mrb_mod_cv_set(mrb, ai, MRB_SYM(_lastai), mrb_nil_value());
865
867
  mrb_define_class_method(mrb, ai, "getaddrinfo", mrb_addrinfo_getaddrinfo, MRB_ARGS_REQ(2)|MRB_ARGS_OPT(4));
866
868
  mrb_define_method(mrb, ai, "getnameinfo", mrb_addrinfo_getnameinfo, MRB_ARGS_OPT(1));
867
869
  #ifndef _WIN32
868
870
  mrb_define_method(mrb, ai, "unix_path", mrb_addrinfo_unix_path, MRB_ARGS_NONE());
869
871
  #endif
870
872
 
871
- io = mrb_class_get(mrb, "IO");
873
+ io = mrb_class_get_id(mrb, MRB_SYM(IO));
872
874
 
873
875
  bsock = mrb_define_class(mrb, "BasicSocket", io);
874
876
  mrb_define_method(mrb, bsock, "_recvfrom", mrb_basicsocket_recvfrom, MRB_ARGS_REQ(1)|MRB_ARGS_OPT(1));
@@ -937,7 +939,7 @@ mrb_mruby_socket_gem_init(mrb_state* mrb)
937
939
 
938
940
  #define define_const(SYM) \
939
941
  do { \
940
- mrb_define_const(mrb, constants, #SYM, mrb_fixnum_value(SYM)); \
942
+ mrb_define_const(mrb, constants, #SYM, mrb_int_value(mrb, SYM)); \
941
943
  } while (0)
942
944
 
943
945
  #include "const.cstub"
@@ -947,7 +949,7 @@ void
947
949
  mrb_mruby_socket_gem_final(mrb_state* mrb)
948
950
  {
949
951
  mrb_value ai;
950
- ai = mrb_mod_cv_get(mrb, mrb_class_get(mrb, "Addrinfo"), mrb_intern_lit(mrb, "_lastai"));
952
+ ai = mrb_mod_cv_get(mrb, mrb_class_get_id(mrb, MRB_SYM(Addrinfo)), MRB_SYM(_lastai));
951
953
  if (mrb_cptr_p(ai)) {
952
954
  freeaddrinfo((struct addrinfo*)mrb_cptr(ai));
953
955
  }
@@ -10,7 +10,8 @@
10
10
  #include <mruby/string.h>
11
11
  #include <mruby/hash.h>
12
12
  #include <mruby/numeric.h>
13
- #ifndef MRB_WITHOUT_FLOAT
13
+ #include <mruby/presym.h>
14
+ #ifndef MRB_NO_FLOAT
14
15
  #include <math.h>
15
16
  #endif
16
17
  #include <ctype.h>
@@ -20,7 +21,7 @@
20
21
  #define EXTENDSIGN(n, l) (((~0U << (n)) >> (((n)*(l)) % BITSPERDIG)) & ~(~0U << (n)))
21
22
 
22
23
  mrb_value mrb_str_format(mrb_state *, mrb_int, const mrb_value *, mrb_value);
23
- #ifndef MRB_WITHOUT_FLOAT
24
+ #ifndef MRB_NO_FLOAT
24
25
  static void fmt_setup(char*,size_t,int,int,mrb_int,mrb_int);
25
26
  #endif
26
27
 
@@ -74,20 +75,36 @@ static mrb_value
74
75
  mrb_fix2binstr(mrb_state *mrb, mrb_value x, int base)
75
76
  {
76
77
  char buf[66], *b = buf + sizeof buf;
77
- mrb_int num = mrb_fixnum(x);
78
+ mrb_int num = mrb_integer(x);
79
+ const int mask = base -1;
80
+ int shift;
81
+ #ifdef MRB_INT64
78
82
  uint64_t val = (uint64_t)num;
83
+ #else
84
+ uint32_t val = (uint32_t)num;
85
+ #endif
79
86
  char d;
80
87
 
81
- if (base != 2) {
88
+ switch (base) {
89
+ case 2:
90
+ shift = 1;
91
+ break;
92
+ case 8:
93
+ shift = 3;
94
+ break;
95
+ case 16:
96
+ shift = 4;
97
+ break;
98
+ default:
82
99
  mrb_raisef(mrb, E_ARGUMENT_ERROR, "invalid radix %d", base);
83
100
  }
84
- if (val == 0) {
101
+ if (num == 0) {
85
102
  return mrb_str_new_lit(mrb, "0");
86
103
  }
87
104
  *--b = '\0';
88
105
  do {
89
- *--b = mrb_digitmap[(int)(val % base)];
90
- } while (val /= base);
106
+ *--b = mrb_digitmap[(int)(val & mask)];
107
+ } while (val >>= shift);
91
108
 
92
109
  if (num < 0) {
93
110
  b = remove_sign_bits(b, base);
@@ -192,20 +209,14 @@ check_name_arg(mrb_state *mrb, int posarg, const char *name, size_t len)
192
209
  #define GETNTHARG(nth) \
193
210
  ((nth >= argc) ? (mrb_raise(mrb, E_ARGUMENT_ERROR, "too few arguments"), mrb_undef_value()) : argv[nth])
194
211
 
195
- #define GETNAMEARG(id, name, len) (\
212
+ #define CHECKNAMEARG(name, len) (\
196
213
  check_name_arg(mrb, posarg, name, len),\
197
- (posarg = -2, mrb_hash_fetch(mrb, get_hash(mrb, &hash, argc, argv), id, mrb_undef_value())))
198
-
199
- #define GETNUM(n, val) \
200
- for (; p < end && ISDIGIT(*p); p++) {\
201
- if (n > (MRB_INT_MAX - (*p - '0'))/10) {\
202
- mrb_raise(mrb, E_ARGUMENT_ERROR, #val " too big"); \
203
- } \
204
- n = 10 * n + (*p - '0'); \
205
- } \
206
- if (p >= end) { \
207
- mrb_raise(mrb, E_ARGUMENT_ERROR, "malformed format string - %*[0-9]"); \
208
- }
214
+ posarg = -2)
215
+
216
+ #define GETNUM(n, val) do { \
217
+ if (!(p = get_num(mrb, p, end, &(n)))) \
218
+ mrb_raise(mrb, E_ARGUMENT_ERROR, #val " too big 1"); \
219
+ } while(0)
209
220
 
210
221
  #define GETASTER(num) do { \
211
222
  mrb_value tmp_v; \
@@ -222,12 +233,32 @@ check_name_arg(mrb_state *mrb, int posarg, const char *name, size_t len)
222
233
  num = mrb_int(mrb, tmp_v); \
223
234
  } while (0)
224
235
 
225
- static mrb_value
236
+ static const char *
237
+ get_num(mrb_state *mrb, const char *p, const char *end, mrb_int *valp)
238
+ {
239
+ mrb_int next_n = *valp;
240
+ for (; p < end && ISDIGIT(*p); p++) {
241
+ if (mrb_int_mul_overflow(10, next_n, &next_n)) {
242
+ return NULL;
243
+ }
244
+ if (MRB_INT_MAX - (*p - '0') < next_n) {
245
+ return NULL;
246
+ }
247
+ next_n += *p - '0';
248
+ }
249
+ if (p >= end) {
250
+ mrb_raise(mrb, E_ARGUMENT_ERROR, "malformed format string - %%*[0-9]");
251
+ }
252
+ *valp = next_n;
253
+ return p;
254
+ }
255
+
256
+ static void
226
257
  get_hash(mrb_state *mrb, mrb_value *hash, mrb_int argc, const mrb_value *argv)
227
258
  {
228
259
  mrb_value tmp;
229
260
 
230
- if (!mrb_undef_p(*hash)) return *hash;
261
+ if (!mrb_undef_p(*hash)) return;
231
262
  if (argc != 2) {
232
263
  mrb_raise(mrb, E_ARGUMENT_ERROR, "one hash required");
233
264
  }
@@ -235,7 +266,7 @@ get_hash(mrb_state *mrb, mrb_value *hash, mrb_int argc, const mrb_value *argv)
235
266
  if (mrb_nil_p(tmp)) {
236
267
  mrb_raise(mrb, E_ARGUMENT_ERROR, "one hash required");
237
268
  }
238
- return (*hash = tmp);
269
+ *hash = tmp;
239
270
  }
240
271
 
241
272
  /*
@@ -492,18 +523,18 @@ get_hash(mrb_state *mrb, mrb_value *hash, mrb_int argc, const mrb_value *argv)
492
523
  * For more complex formatting, Ruby supports a reference by name.
493
524
  * %<name>s style uses format style, but %{name} style doesn't.
494
525
  *
495
- * Exapmles:
526
+ * Examples:
496
527
  * sprintf("%<foo>d : %<bar>f", { :foo => 1, :bar => 2 })
497
528
  * #=> 1 : 2.000000
498
529
  * sprintf("%{foo}f", { :foo => 1 })
499
530
  * # => "1f"
500
531
  */
501
532
 
502
- mrb_value
533
+ static mrb_value
503
534
  mrb_f_sprintf(mrb_state *mrb, mrb_value obj)
504
535
  {
505
536
  mrb_int argc;
506
- mrb_value *argv;
537
+ const mrb_value *argv;
507
538
 
508
539
  mrb_get_args(mrb, "*", &argv, &argc);
509
540
 
@@ -519,7 +550,7 @@ mrb_f_sprintf(mrb_state *mrb, mrb_value obj)
519
550
  static int
520
551
  mrb_int2str(char *buf, size_t len, mrb_int n)
521
552
  {
522
- #ifdef MRB_DISABLE_STDIO
553
+ #ifdef MRB_NO_STDIO
523
554
  char *bufend = buf + len;
524
555
  char *p = bufend - 1;
525
556
 
@@ -557,7 +588,7 @@ mrb_int2str(char *buf, size_t len, mrb_int n)
557
588
  return bufend - p - 1;
558
589
  #else
559
590
  return snprintf(buf, len, "%" MRB_PRId, n);
560
- #endif /* MRB_DISABLE_STDIO */
591
+ #endif /* MRB_NO_STDIO */
561
592
  }
562
593
 
563
594
  mrb_value
@@ -577,19 +608,19 @@ mrb_str_format(mrb_state *mrb, mrb_int argc, const mrb_value *argv, mrb_value fm
577
608
  mrb_value str;
578
609
  mrb_value hash = mrb_undef_value();
579
610
 
580
- #define CHECK_FOR_WIDTH(f) \
581
- if ((f) & FWIDTH) { \
582
- mrb_raise(mrb, E_ARGUMENT_ERROR, "width given twice"); \
583
- } \
584
- if ((f) & FPREC0) { \
585
- mrb_raise(mrb, E_ARGUMENT_ERROR, "width after precision"); \
611
+ #define CHECK_FOR_WIDTH(f) \
612
+ if ((f) & FWIDTH) { \
613
+ mrb_raise(mrb, E_ARGUMENT_ERROR, "width given twice"); \
614
+ } \
615
+ if ((f) & FPREC0) { \
616
+ mrb_raise(mrb, E_ARGUMENT_ERROR, "width after precision"); \
586
617
  }
587
- #define CHECK_FOR_FLAGS(f) \
588
- if ((f) & FWIDTH) { \
589
- mrb_raise(mrb, E_ARGUMENT_ERROR, "flag after width"); \
590
- } \
591
- if ((f) & FPREC0) { \
592
- mrb_raise(mrb, E_ARGUMENT_ERROR, "flag after precision"); \
618
+ #define CHECK_FOR_FLAGS(f) \
619
+ if ((f) & FWIDTH) { \
620
+ mrb_raise(mrb, E_ARGUMENT_ERROR, "flag after width"); \
621
+ } \
622
+ if ((f) & FPREC0) { \
623
+ mrb_raise(mrb, E_ARGUMENT_ERROR, "flag after precision"); \
593
624
  }
594
625
 
595
626
  ++argc;
@@ -676,7 +707,6 @@ retry:
676
707
  case '{': {
677
708
  const char *start = p;
678
709
  char term = (*p == '<') ? '>' : '}';
679
- mrb_value symname;
680
710
 
681
711
  for (; p < end && *p != term; )
682
712
  p++;
@@ -684,10 +714,13 @@ retry:
684
714
  mrb_raisef(mrb, E_ARGUMENT_ERROR, "name%l after <%n>",
685
715
  start, p - start + 1, id);
686
716
  }
687
- symname = mrb_str_new(mrb, start + 1, p - start - 1);
688
- id = mrb_intern_str(mrb, symname);
689
- nextvalue = GETNAMEARG(mrb_symbol_value(id), start, p - start + 1);
690
- if (mrb_undef_p(nextvalue)) {
717
+ CHECKNAMEARG(start, p - start + 1);
718
+ get_hash(mrb, &hash, argc, argv);
719
+ id = mrb_intern_check(mrb, start + 1, p - start - 1);
720
+ if (id) {
721
+ nextvalue = mrb_hash_fetch(mrb, hash, mrb_symbol_value(id), mrb_undef_value());
722
+ }
723
+ if (!id || mrb_undef_p(nextvalue)) {
691
724
  mrb_raisef(mrb, E_KEY_ERROR, "key%l not found", start, p - start + 1);
692
725
  }
693
726
  if (term == '}') goto format_s;
@@ -748,8 +781,8 @@ retry:
748
781
  mrb_raise(mrb, E_ARGUMENT_ERROR, "%c requires a character");
749
782
  }
750
783
  }
751
- else if (mrb_fixnum_p(val)) {
752
- mrb_int n = mrb_fixnum(val);
784
+ else if (mrb_integer_p(val)) {
785
+ mrb_int n = mrb_integer(val);
753
786
  #ifndef MRB_UTF8_STRING
754
787
  char buf[1];
755
788
 
@@ -763,7 +796,7 @@ retry:
763
796
  tmp = mrb_str_new(mrb, buf, 1);
764
797
  }
765
798
  else {
766
- tmp = mrb_funcall(mrb, val, "chr", 0);
799
+ tmp = mrb_funcall_id(mrb, val, MRB_SYM(chr), 0);
767
800
  mrb_check_type(mrb, tmp, MRB_TT_STRING);
768
801
  }
769
802
  #endif
@@ -863,17 +896,17 @@ retry:
863
896
 
864
897
  bin_retry:
865
898
  switch (mrb_type(val)) {
866
- #ifndef MRB_WITHOUT_FLOAT
899
+ #ifndef MRB_NO_FLOAT
867
900
  case MRB_TT_FLOAT:
868
901
  val = mrb_flo_to_fixnum(mrb, val);
869
- if (mrb_fixnum_p(val)) goto bin_retry;
902
+ if (mrb_integer_p(val)) goto bin_retry;
870
903
  break;
871
904
  #endif
872
905
  case MRB_TT_STRING:
873
906
  val = mrb_str_to_inum(mrb, val, 0, TRUE);
874
907
  goto bin_retry;
875
- case MRB_TT_FIXNUM:
876
- v = mrb_fixnum(val);
908
+ case MRB_TT_INTEGER:
909
+ v = mrb_integer(val);
877
910
  break;
878
911
  default:
879
912
  val = mrb_Integer(mrb, val);
@@ -922,27 +955,12 @@ retry:
922
955
  s = nbuf;
923
956
  if (v < 0) {
924
957
  dots = 1;
925
- val = mrb_fix2binstr(mrb, mrb_fixnum_value(v), base);
958
+ val = mrb_fix2binstr(mrb, mrb_int_value(mrb, v), base);
926
959
  }
927
960
  else {
928
- val = mrb_fixnum_to_str(mrb, mrb_fixnum_value(v), base);
961
+ val = mrb_fixnum_to_str(mrb, mrb_int_value(mrb, v), base);
929
962
  }
930
963
  strncpy(++s, RSTRING_PTR(val), sizeof(nbuf)-2);
931
- if (v < 0) {
932
- char d;
933
-
934
- s = remove_sign_bits(s, base);
935
- switch (base) {
936
- case 16: d = 'f'; break;
937
- case 8: d = '7'; break;
938
- case 2: d = '1'; break;
939
- default: d = 0; break;
940
- }
941
-
942
- if (d && *s != d) {
943
- *--s = d;
944
- }
945
- }
946
964
  }
947
965
  {
948
966
  size_t size;
@@ -1030,7 +1048,7 @@ retry:
1030
1048
  }
1031
1049
  break;
1032
1050
 
1033
- #ifndef MRB_WITHOUT_FLOAT
1051
+ #ifndef MRB_NO_FLOAT
1034
1052
  case 'f':
1035
1053
  case 'g':
1036
1054
  case 'G':
@@ -1131,7 +1149,7 @@ retry:
1131
1149
  return result;
1132
1150
  }
1133
1151
 
1134
- #ifndef MRB_WITHOUT_FLOAT
1152
+ #ifndef MRB_NO_FLOAT
1135
1153
  static void
1136
1154
  fmt_setup(char *buf, size_t size, int c, int flags, mrb_int width, mrb_int prec)
1137
1155
  {
@@ -1160,3 +1178,16 @@ fmt_setup(char *buf, size_t size, int c, int flags, mrb_int width, mrb_int prec)
1160
1178
  *buf = '\0';
1161
1179
  }
1162
1180
  #endif
1181
+
1182
+ void
1183
+ mrb_mruby_sprintf_gem_init(mrb_state *mrb)
1184
+ {
1185
+ struct RClass *krn = mrb->kernel_module;
1186
+ mrb_define_module_function(mrb, krn, "sprintf", mrb_f_sprintf, MRB_ARGS_ANY());
1187
+ mrb_define_module_function(mrb, krn, "format", mrb_f_sprintf, MRB_ARGS_ANY());
1188
+ }
1189
+
1190
+ void
1191
+ mrb_mruby_sprintf_gem_final(mrb_state *mrb)
1192
+ {
1193
+ }