script_core 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (224) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -1
  3. data/ext/enterprise_script_service/libseccomp/.travis.yml +3 -5
  4. data/ext/enterprise_script_service/libseccomp/CHANGELOG +10 -0
  5. data/ext/enterprise_script_service/libseccomp/CREDITS +3 -0
  6. data/ext/enterprise_script_service/libseccomp/README.md +18 -0
  7. data/ext/enterprise_script_service/libseccomp/configure.ac +1 -1
  8. data/ext/enterprise_script_service/libseccomp/include/seccomp-syscalls.h +7 -0
  9. data/ext/enterprise_script_service/libseccomp/src/arch-s390-syscalls.c +16 -0
  10. data/ext/enterprise_script_service/libseccomp/src/arch-s390x-syscalls.c +16 -0
  11. data/ext/enterprise_script_service/libseccomp/tests/.gitignore +1 -0
  12. data/ext/enterprise_script_service/libseccomp/tests/15-basic-resolver.c +3 -3
  13. data/ext/enterprise_script_service/libseccomp/tests/52-basic-load.c +48 -0
  14. data/ext/enterprise_script_service/libseccomp/tests/52-basic-load.py +38 -0
  15. data/ext/enterprise_script_service/libseccomp/tests/52-basic-load.tests +11 -0
  16. data/ext/enterprise_script_service/libseccomp/tests/Makefile.am +6 -3
  17. data/ext/enterprise_script_service/libseccomp/tests/regression +4 -0
  18. data/ext/enterprise_script_service/libseccomp/tools/Makefile.am +0 -3
  19. data/ext/enterprise_script_service/libseccomp/tools/scmp_bpf_sim.c +2 -0
  20. data/ext/enterprise_script_service/mruby/.github/workflows/build.yml +106 -0
  21. data/ext/enterprise_script_service/mruby/.github/workflows/main.yml +24 -0
  22. data/ext/enterprise_script_service/mruby/.gitignore +3 -0
  23. data/ext/enterprise_script_service/mruby/.travis.yml +6 -9
  24. data/ext/enterprise_script_service/mruby/AUTHORS +1 -0
  25. data/ext/enterprise_script_service/mruby/Doxyfile +1 -1
  26. data/ext/enterprise_script_service/mruby/LICENSE +1 -1
  27. data/ext/enterprise_script_service/mruby/README.md +6 -2
  28. data/ext/enterprise_script_service/mruby/appveyor.yml +9 -12
  29. data/ext/enterprise_script_service/mruby/appveyor_config.rb +9 -0
  30. data/ext/enterprise_script_service/mruby/build_config.rb +6 -6
  31. data/ext/enterprise_script_service/mruby/doc/guides/compile.md +6 -2
  32. data/ext/enterprise_script_service/mruby/doc/guides/debugger.md +1 -1
  33. data/ext/enterprise_script_service/mruby/doc/guides/mrbconf.md +4 -8
  34. data/ext/enterprise_script_service/mruby/doc/limitations.md +10 -10
  35. data/ext/enterprise_script_service/mruby/doc/opcode.md +108 -95
  36. data/ext/enterprise_script_service/mruby/examples/targets/build_config_ArduinoDue.rb +2 -2
  37. data/ext/enterprise_script_service/mruby/examples/targets/build_config_IntelEdison.rb +2 -2
  38. data/ext/enterprise_script_service/mruby/examples/targets/build_config_IntelGalileo.rb +2 -2
  39. data/ext/enterprise_script_service/mruby/examples/targets/build_config_RX630.rb +2 -2
  40. data/ext/enterprise_script_service/mruby/examples/targets/build_config_chipKITMax32.rb +2 -2
  41. data/ext/enterprise_script_service/mruby/examples/targets/build_config_dreamcast_shelf.rb +108 -0
  42. data/ext/enterprise_script_service/mruby/include/mrbconf.h +10 -7
  43. data/ext/enterprise_script_service/mruby/include/mruby.h +11 -9
  44. data/ext/enterprise_script_service/mruby/include/mruby/array.h +4 -0
  45. data/ext/enterprise_script_service/mruby/include/mruby/boxing_nan.h +11 -2
  46. data/ext/enterprise_script_service/mruby/include/mruby/boxing_word.h +0 -9
  47. data/ext/enterprise_script_service/mruby/include/mruby/common.h +10 -0
  48. data/ext/enterprise_script_service/mruby/include/mruby/compile.h +11 -3
  49. data/ext/enterprise_script_service/mruby/include/mruby/dump.h +1 -17
  50. data/ext/enterprise_script_service/mruby/include/mruby/irep.h +10 -0
  51. data/ext/enterprise_script_service/mruby/include/mruby/istruct.h +4 -1
  52. data/ext/enterprise_script_service/mruby/include/mruby/khash.h +23 -5
  53. data/ext/enterprise_script_service/mruby/include/mruby/numeric.h +1 -0
  54. data/ext/enterprise_script_service/mruby/include/mruby/ops.h +3 -2
  55. data/ext/enterprise_script_service/mruby/include/mruby/string.h +2 -1
  56. data/ext/enterprise_script_service/mruby/include/mruby/value.h +7 -12
  57. data/ext/enterprise_script_service/mruby/include/mruby/version.h +4 -4
  58. data/ext/enterprise_script_service/mruby/lib/mruby/build.rb +2 -30
  59. data/ext/enterprise_script_service/mruby/lib/mruby/build/command.rb +21 -46
  60. data/ext/enterprise_script_service/mruby/lib/mruby/gem.rb +9 -0
  61. data/ext/enterprise_script_service/mruby/lib/mruby/source.rb +3 -1
  62. data/ext/enterprise_script_service/mruby/mrbgems/default.gembox +7 -0
  63. data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/mrblib/array.rb +0 -31
  64. data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/test/array.rb +0 -13
  65. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-config/mrbgem.rake +5 -2
  66. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c +0 -1
  67. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdbconf.h +5 -1
  68. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c +5 -1
  69. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c +7 -11
  70. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mruby/mrbgem.rake +0 -1
  71. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c +6 -2
  72. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-strip/tools/mruby-strip/mruby-strip.c +6 -2
  73. data/ext/enterprise_script_service/mruby/mrbgems/mruby-class-ext/src/class.c +6 -1
  74. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/codegen.c +76 -48
  75. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/parse.y +107 -32
  76. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/y.tab.c +13153 -0
  77. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/mrbgem.rake +13 -15
  78. data/ext/enterprise_script_service/mruby/mrbgems/mruby-error/src/exception.c +3 -3
  79. data/ext/enterprise_script_service/mruby/mrbgems/mruby-eval/src/eval.c +2 -213
  80. data/ext/enterprise_script_service/mruby/mrbgems/mruby-eval/test/eval.rb +21 -0
  81. data/ext/enterprise_script_service/mruby/mrbgems/mruby-hash-ext/src/hash-ext.c +1 -3
  82. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/include/mruby/ext/io.h +39 -7
  83. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrbgem.rake +2 -8
  84. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrblib/file_constants.rb +0 -16
  85. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrblib/io.rb +7 -12
  86. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/file.c +76 -30
  87. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/file_test.c +9 -10
  88. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/io.c +323 -120
  89. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/file.rb +18 -12
  90. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/io.rb +32 -0
  91. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/mruby_io_test.c +57 -49
  92. data/ext/enterprise_script_service/mruby/mrbgems/mruby-metaprog/src/metaprog.c +15 -17
  93. data/ext/enterprise_script_service/mruby/mrbgems/mruby-metaprog/test/metaprog.rb +9 -0
  94. data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/src/method.c +1 -1
  95. data/ext/enterprise_script_service/mruby/mrbgems/mruby-object-ext/src/object.c +3 -12
  96. data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/src/pack.c +113 -10
  97. data/ext/enterprise_script_service/mruby/mrbgems/mruby-print/src/print.c +5 -1
  98. data/ext/enterprise_script_service/mruby/mrbgems/mruby-proc-ext/src/proc.c +2 -2
  99. data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/src/rational.c +9 -9
  100. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sleep/src/mrb_sleep.c +1 -1
  101. data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/mrbgem.rake +1 -1
  102. data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/test/sockettest.c +3 -2
  103. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sprintf/src/sprintf.c +61 -24
  104. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sprintf/test/sprintf.rb +5 -23
  105. data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/src/string.c +3 -3
  106. data/ext/enterprise_script_service/mruby/mrbgems/mruby-symbol-ext/src/symbol.c +1 -1
  107. data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/mrbgem.rake +1 -0
  108. data/ext/enterprise_script_service/mruby/mrbgems/mruby-time/src/time.c +6 -5
  109. data/ext/enterprise_script_service/mruby/mrblib/hash.rb +3 -3
  110. data/ext/enterprise_script_service/mruby/src/array.c +11 -0
  111. data/ext/enterprise_script_service/mruby/src/backtrace.c +2 -2
  112. data/ext/enterprise_script_service/mruby/src/class.c +26 -11
  113. data/ext/enterprise_script_service/mruby/src/codedump.c +4 -0
  114. data/ext/enterprise_script_service/mruby/src/debug.c +8 -5
  115. data/ext/enterprise_script_service/mruby/src/dump.c +3 -65
  116. data/ext/enterprise_script_service/mruby/src/error.c +57 -5
  117. data/ext/enterprise_script_service/mruby/src/etc.c +13 -4
  118. data/ext/enterprise_script_service/mruby/src/fmt_fp.c +98 -21
  119. data/ext/enterprise_script_service/mruby/src/gc.c +10 -275
  120. data/ext/enterprise_script_service/mruby/src/hash.c +5 -6
  121. data/ext/enterprise_script_service/mruby/src/kernel.c +2 -2
  122. data/ext/enterprise_script_service/mruby/src/load.c +56 -30
  123. data/ext/enterprise_script_service/mruby/src/numeric.c +22 -10
  124. data/ext/enterprise_script_service/mruby/src/object.c +12 -4
  125. data/ext/enterprise_script_service/mruby/src/print.c +27 -3
  126. data/ext/enterprise_script_service/mruby/src/proc.c +21 -1
  127. data/ext/enterprise_script_service/mruby/src/state.c +34 -11
  128. data/ext/enterprise_script_service/mruby/src/string.c +69 -35
  129. data/ext/enterprise_script_service/mruby/src/symbol.c +12 -10
  130. data/ext/enterprise_script_service/mruby/src/vm.c +21 -30
  131. data/ext/enterprise_script_service/mruby/tasks/gitlab.rake +19 -22
  132. data/ext/enterprise_script_service/mruby/tasks/mrbgems.rake +1 -1
  133. data/ext/enterprise_script_service/mruby/tasks/toolchains/android.rake +46 -1
  134. data/ext/enterprise_script_service/mruby/tasks/toolchains/gcc.rake +3 -3
  135. data/ext/enterprise_script_service/mruby/tasks/toolchains/openwrt.rake +6 -6
  136. data/ext/enterprise_script_service/mruby/tasks/toolchains/visualcpp.rake +8 -8
  137. data/ext/enterprise_script_service/mruby/test/assert.rb +5 -4
  138. data/ext/enterprise_script_service/mruby/test/t/ensure.rb +8 -26
  139. data/ext/enterprise_script_service/mruby/test/t/exception.rb +2 -2
  140. data/ext/enterprise_script_service/mruby/test/t/kernel.rb +8 -24
  141. data/ext/enterprise_script_service/mruby/travis_config.rb +0 -14
  142. data/ext/enterprise_script_service/msgpack/.github/depends/boost.sh +56 -0
  143. data/ext/enterprise_script_service/msgpack/.github/workflows/coverage.yml +62 -0
  144. data/ext/enterprise_script_service/msgpack/.github/workflows/gha.yml +304 -0
  145. data/ext/enterprise_script_service/msgpack/CHANGELOG.md +11 -0
  146. data/ext/enterprise_script_service/msgpack/CMakeLists.txt +82 -39
  147. data/ext/enterprise_script_service/msgpack/Files.cmake +22 -12
  148. data/ext/enterprise_script_service/msgpack/QUICKSTART-C.md +26 -29
  149. data/ext/enterprise_script_service/msgpack/README.md +3 -2
  150. data/ext/enterprise_script_service/msgpack/appveyor.yml +6 -2
  151. data/ext/enterprise_script_service/msgpack/ci/build_cmake.sh +3 -1
  152. data/ext/enterprise_script_service/msgpack/cmake/CodeCoverage.cmake +55 -0
  153. data/ext/enterprise_script_service/msgpack/codecov.yml +36 -0
  154. data/ext/enterprise_script_service/msgpack/example/CMakeLists.txt +9 -5
  155. data/ext/enterprise_script_service/msgpack/example/boost/CMakeLists.txt +1 -1
  156. data/ext/enterprise_script_service/msgpack/example/c/CMakeLists.txt +17 -6
  157. data/ext/enterprise_script_service/msgpack/example/c/boundary.c +296 -0
  158. data/ext/enterprise_script_service/msgpack/example/c/jsonconv.c +419 -0
  159. data/ext/enterprise_script_service/msgpack/example/c/simple_c.c +1 -1
  160. data/ext/enterprise_script_service/msgpack/example/cpp03/CMakeLists.txt +3 -3
  161. data/ext/enterprise_script_service/msgpack/example/cpp11/CMakeLists.txt +2 -2
  162. data/ext/enterprise_script_service/msgpack/example/x3/CMakeLists.txt +2 -2
  163. data/ext/enterprise_script_service/msgpack/include/msgpack/pack.h +24 -1
  164. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/array_ref.hpp +5 -4
  165. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/boost/optional.hpp +4 -4
  166. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/cpp17/vector_byte.hpp +8 -8
  167. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/map.hpp +4 -4
  168. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/vector.hpp +4 -4
  169. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/vector_char.hpp +8 -8
  170. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/vector_unsigned_char.hpp +8 -8
  171. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/wstring.hpp +4 -4
  172. data/ext/enterprise_script_service/msgpack/include/msgpack/v3/unpack.hpp +6 -6
  173. data/ext/enterprise_script_service/msgpack/include/msgpack/version_master.h +2 -2
  174. data/ext/enterprise_script_service/msgpack/include/msgpack/zbuffer.h +4 -4
  175. data/ext/enterprise_script_service/msgpack/make_file_list.sh +38 -11
  176. data/ext/enterprise_script_service/msgpack/src/vrefbuffer.c +6 -0
  177. data/ext/enterprise_script_service/msgpack/test/CMakeLists.txt +86 -64
  178. data/ext/enterprise_script_service/msgpack/test/array_ref.cpp +4 -0
  179. data/ext/enterprise_script_service/msgpack/test/boost_fusion.cpp +4 -0
  180. data/ext/enterprise_script_service/msgpack/test/boost_optional.cpp +4 -0
  181. data/ext/enterprise_script_service/msgpack/test/boost_string_ref.cpp +4 -1
  182. data/ext/enterprise_script_service/msgpack/test/boost_string_view.cpp +4 -0
  183. data/ext/enterprise_script_service/msgpack/test/boost_variant.cpp +4 -0
  184. data/ext/enterprise_script_service/msgpack/test/buffer.cpp +4 -47
  185. data/ext/enterprise_script_service/msgpack/test/buffer_c.cpp +148 -0
  186. data/ext/enterprise_script_service/msgpack/test/carray.cpp +4 -0
  187. data/ext/enterprise_script_service/msgpack/test/cases.cpp +8 -4
  188. data/ext/enterprise_script_service/msgpack/test/convert.cpp +8 -4
  189. data/ext/enterprise_script_service/msgpack/test/fixint.cpp +4 -0
  190. data/ext/enterprise_script_service/msgpack/test/fixint_c.cpp +4 -0
  191. data/ext/enterprise_script_service/msgpack/test/fuzz_unpack_pack_fuzzer_cpp11.cpp +4 -0
  192. data/ext/enterprise_script_service/msgpack/test/iterator_cpp11.cpp +4 -0
  193. data/ext/enterprise_script_service/msgpack/test/json.cpp +4 -0
  194. data/ext/enterprise_script_service/msgpack/test/limit.cpp +8 -4
  195. data/ext/enterprise_script_service/msgpack/test/msgpack_basic.cpp +4 -0
  196. data/ext/enterprise_script_service/msgpack/test/msgpack_c.cpp +159 -0
  197. data/ext/enterprise_script_service/msgpack/test/msgpack_container.cpp +4 -0
  198. data/ext/enterprise_script_service/msgpack/test/msgpack_cpp11.cpp +32 -27
  199. data/ext/enterprise_script_service/msgpack/test/msgpack_cpp17.cpp +4 -0
  200. data/ext/enterprise_script_service/msgpack/test/msgpack_stream.cpp +4 -0
  201. data/ext/enterprise_script_service/msgpack/test/msgpack_tuple.cpp +4 -1
  202. data/ext/enterprise_script_service/msgpack/test/msgpack_vref.cpp +4 -0
  203. data/ext/enterprise_script_service/msgpack/test/msgpack_x3_parse.cpp +4 -0
  204. data/ext/enterprise_script_service/msgpack/test/object.cpp +4 -1
  205. data/ext/enterprise_script_service/msgpack/test/object_with_zone.cpp +12 -8
  206. data/ext/enterprise_script_service/msgpack/test/pack_unpack.cpp +30 -26
  207. data/ext/enterprise_script_service/msgpack/test/pack_unpack_c.cpp +4 -0
  208. data/ext/enterprise_script_service/msgpack/test/raw.cpp +4 -0
  209. data/ext/enterprise_script_service/msgpack/test/reference.cpp +4 -0
  210. data/ext/enterprise_script_service/msgpack/test/reference_cpp11.cpp +4 -0
  211. data/ext/enterprise_script_service/msgpack/test/reference_wrapper_cpp11.cpp +4 -0
  212. data/ext/enterprise_script_service/msgpack/test/shared_ptr_cpp11.cpp +4 -0
  213. data/ext/enterprise_script_service/msgpack/test/size_equal_only.cpp +4 -0
  214. data/ext/enterprise_script_service/msgpack/test/streaming.cpp +8 -4
  215. data/ext/enterprise_script_service/msgpack/test/streaming_c.cpp +4 -0
  216. data/ext/enterprise_script_service/msgpack/test/unique_ptr_cpp11.cpp +4 -0
  217. data/ext/enterprise_script_service/msgpack/test/user_class.cpp +16 -12
  218. data/ext/enterprise_script_service/msgpack/test/version.cpp +4 -0
  219. data/ext/enterprise_script_service/msgpack/test/visitor.cpp +4 -0
  220. data/ext/enterprise_script_service/msgpack/test/zone.cpp +4 -0
  221. data/lib/script_core/version.rb +1 -1
  222. data/script_core.gemspec +1 -1
  223. metadata +23 -9
  224. data/ext/enterprise_script_service/msgpack/.travis.yml +0 -258
