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
@@ -288,3 +288,10 @@
288
288
  assert_equal({:a=>100}, h.slice(:a))
289
289
  assert_equal({:b=>200, :c=>300}, h.slice(:b, :c, :d))
290
290
  end
291
+
292
+ assert("Hash#except") do
293
+ h = { a: 100, b: 200, c: 300 }
294
+ assert_equal({:b=>200, :c=>300}, h.except(:a))
295
+ assert_equal({:a=>100}, h.except(:b, :c, :d))
296
+ assert_equal(h, h.except)
297
+ end
@@ -10,10 +10,10 @@ istruct_test_initialize(mrb_state *mrb, mrb_value self)
10
10
  mrb_int size = mrb_istruct_size();
11
11
  mrb_value object = mrb_get_arg1(mrb);
12
12
 
13
- if (mrb_fixnum_p(object)) {
13
+ if (mrb_integer_p(object)) {
14
14
  strncpy(string, "fixnum", size-1);
15
15
  }
16
- #ifndef MRB_WITHOUT_FLOAT
16
+ #ifndef MRB_NO_FLOAT
17
17
  else if (mrb_float_p(object)) {
18
18
  strncpy(string, "float", size-1);
19
19
  }
@@ -4,7 +4,8 @@ mruby-io
4
4
  `IO` and `File` classes for mruby
5
5
 
6
6
  ## Installation
7
- Add the line below to your `build_config.rb`:
7
+
8
+ Add the line below to your build configuration.
8
9
 
9
10
  ```
10
11
  conf.gem core: 'mruby-io'
@@ -13,7 +14,8 @@ Add the line below to your `build_config.rb`:
13
14
  ## Implemented methods
14
15
 
15
16
  ### IO
16
- - http://doc.ruby-lang.org/ja/1.9.3/class/IO.html
17
+
18
+ - https://doc.ruby-lang.org/ja/1.9.3/class/IO.html
17
19
 
18
20
  | method | mruby-io | memo |
19
21
  | ------------------------- | -------- | ---- |
@@ -97,7 +99,8 @@ Add the line below to your `build_config.rb`:
97
99
  | IO#write_nonblock | | |
98
100
 
99
101
  ### File
100
- - http://doc.ruby-lang.org/ja/1.9.3/class/File.html
102
+
103
+ - https://doc.ruby-lang.org/ja/1.9.3/class/File.html
101
104
 
102
105
  | method | mruby-io | memo |
103
106
  | --------------------------- | -------- | ---- |
@@ -167,26 +170,25 @@ Add the line below to your `build_config.rb`:
167
170
  | File#size | | |
168
171
  | File#truncate | | |
169
172
 
170
-
171
173
  ## License
172
174
 
173
175
  Copyright (c) 2013 Internet Initiative Japan Inc.
174
176
  Copyright (c) 2017 mruby developers
175
177
 
176
- Permission is hereby granted, free of charge, to any person obtaining a
177
- copy of this software and associated documentation files (the "Software"),
178
- to deal in the Software without restriction, including without limitation
179
- the rights to use, copy, modify, merge, publish, distribute, sublicense,
180
- and/or sell copies of the Software, and to permit persons to whom the
178
+ Permission is hereby granted, free of charge, to any person obtaining a
179
+ copy of this software and associated documentation files (the "Software"),
180
+ to deal in the Software without restriction, including without limitation
181
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
182
+ and/or sell copies of the Software, and to permit persons to whom the
181
183
  Software is furnished to do so, subject to the following conditions:
182
184
 
183
- The above copyright notice and this permission notice shall be included in
185
+ The above copyright notice and this permission notice shall be included in
184
186
  all copies or substantial portions of the Software.
185
187
 
186
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
187
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
188
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
189
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
190
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
191
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
188
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
189
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
190
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
191
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
192
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
193
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
192
194
  DEALINGS IN THE SOFTWARE.
@@ -7,8 +7,8 @@
7
7
 
8
8
  #include <mruby.h>
9
9
 
10
- #ifdef MRB_DISABLE_STDIO
11
- # error IO and File conflicts 'MRB_DISABLE_STDIO' configuration in your 'build_config.rb'
10
+ #ifdef MRB_NO_STDIO
11
+ # error IO and File conflicts 'MRB_NO_STDIO' in your build configuration
12
12
  #endif
13
13
 
14
14
  #if defined(__cplusplus)
@@ -2,7 +2,7 @@ class File < IO
2
2
  attr_accessor :path
3
3
 
4
4
  def initialize(fd_or_path, mode = "r", perm = 0666)
5
- if fd_or_path.kind_of? Fixnum
5
+ if fd_or_path.kind_of? Integer
6
6
  super(fd_or_path, mode)
7
7
  else
8
8
  @path = fd_or_path
@@ -11,6 +11,11 @@ def initialize(fd_or_path, mode = "r", perm = 0666)
11
11
  end
12
12
  end
13
13
 
14
+ def mtime
15
+ t = self._mtime
16
+ t && Time.at(t)
17
+ end
18
+
14
19
  def self.join(*names)
15
20
  return "" if names.empty?
16
21
 
@@ -186,9 +191,9 @@ def self.zero?(file)
186
191
 
187
192
  def self.extname(filename)
188
193
  fname = self.basename(filename)
189
- return '' if fname[0] == '.' || fname.index('.').nil?
190
- ext = fname.split('.').last
191
- ext.empty? ? '' : ".#{ext}"
194
+ epos = fname.rindex('.')
195
+ return '' if epos == 0 || epos.nil?
196
+ return fname[epos..-1]
192
197
  end
193
198
 
194
199
  def self.path(filename)
@@ -186,7 +186,7 @@ def ungetc(substr)
186
186
 
187
187
  def read(length = nil, outbuf = "")
188
188
  unless length.nil?
189
- unless length.is_a? Fixnum
189
+ unless length.is_a? Integer
190
190
  raise TypeError.new "can't convert #{length.class} into Integer"
191
191
  end
192
192
  if length < 0
@@ -229,7 +229,7 @@ def readline(arg = "\n", limit = nil)
229
229
  case arg
230
230
  when String
231
231
  rs = arg
232
- when Fixnum
232
+ when Integer
233
233
  rs = "\n"
234
234
  limit = arg
235
235
  else
@@ -8,6 +8,7 @@
8
8
  #include "mruby/string.h"
9
9
  #include "mruby/ext/io.h"
10
10
  #include "mruby/error.h"
11
+ #include "mruby/presym.h"
11
12
 
12
13
  #include <sys/types.h>
13
14
  #include <sys/stat.h>
@@ -66,12 +67,16 @@
66
67
  #define LOCK_UN 8
67
68
  #endif
68
69
 
69
- #ifndef _WIN32
70
+ #if !defined(_WIN32) || defined(MRB_MINGW32_LEGACY)
70
71
  typedef struct stat mrb_stat;
71
72
  # define mrb_stat(path, sb) stat(path, sb)
72
73
  # define mrb_fstat(fd, sb) fstat(fd, sb)
74
+ #elif defined MRB_INT32
75
+ typedef struct _stat32 mrb_stat;
76
+ # define mrb_stat(path, sb) _stat32(path, sb)
77
+ # define mrb_fstat(fd, sb) _fstat32(fd, sb)
73
78
  #else
74
- typedef struct __stat64 mrb_stat;
79
+ typedef struct _stat64 mrb_stat;
75
80
  # define mrb_stat(path, sb) _stat64(path, sb)
76
81
  # define mrb_fstat(fd, sb) _fstat64(fd, sb)
77
82
  #endif
@@ -111,7 +116,7 @@ mrb_file_s_umask(mrb_state *mrb, mrb_value klass)
111
116
  static mrb_value
112
117
  mrb_file_s_unlink(mrb_state *mrb, mrb_value obj)
113
118
  {
114
- mrb_value *argv;
119
+ const mrb_value *argv;
115
120
  mrb_value pathv;
116
121
  mrb_int argc, i;
117
122
  char *path;
@@ -254,7 +259,7 @@ mrb_file_realpath(mrb_state *mrb, mrb_value klass)
254
259
  pathname = s;
255
260
  }
256
261
  cpath = mrb_locale_from_utf8(RSTRING_CSTR(mrb, pathname), -1);
257
- result = mrb_str_buf_new(mrb, PATH_MAX);
262
+ result = mrb_str_new_capa(mrb, PATH_MAX);
258
263
  if (realpath(cpath, RSTRING_PTR(result)) == NULL) {
259
264
  mrb_locale_free(cpath);
260
265
  mrb_sys_fail(mrb, cpath);
@@ -286,20 +291,20 @@ mrb_file__getwd(mrb_state *mrb, mrb_value klass)
286
291
  #define IS_DEVICEID(x) (x == '.' || x == '?')
287
292
  #define CHECK_UNCDEV_PATH (IS_FILESEP(path[0]) && IS_FILESEP(path[1]))
288
293
 
289
- static int
294
+ static int
290
295
  is_absolute_traditional_path(const char *path, size_t len)
291
296
  {
292
297
  if (len < 3) return 0;
293
298
  return (ISALPHA(path[0]) && IS_VOLSEP(path[1]) && IS_FILESEP(path[2]));
294
299
  }
295
300
 
296
- static int
297
- is_aboslute_unc_path(const char *path, size_t len) {
301
+ static int
302
+ is_absolute_unc_path(const char *path, size_t len) {
298
303
  if (len < 2) return 0;
299
304
  return (CHECK_UNCDEV_PATH && !IS_DEVICEID(path[2]));
300
305
  }
301
306
 
302
- static int
307
+ static int
303
308
  is_absolute_device_path(const char *path, size_t len) {
304
309
  if (len < 4) return 0;
305
310
  return (CHECK_UNCDEV_PATH && IS_DEVICEID(path[2]) && IS_FILESEP(path[3]));
@@ -312,8 +317,8 @@ mrb_file_is_absolute_path(const char *path)
312
317
  if (IS_FILESEP(path[0])) return 1;
313
318
  if (len > 0)
314
319
  return (
315
- is_absolute_traditional_path(path, len) ||
316
- is_aboslute_unc_path(path, len) ||
320
+ is_absolute_traditional_path(path, len) ||
321
+ is_absolute_unc_path(path, len) ||
317
322
  is_absolute_device_path(path, len)
318
323
  );
319
324
  else
@@ -390,15 +395,12 @@ mrb_file__gethome(mrb_state *mrb, mrb_value klass)
390
395
  static mrb_value
391
396
  mrb_file_mtime(mrb_state *mrb, mrb_value self)
392
397
  {
393
- mrb_value obj;
394
- struct stat st;
395
- int fd;
398
+ int fd = mrb_io_fileno(mrb, self);
399
+ mrb_stat st;
396
400
 
397
- obj = mrb_obj_value(mrb_class_get(mrb, "Time"));
398
- fd = mrb_io_fileno(mrb, self);
399
- if (fstat(fd, &st) == -1)
401
+ if (mrb_fstat(fd, &st) == -1)
400
402
  return mrb_false_value();
401
- return mrb_funcall(mrb, obj, "at", 1, mrb_fixnum_value(st.st_mtime));
403
+ return mrb_int_value(mrb, (mrb_int)st.st_mtime);
402
404
  }
403
405
 
404
406
  static mrb_value
@@ -447,14 +449,14 @@ mrb_file_size(mrb_state *mrb, mrb_value self)
447
449
  }
448
450
 
449
451
  if (st.st_size > MRB_INT_MAX) {
450
- #ifdef MRB_WITHOUT_FLOAT
451
- mrb_raise(mrb, E_RUNTIME_ERROR, "File#size too large for MRB_WITHOUT_FLOAT");
452
+ #ifdef MRB_NO_FLOAT
453
+ mrb_raise(mrb, E_RUNTIME_ERROR, "File#size too large for MRB_NO_FLOAT");
452
454
  #else
453
455
  return mrb_float_value(mrb, (mrb_float)st.st_size);
454
456
  #endif
455
457
  }
456
458
 
457
- return mrb_fixnum_value((mrb_int)st.st_size);
459
+ return mrb_int_value(mrb, (mrb_int)st.st_size);
458
460
  }
459
461
 
460
462
  static int
@@ -532,7 +534,7 @@ static mrb_value
532
534
  mrb_file_s_chmod(mrb_state *mrb, mrb_value klass) {
533
535
  mrb_int mode;
534
536
  mrb_int argc, i;
535
- mrb_value *filenames;
537
+ const mrb_value *filenames;
536
538
  int ai = mrb_gc_arena_save(mrb);
537
539
 
538
540
  mrb_get_args(mrb, "i*", &mode, &filenames, &argc);
@@ -556,7 +558,8 @@ mrb_file_s_readlink(mrb_state *mrb, mrb_value klass) {
556
558
  mrb_raise(mrb, E_NOTIMP_ERROR, "readlink is not supported on this platform");
557
559
  return mrb_nil_value(); // unreachable
558
560
  #else
559
- char *path, *buf, *tmp;
561
+ const char *path;
562
+ char *buf, *tmp;
560
563
  size_t bufsize = 100;
561
564
  ssize_t rc;
562
565
  mrb_value ret;
@@ -608,40 +611,40 @@ mrb_init_file(mrb_state *mrb)
608
611
  mrb_define_class_method(mrb, file, "_gethome", mrb_file__gethome, MRB_ARGS_OPT(1));
609
612
 
610
613
  mrb_define_method(mrb, file, "flock", mrb_file_flock, MRB_ARGS_REQ(1));
611
- mrb_define_method(mrb, file, "mtime", mrb_file_mtime, MRB_ARGS_NONE());
614
+ mrb_define_method(mrb, file, "_mtime", mrb_file_mtime, MRB_ARGS_NONE());
612
615
  mrb_define_method(mrb, file, "size", mrb_file_size, MRB_ARGS_NONE());
613
616
  mrb_define_method(mrb, file, "truncate", mrb_file_truncate, MRB_ARGS_REQ(1));
614
617
 
615
- cnst = mrb_define_module_under(mrb, file, "Constants");
616
- mrb_define_const(mrb, cnst, "LOCK_SH", mrb_fixnum_value(LOCK_SH));
617
- mrb_define_const(mrb, cnst, "LOCK_EX", mrb_fixnum_value(LOCK_EX));
618
- mrb_define_const(mrb, cnst, "LOCK_UN", mrb_fixnum_value(LOCK_UN));
619
- mrb_define_const(mrb, cnst, "LOCK_NB", mrb_fixnum_value(LOCK_NB));
620
- mrb_define_const(mrb, cnst, "SEPARATOR", mrb_str_new_cstr(mrb, FILE_SEPARATOR));
621
- mrb_define_const(mrb, cnst, "PATH_SEPARATOR", mrb_str_new_cstr(mrb, PATH_SEPARATOR));
618
+ cnst = mrb_define_module_under_id(mrb, file, MRB_SYM(Constants));
619
+ mrb_define_const_id(mrb, cnst, MRB_SYM(LOCK_SH), mrb_fixnum_value(LOCK_SH));
620
+ mrb_define_const_id(mrb, cnst, MRB_SYM(LOCK_EX), mrb_fixnum_value(LOCK_EX));
621
+ mrb_define_const_id(mrb, cnst, MRB_SYM(LOCK_UN), mrb_fixnum_value(LOCK_UN));
622
+ mrb_define_const_id(mrb, cnst, MRB_SYM(LOCK_NB), mrb_fixnum_value(LOCK_NB));
623
+ mrb_define_const_id(mrb, cnst, MRB_SYM(SEPARATOR), mrb_str_new_cstr(mrb, FILE_SEPARATOR));
624
+ mrb_define_const_id(mrb, cnst, MRB_SYM(PATH_SEPARATOR), mrb_str_new_cstr(mrb, PATH_SEPARATOR));
622
625
  #if defined(_WIN32) || defined(_WIN64)
623
- mrb_define_const(mrb, cnst, "ALT_SEPARATOR", mrb_str_new_cstr(mrb, FILE_ALT_SEPARATOR));
626
+ mrb_define_const_id(mrb, cnst, MRB_SYM(ALT_SEPARATOR), mrb_str_new_cstr(mrb, FILE_ALT_SEPARATOR));
624
627
  #else
625
- mrb_define_const(mrb, cnst, "ALT_SEPARATOR", mrb_nil_value());
628
+ mrb_define_const_id(mrb, cnst, MRB_SYM(ALT_SEPARATOR), mrb_nil_value());
626
629
  #endif
627
- mrb_define_const(mrb, cnst, "NULL", mrb_str_new_cstr(mrb, NULL_FILE));
628
-
629
- mrb_define_const(mrb, cnst, "RDONLY", mrb_fixnum_value(MRB_O_RDONLY));
630
- mrb_define_const(mrb, cnst, "WRONLY", mrb_fixnum_value(MRB_O_WRONLY));
631
- mrb_define_const(mrb, cnst, "RDWR", mrb_fixnum_value(MRB_O_RDWR));
632
- mrb_define_const(mrb, cnst, "APPEND", mrb_fixnum_value(MRB_O_APPEND));
633
- mrb_define_const(mrb, cnst, "CREAT", mrb_fixnum_value(MRB_O_CREAT));
634
- mrb_define_const(mrb, cnst, "EXCL", mrb_fixnum_value(MRB_O_EXCL));
635
- mrb_define_const(mrb, cnst, "TRUNC", mrb_fixnum_value(MRB_O_TRUNC));
636
- mrb_define_const(mrb, cnst, "NONBLOCK", mrb_fixnum_value(MRB_O_NONBLOCK));
637
- mrb_define_const(mrb, cnst, "NOCTTY", mrb_fixnum_value(MRB_O_NOCTTY));
638
- mrb_define_const(mrb, cnst, "BINARY", mrb_fixnum_value(MRB_O_BINARY));
639
- mrb_define_const(mrb, cnst, "SHARE_DELETE", mrb_fixnum_value(MRB_O_SHARE_DELETE));
640
- mrb_define_const(mrb, cnst, "SYNC", mrb_fixnum_value(MRB_O_SYNC));
641
- mrb_define_const(mrb, cnst, "DSYNC", mrb_fixnum_value(MRB_O_DSYNC));
642
- mrb_define_const(mrb, cnst, "RSYNC", mrb_fixnum_value(MRB_O_RSYNC));
643
- mrb_define_const(mrb, cnst, "NOFOLLOW", mrb_fixnum_value(MRB_O_NOFOLLOW));
644
- mrb_define_const(mrb, cnst, "NOATIME", mrb_fixnum_value(MRB_O_NOATIME));
645
- mrb_define_const(mrb, cnst, "DIRECT", mrb_fixnum_value(MRB_O_DIRECT));
646
- mrb_define_const(mrb, cnst, "TMPFILE", mrb_fixnum_value(MRB_O_TMPFILE));
630
+ mrb_define_const_id(mrb, cnst, MRB_SYM(NULL), mrb_str_new_cstr(mrb, NULL_FILE));
631
+
632
+ mrb_define_const_id(mrb, cnst, MRB_SYM(RDONLY), mrb_fixnum_value(MRB_O_RDONLY));
633
+ mrb_define_const_id(mrb, cnst, MRB_SYM(WRONLY), mrb_fixnum_value(MRB_O_WRONLY));
634
+ mrb_define_const_id(mrb, cnst, MRB_SYM(RDWR), mrb_fixnum_value(MRB_O_RDWR));
635
+ mrb_define_const_id(mrb, cnst, MRB_SYM(APPEND), mrb_fixnum_value(MRB_O_APPEND));
636
+ mrb_define_const_id(mrb, cnst, MRB_SYM(CREAT), mrb_fixnum_value(MRB_O_CREAT));
637
+ mrb_define_const_id(mrb, cnst, MRB_SYM(EXCL), mrb_fixnum_value(MRB_O_EXCL));
638
+ mrb_define_const_id(mrb, cnst, MRB_SYM(TRUNC), mrb_fixnum_value(MRB_O_TRUNC));
639
+ mrb_define_const_id(mrb, cnst, MRB_SYM(NONBLOCK), mrb_fixnum_value(MRB_O_NONBLOCK));
640
+ mrb_define_const_id(mrb, cnst, MRB_SYM(NOCTTY), mrb_fixnum_value(MRB_O_NOCTTY));
641
+ mrb_define_const_id(mrb, cnst, MRB_SYM(BINARY), mrb_fixnum_value(MRB_O_BINARY));
642
+ mrb_define_const_id(mrb, cnst, MRB_SYM(SHARE_DELETE), mrb_fixnum_value(MRB_O_SHARE_DELETE));
643
+ mrb_define_const_id(mrb, cnst, MRB_SYM(SYNC), mrb_fixnum_value(MRB_O_SYNC));
644
+ mrb_define_const_id(mrb, cnst, MRB_SYM(DSYNC), mrb_fixnum_value(MRB_O_DSYNC));
645
+ mrb_define_const_id(mrb, cnst, MRB_SYM(RSYNC), mrb_fixnum_value(MRB_O_RSYNC));
646
+ mrb_define_const_id(mrb, cnst, MRB_SYM(NOFOLLOW), mrb_fixnum_value(MRB_O_NOFOLLOW));
647
+ mrb_define_const_id(mrb, cnst, MRB_SYM(NOATIME), mrb_fixnum_value(MRB_O_NOATIME));
648
+ mrb_define_const_id(mrb, cnst, MRB_SYM(DIRECT), mrb_fixnum_value(MRB_O_DIRECT));
649
+ mrb_define_const_id(mrb, cnst, MRB_SYM(TMPFILE), mrb_fixnum_value(MRB_O_TMPFILE));
647
650
  }
@@ -66,11 +66,13 @@ mrb_stat(mrb_state *mrb, mrb_value obj, struct stat *st)
66
66
  return mrb_stat0(mrb, obj, st, 0);
67
67
  }
68
68
 
69
+ #ifdef S_ISLNK
69
70
  static int
70
71
  mrb_lstat(mrb_state *mrb, mrb_value obj, struct stat *st)
71
72
  {
72
73
  return mrb_stat0(mrb, obj, st, 1);
73
74
  }
75
+ #endif
74
76
 
75
77
  /*
76
78
  * Document-method: directory?
@@ -302,7 +304,7 @@ mrb_filetest_s_size(mrb_state *mrb, mrb_value klass)
302
304
  if (mrb_stat(mrb, obj, &st) < 0)
303
305
  mrb_sys_fail(mrb, "mrb_stat");
304
306
 
305
- return mrb_fixnum_value(st.st_size);
307
+ return mrb_int_value(mrb, st.st_size);
306
308
  }
307
309
 
308
310
  /*
@@ -324,7 +326,7 @@ mrb_filetest_s_size_p(mrb_state *mrb, mrb_value klass)
324
326
  if (st.st_size == 0)
325
327
  return mrb_nil_value();
326
328
 
327
- return mrb_fixnum_value(st.st_size);
329
+ return mrb_int_value(mrb, st.st_size);
328
330
  }
329
331
 
330
332
  void
@@ -11,6 +11,7 @@
11
11
  #include "mruby/variable.h"
12
12
  #include "mruby/ext/io.h"
13
13
  #include "mruby/error.h"
14
+ #include "mruby/presym.h"
14
15
 
15
16
  #include <sys/types.h>
16
17
  #include <sys/stat.h>
@@ -18,6 +19,7 @@
18
19
  #if defined(_WIN32) || defined(_WIN64)
19
20
  #include <winsock.h>
20
21
  #include <io.h>
22
+ #include <basetsd.h>
21
23
  #define open _open
22
24
  #define close _close
23
25
  #define dup _dup
@@ -32,6 +34,12 @@
32
34
  typedef long fsuseconds_t;
33
35
  typedef int fmode_t;
34
36
  typedef int mrb_io_read_write_size;
37
+ #ifndef MRB_MINGW32_LEGACY
38
+ #if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED) && \
39
+ !defined(__have_typedef_ssize_t)
40
+ typedef SSIZE_T ssize_t;
41
+ #endif
42
+ #endif
35
43
 
36
44
  #ifndef O_TMPFILE
37
45
  #define O_TMPFILE O_TEMPORARY
@@ -95,18 +103,18 @@ io_set_process_status(mrb_state *mrb, pid_t pid, int status)
95
103
  mrb_value v;
96
104
 
97
105
  c_status = NULL;
98
- if (mrb_class_defined(mrb, "Process")) {
99
- c_process = mrb_module_get(mrb, "Process");
100
- if (mrb_const_defined(mrb, mrb_obj_value(c_process), mrb_intern_cstr(mrb, "Status"))) {
101
- c_status = mrb_class_get_under(mrb, c_process, "Status");
106
+ if (mrb_class_defined_id(mrb, MRB_SYM(Process))) {
107
+ c_process = mrb_module_get_id(mrb, MRB_SYM(Process));
108
+ if (mrb_const_defined(mrb, mrb_obj_value(c_process), MRB_SYM(Status))) {
109
+ c_status = mrb_class_get_under_id(mrb, c_process, MRB_SYM(Status));
102
110
  }
103
111
  }
104
112
  if (c_status != NULL) {
105
- v = mrb_funcall(mrb, mrb_obj_value(c_status), "new", 2, mrb_fixnum_value(pid), mrb_fixnum_value(status));
113
+ v = mrb_funcall_id(mrb, mrb_obj_value(c_status), MRB_SYM(new), 2, mrb_fixnum_value(pid), mrb_fixnum_value(status));
106
114
  } else {
107
115
  v = mrb_fixnum_value(WEXITSTATUS(status));
108
116
  }
109
- mrb_gv_set(mrb, mrb_intern_cstr(mrb, "$?"), v);
117
+ mrb_gv_set(mrb, mrb_intern_lit(mrb, "$?"), v);
110
118
  }
111
119
 
112
120
  static int
@@ -319,20 +327,20 @@ mrb_io_alloc(mrb_state *mrb)
319
327
  #define NOFILE 64
320
328
  #endif
321
329
 
330
+ #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
331
+ # define mrb_io_s_popen mrb_notimplement_m
332
+ #else
322
333
  static int
323
- option_to_fd(mrb_state *mrb, mrb_value hash, const char *key)
334
+ option_to_fd(mrb_state *mrb, mrb_value v)
324
335
  {
325
- mrb_value opt;
326
-
327
- if (!mrb_hash_p(hash)) return -1;
328
- opt = mrb_hash_fetch(mrb, hash, mrb_symbol_value(mrb_intern_static(mrb, key, strlen(key))), mrb_nil_value());
329
- if (mrb_nil_p(opt)) return -1;
336
+ if (mrb_undef_p(v)) return -1;
337
+ if (mrb_nil_p(v)) return -1;
330
338
 
331
- switch (mrb_type(opt)) {
339
+ switch (mrb_type(v)) {
332
340
  case MRB_TT_DATA: /* IO */
333
- return mrb_io_fileno(mrb, opt);
334
- case MRB_TT_FIXNUM:
335
- return (int)mrb_fixnum(opt);
341
+ return mrb_io_fileno(mrb, v);
342
+ case MRB_TT_INTEGER:
343
+ return (int)mrb_integer(v);
336
344
  default:
337
345
  mrb_raise(mrb, E_ARGUMENT_ERROR, "wrong exec redirect action");
338
346
  break;
@@ -340,16 +348,42 @@ option_to_fd(mrb_state *mrb, mrb_value hash, const char *key)
340
348
  return -1; /* never reached */
341
349
  }
342
350
 
351
+ static mrb_value
352
+ mrb_io_s_popen_args(mrb_state *mrb, mrb_value klass,
353
+ const char **cmd, int *flags, int *doexec,
354
+ int *opt_in, int *opt_out, int *opt_err)
355
+ {
356
+ mrb_value mode = mrb_nil_value();
357
+ struct { mrb_value opt_in, opt_out, opt_err; } kv;
358
+ mrb_sym knames[3] = {MRB_SYM(in), MRB_SYM(out), MRB_SYM(err)};
359
+ const mrb_kwargs kw = {
360
+ 3, 0,
361
+ knames,
362
+ &kv.opt_in,
363
+ NULL,
364
+ };
365
+
366
+ mrb_get_args(mrb, "z|o:", cmd, &mode, &kw);
367
+
368
+ *flags = mrb_io_mode_to_flags(mrb, mode);
369
+ *doexec = (strcmp("-", *cmd) != 0);
370
+ *opt_in = option_to_fd(mrb, kv.opt_in);
371
+ *opt_out = option_to_fd(mrb, kv.opt_out);
372
+ *opt_err = option_to_fd(mrb, kv.opt_err);
373
+
374
+ return mrb_obj_value(mrb_data_object_alloc(mrb, mrb_class_ptr(klass), NULL, &mrb_io_type));
375
+ }
376
+
343
377
  #ifdef _WIN32
344
378
  static mrb_value
345
379
  mrb_io_s_popen(mrb_state *mrb, mrb_value klass)
346
380
  {
347
- mrb_value cmd, io;
348
- mrb_value mode = mrb_str_new_cstr(mrb, "r");
349
- mrb_value opt = mrb_hash_new(mrb);
381
+ mrb_value io;
382
+ int doexec;
383
+ int opt_in, opt_out, opt_err;
384
+ const char *cmd;
350
385
 
351
386
  struct mrb_io *fptr;
352
- const char *pname;
353
387
  int pid = 0, flags;
354
388
  STARTUPINFO si;
355
389
  PROCESS_INFORMATION pi;
@@ -358,24 +392,13 @@ mrb_io_s_popen(mrb_state *mrb, mrb_value klass)
358
392
  HANDLE ifd[2];
359
393
  HANDLE ofd[2];
360
394
 
361
- int doexec;
362
- int opt_in, opt_out, opt_err;
363
-
364
395
  ifd[0] = INVALID_HANDLE_VALUE;
365
396
  ifd[1] = INVALID_HANDLE_VALUE;
366
397
  ofd[0] = INVALID_HANDLE_VALUE;
367
398
  ofd[1] = INVALID_HANDLE_VALUE;
368
399
 
369
- mrb_get_args(mrb, "S|oH", &cmd, &mode, &opt);
370
- io = mrb_obj_value(mrb_data_object_alloc(mrb, mrb_class_ptr(klass), NULL, &mrb_io_type));
371
-
372
- pname = RSTRING_CSTR(mrb, cmd);
373
- flags = mrb_io_mode_to_flags(mrb, mode);
374
-
375
- doexec = (strcmp("-", pname) != 0);
376
- opt_in = option_to_fd(mrb, opt, "in");
377
- opt_out = option_to_fd(mrb, opt, "out");
378
- opt_err = option_to_fd(mrb, opt, "err");
400
+ io = mrb_io_s_popen_args(mrb, klass, &cmd, &flags, &doexec,
401
+ &opt_in, &opt_out, &opt_err);
379
402
 
380
403
  saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
381
404
  saAttr.bInheritHandle = TRUE;
@@ -410,13 +433,13 @@ mrb_io_s_popen(mrb_state *mrb, mrb_value klass)
410
433
  si.hStdInput = ifd[0];
411
434
  }
412
435
  if (!CreateProcess(
413
- NULL, (char*)pname, NULL, NULL,
436
+ NULL, (char*)cmd, NULL, NULL,
414
437
  TRUE, CREATE_NEW_PROCESS_GROUP, NULL, NULL, &si, &pi)) {
415
438
  CloseHandle(ifd[0]);
416
439
  CloseHandle(ifd[1]);
417
440
  CloseHandle(ofd[0]);
418
441
  CloseHandle(ofd[1]);
419
- mrb_raisef(mrb, E_IO_ERROR, "command not found: %v", cmd);
442
+ mrb_raisef(mrb, E_IO_ERROR, "command not found: %s", cmd);
420
443
  }
421
444
  CloseHandle(pi.hThread);
422
445
  CloseHandle(ifd[0]);
@@ -424,7 +447,7 @@ mrb_io_s_popen(mrb_state *mrb, mrb_value klass)
424
447
  pid = pi.dwProcessId;
425
448
  }
426
449
 
427
- mrb_iv_set(mrb, io, mrb_intern_cstr(mrb, "@buf"), mrb_str_new_cstr(mrb, ""));
450
+ mrb_iv_set(mrb, io, mrb_intern_lit(mrb, "@buf"), mrb_str_new_cstr(mrb, ""));
428
451
 
429
452
  fptr = mrb_io_alloc(mrb);
430
453
  fptr->fd = _open_osfhandle((intptr_t)ofd[0], 0);
@@ -438,40 +461,23 @@ mrb_io_s_popen(mrb_state *mrb, mrb_value klass)
438
461
  DATA_PTR(io) = fptr;
439
462
  return io;
440
463
  }
441
- #elif defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
442
- static mrb_value
443
- mrb_io_s_popen(mrb_state *mrb, mrb_value klass)
444
- {
445
- mrb_raise(mrb, E_NOTIMP_ERROR, "IO#popen is not supported on the platform");
446
- return mrb_false_value();
447
- }
448
464
  #else
449
465
  static mrb_value
450
466
  mrb_io_s_popen(mrb_state *mrb, mrb_value klass)
451
467
  {
452
- mrb_value cmd, io, result;
453
- mrb_value mode = mrb_str_new_cstr(mrb, "r");
454
- mrb_value opt = mrb_hash_new(mrb);
468
+ mrb_value io, result;
469
+ int doexec;
470
+ int opt_in, opt_out, opt_err;
471
+ const char *cmd;
455
472
 
456
473
  struct mrb_io *fptr;
457
- const char *pname;
458
474
  int pid, flags, fd, write_fd = -1;
459
475
  int pr[2] = { -1, -1 };
460
476
  int pw[2] = { -1, -1 };
461
- int doexec;
462
477
  int saved_errno;
463
- int opt_in, opt_out, opt_err;
464
-
465
- mrb_get_args(mrb, "S|oH", &cmd, &mode, &opt);
466
- io = mrb_obj_value(mrb_data_object_alloc(mrb, mrb_class_ptr(klass), NULL, &mrb_io_type));
467
478
 
468
- pname = RSTRING_CSTR(mrb, cmd);
469
- flags = mrb_io_mode_to_flags(mrb, mode);
470
-
471
- doexec = (strcmp("-", pname) != 0);
472
- opt_in = option_to_fd(mrb, opt, "in");
473
- opt_out = option_to_fd(mrb, opt, "out");
474
- opt_err = option_to_fd(mrb, opt, "err");
479
+ io = mrb_io_s_popen_args(mrb, klass, &cmd, &flags, &doexec,
480
+ &opt_in, &opt_out, &opt_err);
475
481
 
476
482
  if (OPEN_READABLE_P(flags)) {
477
483
  if (pipe(pr) == -1) {
@@ -528,8 +534,8 @@ mrb_io_s_popen(mrb_state *mrb, mrb_value klass)
528
534
  for (fd = 3; fd < NOFILE; fd++) {
529
535
  close(fd);
530
536
  }
531
- mrb_proc_exec(pname);
532
- mrb_raisef(mrb, E_IO_ERROR, "command not found: %v", cmd);
537
+ mrb_proc_exec(cmd);
538
+ mrb_raisef(mrb, E_IO_ERROR, "command not found: %s", cmd);
533
539
  _exit(127);
534
540
  }
535
541
  result = mrb_nil_value();
@@ -549,7 +555,7 @@ mrb_io_s_popen(mrb_state *mrb, mrb_value klass)
549
555
  fd = pw[1];
550
556
  }
551
557
 
552
- mrb_iv_set(mrb, io, mrb_intern_cstr(mrb, "@buf"), mrb_str_new_cstr(mrb, ""));
558
+ mrb_iv_set(mrb, io, mrb_intern_lit(mrb, "@buf"), mrb_str_new_cstr(mrb, ""));
553
559
 
554
560
  fptr = mrb_io_alloc(mrb);
555
561
  fptr->fd = fd;
@@ -580,7 +586,8 @@ mrb_io_s_popen(mrb_state *mrb, mrb_value klass)
580
586
  }
581
587
  return result;
582
588
  }
583
- #endif
589
+ #endif /* _WIN32 */
590
+ #endif /* TARGET_OS_IPHONE */
584
591
 
585
592
  static int
586
593
  mrb_dup(mrb_state *mrb, int fd, mrb_bool *failed)
@@ -617,8 +624,8 @@ mrb_io_initialize_copy(mrb_state *mrb, mrb_value copy)
617
624
  DATA_TYPE(copy) = &mrb_io_type;
618
625
  DATA_PTR(copy) = fptr_copy;
619
626
 
620
- buf = mrb_iv_get(mrb, orig, mrb_intern_cstr(mrb, "@buf"));
621
- mrb_iv_set(mrb, copy, mrb_intern_cstr(mrb, "@buf"), buf);
627
+ buf = mrb_iv_get(mrb, orig, mrb_intern_lit(mrb, "@buf"));
628
+ mrb_iv_set(mrb, copy, mrb_intern_lit(mrb, "@buf"), buf);
622
629
 
623
630
  fptr_copy->fd = mrb_dup(mrb, fptr_orig->fd, &failed);
624
631
  if (failed) {
@@ -692,7 +699,15 @@ mrb_io_initialize(mrb_state *mrb, mrb_value io)
692
699
  mode = opt = mrb_nil_value();
693
700
 
694
701
  mrb_get_args(mrb, "i|oo", &fd, &mode, &opt);
695
- check_file_descriptor(mrb, fd);
702
+ switch (fd) {
703
+ case 0: /* STDIN_FILENO */
704
+ case 1: /* STDOUT_FILENO */
705
+ case 2: /* STDERR_FILENO */
706
+ break;
707
+ default:
708
+ check_file_descriptor(mrb, fd);
709
+ break;
710
+ }
696
711
  if (mrb_nil_p(mode)) {
697
712
  mode = mrb_str_new_cstr(mrb, "r");
698
713
  }
@@ -702,7 +717,7 @@ mrb_io_initialize(mrb_state *mrb, mrb_value io)
702
717
 
703
718
  flags = mrb_io_mode_to_flags(mrb, mode);
704
719
 
705
- mrb_iv_set(mrb, io, mrb_intern_cstr(mrb, "@buf"), mrb_str_new_cstr(mrb, ""));
720
+ mrb_iv_set(mrb, io, mrb_intern_lit(mrb, "@buf"), mrb_str_new_cstr(mrb, ""));
706
721
 
707
722
  fptr = (struct mrb_io *)DATA_PTR(io);
708
723
  if (fptr != NULL) {
@@ -966,13 +981,13 @@ mrb_io_sysseek(mrb_state *mrb, mrb_value io)
966
981
  mrb_sys_fail(mrb, "sysseek");
967
982
  }
968
983
  if (pos > MRB_INT_MAX) {
969
- #ifndef MRB_WITHOUT_FLOAT
984
+ #ifndef MRB_NO_FLOAT
970
985
  return mrb_float_value(mrb, (mrb_float)pos);
971
986
  #else
972
- mrb_raise(mrb, E_IO_ERROR, "sysseek reached too far for MRB_WITHOUT_FLOAT");
987
+ mrb_raise(mrb, E_IO_ERROR, "sysseek reached too far for MRB_NO_FLOAT");
973
988
  #endif
974
989
  } else {
975
- return mrb_fixnum_value(pos);
990
+ return mrb_int_value(mrb, pos);
976
991
  }
977
992
  }
978
993
 
@@ -999,7 +1014,7 @@ mrb_io_syswrite_common(mrb_state *mrb,
999
1014
  mrb_sys_fail(mrb, 0);
1000
1015
  }
1001
1016
 
1002
- return mrb_fixnum_value(length);
1017
+ return mrb_int_value(mrb, (mrb_int)length);
1003
1018
  }
1004
1019
 
1005
1020
  static mrb_io_read_write_size
@@ -1069,12 +1084,12 @@ time2timeval(mrb_state *mrb, mrb_value time)
1069
1084
  struct timeval t = { 0, 0 };
1070
1085
 
1071
1086
  switch (mrb_type(time)) {
1072
- case MRB_TT_FIXNUM:
1073
- t.tv_sec = (ftime_t)mrb_fixnum(time);
1087
+ case MRB_TT_INTEGER:
1088
+ t.tv_sec = (ftime_t)mrb_integer(time);
1074
1089
  t.tv_usec = 0;
1075
1090
  break;
1076
1091
 
1077
- #ifndef MRB_WITHOUT_FLOAT
1092
+ #ifndef MRB_NO_FLOAT
1078
1093
  case MRB_TT_FLOAT:
1079
1094
  t.tv_sec = (ftime_t)mrb_float(time);
1080
1095
  t.tv_usec = (fsuseconds_t)((mrb_float(time) - t.tv_sec) * 1000000.0);
@@ -1091,7 +1106,7 @@ time2timeval(mrb_state *mrb, mrb_value time)
1091
1106
  static int
1092
1107
  mrb_io_read_data_pending(mrb_state *mrb, mrb_value io)
1093
1108
  {
1094
- mrb_value buf = mrb_iv_get(mrb, io, mrb_intern_cstr(mrb, "@buf"));
1109
+ mrb_value buf = mrb_iv_get(mrb, io, mrb_intern_lit(mrb, "@buf"));
1095
1110
  if (mrb_string_p(buf) && RSTRING_LEN(buf) > 0) {
1096
1111
  return 1;
1097
1112
  }
@@ -1113,7 +1128,7 @@ mrb_io_s_pipe(mrb_state *mrb, mrb_value klass)
1113
1128
  }
1114
1129
 
1115
1130
  r = mrb_obj_value(mrb_data_object_alloc(mrb, mrb_class_ptr(klass), NULL, &mrb_io_type));
1116
- mrb_iv_set(mrb, r, mrb_intern_cstr(mrb, "@buf"), mrb_str_new_cstr(mrb, ""));
1131
+ mrb_iv_set(mrb, r, mrb_intern_lit(mrb, "@buf"), mrb_str_new_cstr(mrb, ""));
1117
1132
  fptr_r = mrb_io_alloc(mrb);
1118
1133
  fptr_r->fd = pipes[0];
1119
1134
  fptr_r->readable = 1;
@@ -1123,7 +1138,7 @@ mrb_io_s_pipe(mrb_state *mrb, mrb_value klass)
1123
1138
  DATA_PTR(r) = fptr_r;
1124
1139
 
1125
1140
  w = mrb_obj_value(mrb_data_object_alloc(mrb, mrb_class_ptr(klass), NULL, &mrb_io_type));
1126
- mrb_iv_set(mrb, w, mrb_intern_cstr(mrb, "@buf"), mrb_str_new_cstr(mrb, ""));
1141
+ mrb_iv_set(mrb, w, mrb_intern_lit(mrb, "@buf"), mrb_str_new_cstr(mrb, ""));
1127
1142
  fptr_w = mrb_io_alloc(mrb);
1128
1143
  fptr_w->fd = pipes[1];
1129
1144
  fptr_w->readable = 0;
@@ -1139,7 +1154,7 @@ mrb_io_s_pipe(mrb_state *mrb, mrb_value klass)
1139
1154
  static mrb_value
1140
1155
  mrb_io_s_select(mrb_state *mrb, mrb_value klass)
1141
1156
  {
1142
- mrb_value *argv;
1157
+ const mrb_value *argv;
1143
1158
  mrb_int argc;
1144
1159
  mrb_value read, read_io, write, except, timeout, list;
1145
1160
  struct timeval *tp, timerec;
@@ -1316,10 +1331,10 @@ mrb_io_fileno_m(mrb_state *mrb, mrb_value io)
1316
1331
  return mrb_fixnum_value(fd);
1317
1332
  }
1318
1333
 
1334
+ #if defined(F_GETFD) && defined(F_SETFD) && defined(FD_CLOEXEC)
1319
1335
  static mrb_value
1320
1336
  mrb_io_close_on_exec_p(mrb_state *mrb, mrb_value self)
1321
1337
  {
1322
- #if defined(F_GETFD) && defined(F_SETFD) && defined(FD_CLOEXEC)
1323
1338
  struct mrb_io *fptr;
1324
1339
  int ret;
1325
1340
 
@@ -1333,17 +1348,15 @@ mrb_io_close_on_exec_p(mrb_state *mrb, mrb_value self)
1333
1348
  if ((ret = fcntl(fptr->fd, F_GETFD)) == -1) mrb_sys_fail(mrb, "F_GETFD failed");
1334
1349
  if (!(ret & FD_CLOEXEC)) return mrb_false_value();
1335
1350
  return mrb_true_value();
1336
-
1351
+ }
1337
1352
  #else
1338
- mrb_raise(mrb, E_NOTIMP_ERROR, "IO#close_on_exec? is not supported on the platform");
1339
- return mrb_false_value();
1353
+ # define mrb_io_close_on_exec_p mrb_notimplement_m
1340
1354
  #endif
1341
- }
1342
1355
 
1356
+ #if defined(F_GETFD) && defined(F_SETFD) && defined(FD_CLOEXEC)
1343
1357
  static mrb_value
1344
1358
  mrb_io_set_close_on_exec(mrb_state *mrb, mrb_value self)
1345
1359
  {
1346
- #if defined(F_GETFD) && defined(F_SETFD) && defined(FD_CLOEXEC)
1347
1360
  struct mrb_io *fptr;
1348
1361
  int flag, ret;
1349
1362
  mrb_bool b;
@@ -1370,11 +1383,10 @@ mrb_io_set_close_on_exec(mrb_state *mrb, mrb_value self)
1370
1383
  }
1371
1384
 
1372
1385
  return mrb_bool_value(b);
1386
+ }
1373
1387
  #else
1374
- mrb_raise(mrb, E_NOTIMP_ERROR, "IO#close_on_exec= is not supported on the platform");
1375
- return mrb_nil_value();
1388
+ # define mrb_io_set_close_on_exec mrb_notimplement_m
1376
1389
  #endif
1377
- }
1378
1390
 
1379
1391
  static mrb_value
1380
1392
  mrb_io_set_sync(mrb_state *mrb, mrb_value self)