@@ -110,18 +110,22 @@
110
110
  end
111
111
 
112
112
  assert('File.realpath') do
113
- if File::ALT_SEPARATOR
114
- readme_path = File._getwd + File::ALT_SEPARATOR + "README.md"
115
- assert_equal readme_path, File.realpath("README.md")
116
- else
117
- dir = MRubyIOTestUtil.mkdtemp("mruby-io-test.XXXXXX")
118
- begin
119
- dir1 = File.realpath($mrbtest_io_rfname)
120
- dir2 = File.realpath("./#{dir}//./../#{$mrbtest_io_symlinkname}")
121
- assert_equal dir1, dir2
122
- ensure
123
- MRubyIOTestUtil.rmdir dir
113
+ dir = MRubyIOTestUtil.mkdtemp("mruby-io-test.XXXXXX")
114
+ begin
115
+ sep = File::ALT_SEPARATOR || File::SEPARATOR
116
+ relative_path = "#{File.basename(dir)}#{sep}realpath_test"
117
+ path = "#{File._getwd}#{sep}#{relative_path}"
118
+ File.open(path, "w"){}
119
+ assert_equal path, File.realpath(relative_path)
120
+
121
+ unless MRubyIOTestUtil.win?
122
+ path1 = File.realpath($mrbtest_io_rfname)
123
+ path2 = File.realpath($mrbtest_io_symlinkname)
124
+ assert_equal path1, path2
124
125
  end
126
+ ensure
127
+ File.delete path rescue nil
128
+ MRubyIOTestUtil.rmdir dir
125
129
  end
126
130
 
127
131
  assert_raise(ArgumentError) { File.realpath("TO\0DO") }
@@ -129,7 +133,9 @@
129
133
 
130
134
  assert("File.readlink") do
131
135
  begin
132
- assert_equal $mrbtest_io_rfname, File.readlink($mrbtest_io_symlinkname)
136
+ exp = File.basename($mrbtest_io_rfname)
137
+ act = File.readlink($mrbtest_io_symlinkname)
138
+ assert_equal exp, act
133
139
  rescue NotImplementedError => e
134
140
  skip e.message
135
141
  end
@@ -24,6 +24,10 @@ def assert_io_open(meth)
24
24
  end
25
25
  end
26
26
  io2.close unless meth == :open
27
+
28
+ assert_raise(RuntimeError) { IO.__send__(meth, 1023) } # For Windows
29
+ assert_raise(RuntimeError) { IO.__send__(meth, 1 << 26) }
30
+ assert_raise(RuntimeError) { IO.__send__(meth, 1 << 32) } if (1 << 32).kind_of?(Integer)
27
31
  end
28
32
  end
29
33
 
@@ -564,6 +568,34 @@ def io._buf
564
568
  end
565
569
  end
566
570
 
571
+ assert('IO#pread') do
572
+ skip "IO#pread is not implemented on this configuration" unless MRubyIOTestUtil::MRB_WITH_IO_PREAD_PWRITE
573
+
574
+ IO.open(IO.sysopen($mrbtest_io_rfname, 'r'), 'r') do |io|
575
+ assert_equal $mrbtest_io_msg.byteslice(5, 8), io.pread(8, 5)
576
+ assert_equal 0, io.pos
577
+ assert_equal $mrbtest_io_msg.byteslice(1, 5), io.pread(5, 1)
578
+ assert_equal 0, io.pos
579
+ assert_raise(RuntimeError) { io.pread(20, -9) }
580
+ end
581
+ end
582
+
583
+ assert('IO#pwrite') do
584
+ skip "IO#pwrite is not implemented on this configuration" unless MRubyIOTestUtil::MRB_WITH_IO_PREAD_PWRITE
585
+
586
+ IO.open(IO.sysopen($mrbtest_io_wfname, 'w+'), 'w+') do |io|
587
+ assert_equal 6, io.pwrite("Warld!", 7)
588
+ assert_equal 0, io.pos
589
+ assert_equal 7, io.pwrite("Hello, ", 0)
590
+ assert_equal 0, io.pos
591
+ assert_equal "Hello, Warld!", io.read
592
+ assert_equal 6, io.pwrite("world!", 7)
593
+ assert_equal 13, io.pos
594
+ io.pos = 0
595
+ assert_equal "Hello, world!", io.read
596
+ end
597
+ end
598
+
567
599
  assert('IO.pipe') do
568
600
  begin
569
601
  called = false
@@ -1,5 +1,7 @@
1
+ #include <mruby/common.h>
1
2
  #include <sys/types.h>
2
3
  #include <errno.h>
4
+ #include <string.h>
3
5
 
4
6
  #if defined(_WIN32) || defined(_WIN64)
5
7
 
@@ -7,7 +9,6 @@
7
9
  #include <io.h>
8
10
  #include <fcntl.h>
9
11
  #include <direct.h>
10
- #include <string.h>
11
12
  #include <stdlib.h>
12
13
  #include <malloc.h>
13
14
 
@@ -18,12 +19,6 @@ typedef int mode_t;
18
19
  #define open _open
19
20
  #define close _close
20
21
 
21
- #if defined(__MINGW64_VERSION_MAJOR)
22
- # define MRB_MINGW64_VERSION (__MINGW64_VERSION_MAJOR * 1000 + __MINGW64_VERSION_MINOR)
23
- #elif defined(__MINGW32_MAJOR_VERSION)
24
- # define MRB_MINGW32_VERSION (__MINGW32_MAJOR_VERSION * 1000 + __MINGW32_MINOR_VERSION)
25
- #endif
26
-
27
22
  #if defined(_MSC_VER) || \
28
23
  (defined(MRB_MINGW32_VERSION) && MRB_MINGW32_VERSION < 3021) || \
29
24
  (defined(MRB_MINGW64_VERSION) && MRB_MINGW64_VERSION < 4000)
@@ -58,10 +53,11 @@ mkdtemp(char *temp)
58
53
  #include <sys/socket.h>
59
54
  #include <unistd.h>
60
55
  #include <sys/un.h>
56
+ #include <fcntl.h>
57
+ #include <libgen.h>
61
58
  #endif
62
59
 
63
60
  #include <sys/stat.h>
64
- #include <stdio.h>
65
61
  #include <stdlib.h>
66
62
 
67
63
  #include "mruby.h"
@@ -69,51 +65,55 @@ mkdtemp(char *temp)
69
65
  #include "mruby/error.h"
70
66
  #include "mruby/string.h"
71
67
  #include "mruby/variable.h"
68
+ #include <mruby/ext/io.h>
72
69
 
73
70
  static mrb_value
74
71
  mrb_io_test_io_setup(mrb_state *mrb, mrb_value self)
75
72
  {
76
- char rfname[] = "tmp.mruby-io-test-r.XXXXXXXX";
77
- char wfname[] = "tmp.mruby-io-test-w.XXXXXXXX";
78
- char symlinkname[] = "tmp.mruby-io-test-l.XXXXXXXX";
79
- char socketname[] = "tmp.mruby-io-test-s.XXXXXXXX";
73
+ #define GVNAME(n) "$mrbtest_io_" #n "name"
74
+ enum {IDX_READ, IDX_WRITE, IDX_LINK, IDX_SOCKET, IDX_COUNT};
75
+ const char *gvnames[] = {GVNAME(rf), GVNAME(wf), GVNAME(symlink), GVNAME(socket)};
76
+ char *fnames[IDX_COUNT];
77
+ int fds[IDX_COUNT];
80
78
  char msg[] = "mruby io test\n";
81
79
  mode_t mask;
82
- int fd0, fd1;
83
80
  FILE *fp;
84
-
81
+ int i;
85
82
  #if !defined(_WIN32) && !defined(_WIN64)
86
- int fd2, fd3;
87
83
  struct sockaddr_un sun0;
88
84
  #endif
89
85
 
90
- mask = umask(077);
91
- fd0 = mkstemp(rfname);
92
- fd1 = mkstemp(wfname);
93
- if (fd0 == -1 || fd1 == -1) {
94
- mrb_raise(mrb, E_RUNTIME_ERROR, "can't create temporary file");
95
- return mrb_nil_value();
96
- }
97
- close(fd0);
98
- close(fd1);
86
+ mrb_gv_set(mrb, mrb_intern_cstr(mrb, "$mrbtest_io_msg"), mrb_str_new_cstr(mrb, msg));
99
87
 
88
+ mask = umask(077);
89
+ for (i = 0; i < IDX_COUNT; i++) {
90
+ mrb_value fname = mrb_str_new_capa(mrb, 0);
100
91
  #if !defined(_WIN32) && !defined(_WIN64)
101
- fd2 = mkstemp(symlinkname);
102
- fd3 = mkstemp(socketname);
103
- if (fd2 == -1 || fd3 == -1) {
104
- mrb_raise(mrb, E_RUNTIME_ERROR, "can't create temporary file");
105
- return mrb_nil_value();
106
- }
92
+ /*
93
+ * Workaround for not being able to bind a socket to some file systems
94
+ * (e.g. vboxsf, NFS). [#4981]
95
+ */
96
+ char *tmpdir = getenv("TMPDIR");
97
+ if (tmpdir && strlen(tmpdir) > 0) {
98
+ mrb_str_cat_cstr(mrb, fname, tmpdir);
99
+ if (*(RSTRING_END(fname)-1) != '/') mrb_str_cat_lit(mrb, fname, "/");
100
+ } else {
101
+ mrb_str_cat_lit(mrb, fname, "/tmp/");
102
+ }
107
103
  #endif
104
+ mrb_str_cat_cstr(mrb, fname, gvnames[i]+1);
105
+ mrb_str_cat_cstr(mrb, fname, ".XXXXXXXX");
106
+ fnames[i] = RSTRING_PTR(fname);
107
+ fds[i] = mkstemp(fnames[i]);
108
+ if (fds[i] == -1) {
109
+ mrb_raise(mrb, E_RUNTIME_ERROR, "can't create temporary file");
110
+ }
111
+ close(fds[i]);
112
+ mrb_gv_set(mrb, mrb_intern_cstr(mrb, gvnames[i]), fname);
113
+ }
108
114
  umask(mask);
109
115
 
110
- mrb_gv_set(mrb, mrb_intern_cstr(mrb, "$mrbtest_io_rfname"), mrb_str_new_cstr(mrb, rfname));
111
- mrb_gv_set(mrb, mrb_intern_cstr(mrb, "$mrbtest_io_wfname"), mrb_str_new_cstr(mrb, wfname));
112
- mrb_gv_set(mrb, mrb_intern_cstr(mrb, "$mrbtest_io_symlinkname"), mrb_str_new_cstr(mrb, symlinkname));
113
- mrb_gv_set(mrb, mrb_intern_cstr(mrb, "$mrbtest_io_socketname"), mrb_str_new_cstr(mrb, socketname));
114
- mrb_gv_set(mrb, mrb_intern_cstr(mrb, "$mrbtest_io_msg"), mrb_str_new_cstr(mrb, msg));
115
-
116
- fp = fopen(rfname, "wb");
116
+ fp = fopen(fnames[IDX_READ], "wb");
117
117
  if (fp == NULL) {
118
118
  mrb_raise(mrb, E_RUNTIME_ERROR, "can't open temporary file");
119
119
  return mrb_nil_value();
@@ -121,7 +121,7 @@ mrb_io_test_io_setup(mrb_state *mrb, mrb_value self)
121
121
  fputs(msg, fp);
122
122
  fclose(fp);
123
123
 
124
- fp = fopen(wfname, "wb");
124
+ fp = fopen(fnames[IDX_WRITE], "wb");
125
125
  if (fp == NULL) {
126
126
  mrb_raise(mrb, E_RUNTIME_ERROR, "can't open temporary file");
127
127
  return mrb_nil_value();
@@ -129,29 +129,29 @@ mrb_io_test_io_setup(mrb_state *mrb, mrb_value self)
129
129
  fclose(fp);
130
130
 
131
131
  #if !defined(_WIN32) && !defined(_WIN64)
132
- unlink(symlinkname);
133
- close(fd2);
134
- if (symlink(rfname, symlinkname) == -1) {
132
+ unlink(fnames[IDX_LINK]);
133
+ if (symlink(basename(fnames[IDX_READ]), fnames[IDX_LINK]) == -1) {
135
134
  mrb_raise(mrb, E_RUNTIME_ERROR, "can't make a symbolic link");
136
135
  }
137
136
 
138
- unlink(socketname);
139
- close(fd3);
140
- fd3 = socket(AF_UNIX, SOCK_STREAM, 0);
141
- if (fd3 == -1) {
137
+ unlink(fnames[IDX_SOCKET]);
138
+ fds[IDX_SOCKET] = socket(AF_UNIX, SOCK_STREAM, 0);
139
+ if (fds[IDX_SOCKET] == -1) {
142
140
  mrb_raise(mrb, E_RUNTIME_ERROR, "can't make a socket");
143
141
  }
144
142
  sun0.sun_family = AF_UNIX;
145
- snprintf(sun0.sun_path, sizeof(sun0.sun_path), "%s", socketname);
146
- if (bind(fd3, (struct sockaddr *)&sun0, sizeof(sun0)) == -1) {
143
+ strncpy(sun0.sun_path, fnames[IDX_SOCKET], sizeof(sun0.sun_path)-1);
144
+ sun0.sun_path[sizeof(sun0.sun_path)-1] = 0;
145
+ if (bind(fds[IDX_SOCKET], (struct sockaddr *)&sun0, sizeof(sun0)) == -1) {
147
146
  mrb_raisef(mrb, E_RUNTIME_ERROR, "can't bind AF_UNIX socket to %s: %d",
148
147
  sun0.sun_path,
149
148
  errno);
150
149
  }
151
- close(fd3);
150
+ close(fds[IDX_SOCKET]);
152
151
  #endif
153
152
 
154
153
  return mrb_true_value();
154
+ #undef GVNAME
155
155
  }
156
156
 
157
157
  static mrb_value
@@ -210,7 +210,7 @@ mrb_io_test_rmdir(mrb_state *mrb, mrb_value klass)
210
210
  return mrb_true_value();
211
211
  }
212
212
 
213
- mrb_value
213
+ static mrb_value
214
214
  mrb_io_win_p(mrb_state *mrb, mrb_value klass)
215
215
  {
216
216
  #if defined(_WIN32) || defined(_WIN64)
@@ -224,6 +224,12 @@ mrb_io_win_p(mrb_state *mrb, mrb_value klass)
224
224
  #endif
225
225
  }
226
226
 
227
+ #ifdef MRB_WITH_IO_PREAD_PWRITE
228
+ # define MRB_WITH_IO_PREAD_PWRITE_ENABLED TRUE
229
+ #else
230
+ # define MRB_WITH_IO_PREAD_PWRITE_ENABLED FALSE
231
+ #endif
232
+
227
233
  void
228
234
  mrb_mruby_io_gem_test(mrb_state* mrb)
229
235
  {
@@ -234,4 +240,6 @@ mrb_mruby_io_gem_test(mrb_state* mrb)
234
240
  mrb_define_class_method(mrb, io_test, "mkdtemp", mrb_io_test_mkdtemp, MRB_ARGS_REQ(1));
235
241
  mrb_define_class_method(mrb, io_test, "rmdir", mrb_io_test_rmdir, MRB_ARGS_REQ(1));
236
242
  mrb_define_class_method(mrb, io_test, "win?", mrb_io_win_p, MRB_ARGS_NONE());
243
+
244
+ mrb_define_const(mrb, io_test, "MRB_WITH_IO_PREAD_PWRITE", mrb_bool_value(MRB_WITH_IO_PREAD_PWRITE_ENABLED));
237
245
  }
@@ -139,31 +139,30 @@ mrb_local_variables(mrb_state *mrb, mrb_value self)
139
139
 
140
140
  proc = mrb->c->ci[-1].proc;
141
141
 
142
- if (MRB_PROC_CFUNC_P(proc)) {
142
+ if (proc == NULL || MRB_PROC_CFUNC_P(proc)) {
143
143
  return mrb_ary_new(mrb);
144
144
  }
145
145
  vars = mrb_hash_new(mrb);
146
146
  while (proc) {
147
147
  if (MRB_PROC_CFUNC_P(proc)) break;
148
148
  irep = proc->body.irep;
149
- if (!irep->lv) break;
150
- for (i = 0; i + 1 < irep->nlocals; ++i) {
151
- if (irep->lv[i].name) {
152
- mrb_sym sym = irep->lv[i].name;
153
- const char *name = mrb_sym_name(mrb, sym);
154
- switch (name[0]) {
155
- case '*': case '&':
156
- break;
157
- default:
158
- mrb_hash_set(mrb, vars, mrb_symbol_value(sym), mrb_true_value());
159
- break;
149
+ if (irep->lv) {
150
+ for (i = 0; i + 1 < irep->nlocals; ++i) {
151
+ if (irep->lv[i].name) {
152
+ mrb_sym sym = irep->lv[i].name;
153
+ const char *name = mrb_sym_name(mrb, sym);
154
+ switch (name[0]) {
155
+ case '*': case '&':
156
+ break;
157
+ default:
158
+ mrb_hash_set(mrb, vars, mrb_symbol_value(sym), mrb_true_value());
159
+ break;
160
+ }
160
161
  }
161
162
  }
162
163
  }
163
- if (!MRB_PROC_ENV_P(proc)) break;
164
+ if (MRB_PROC_SCOPE_P(proc)) break;
164
165
  proc = proc->upper;
165
- //if (MRB_PROC_SCOPE_P(proc)) break;
166
- if (!proc->c) break;
167
166
  }
168
167
 
169
168
  return mrb_hash_keys(mrb, vars);
@@ -671,8 +670,7 @@ mrb_mod_s_nesting(mrb_state *mrb, mrb_value mod)
671
670
 
672
671
  ary = mrb_ary_new(mrb);
673
672
  proc = mrb->c->ci[-1].proc; /* callee proc */
674
- mrb_assert(!MRB_PROC_CFUNC_P(proc));
675
- while (proc) {
673
+ while (proc && !MRB_PROC_CFUNC_P(proc)) {
676
674
  if (MRB_PROC_SCOPE_P(proc)) {
677
675
  struct RClass *c2 = MRB_PROC_TARGET_CLASS(proc);
678
676
 
@@ -114,6 +114,15 @@ def foo
114
114
  # Kernel#local_variables: 15.3.1.3.28
115
115
  local_variables.sort
116
116
  }.call(-1, -2)
117
+
118
+ a = Object.new
119
+ def a.hoge(vars, *, **)
120
+ Proc.new {
121
+ x, y = 1, 2
122
+ local_variables.sort
123
+ }
124
+ end
125
+ assert_equal([:vars, :x, :y]) { a.hoge(0).call }
117
126
  end
118
127
 
119
128
  assert('Kernel#define_singleton_method') do
@@ -110,7 +110,7 @@ method_eql(mrb_state *mrb, mrb_value self)
110
110
 
111
111
  static mrb_value
112
112
  mcall(mrb_state *mrb, mrb_value recv, mrb_value proc, mrb_value name, struct RClass *owner,
113
- int argc, mrb_value *argv, mrb_value block)
113
+ mrb_int argc, mrb_value *argv, mrb_value block)
114
114
  {
115
115
  mrb_value ret;
116
116
  mrb_sym orig_mid = mrb->c->ci->mid;
@@ -101,18 +101,9 @@ mrb_obj_instance_exec(mrb_state *mrb, mrb_value self)
101
101
  struct RClass *c;
102
102
 
103
103
  mrb_get_args(mrb, "*&!", &argv, &argc, &blk);
104
-
105
- switch (mrb_type(self)) {
106
- case MRB_TT_SYMBOL:
107
- case MRB_TT_FIXNUM:
108
- #ifndef MRB_WITHOUT_FLOAT
109
- case MRB_TT_FLOAT:
110
- #endif
111
- c = NULL;
112
- break;
113
- default:
114
- c = mrb_class_ptr(mrb_singleton_class(mrb, self));
115
- break;
104
+ c = mrb_singleton_class_ptr(mrb, self);
105
+ if (mrb->c->ci->acc < 0) {
106
+ return mrb_yield_with_class(mrb, blk, argc, argv, self, c);
116
107
  }
117
108
  mrb->c->ci->target_class = c;
118
109
  return mrb_yield_cont(mrb, blk, self, argc, argv);
@@ -2,7 +2,7 @@
2
2
  ** pack.c - Array#pack, String#unpack
3
3
  */
4
4
 
5
- #include "mruby.h"
5
+ #include <mruby.h>
6
6
  #include "mruby/error.h"
7
7
  #include "mruby/array.h"
8
8
  #include "mruby/class.h"
@@ -13,7 +13,6 @@
13
13
  #include <ctype.h>
14
14
  #include <errno.h>
15
15
  #include <limits.h>
16
- #include <stdio.h>
17
16
  #include <string.h>
18
17
 
19
18
  struct tmpl {
@@ -213,6 +212,59 @@ pack_l(mrb_state *mrb, mrb_value o, mrb_value str, mrb_int sidx, unsigned int fl
213
212
  return 4;
214
213
  }
215
214
 
215
+ #ifndef MRB_INT64
216
+ static void
217
+ u32tostr(char *buf, size_t len, uint32_t n)
218
+ {
219
+ #ifdef MRB_DISABLE_STDIO
220
+ char *bufend = buf + len;
221
+ char *p = bufend - 1;
222
+
223
+ if (len < 1) {
224
+ return;
225
+ }
226
+
227
+ *p -- = '\0';
228
+ len --;
229
+
230
+ if (n > 0) {
231
+ for (; len > 0 && n > 0; len --, n /= 10) {
232
+ *p -- = '0' + (n % 10);
233
+ }
234
+ p ++;
235
+ }
236
+ else if (len > 0) {
237
+ *p = '0';
238
+ len --;
239
+ }
240
+
241
+ memmove(buf, p, bufend - p);
242
+ #else
243
+ snprintf(buf, len, "%" PRIu32, n);
244
+ #endif /* MRB_DISABLE_STDIO */
245
+ }
246
+
247
+ static void
248
+ i32tostr(char *buf, size_t len, int32_t n)
249
+ {
250
+ #ifdef MRB_DISABLE_STDIO
251
+ if (len < 1) {
252
+ return;
253
+ }
254
+
255
+ if (n < 0) {
256
+ *buf ++ = '-';
257
+ len --;
258
+ n = -n;
259
+ }
260
+
261
+ u32tostr(buf, len, (uint32_t)n);
262
+ #else
263
+ snprintf(buf, len, "%" PRId32, n);
264
+ #endif /* MRB_DISABLE_STDIO */
265
+ }
266
+ #endif /* MRB_INT64 */
267
+
216
268
  static int
217
269
  unpack_l(mrb_state *mrb, const unsigned char *src, int srclen, mrb_value ary, unsigned int flags)
218
270
  {
@@ -237,16 +289,16 @@ unpack_l(mrb_state *mrb, const unsigned char *src, int srclen, mrb_value ary, un
237
289
  int32_t sl = ul;
238
290
  #ifndef MRB_INT64
239
291
  if (!FIXABLE(sl)) {
240
- snprintf(msg, sizeof(msg), "cannot unpack to Fixnum: %" PRId32, sl);
241
- mrb_raise(mrb, E_RANGE_ERROR, msg);
292
+ i32tostr(msg, sizeof(msg), sl);
293
+ mrb_raisef(mrb, E_RANGE_ERROR, "cannot unpack to Fixnum: %s", msg);
242
294
  }
243
295
  #endif
244
296
  n = sl;
245
297
  } else {
246
298
  #ifndef MRB_INT64
247
299
  if (!POSFIXABLE(ul)) {
248
- snprintf(msg, sizeof(msg), "cannot unpack to Fixnum: %" PRIu32, ul);
249
- mrb_raise(mrb, E_RANGE_ERROR, msg);
300
+ u32tostr(msg, sizeof(msg), ul);
301
+ mrb_raisef(mrb, E_RANGE_ERROR, "cannot unpack to Fixnum: %s", msg);
250
302
  }
251
303
  #endif
252
304
  n = ul;
@@ -284,6 +336,57 @@ pack_q(mrb_state *mrb, mrb_value o, mrb_value str, mrb_int sidx, unsigned int fl
284
336
  return 8;
285
337
  }
286
338
 
339
+ static void
340
+ u64tostr(char *buf, size_t len, uint64_t n)
341
+ {
342
+ #ifdef MRB_DISABLE_STDIO
343
+ char *bufend = buf + len;
344
+ char *p = bufend - 1;
345
+
346
+ if (len < 1) {
347
+ return;
348
+ }
349
+
350
+ *p -- = '\0';
351
+ len --;
352
+
353
+ if (n > 0) {
354
+ for (; len > 0 && n > 0; len --, n /= 10) {
355
+ *p -- = '0' + (n % 10);
356
+ }
357
+ p ++;
358
+ }
359
+ else if (len > 0) {
360
+ *p = '0';
361
+ len --;
362
+ }
363
+
364
+ memmove(buf, p, bufend - p);
365
+ #else
366
+ snprintf(buf, len, "%" PRIu64, n);
367
+ #endif /* MRB_DISABLE_STDIO */
368
+ }
369
+
370
+ static void
371
+ i64tostr(char *buf, size_t len, int64_t n)
372
+ {
373
+ #ifdef MRB_DISABLE_STDIO
374
+ if (len < 1) {
375
+ return;
376
+ }
377
+
378
+ if (n < 0) {
379
+ *buf ++ = '-';
380
+ len --;
381
+ n = -n;
382
+ }
383
+
384
+ u64tostr(buf, len, (uint64_t)n);
385
+ #else
386
+ snprintf(buf, len, "%" PRId64, n);
387
+ #endif /* MRB_DISABLE_STDIO */
388
+ }
389
+
287
390
  static int
288
391
  unpack_q(mrb_state *mrb, const unsigned char *src, int srclen, mrb_value ary, unsigned int flags)
289
392
  {
@@ -307,14 +410,14 @@ unpack_q(mrb_state *mrb, const unsigned char *src, int srclen, mrb_value ary, un
307
410
  if (flags & PACK_FLAG_SIGNED) {
308
411
  int64_t sll = ull;
309
412
  if (!FIXABLE(sll)) {
310
- snprintf(msg, sizeof(msg), "cannot unpack to Fixnum: %" PRId64, sll);
311
- mrb_raise(mrb, E_RANGE_ERROR, msg);
413
+ i64tostr(msg, sizeof(msg), sll);
414
+ mrb_raisef(mrb, E_RANGE_ERROR, "cannot unpack to Fixnum: %s", msg);
312
415
  }
313
416
  n = sll;
314
417
  } else {
315
418
  if (!POSFIXABLE(ull)) {
316
- snprintf(msg, sizeof(msg), "cannot unpack to Fixnum: %" PRIu64, ull);
317
- mrb_raise(mrb, E_RANGE_ERROR, msg);
419
+ u64tostr(msg, sizeof(msg), ull);
420
+ mrb_raisef(mrb, E_RANGE_ERROR, "cannot unpack to Fixnum: %s", msg);
318
421
  }
319
422
  n = ull;
320
423
  }