script_core 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (381) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.rubocop.yml +8 -6
  4. data/.ruby-version +1 -1
  5. data/Gemfile +2 -1
  6. data/bin/sandbox +1 -1
  7. data/ext/enterprise_script_service/Rakefile +1 -1
  8. data/ext/enterprise_script_service/flags.rb +5 -0
  9. data/ext/enterprise_script_service/libseccomp/CHANGELOG +15 -0
  10. data/ext/enterprise_script_service/libseccomp/CREDITS +3 -0
  11. data/ext/enterprise_script_service/libseccomp/Makefile.am +1 -1
  12. data/ext/enterprise_script_service/libseccomp/README.md +1 -1
  13. data/ext/enterprise_script_service/libseccomp/SECURITY.md +45 -0
  14. data/ext/enterprise_script_service/libseccomp/configure.ac +3 -3
  15. data/ext/enterprise_script_service/libseccomp/doc/admin/MAINTAINER_PROCESS.md +95 -0
  16. data/ext/enterprise_script_service/libseccomp/{RELEASE_PROCESS.md → doc/admin/RELEASE_PROCESS.md} +9 -1
  17. data/ext/enterprise_script_service/libseccomp/include/Makefile.am +1 -1
  18. data/ext/enterprise_script_service/libseccomp/include/seccomp-syscalls.h +2292 -0
  19. data/ext/enterprise_script_service/libseccomp/include/seccomp.h.in +3 -1065
  20. data/ext/enterprise_script_service/libseccomp/src/arch-aarch64-syscalls.c +35 -3
  21. data/ext/enterprise_script_service/libseccomp/src/arch-arm-syscalls.c +35 -3
  22. data/ext/enterprise_script_service/libseccomp/src/arch-mips-syscalls.c +43 -11
  23. data/ext/enterprise_script_service/libseccomp/src/arch-mips64-syscalls.c +33 -1
  24. data/ext/enterprise_script_service/libseccomp/src/arch-mips64n32-syscalls.c +33 -1
  25. data/ext/enterprise_script_service/libseccomp/src/arch-parisc-syscalls.c +34 -2
  26. data/ext/enterprise_script_service/libseccomp/src/arch-ppc-syscalls.c +43 -11
  27. data/ext/enterprise_script_service/libseccomp/src/arch-ppc64-syscalls.c +44 -12
  28. data/ext/enterprise_script_service/libseccomp/src/arch-s390-syscalls.c +46 -14
  29. data/ext/enterprise_script_service/libseccomp/src/arch-s390.c +142 -18
  30. data/ext/enterprise_script_service/libseccomp/src/arch-s390x-syscalls.c +47 -15
  31. data/ext/enterprise_script_service/libseccomp/src/arch-s390x.c +143 -17
  32. data/ext/enterprise_script_service/libseccomp/src/arch-x32-syscalls.c +33 -1
  33. data/ext/enterprise_script_service/libseccomp/src/arch-x86-syscalls.c +94 -12
  34. data/ext/enterprise_script_service/libseccomp/src/arch-x86.c +142 -19
  35. data/ext/enterprise_script_service/libseccomp/src/arch-x86_64-syscalls.c +33 -1
  36. data/ext/enterprise_script_service/libseccomp/src/db.c +1 -0
  37. data/ext/enterprise_script_service/libseccomp/src/gen_bpf.c +10 -3
  38. data/ext/enterprise_script_service/libseccomp/src/python/Makefile.am +4 -4
  39. data/ext/enterprise_script_service/libseccomp/src/python/seccomp.pyx +2 -0
  40. data/ext/enterprise_script_service/libseccomp/tests/.gitignore +1 -0
  41. data/ext/enterprise_script_service/libseccomp/tests/50-sim-hash_collision.c +98 -0
  42. data/ext/enterprise_script_service/libseccomp/tests/50-sim-hash_collision.py +61 -0
  43. data/ext/enterprise_script_service/libseccomp/tests/50-sim-hash_collision.tests +18 -0
  44. data/ext/enterprise_script_service/libseccomp/tests/Makefile.am +6 -3
  45. data/ext/enterprise_script_service/libseccomp/tools/Makefile.am +0 -2
  46. data/ext/enterprise_script_service/libseccomp/tools/check-syntax +1 -0
  47. data/ext/enterprise_script_service/libseccomp/tools/scmp_bpf_sim.c +2 -0
  48. data/ext/enterprise_script_service/mruby-mpdecimal/src/ext.c +1 -1
  49. data/ext/enterprise_script_service/mruby/.gitignore +2 -2
  50. data/ext/enterprise_script_service/mruby/CONTRIBUTING.md +10 -3
  51. data/ext/enterprise_script_service/mruby/Doxyfile +2408 -0
  52. data/ext/enterprise_script_service/mruby/README.md +21 -8
  53. data/ext/enterprise_script_service/mruby/Rakefile +4 -13
  54. data/ext/enterprise_script_service/mruby/appveyor_config.rb +1 -1
  55. data/ext/enterprise_script_service/mruby/build_config.rb +3 -3
  56. data/ext/enterprise_script_service/mruby/doc/guides/compile.md +42 -42
  57. data/ext/enterprise_script_service/mruby/doc/guides/debugger.md +1 -1
  58. data/ext/enterprise_script_service/mruby/doc/guides/mrbconf.md +45 -6
  59. data/ext/enterprise_script_service/mruby/doc/guides/mrbgems.md +5 -0
  60. data/ext/enterprise_script_service/mruby/doc/limitations.md +88 -38
  61. data/ext/enterprise_script_service/mruby/doc/mruby_logo_red_icon.png +0 -0
  62. data/ext/enterprise_script_service/mruby/doc/opcode.md +94 -94
  63. data/ext/enterprise_script_service/mruby/include/mrbconf.h +74 -11
  64. data/ext/enterprise_script_service/mruby/include/mruby.h +242 -146
  65. data/ext/enterprise_script_service/mruby/include/mruby/array.h +7 -7
  66. data/ext/enterprise_script_service/mruby/include/mruby/boxing_nan.h +2 -9
  67. data/ext/enterprise_script_service/mruby/include/mruby/boxing_no.h +11 -10
  68. data/ext/enterprise_script_service/mruby/include/mruby/boxing_word.h +104 -69
  69. data/ext/enterprise_script_service/mruby/include/mruby/class.h +7 -5
  70. data/ext/enterprise_script_service/mruby/include/mruby/common.h +9 -7
  71. data/ext/enterprise_script_service/mruby/include/mruby/compile.h +6 -6
  72. data/ext/enterprise_script_service/mruby/include/mruby/data.h +5 -5
  73. data/ext/enterprise_script_service/mruby/include/mruby/debug.h +2 -2
  74. data/ext/enterprise_script_service/mruby/include/mruby/dump.h +3 -7
  75. data/ext/enterprise_script_service/mruby/include/mruby/error.h +34 -6
  76. data/ext/enterprise_script_service/mruby/include/mruby/gc.h +2 -2
  77. data/ext/enterprise_script_service/mruby/include/mruby/hash.h +4 -11
  78. data/ext/enterprise_script_service/mruby/include/mruby/irep.h +16 -4
  79. data/ext/enterprise_script_service/mruby/include/mruby/istruct.h +4 -4
  80. data/ext/enterprise_script_service/mruby/include/mruby/khash.h +2 -2
  81. data/ext/enterprise_script_service/mruby/include/mruby/numeric.h +41 -7
  82. data/ext/enterprise_script_service/mruby/include/mruby/object.h +8 -9
  83. data/ext/enterprise_script_service/mruby/include/mruby/opcode.h +2 -2
  84. data/ext/enterprise_script_service/mruby/include/mruby/ops.h +6 -6
  85. data/ext/enterprise_script_service/mruby/include/mruby/proc.h +19 -13
  86. data/ext/enterprise_script_service/mruby/include/mruby/range.h +10 -4
  87. data/ext/enterprise_script_service/mruby/include/mruby/re.h +2 -2
  88. data/ext/enterprise_script_service/mruby/include/mruby/string.h +130 -107
  89. data/ext/enterprise_script_service/mruby/include/mruby/throw.h +2 -2
  90. data/ext/enterprise_script_service/mruby/include/mruby/value.h +137 -49
  91. data/ext/enterprise_script_service/mruby/include/mruby/variable.h +3 -5
  92. data/ext/enterprise_script_service/mruby/include/mruby/version.h +24 -10
  93. data/ext/enterprise_script_service/mruby/lib/mruby-core-ext.rb +2 -39
  94. data/ext/enterprise_script_service/mruby/lib/mruby/build.rb +32 -15
  95. data/ext/enterprise_script_service/mruby/lib/mruby/build/command.rb +63 -17
  96. data/ext/enterprise_script_service/mruby/lib/mruby/build/load_gems.rb +24 -10
  97. data/ext/enterprise_script_service/mruby/lib/mruby/gem.rb +11 -7
  98. data/ext/enterprise_script_service/mruby/lib/mruby/lockfile.rb +81 -0
  99. data/ext/enterprise_script_service/mruby/minirake +27 -11
  100. data/ext/enterprise_script_service/mruby/mrbgems/default.gembox +3 -0
  101. data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/mrbgem.rake +0 -1
  102. data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/mrblib/array.rb +47 -9
  103. data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/src/array.c +3 -3
  104. data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/test/array.rb +50 -29
  105. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.c +3 -3
  106. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/apiprint.c +2 -2
  107. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/cmdprint.c +3 -3
  108. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c +2 -2
  109. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.h +1 -1
  110. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdbconf.h +4 -0
  111. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c +28 -1
  112. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c +1 -2
  113. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mruby/bintest/mruby.rb +75 -8
  114. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c +134 -90
  115. data/ext/enterprise_script_service/mruby/mrbgems/mruby-class-ext/src/class.c +7 -8
  116. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/codegen.c +69 -46
  117. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/keywords +0 -3
  118. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/lex.def +51 -59
  119. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/parse.y +430 -241
  120. data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/mrbgem.rake +10 -0
  121. data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/mrblib/complex.rb +122 -0
  122. data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/src/complex.c +249 -0
  123. data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/test/complex.rb +153 -0
  124. data/ext/enterprise_script_service/mruby/mrbgems/mruby-enum-chain/mrblib/chain.rb +19 -17
  125. data/ext/enterprise_script_service/mruby/mrbgems/mruby-enum-chain/test/enum_chain.rb +41 -9
  126. data/ext/enterprise_script_service/mruby/mrbgems/mruby-enum-ext/mrblib/enum.rb +30 -4
  127. data/ext/enterprise_script_service/mruby/mrbgems/mruby-enum-ext/test/enum.rb +8 -3
  128. data/ext/enterprise_script_service/mruby/mrbgems/mruby-enumerator/mrbgem.rake +0 -1
  129. data/ext/enterprise_script_service/mruby/mrbgems/mruby-enumerator/mrblib/enumerator.rb +46 -14
  130. data/ext/enterprise_script_service/mruby/mrbgems/mruby-enumerator/test/enumerator.rb +51 -2
  131. data/ext/enterprise_script_service/mruby/mrbgems/mruby-error/src/exception.c +10 -0
  132. data/ext/enterprise_script_service/mruby/mrbgems/mruby-eval/src/eval.c +47 -44
  133. data/ext/enterprise_script_service/mruby/mrbgems/mruby-eval/test/eval.rb +2 -2
  134. data/ext/enterprise_script_service/mruby/mrbgems/mruby-exit/src/mruby-exit.c +9 -4
  135. data/ext/enterprise_script_service/mruby/mrbgems/mruby-fiber/src/fiber.c +16 -12
  136. data/ext/enterprise_script_service/mruby/mrbgems/mruby-fiber/test/fiber.rb +1 -1
  137. data/ext/enterprise_script_service/mruby/mrbgems/mruby-hash-ext/mrbgem.rake +0 -2
  138. data/ext/enterprise_script_service/mruby/mrbgems/mruby-hash-ext/mrblib/hash.rb +3 -0
  139. data/ext/enterprise_script_service/mruby/mrbgems/mruby-hash-ext/test/hash.rb +3 -7
  140. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/README.md +1 -3
  141. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrbgem.rake +1 -1
  142. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrblib/file.rb +0 -5
  143. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrblib/io.rb +24 -38
  144. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrblib/kernel.rb +16 -0
  145. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/file.c +19 -18
  146. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/file_test.c +5 -16
  147. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/io.c +54 -42
  148. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/file.rb +24 -20
  149. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/file_test.rb +4 -9
  150. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/io.rb +41 -35
  151. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/mruby_io_test.c +9 -36
  152. data/ext/enterprise_script_service/mruby/mrbgems/mruby-kernel-ext/mrbgem.rake +1 -1
  153. data/ext/enterprise_script_service/mruby/mrbgems/mruby-kernel-ext/src/kernel.c +9 -27
  154. data/ext/enterprise_script_service/mruby/mrbgems/mruby-kernel-ext/test/kernel.rb +2 -0
  155. data/ext/enterprise_script_service/mruby/mrbgems/mruby-math/src/math.c +5 -2
  156. data/ext/enterprise_script_service/mruby/mrbgems/mruby-metaprog/src/metaprog.c +39 -24
  157. data/ext/enterprise_script_service/mruby/mrbgems/mruby-metaprog/test/metaprog.rb +48 -17
  158. data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/mrblib/method.rb +0 -12
  159. data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/src/method.c +134 -101
  160. data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/test/method.rb +9 -1
  161. data/ext/enterprise_script_service/mruby/mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb +1 -5
  162. data/ext/enterprise_script_service/mruby/mrbgems/mruby-numeric-ext/src/numeric_ext.c +17 -37
  163. data/ext/enterprise_script_service/mruby/mrbgems/mruby-numeric-ext/test/numeric.rb +0 -8
  164. data/ext/enterprise_script_service/mruby/mrbgems/mruby-object-ext/mrbgem.rake +1 -1
  165. data/ext/enterprise_script_service/mruby/mrbgems/mruby-object-ext/mrblib/object.rb +15 -1
  166. data/ext/enterprise_script_service/mruby/mrbgems/mruby-object-ext/src/object.c +35 -6
  167. data/ext/enterprise_script_service/mruby/mrbgems/mruby-object-ext/test/nil.rb +4 -0
  168. data/ext/enterprise_script_service/mruby/mrbgems/mruby-objectspace/src/mruby_objectspace.c +1 -5
  169. data/ext/enterprise_script_service/mruby/mrbgems/mruby-objectspace/test/objectspace.rb +1 -1
  170. data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/src/pack.c +28 -23
  171. data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/test/pack.rb +43 -49
  172. data/ext/enterprise_script_service/mruby/mrbgems/mruby-print/mrblib/print.rb +3 -9
  173. data/ext/enterprise_script_service/mruby/mrbgems/mruby-proc-ext/src/proc.c +6 -9
  174. data/ext/enterprise_script_service/mruby/mrbgems/mruby-proc-ext/test/proc.rb +21 -5
  175. data/ext/enterprise_script_service/mruby/mrbgems/mruby-random/src/random.c +157 -124
  176. data/ext/enterprise_script_service/mruby/mrbgems/mruby-random/test/random.rb +72 -26
  177. data/ext/enterprise_script_service/mruby/mrbgems/mruby-range-ext/mrblib/range.rb +38 -0
  178. data/ext/enterprise_script_service/mruby/mrbgems/mruby-range-ext/src/range.c +26 -11
  179. data/ext/enterprise_script_service/mruby/mrbgems/mruby-range-ext/test/range.rb +111 -1
  180. data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/mrbgem.rake +5 -0
  181. data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/mrblib/rational.rb +117 -0
  182. data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/src/rational.c +209 -0
  183. data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/test/rational.rb +308 -0
  184. data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/README.md +1 -1
  185. data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/src/socket.c +10 -9
  186. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sprintf/src/kernel.c +2 -2
  187. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sprintf/src/sprintf.c +22 -24
  188. data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/mrbgem.rake +0 -1
  189. data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/mrblib/string.rb +8 -4
  190. data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/src/string.c +116 -117
  191. data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/test/numeric.rb +29 -0
  192. data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/test/range.rb +26 -0
  193. data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/test/string.rb +32 -50
  194. data/ext/enterprise_script_service/mruby/mrbgems/mruby-struct/mrblib/struct.rb +5 -7
  195. data/ext/enterprise_script_service/mruby/mrbgems/mruby-struct/src/struct.c +43 -57
  196. data/ext/enterprise_script_service/mruby/mrbgems/mruby-struct/test/struct.rb +16 -11
  197. data/ext/enterprise_script_service/mruby/mrbgems/mruby-symbol-ext/src/symbol.c +2 -2
  198. data/ext/enterprise_script_service/mruby/mrbgems/mruby-symbol-ext/test/symbol.rb +1 -1
  199. data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/driver.c +152 -1
  200. data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/mrbgem.rake +4 -3
  201. data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/vformat.c +200 -0
  202. data/ext/enterprise_script_service/mruby/mrbgems/mruby-time/include/mruby/time.h +2 -1
  203. data/ext/enterprise_script_service/mruby/mrbgems/mruby-time/src/time.c +199 -68
  204. data/ext/enterprise_script_service/mruby/mrbgems/mruby-time/test/time.rb +81 -46
  205. data/ext/enterprise_script_service/mruby/mrblib/array.rb +14 -16
  206. data/ext/enterprise_script_service/mruby/mrblib/enum.rb +13 -9
  207. data/ext/enterprise_script_service/mruby/mrblib/hash.rb +5 -7
  208. data/ext/enterprise_script_service/mruby/mrblib/kernel.rb +1 -1
  209. data/ext/enterprise_script_service/mruby/mrblib/numeric.rb +4 -4
  210. data/ext/enterprise_script_service/mruby/mrblib/range.rb +1 -1
  211. data/ext/enterprise_script_service/mruby/mrblib/string.rb +55 -112
  212. data/ext/enterprise_script_service/mruby/mruby-source.gemspec +1 -1
  213. data/ext/enterprise_script_service/mruby/oss-fuzz/config/mruby.dict +105 -0
  214. data/ext/enterprise_script_service/mruby/oss-fuzz/config/mruby_fuzzer.options +5 -0
  215. data/ext/enterprise_script_service/mruby/oss-fuzz/config/mruby_proto_fuzzer.options +4 -0
  216. data/ext/enterprise_script_service/mruby/oss-fuzz/mruby_fuzzer.c +18 -0
  217. data/ext/enterprise_script_service/mruby/oss-fuzz/mruby_proto_fuzzer.cpp +44 -0
  218. data/ext/enterprise_script_service/mruby/oss-fuzz/proto_to_ruby.cpp +455 -0
  219. data/ext/enterprise_script_service/mruby/oss-fuzz/proto_to_ruby.h +55 -0
  220. data/ext/enterprise_script_service/mruby/oss-fuzz/ruby.proto +201 -0
  221. data/ext/enterprise_script_service/mruby/src/array.c +95 -46
  222. data/ext/enterprise_script_service/mruby/src/backtrace.c +6 -8
  223. data/ext/enterprise_script_service/mruby/src/class.c +370 -278
  224. data/ext/enterprise_script_service/mruby/src/codedump.c +34 -34
  225. data/ext/enterprise_script_service/mruby/src/debug.c +2 -2
  226. data/ext/enterprise_script_service/mruby/src/dump.c +8 -6
  227. data/ext/enterprise_script_service/mruby/src/enum.c +1 -1
  228. data/ext/enterprise_script_service/mruby/src/error.c +157 -55
  229. data/ext/enterprise_script_service/mruby/src/etc.c +13 -46
  230. data/ext/enterprise_script_service/mruby/src/fmt_fp.c +2 -2
  231. data/ext/enterprise_script_service/mruby/src/gc.c +30 -11
  232. data/ext/enterprise_script_service/mruby/src/hash.c +23 -14
  233. data/ext/enterprise_script_service/mruby/src/kernel.c +16 -54
  234. data/ext/enterprise_script_service/mruby/src/load.c +40 -76
  235. data/ext/enterprise_script_service/mruby/src/numeric.c +164 -94
  236. data/ext/enterprise_script_service/mruby/src/object.c +16 -39
  237. data/ext/enterprise_script_service/mruby/src/pool.c +0 -2
  238. data/ext/enterprise_script_service/mruby/src/proc.c +47 -48
  239. data/ext/enterprise_script_service/mruby/src/range.c +22 -35
  240. data/ext/enterprise_script_service/mruby/src/state.c +5 -94
  241. data/ext/enterprise_script_service/mruby/src/string.c +874 -710
  242. data/ext/enterprise_script_service/mruby/src/symbol.c +73 -48
  243. data/ext/enterprise_script_service/mruby/src/variable.c +58 -38
  244. data/ext/enterprise_script_service/mruby/src/vm.c +133 -304
  245. data/ext/enterprise_script_service/mruby/tasks/doc.rake +48 -0
  246. data/ext/enterprise_script_service/mruby/tasks/toolchains/clang.rake +3 -4
  247. data/ext/enterprise_script_service/mruby/tasks/toolchains/gcc.rake +20 -19
  248. data/ext/enterprise_script_service/mruby/tasks/toolchains/visualcpp.rake +0 -12
  249. data/ext/enterprise_script_service/mruby/test/assert.rb +186 -25
  250. data/ext/enterprise_script_service/mruby/test/t/array.rb +34 -6
  251. data/ext/enterprise_script_service/mruby/test/t/class.rb +26 -0
  252. data/ext/enterprise_script_service/mruby/test/t/enumerable.rb +2 -2
  253. data/ext/enterprise_script_service/mruby/test/t/float.rb +17 -17
  254. data/ext/enterprise_script_service/mruby/test/t/hash.rb +2 -0
  255. data/ext/enterprise_script_service/mruby/test/t/integer.rb +14 -6
  256. data/ext/enterprise_script_service/mruby/test/t/kernel.rb +38 -19
  257. data/ext/enterprise_script_service/mruby/test/t/module.rb +87 -14
  258. data/ext/enterprise_script_service/mruby/test/t/numeric.rb +65 -23
  259. data/ext/enterprise_script_service/mruby/test/t/range.rb +4 -4
  260. data/ext/enterprise_script_service/mruby/test/t/string.rb +211 -49
  261. data/ext/enterprise_script_service/mruby/test/t/syntax.rb +19 -2
  262. data/ext/enterprise_script_service/mruby/test/t/vformat.rb +92 -0
  263. data/ext/enterprise_script_service/mruby/travis_config.rb +2 -2
  264. data/ext/enterprise_script_service/mruby_config.rb +10 -0
  265. data/ext/enterprise_script_service/mruby_engine.cpp +2 -2
  266. data/ext/enterprise_script_service/mruby_engine.gembox +1 -0
  267. data/ext/enterprise_script_service/msgpack/CHANGELOG.md +14 -0
  268. data/ext/enterprise_script_service/msgpack/Files.cmake +4 -0
  269. data/ext/enterprise_script_service/msgpack/README.md +1 -1
  270. data/ext/enterprise_script_service/msgpack/appveyor.yml +1 -1
  271. data/ext/enterprise_script_service/msgpack/erb/v1/cpp03_msgpack_tuple.hpp.erb +1 -1
  272. data/ext/enterprise_script_service/msgpack/erb/v1/cpp03_msgpack_tuple_decl.hpp.erb +1 -1
  273. data/ext/enterprise_script_service/msgpack/erb/v1/cpp03_zone.hpp.erb +3 -3
  274. data/ext/enterprise_script_service/msgpack/example/boost/asio_send_recv.cpp +1 -1
  275. data/ext/enterprise_script_service/msgpack/include/msgpack/adaptor/cpp11/timespec.hpp +16 -0
  276. data/ext/enterprise_script_service/msgpack/include/msgpack/adaptor/wstring.hpp +15 -0
  277. data/ext/enterprise_script_service/msgpack/include/msgpack/object.h +2 -0
  278. data/ext/enterprise_script_service/msgpack/include/msgpack/pack_template.h +17 -9
  279. data/ext/enterprise_script_service/msgpack/include/msgpack/sysdep.h +27 -16
  280. data/ext/enterprise_script_service/msgpack/include/msgpack/type.hpp +2 -0
  281. data/ext/enterprise_script_service/msgpack/include/msgpack/unpack_template.h +5 -0
  282. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/array_ref.hpp +0 -1
  283. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/check_container_size.hpp +1 -1
  284. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/cpp11/chrono.hpp +5 -5
  285. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/cpp11/timespec.hpp +140 -0
  286. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/detail/cpp03_msgpack_tuple.hpp +32 -32
  287. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/detail/cpp03_msgpack_tuple_decl.hpp +32 -32
  288. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/detail/cpp11_msgpack_tuple.hpp +6 -6
  289. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/detail/cpp11_msgpack_tuple_decl.hpp +10 -10
  290. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/ext.hpp +1 -1
  291. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/fixint.hpp +5 -4
  292. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/int.hpp +40 -13
  293. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/int_decl.hpp +3 -2
  294. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/wstring.hpp +121 -0
  295. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/detail/cpp03_zone.hpp +3 -3
  296. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/detail/cpp11_zone.hpp +3 -3
  297. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/object.hpp +6 -6
  298. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/object_fwd.hpp +1 -1
  299. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/pack.hpp +40 -5
  300. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/unpack.hpp +11 -11
  301. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/vrefbuffer.hpp +7 -7
  302. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/zbuffer.hpp +5 -5
  303. data/ext/enterprise_script_service/msgpack/include/msgpack/v2/adaptor/int_decl.hpp +1 -1
  304. data/ext/enterprise_script_service/msgpack/include/msgpack/v2/create_object_visitor.hpp +1 -1
  305. data/ext/enterprise_script_service/msgpack/include/msgpack/v2/parse.hpp +13 -13
  306. data/ext/enterprise_script_service/msgpack/include/msgpack/v2/x3_parse.hpp +28 -26
  307. data/ext/enterprise_script_service/msgpack/include/msgpack/v3/adaptor/int_decl.hpp +1 -1
  308. data/ext/enterprise_script_service/msgpack/include/msgpack/v3/parse.hpp +13 -13
  309. data/ext/enterprise_script_service/msgpack/include/msgpack/version_master.h +2 -2
  310. data/ext/enterprise_script_service/msgpack/include/msgpack/zbuffer.h +6 -6
  311. data/ext/enterprise_script_service/msgpack/include/msgpack/zone.h +1 -1
  312. data/ext/enterprise_script_service/msgpack/src/objectc.c +83 -148
  313. data/ext/enterprise_script_service/msgpack/src/unpack.c +73 -47
  314. data/ext/enterprise_script_service/msgpack/test/CMakeLists.txt +1 -1
  315. data/ext/enterprise_script_service/msgpack/test/array_ref.cpp +5 -0
  316. data/ext/enterprise_script_service/msgpack/test/boost_fusion.cpp +5 -0
  317. data/ext/enterprise_script_service/msgpack/test/boost_optional.cpp +7 -0
  318. data/ext/enterprise_script_service/msgpack/test/boost_string_ref.cpp +7 -0
  319. data/ext/enterprise_script_service/msgpack/test/boost_string_view.cpp +6 -0
  320. data/ext/enterprise_script_service/msgpack/test/boost_variant.cpp +15 -9
  321. data/ext/enterprise_script_service/msgpack/test/buffer.cpp +7 -0
  322. data/ext/enterprise_script_service/msgpack/test/carray.cpp +7 -0
  323. data/ext/enterprise_script_service/msgpack/test/cases.cpp +7 -1
  324. data/ext/enterprise_script_service/msgpack/test/convert.cpp +6 -0
  325. data/ext/enterprise_script_service/msgpack/test/fixint.cpp +7 -1
  326. data/ext/enterprise_script_service/msgpack/test/fixint_c.cpp +6 -1
  327. data/ext/enterprise_script_service/msgpack/test/fuzz_unpack_pack_fuzzer_cpp11.cpp +5 -0
  328. data/ext/enterprise_script_service/msgpack/test/iterator_cpp11.cpp +8 -2
  329. data/ext/enterprise_script_service/msgpack/test/json.cpp +6 -0
  330. data/ext/enterprise_script_service/msgpack/test/limit.cpp +7 -0
  331. data/ext/enterprise_script_service/msgpack/test/msgpack_basic.cpp +128 -6
  332. data/ext/enterprise_script_service/msgpack/test/msgpack_c.cpp +7 -2
  333. data/ext/enterprise_script_service/msgpack/test/msgpack_container.cpp +20 -3
  334. data/ext/enterprise_script_service/msgpack/test/msgpack_cpp11.cpp +159 -0
  335. data/ext/enterprise_script_service/msgpack/test/msgpack_cpp17.cpp +5 -0
  336. data/ext/enterprise_script_service/msgpack/test/msgpack_stream.cpp +8 -3
  337. data/ext/enterprise_script_service/msgpack/test/msgpack_tuple.cpp +6 -0
  338. data/ext/enterprise_script_service/msgpack/test/msgpack_vref.cpp +5 -0
  339. data/ext/enterprise_script_service/msgpack/test/msgpack_x3_parse.cpp +23 -18
  340. data/ext/enterprise_script_service/msgpack/test/object.cpp +77 -45
  341. data/ext/enterprise_script_service/msgpack/test/object_with_zone.cpp +28 -10
  342. data/ext/enterprise_script_service/msgpack/test/pack_unpack.cpp +25 -18
  343. data/ext/enterprise_script_service/msgpack/test/pack_unpack_c.cpp +7 -0
  344. data/ext/enterprise_script_service/msgpack/test/raw.cpp +17 -12
  345. data/ext/enterprise_script_service/msgpack/test/reference.cpp +6 -0
  346. data/ext/enterprise_script_service/msgpack/test/reference_cpp11.cpp +6 -0
  347. data/ext/enterprise_script_service/msgpack/test/reference_wrapper_cpp11.cpp +6 -0
  348. data/ext/enterprise_script_service/msgpack/test/shared_ptr_cpp11.cpp +6 -0
  349. data/ext/enterprise_script_service/msgpack/test/size_equal_only.cpp +6 -2
  350. data/ext/enterprise_script_service/msgpack/test/streaming.cpp +10 -3
  351. data/ext/enterprise_script_service/msgpack/test/streaming_c.cpp +7 -0
  352. data/ext/enterprise_script_service/msgpack/test/unique_ptr_cpp11.cpp +6 -0
  353. data/ext/enterprise_script_service/msgpack/test/user_class.cpp +5 -0
  354. data/ext/enterprise_script_service/msgpack/test/version.cpp +6 -0
  355. data/ext/enterprise_script_service/msgpack/test/visitor.cpp +7 -0
  356. data/ext/enterprise_script_service/msgpack/test/zone.cpp +6 -0
  357. data/lib/script_core/version.rb +1 -1
  358. data/lib/tasks/mruby/engine.gembox.example +1 -0
  359. data/lib/tasks/script_core.rake +21 -3
  360. data/spec/dummy/app/helpers/fields_helper.rb +2 -2
  361. data/spec/dummy/mruby/engine.gembox +1 -0
  362. data/spec/script_core_spec.rb +1 -1
  363. metadata +38 -22
  364. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/.gitignore +0 -1
  365. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/.travis.yml +0 -2
  366. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/run_test.rb +0 -26
  367. data/ext/enterprise_script_service/mruby/mrbgems/mruby-kernel-ext/mrblib/kernel.rb +0 -15
  368. data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/mrblib/unbound_method.rb +0 -9
  369. data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/.gitignore +0 -5
  370. data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/.travis.yml +0 -2
  371. data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/packtest.rb +0 -157
  372. data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/run_test.rb +0 -26
  373. data/ext/enterprise_script_service/mruby/mrbgems/mruby-random/src/mt19937ar.c +0 -224
  374. data/ext/enterprise_script_service/mruby/mrbgems/mruby-random/src/mt19937ar.h +0 -80
  375. data/ext/enterprise_script_service/mruby/mrbgems/mruby-random/src/random.h +0 -12
  376. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sleep/.gitignore +0 -4
  377. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sleep/.travis.yml +0 -29
  378. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sleep/.travis_build_config.rb +0 -6
  379. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sleep/Rakefile +0 -29
  380. data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/.travis.yml +0 -4
  381. data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/run_test.rb +0 -28
@@ -25,6 +25,10 @@
25
25
  ** [ MIT license: http://www.opensource.org/licenses/mit-license.php ]
26
26
  */
27
27
 
28
+ /**
29
+ * @file mruby.h
30
+ */
31
+
28
32
  #ifndef MRUBY_H
29
33
  #define MRUBY_H
30
34
 
@@ -84,7 +88,7 @@
84
88
  #endif
85
89
  #endif
86
90
 
87
- #include "mruby/common.h"
91
+ #include <mruby/common.h>
88
92
  #include <mruby/value.h>
89
93
  #include <mruby/gc.h>
90
94
  #include <mruby/version.h>
@@ -97,11 +101,14 @@ MRB_BEGIN_DECL
97
101
  typedef uint8_t mrb_code;
98
102
 
99
103
  /**
100
- * Required arguments signature type.
104
+ * \class mrb_aspec
105
+ *
106
+ * Specifies the number of arguments a function takes
107
+ *
108
+ * Example: `MRB_ARGS_REQ(2) | MRB_ARGS_OPT(1)` for a method that expects 2..3 arguments
101
109
  */
102
110
  typedef uint32_t mrb_aspec;
103
111
 
104
-
105
112
  struct mrb_irep;
106
113
  struct mrb_state;
107
114
 
@@ -127,8 +134,8 @@ typedef struct {
127
134
  uint16_t ridx;
128
135
  uint16_t epos;
129
136
  struct REnv *env;
130
- mrb_code *pc; /* return address */
131
- mrb_code *err; /* error position */
137
+ const mrb_code *pc; /* return address */
138
+ const mrb_code *err; /* error position */
132
139
  int argc;
133
140
  int acc;
134
141
  struct RClass *target_class;
@@ -170,13 +177,22 @@ struct mrb_context {
170
177
  # define MRB_METHOD_CACHE_SIZE (1<<7)
171
178
  #endif
172
179
 
173
- typedef mrb_value (*mrb_func_t)(struct mrb_state *mrb, mrb_value);
180
+ /**
181
+ * Function pointer type for a function callable by mruby.
182
+ *
183
+ * The arguments to the function are stored on the mrb_state. To get them see mrb_get_args
184
+ *
185
+ * @param mrb The mruby state
186
+ * @param self The self object
187
+ * @return [mrb_value] The function's return value
188
+ */
189
+ typedef mrb_value (*mrb_func_t)(struct mrb_state *mrb, mrb_value self);
174
190
 
175
- #ifdef MRB_METHOD_TABLE_INLINE
191
+ #ifndef MRB_METHOD_T_STRUCT
176
192
  typedef uintptr_t mrb_method_t;
177
193
  #else
178
194
  typedef struct {
179
- mrb_bool func_p;
195
+ uint8_t flags;
180
196
  union {
181
197
  struct RProc *proc;
182
198
  mrb_func_t func;
@@ -196,13 +212,9 @@ struct mrb_jmpbuf;
196
212
 
197
213
  typedef void (*mrb_atexit_func)(struct mrb_state*);
198
214
 
199
- #define MRB_STATE_NO_REGEXP 1
200
- #define MRB_STATE_REGEXP 2
201
-
202
215
  typedef struct mrb_state {
203
216
  struct mrb_jmpbuf *jmp;
204
217
 
205
- uint32_t flags;
206
218
  mrb_allocf allocf; /* memory allocation function */
207
219
  void *allocf_ud; /* auxiliary data of allocf */
208
220
 
@@ -232,7 +244,6 @@ typedef struct mrb_state {
232
244
  struct RClass *symbol_class;
233
245
  struct RClass *kernel_module;
234
246
 
235
- struct alloca_header *mems;
236
247
  mrb_gc gc;
237
248
 
238
249
  #ifdef MRB_METHOD_CACHE
@@ -248,8 +259,8 @@ typedef struct mrb_state {
248
259
  #endif
249
260
 
250
261
  #ifdef MRB_ENABLE_DEBUG_HOOK
251
- void (*code_fetch_hook)(struct mrb_state* mrb, struct mrb_irep *irep, mrb_code *pc, mrb_value *regs);
252
- void (*debug_op_hook)(struct mrb_state* mrb, struct mrb_irep *irep, mrb_code *pc, mrb_value *regs);
262
+ void (*code_fetch_hook)(struct mrb_state* mrb, struct mrb_irep *irep, const mrb_code *pc, mrb_value *regs);
263
+ void (*debug_op_hook)(struct mrb_state* mrb, struct mrb_irep *irep, const mrb_code *pc, mrb_value *regs);
253
264
  #endif
254
265
 
255
266
  #ifdef MRB_BYTECODE_DECODE_OPTION
@@ -290,9 +301,9 @@ typedef struct mrb_state {
290
301
  * //free(TheAnimals);
291
302
  * }
292
303
  *
293
- * @param [mrb_state *] mrb The current mruby state.
294
- * @param [const char *] name The name of the defined class.
295
- * @param [struct RClass *] super The new class parent.
304
+ * @param mrb The current mruby state.
305
+ * @param name The name of the defined class.
306
+ * @param super The new class parent.
296
307
  * @return [struct RClass *] Reference to the newly defined class.
297
308
  * @see mrb_define_class_under
298
309
  */
@@ -301,12 +312,12 @@ MRB_API struct RClass *mrb_define_class(mrb_state *mrb, const char *name, struct
301
312
  /**
302
313
  * Defines a new module.
303
314
  *
304
- * @param [mrb_state *] mrb_state* The current mruby state.
305
- * @param [const char *] char* The name of the module.
315
+ * @param mrb The current mruby state.
316
+ * @param name The name of the module.
306
317
  * @return [struct RClass *] Reference to the newly defined module.
307
318
  */
308
- MRB_API struct RClass *mrb_define_module(mrb_state *, const char*);
309
- MRB_API mrb_value mrb_singleton_class(mrb_state*, mrb_value);
319
+ MRB_API struct RClass *mrb_define_module(mrb_state *mrb, const char *name);
320
+ MRB_API mrb_value mrb_singleton_class(mrb_state *mrb, mrb_value val);
310
321
 
311
322
  /**
312
323
  * Include a module in another class or module.
@@ -315,11 +326,11 @@ MRB_API mrb_value mrb_singleton_class(mrb_state*, mrb_value);
315
326
  * module B
316
327
  * include A
317
328
  * end
318
- * @param [mrb_state *] mrb_state* The current mruby state.
319
- * @param [struct RClass *] RClass* A reference to module or a class.
320
- * @param [struct RClass *] RClass* A reference to the module to be included.
329
+ * @param mrb The current mruby state.
330
+ * @param cla A reference to module or a class.
331
+ * @param included A reference to the module to be included.
321
332
  */
322
- MRB_API void mrb_include_module(mrb_state*, struct RClass*, struct RClass*);
333
+ MRB_API void mrb_include_module(mrb_state *mrb, struct RClass *cla, struct RClass *included);
323
334
 
324
335
  /**
325
336
  * Prepends a module in another class or module.
@@ -328,11 +339,11 @@ MRB_API void mrb_include_module(mrb_state*, struct RClass*, struct RClass*);
328
339
  * module B
329
340
  * prepend A
330
341
  * end
331
- * @param [mrb_state *] mrb_state* The current mruby state.
332
- * @param [struct RClass *] RClass* A reference to module or a class.
333
- * @param [struct RClass *] RClass* A reference to the module to be prepended.
342
+ * @param mrb The current mruby state.
343
+ * @param cla A reference to module or a class.
344
+ * @param prepended A reference to the module to be prepended.
334
345
  */
335
- MRB_API void mrb_prepend_module(mrb_state*, struct RClass*, struct RClass*);
346
+ MRB_API void mrb_prepend_module(mrb_state *mrb, struct RClass *cla, struct RClass *prepended);
336
347
 
337
348
  /**
338
349
  * Defines a global function in ruby.
@@ -341,7 +352,6 @@ MRB_API void mrb_prepend_module(mrb_state*, struct RClass*, struct RClass*);
341
352
  *
342
353
  * Example:
343
354
  *
344
- * !!!c
345
355
  * mrb_value example_method(mrb_state* mrb, mrb_value self)
346
356
  * {
347
357
  * puts("Executing example command!");
@@ -353,11 +363,11 @@ MRB_API void mrb_prepend_module(mrb_state*, struct RClass*, struct RClass*);
353
363
  * mrb_define_method(mrb, mrb->kernel_module, "example_method", example_method, MRB_ARGS_NONE());
354
364
  * }
355
365
  *
356
- * @param [mrb_state *] mrb The MRuby state reference.
357
- * @param [struct RClass *] cla The class pointer where the method will be defined.
358
- * @param [const char *] name The name of the method being defined.
359
- * @param [mrb_func_t] func The function pointer to the method definition.
360
- * @param [mrb_aspec] aspec The method parameters declaration.
366
+ * @param mrb The MRuby state reference.
367
+ * @param cla The class pointer where the method will be defined.
368
+ * @param name The name of the method being defined.
369
+ * @param func The function pointer to the method definition.
370
+ * @param aspec The method parameters declaration.
361
371
  */
362
372
  MRB_API void mrb_define_method(mrb_state *mrb, struct RClass *cla, const char *name, mrb_func_t func, mrb_aspec aspec);
363
373
 
@@ -380,14 +390,20 @@ MRB_API void mrb_define_method(mrb_state *mrb, struct RClass *cla, const char *n
380
390
  * foo = mrb_define_class(mrb, "Foo", mrb->object_class);
381
391
  * mrb_define_class_method(mrb, foo, "bar", bar_method, MRB_ARGS_NONE());
382
392
  * }
383
- * @param [mrb_state *] mrb_state* The MRuby state reference.
384
- * @param [struct RClass *] RClass* The class where the class method will be defined.
385
- * @param [const char *] char* The name of the class method being defined.
386
- * @param [mrb_func_t] mrb_func_t The function pointer to the class method definition.
387
- * @param [mrb_aspec] mrb_aspec The method parameters declaration.
393
+ * @param mrb The MRuby state reference.
394
+ * @param cla The class where the class method will be defined.
395
+ * @param name The name of the class method being defined.
396
+ * @param fun The function pointer to the class method definition.
397
+ * @param aspec The method parameters declaration.
398
+ */
399
+ MRB_API void mrb_define_class_method(mrb_state *mrb, struct RClass *cla, const char *name, mrb_func_t fun, mrb_aspec aspec);
400
+
401
+ /**
402
+ * Defines a singleton method
403
+ *
404
+ * @see mrb_define_class_method
388
405
  */
389
- MRB_API void mrb_define_class_method(mrb_state *, struct RClass *, const char *, mrb_func_t, mrb_aspec);
390
- MRB_API void mrb_define_singleton_method(mrb_state*, struct RObject*, const char*, mrb_func_t, mrb_aspec);
406
+ MRB_API void mrb_define_singleton_method(mrb_state *mrb, struct RObject *cla, const char *name, mrb_func_t fun, mrb_aspec aspec);
391
407
 
392
408
  /**
393
409
  * Defines a module function.
@@ -408,13 +424,13 @@ MRB_API void mrb_define_singleton_method(mrb_state*, struct RObject*, const char
408
424
  * foo = mrb_define_module(mrb, "Foo");
409
425
  * mrb_define_module_function(mrb, foo, "bar", bar_method, MRB_ARGS_NONE());
410
426
  * }
411
- * @param [mrb_state *] mrb_state* The MRuby state reference.
412
- * @param [struct RClass *] RClass* The module where the module function will be defined.
413
- * @param [const char *] char* The name of the module function being defined.
414
- * @param [mrb_func_t] mrb_func_t The function pointer to the module function definition.
415
- * @param [mrb_aspec] mrb_aspec The method parameters declaration.
427
+ * @param mrb The MRuby state reference.
428
+ * @param cla The module where the module function will be defined.
429
+ * @param name The name of the module function being defined.
430
+ * @param fun The function pointer to the module function definition.
431
+ * @param aspec The method parameters declaration.
416
432
  */
417
- MRB_API void mrb_define_module_function(mrb_state*, struct RClass*, const char*, mrb_func_t, mrb_aspec);
433
+ MRB_API void mrb_define_module_function(mrb_state *mrb, struct RClass *cla, const char *name, mrb_func_t fun, mrb_aspec aspec);
418
434
 
419
435
  /**
420
436
  * Defines a constant.
@@ -437,12 +453,12 @@ MRB_API void mrb_define_module_function(mrb_state*, struct RClass*, const char*,
437
453
  * mrb_value
438
454
  * mrb_example_gem_final(mrb_state* mrb){
439
455
  * }
440
- * @param [mrb_state *] mrb_state* The MRuby state reference.
441
- * @param [struct RClass *] RClass* A class or module the constant is defined in.
442
- * @param [const char *] name The name of the constant being defined.
443
- * @param [mrb_value] mrb_value The value for the constant.
456
+ * @param mrb The MRuby state reference.
457
+ * @param cla A class or module the constant is defined in.
458
+ * @param name The name of the constant being defined.
459
+ * @param val The value for the constant.
444
460
  */
445
- MRB_API void mrb_define_const(mrb_state*, struct RClass*, const char *name, mrb_value);
461
+ MRB_API void mrb_define_const(mrb_state* mrb, struct RClass* cla, const char *name, mrb_value val);
446
462
 
447
463
  /**
448
464
  * Undefines a method.
@@ -488,11 +504,11 @@ MRB_API void mrb_define_const(mrb_state*, struct RClass*, const char *name, mrb_
488
504
  *
489
505
  * mrb_example_gem_final(mrb_state* mrb){
490
506
  * }
491
- * @param [mrb_state*] mrb_state* The mruby state reference.
492
- * @param [struct RClass*] RClass* A class the method will be undefined from.
493
- * @param [const char*] const char* The name of the method to be undefined.
507
+ * @param mrb The mruby state reference.
508
+ * @param cla The class the method will be undefined from.
509
+ * @param name The name of the method to be undefined.
494
510
  */
495
- MRB_API void mrb_undef_method(mrb_state*, struct RClass*, const char*);
511
+ MRB_API void mrb_undef_method(mrb_state *mrb, struct RClass *cla, const char *name);
496
512
  MRB_API void mrb_undef_method_id(mrb_state*, struct RClass*, mrb_sym);
497
513
 
498
514
  /**
@@ -528,11 +544,11 @@ MRB_API void mrb_undef_method_id(mrb_state*, struct RClass*, mrb_sym);
528
544
  * void
529
545
  * mrb_example_gem_final(mrb_state* mrb){
530
546
  * }
531
- * @param [mrb_state*] mrb_state* The mruby state reference.
532
- * @param [RClass*] RClass* A class the class method will be undefined from.
533
- * @param [const char*] const char* The name of the class method to be undefined.
547
+ * @param mrb The mruby state reference.
548
+ * @param cls A class the class method will be undefined from.
549
+ * @param name The name of the class method to be undefined.
534
550
  */
535
- MRB_API void mrb_undef_class_method(mrb_state*, struct RClass*, const char*);
551
+ MRB_API void mrb_undef_class_method(mrb_state *mrb, struct RClass *cls, const char *name);
536
552
 
537
553
  /**
538
554
  * Initialize a new object instance of c class.
@@ -556,10 +572,10 @@ MRB_API void mrb_undef_class_method(mrb_state*, struct RClass*, const char*);
556
572
  * obj = mrb_obj_new(mrb, example_class, 0, NULL); # => ExampleClass.new
557
573
  * mrb_p(mrb, obj); // => Kernel#p
558
574
  * }
559
- * @param [mrb_state*] mrb The current mruby state.
560
- * @param [RClass*] c Reference to the class of the new object.
561
- * @param [mrb_int] argc Number of arguments in argv
562
- * @param [const mrb_value *] argv Array of mrb_value to initialize the object
575
+ * @param mrb The current mruby state.
576
+ * @param c Reference to the class of the new object.
577
+ * @param argc Number of arguments in argv
578
+ * @param argv Array of mrb_value to initialize the object
563
579
  * @return [mrb_value] The newly initialized object
564
580
  */
565
581
  MRB_API mrb_value mrb_obj_new(mrb_state *mrb, struct RClass *c, mrb_int argc, const mrb_value *argv);
@@ -570,8 +586,6 @@ MRB_INLINE mrb_value mrb_class_new_instance(mrb_state *mrb, mrb_int argc, const
570
586
  return mrb_obj_new(mrb,c,argc,argv);
571
587
  }
572
588
 
573
- MRB_API mrb_value mrb_instance_new(mrb_state *mrb, mrb_value cv);
574
-
575
589
  /**
576
590
  * Creates a new instance of Class, Class.
577
591
  *
@@ -587,8 +601,8 @@ MRB_API mrb_value mrb_instance_new(mrb_state *mrb, mrb_value cv);
587
601
  * mrb_p(mrb, obj); // => Kernel#p
588
602
  * }
589
603
  *
590
- * @param [mrb_state*] mrb The current mruby state.
591
- * @param [struct RClass *] super The super class or parent.
604
+ * @param mrb The current mruby state.
605
+ * @param super The super class or parent.
592
606
  * @return [struct RClass *] Reference to the new class.
593
607
  */
594
608
  MRB_API struct RClass * mrb_class_new(mrb_state *mrb, struct RClass *super);
@@ -604,7 +618,7 @@ MRB_API struct RClass * mrb_class_new(mrb_state *mrb, struct RClass *super);
604
618
  * example_module = mrb_module_new(mrb);
605
619
  * }
606
620
  *
607
- * @param [mrb_state*] mrb The current mruby state.
621
+ * @param mrb The current mruby state.
608
622
  * @return [struct RClass *] Reference to the new module.
609
623
  */
610
624
  MRB_API struct RClass * mrb_module_new(mrb_state *mrb);
@@ -631,24 +645,24 @@ MRB_API struct RClass * mrb_module_new(mrb_state *mrb);
631
645
  * }
632
646
  * }
633
647
  *
634
- * @param [mrb_state*] mrb The current mruby state.
635
- * @param [const char *] name A string representing the name of the class.
648
+ * @param mrb The current mruby state.
649
+ * @param name A string representing the name of the class.
636
650
  * @return [mrb_bool] A boolean value.
637
651
  */
638
652
  MRB_API mrb_bool mrb_class_defined(mrb_state *mrb, const char *name);
639
653
 
640
654
  /**
641
655
  * Gets a class.
642
- * @param [mrb_state*] mrb The current mruby state.
643
- * @param [const char *] name The name of the class.
656
+ * @param mrb The current mruby state.
657
+ * @param name The name of the class.
644
658
  * @return [struct RClass *] A reference to the class.
645
659
  */
646
660
  MRB_API struct RClass * mrb_class_get(mrb_state *mrb, const char *name);
647
661
 
648
662
  /**
649
663
  * Gets a exception class.
650
- * @param [mrb_state*] mrb The current mruby state.
651
- * @param [const char *] name The name of the class.
664
+ * @param mrb The current mruby state.
665
+ * @param name The name of the class.
652
666
  * @return [struct RClass *] A reference to the class.
653
667
  */
654
668
  MRB_API struct RClass * mrb_exc_get(mrb_state *mrb, const char *name);
@@ -677,35 +691,35 @@ MRB_API struct RClass * mrb_exc_get(mrb_state *mrb, const char *name);
677
691
  * }
678
692
  * }
679
693
  *
680
- * @param [mrb_state*] mrb The current mruby state.
681
- * @param [struct RClass *] outer The name of the outer class.
682
- * @param [const char *] name A string representing the name of the inner class.
694
+ * @param mrb The current mruby state.
695
+ * @param outer The name of the outer class.
696
+ * @param name A string representing the name of the inner class.
683
697
  * @return [mrb_bool] A boolean value.
684
698
  */
685
699
  MRB_API mrb_bool mrb_class_defined_under(mrb_state *mrb, struct RClass *outer, const char *name);
686
700
 
687
701
  /**
688
702
  * Gets a child class.
689
- * @param [mrb_state*] mrb The current mruby state.
690
- * @param [struct RClass *] outer The name of the parent class.
691
- * @param [const char *] name The name of the class.
703
+ * @param mrb The current mruby state.
704
+ * @param outer The name of the parent class.
705
+ * @param name The name of the class.
692
706
  * @return [struct RClass *] A reference to the class.
693
707
  */
694
708
  MRB_API struct RClass * mrb_class_get_under(mrb_state *mrb, struct RClass *outer, const char *name);
695
709
 
696
710
  /**
697
711
  * Gets a module.
698
- * @param [mrb_state*] mrb The current mruby state.
699
- * @param [const char *] name The name of the module.
712
+ * @param mrb The current mruby state.
713
+ * @param name The name of the module.
700
714
  * @return [struct RClass *] A reference to the module.
701
715
  */
702
716
  MRB_API struct RClass * mrb_module_get(mrb_state *mrb, const char *name);
703
717
 
704
718
  /**
705
719
  * Gets a module defined under another module.
706
- * @param [mrb_state*] mrb The current mruby state.
707
- * @param [struct RClass *] outer The name of the outer module.
708
- * @param [const char *] name The name of the module.
720
+ * @param mrb The current mruby state.
721
+ * @param outer The name of the outer module.
722
+ * @param name The name of the module.
709
723
  * @return [struct RClass *] A reference to the module.
710
724
  */
711
725
  MRB_API struct RClass * mrb_module_get_under(mrb_state *mrb, struct RClass *outer, const char *name);
@@ -719,8 +733,8 @@ MRB_API mrb_value mrb_notimplement_m(mrb_state*, mrb_value);
719
733
  *
720
734
  * Equivalent to:
721
735
  * Object#dup
722
- * @param [mrb_state*] mrb The current mruby state.
723
- * @param [mrb_value] obj Object to be duplicate.
736
+ * @param mrb The current mruby state.
737
+ * @param obj Object to be duplicate.
724
738
  * @return [mrb_value] The newly duplicated object.
725
739
  */
726
740
  MRB_API mrb_value mrb_obj_dup(mrb_state *mrb, mrb_value obj);
@@ -760,9 +774,9 @@ MRB_API mrb_value mrb_obj_dup(mrb_state *mrb, mrb_value obj);
760
774
  * }
761
775
  * }
762
776
  *
763
- * @param [mrb_state*] mrb The current mruby state.
764
- * @param [struct RClass *] c A reference to a class.
765
- * @param [mrb_sym] mid A symbol referencing a method id.
777
+ * @param mrb The current mruby state.
778
+ * @param c A reference to a class.
779
+ * @param mid A symbol referencing a method id.
766
780
  * @return [mrb_bool] A boolean value.
767
781
  */
768
782
  MRB_API mrb_bool mrb_obj_respond_to(mrb_state *mrb, struct RClass* c, mrb_sym mid);
@@ -770,10 +784,10 @@ MRB_API mrb_bool mrb_obj_respond_to(mrb_state *mrb, struct RClass* c, mrb_sym mi
770
784
  /**
771
785
  * Defines a new class under a given module
772
786
  *
773
- * @param [mrb_state*] mrb The current mruby state.
774
- * @param [struct RClass *] outer Reference to the module under which the new class will be defined
775
- * @param [const char *] name The name of the defined class
776
- * @param [struct RClass *] super The new class parent
787
+ * @param mrb The current mruby state.
788
+ * @param outer Reference to the module under which the new class will be defined
789
+ * @param name The name of the defined class
790
+ * @param super The new class parent
777
791
  * @return [struct RClass *] Reference to the newly defined class
778
792
  * @see mrb_define_class
779
793
  */
@@ -843,34 +857,93 @@ MRB_API struct RClass * mrb_define_module_under(mrb_state *mrb, struct RClass *o
843
857
  * | `S` | {String} | {mrb_value} | when `!` follows, the value may be `nil` |
844
858
  * | `A` | {Array} | {mrb_value} | when `!` follows, the value may be `nil` |
845
859
  * | `H` | {Hash} | {mrb_value} | when `!` follows, the value may be `nil` |
846
- * | `s` | {String} | char *, {mrb_int} | Receive two arguments; `s!` gives (`NULL`,`0`) for `nil` |
860
+ * | `s` | {String} | char *, {mrb_int} | Receive two arguments; `s!` gives (`NULL`,`0`) for `nil` |
847
861
  * | `z` | {String} | char * | `NULL` terminated string; `z!` gives `NULL` for `nil` |
848
862
  * | `a` | {Array} | {mrb_value} *, {mrb_int} | Receive two arguments; `a!` gives (`NULL`,`0`) for `nil` |
849
- * | `f` | {Float} | {mrb_float} | |
850
- * | `i` | {Integer} | {mrb_int} | |
863
+ * | `f` | {Fixnum}/{Float} | {mrb_float} | |
864
+ * | `i` | {Fixnum}/{Float} | {mrb_int} | |
851
865
  * | `b` | boolean | {mrb_bool} | |
852
- * | `n` | {Symbol} | {mrb_sym} | |
866
+ * | `n` | {String}/{Symbol} | {mrb_sym} | |
867
+ * | `d` | data | void *, {mrb_data_type} const | 2nd argument will be used to check data type so it won't be modified; when `!` follows, the value may be `nil` |
868
+ * | `I` | inline struct | void * | |
853
869
  * | `&` | block | {mrb_value} | &! raises exception if no block given. |
854
- * | `*` | rest arguments | {mrb_value} *, {mrb_int} | Receive the rest of arguments as an array; *! avoid copy of the stack. |
855
- * | &vert; | optional | | After this spec following specs would be optional. |
870
+ * | `*` | rest arguments | {mrb_value} *, {mrb_int} | Receive the rest of arguments as an array; `*!` avoid copy of the stack. |
871
+ * | <code>\|</code> | optional | | After this spec following specs would be optional. |
856
872
  * | `?` | optional given | {mrb_bool} | `TRUE` if preceding argument is given. Used to check optional argument is given. |
873
+ * | `:` | keyword args | {mrb_kwargs} const | Get keyword arguments. @see mrb_kwargs |
857
874
  *
858
875
  * @see mrb_get_args
859
876
  */
860
877
  typedef const char *mrb_args_format;
861
878
 
879
+ /**
880
+ * Get keyword arguments by `mrb_get_args()` with `:` specifier.
881
+ *
882
+ * `mrb_kwargs::num` indicates that the number of keyword values.
883
+ *
884
+ * `mrb_kwargs::values` is an object array, and the keyword argument corresponding to the string array is assigned.
885
+ * Note that `undef` is assigned if there is no keyword argument corresponding to `mrb_kwargs::optional`.
886
+ *
887
+ * `mrb_kwargs::table` accepts a string array.
888
+ *
889
+ * `mrb_kwargs::required` indicates that the specified number of keywords starting from the beginning of the string array are required.
890
+ *
891
+ * `mrb_kwargs::rest` is the remaining keyword argument that can be accepted as `**rest` in Ruby.
892
+ * If `NULL` is specified, `ArgumentError` is raised when there is an undefined keyword.
893
+ *
894
+ * Examples:
895
+ *
896
+ * // def method(a: 1, b: 2)
897
+ *
898
+ * uint32_t kw_num = 2;
899
+ * const char *kw_names[kw_num] = { "a", "b" };
900
+ * uint32_t kw_required = 0;
901
+ * mrb_value kw_values[kw_num];
902
+ * const mrb_kwargs kwargs = { kw_num, kw_values, kw_names, kw_required, NULL };
903
+ *
904
+ * mrb_get_args(mrb, ":", &kwargs);
905
+ * if (mrb_undef_p(kw_values[0])) { kw_values[0] = mrb_fixnum_value(1); }
906
+ * if (mrb_undef_p(kw_values[1])) { kw_values[1] = mrb_fixnum_value(2); }
907
+ *
908
+ *
909
+ * // def method(str, x:, y: 2, z: "default string", **opts)
910
+ *
911
+ * mrb_value str, kw_rest;
912
+ * uint32_t kw_num = 3;
913
+ * const char *kw_names[kw_num] = { "x", "y", "z" };
914
+ * uint32_t kw_required = 1;
915
+ * mrb_value kw_values[kw_num];
916
+ * const mrb_kwargs kwargs = { kw_num, kw_values, kw_names, kw_required, &kw_rest };
917
+ *
918
+ * mrb_get_args(mrb, "S:", &str, &kwargs);
919
+ * // or: mrb_get_args(mrb, ":S", &kwargs, &str);
920
+ * if (mrb_undef_p(kw_values[1])) { kw_values[1] = mrb_fixnum_value(2); }
921
+ * if (mrb_undef_p(kw_values[2])) { kw_values[2] = mrb_str_new_cstr(mrb, "default string"); }
922
+ */
923
+ typedef struct mrb_kwargs mrb_kwargs;
924
+
925
+ struct mrb_kwargs
926
+ {
927
+ uint32_t num;
928
+ mrb_value *values;
929
+ const char *const *table;
930
+ uint32_t required;
931
+ mrb_value *rest;
932
+ };
933
+
862
934
  /**
863
935
  * Retrieve arguments from mrb_state.
864
936
  *
865
937
  * @param mrb The current MRuby state.
866
- * @param format [mrb_args_format] is a list of format specifiers
938
+ * @param format is a list of format specifiers
867
939
  * @param ... The passing variadic arguments must be a pointer of retrieving type.
868
940
  * @return the number of arguments retrieved.
869
941
  * @see mrb_args_format
942
+ * @see mrb_kwargs
870
943
  */
871
944
  MRB_API mrb_int mrb_get_args(mrb_state *mrb, mrb_args_format format, ...);
872
945
 
873
- static inline mrb_sym
946
+ MRB_INLINE mrb_sym
874
947
  mrb_get_mid(mrb_state *mrb) /* get method symbol */
875
948
  {
876
949
  return mrb->c->ci->mid;
@@ -896,6 +969,8 @@ MRB_API mrb_value* mrb_get_argv(mrb_state *mrb);
896
969
  /**
897
970
  * Call existing ruby functions.
898
971
  *
972
+ * Example:
973
+ *
899
974
  * #include <stdio.h>
900
975
  * #include <mruby.h>
901
976
  * #include "mruby/compile.h"
@@ -912,15 +987,16 @@ MRB_API mrb_value* mrb_get_argv(mrb_state *mrb);
912
987
  * mrb_funcall(mrb, obj, "method_name", 1, mrb_fixnum_value(i));
913
988
  * fclose(fp);
914
989
  * mrb_close(mrb);
915
- * }
916
- * @param [mrb_state*] mrb_state* The current mruby state.
917
- * @param [mrb_value] mrb_value A reference to an mruby value.
918
- * @param [const char*] const char* The name of the method.
919
- * @param [mrb_int] mrb_int The number of arguments the method has.
920
- * @param [...] ... Variadic values(not type safe!).
921
- * @return [mrb_value] mrb_value mruby function value.
990
+ * }
991
+ *
992
+ * @param mrb The current mruby state.
993
+ * @param val A reference to an mruby value.
994
+ * @param name The name of the method.
995
+ * @param argc The number of arguments the method has.
996
+ * @param ... Variadic values(not type safe!).
997
+ * @return [mrb_value] mruby function value.
922
998
  */
923
- MRB_API mrb_value mrb_funcall(mrb_state*, mrb_value, const char*, mrb_int,...);
999
+ MRB_API mrb_value mrb_funcall(mrb_state *mrb, mrb_value val, const char *name, mrb_int argc, ...);
924
1000
  /**
925
1001
  * Call existing ruby functions. This is basically the type safe version of mrb_funcall.
926
1002
  *
@@ -942,32 +1018,35 @@ MRB_API mrb_value mrb_funcall(mrb_state*, mrb_value, const char*, mrb_int,...);
942
1018
  * fclose(fp);
943
1019
  * mrb_close(mrb);
944
1020
  * }
945
- * @param [mrb_state*] mrb_state* The current mruby state.
946
- * @param [mrb_value] mrb_value A reference to an mruby value.
947
- * @param [mrb_sym] mrb_sym The symbol representing the method.
948
- * @param [mrb_int] mrb_int The number of arguments the method has.
949
- * @param [const mrb_value*] mrb_value* Pointer to the object.
1021
+ * @param mrb The current mruby state.
1022
+ * @param val A reference to an mruby value.
1023
+ * @param name_sym The symbol representing the method.
1024
+ * @param argc The number of arguments the method has.
1025
+ * @param obj Pointer to the object.
950
1026
  * @return [mrb_value] mrb_value mruby function value.
951
1027
  * @see mrb_funcall
952
1028
  */
953
- MRB_API mrb_value mrb_funcall_argv(mrb_state*, mrb_value, mrb_sym, mrb_int, const mrb_value*);
1029
+ MRB_API mrb_value mrb_funcall_argv(mrb_state *mrb, mrb_value val, mrb_sym name, mrb_int argc, const mrb_value *argv);
954
1030
  /**
955
1031
  * Call existing ruby functions with a block.
956
1032
  */
957
- MRB_API mrb_value mrb_funcall_with_block(mrb_state*, mrb_value, mrb_sym, mrb_int, const mrb_value*, mrb_value);
1033
+ MRB_API mrb_value mrb_funcall_with_block(mrb_state *mrb, mrb_value val, mrb_sym name, mrb_int argc, const mrb_value *argv, mrb_value block);
958
1034
  /**
959
1035
  * Create a symbol
960
1036
  *
1037
+ * Example:
1038
+ *
961
1039
  * # Ruby style:
962
1040
  * :pizza # => :pizza
963
1041
  *
964
1042
  * // C style:
965
1043
  * mrb_sym m_sym = mrb_intern_lit(mrb, "pizza"); // => :pizza
966
- * @param [mrb_state*] mrb_state* The current mruby state.
967
- * @param [const char*] const char* The name of the method.
1044
+ *
1045
+ * @param mrb The current mruby state.
1046
+ * @param str The string to be symbolized
968
1047
  * @return [mrb_sym] mrb_sym A symbol.
969
1048
  */
970
- MRB_API mrb_sym mrb_intern_cstr(mrb_state*,const char*);
1049
+ MRB_API mrb_sym mrb_intern_cstr(mrb_state *mrb, const char* str);
971
1050
  MRB_API mrb_sym mrb_intern(mrb_state*,const char*,size_t);
972
1051
  MRB_API mrb_sym mrb_intern_static(mrb_state*,const char*,size_t);
973
1052
  #define mrb_intern_lit(mrb, lit) mrb_intern_static(mrb, lit, mrb_strlen_lit(lit))
@@ -975,9 +1054,13 @@ MRB_API mrb_sym mrb_intern_str(mrb_state*,mrb_value);
975
1054
  MRB_API mrb_value mrb_check_intern_cstr(mrb_state*,const char*);
976
1055
  MRB_API mrb_value mrb_check_intern(mrb_state*,const char*,size_t);
977
1056
  MRB_API mrb_value mrb_check_intern_str(mrb_state*,mrb_value);
978
- MRB_API const char *mrb_sym2name(mrb_state*,mrb_sym);
979
- MRB_API const char *mrb_sym2name_len(mrb_state*,mrb_sym,mrb_int*);
980
- MRB_API mrb_value mrb_sym2str(mrb_state*,mrb_sym);
1057
+ MRB_API const char *mrb_sym_name(mrb_state*,mrb_sym);
1058
+ MRB_API const char *mrb_sym_name_len(mrb_state*,mrb_sym,mrb_int*);
1059
+ MRB_API const char *mrb_sym_dump(mrb_state*,mrb_sym);
1060
+ MRB_API mrb_value mrb_sym_str(mrb_state*,mrb_sym);
1061
+ #define mrb_sym2name(mrb,sym) mrb_sym_name(mrb,sym)
1062
+ #define mrb_sym2name_len(mrb,sym,len) mrb_sym_name_len(mrb,sym,len)
1063
+ #define mrb_sym2str(mrb,sym) mrb_sym_str(mrb,sym)
981
1064
 
982
1065
  MRB_API void *mrb_malloc(mrb_state*, size_t); /* raise RuntimeError if no mem */
983
1066
  MRB_API void *mrb_calloc(mrb_state*, size_t, size_t); /* ditto */
@@ -996,6 +1079,12 @@ MRB_API mrb_value mrb_str_new_cstr(mrb_state*, const char*);
996
1079
  MRB_API mrb_value mrb_str_new_static(mrb_state *mrb, const char *p, size_t len);
997
1080
  #define mrb_str_new_lit(mrb, lit) mrb_str_new_static(mrb, (lit), mrb_strlen_lit(lit))
998
1081
 
1082
+ MRB_API mrb_value mrb_obj_freeze(mrb_state*, mrb_value);
1083
+ #define mrb_str_new_frozen(mrb,p,len) mrb_obj_freeze(mrb,mrb_str_new(mrb,p,len))
1084
+ #define mrb_str_new_cstr_frozen(mrb,p) mrb_obj_freeze(mrb,mrb_str_new_cstr(mrb,p))
1085
+ #define mrb_str_new_static_frozen(mrb,p,len) mrb_obj_freeze(mrb,mrb_str_new_static(mrb,p,len))
1086
+ #define mrb_str_new_lit_frozen(mrb,lit) mrb_obj_freeze(mrb,mrb_str_new_lit(mrb,lit))
1087
+
999
1088
  #ifdef _WIN32
1000
1089
  MRB_API char* mrb_utf8_from_locale(const char *p, int len);
1001
1090
  MRB_API char* mrb_locale_from_utf8(const char *p, int len);
@@ -1058,11 +1147,11 @@ MRB_API void mrb_close(mrb_state *mrb);
1058
1147
  */
1059
1148
  MRB_API void* mrb_default_allocf(mrb_state*, void*, size_t, void*);
1060
1149
 
1061
- MRB_API mrb_value mrb_top_self(mrb_state *);
1062
- MRB_API mrb_value mrb_run(mrb_state*, struct RProc*, mrb_value);
1063
- MRB_API mrb_value mrb_top_run(mrb_state*, struct RProc*, mrb_value, unsigned int);
1064
- MRB_API mrb_value mrb_vm_run(mrb_state*, struct RProc*, mrb_value, unsigned int);
1065
- MRB_API mrb_value mrb_vm_exec(mrb_state*, struct RProc*, mrb_code*);
1150
+ MRB_API mrb_value mrb_top_self(mrb_state *mrb);
1151
+ MRB_API mrb_value mrb_run(mrb_state *mrb, struct RProc* proc, mrb_value self);
1152
+ MRB_API mrb_value mrb_top_run(mrb_state *mrb, struct RProc *proc, mrb_value self, unsigned int stack_keep);
1153
+ MRB_API mrb_value mrb_vm_run(mrb_state *mrb, struct RProc *proc, mrb_value self, unsigned int stack_keep);
1154
+ MRB_API mrb_value mrb_vm_exec(mrb_state *mrb, struct RProc *proc, const mrb_code *iseq);
1066
1155
  /* compatibility macros */
1067
1156
  #define mrb_toplevel_run_keep(m,p,k) mrb_top_run((m),(p),mrb_top_self(m),(k))
1068
1157
  #define mrb_toplevel_run(m,p) mrb_toplevel_run_keep((m),(p),0)
@@ -1072,8 +1161,8 @@ MRB_API void mrb_p(mrb_state*, mrb_value);
1072
1161
  MRB_API mrb_int mrb_obj_id(mrb_value obj);
1073
1162
  MRB_API mrb_sym mrb_obj_to_sym(mrb_state *mrb, mrb_value name);
1074
1163
 
1075
- MRB_API mrb_bool mrb_obj_eq(mrb_state*, mrb_value, mrb_value);
1076
- MRB_API mrb_bool mrb_obj_equal(mrb_state*, mrb_value, mrb_value);
1164
+ MRB_API mrb_bool mrb_obj_eq(mrb_state *mrb, mrb_value a, mrb_value b);
1165
+ MRB_API mrb_bool mrb_obj_equal(mrb_state *mrb, mrb_value a, mrb_value b);
1077
1166
  MRB_API mrb_bool mrb_equal(mrb_state *mrb, mrb_value obj1, mrb_value obj2);
1078
1167
  MRB_API mrb_value mrb_convert_to_integer(mrb_state *mrb, mrb_value val, mrb_int base);
1079
1168
  MRB_API mrb_value mrb_Integer(mrb_state *mrb, mrb_value val);
@@ -1082,17 +1171,16 @@ MRB_API mrb_value mrb_Float(mrb_state *mrb, mrb_value val);
1082
1171
  #endif
1083
1172
  MRB_API mrb_value mrb_inspect(mrb_state *mrb, mrb_value obj);
1084
1173
  MRB_API mrb_bool mrb_eql(mrb_state *mrb, mrb_value obj1, mrb_value obj2);
1174
+ /* mrb_cmp(mrb, obj1, obj2): 1:0:-1; -2 for error */
1175
+ MRB_API mrb_int mrb_cmp(mrb_state *mrb, mrb_value obj1, mrb_value obj2);
1085
1176
 
1086
- static inline int mrb_gc_arena_save(mrb_state*);
1087
- static inline void mrb_gc_arena_restore(mrb_state*,int);
1088
-
1089
- static inline int
1177
+ MRB_INLINE int
1090
1178
  mrb_gc_arena_save(mrb_state *mrb)
1091
1179
  {
1092
1180
  return mrb->gc.arena_idx;
1093
1181
  }
1094
1182
 
1095
- static inline void
1183
+ MRB_INLINE void
1096
1184
  mrb_gc_arena_restore(mrb_state *mrb, int idx)
1097
1185
  {
1098
1186
  mrb->gc.arena_idx = idx;
@@ -1143,6 +1231,7 @@ MRB_API mrb_noreturn void mrb_exc_raise(mrb_state *mrb, mrb_value exc);
1143
1231
  MRB_API mrb_noreturn void mrb_raise(mrb_state *mrb, struct RClass *c, const char *msg);
1144
1232
  MRB_API mrb_noreturn void mrb_raisef(mrb_state *mrb, struct RClass *c, const char *fmt, ...);
1145
1233
  MRB_API mrb_noreturn void mrb_name_error(mrb_state *mrb, mrb_sym id, const char *fmt, ...);
1234
+ MRB_API mrb_noreturn void mrb_frozen_error(mrb_state *mrb, void *frozen_obj);
1146
1235
  MRB_API void mrb_warn(mrb_state *mrb, const char *fmt, ...);
1147
1236
  MRB_API mrb_noreturn void mrb_bug(mrb_state *mrb, const char *fmt, ...);
1148
1237
  MRB_API void mrb_print_backtrace(mrb_state *mrb);
@@ -1193,9 +1282,15 @@ MRB_API void mrb_gc_unregister(mrb_state *mrb, mrb_value obj);
1193
1282
 
1194
1283
  MRB_API mrb_value mrb_to_int(mrb_state *mrb, mrb_value val);
1195
1284
  #define mrb_int(mrb, val) mrb_fixnum(mrb_to_int(mrb, val))
1285
+ /* string type checking (contrary to the name, it doesn't convert) */
1196
1286
  MRB_API mrb_value mrb_to_str(mrb_state *mrb, mrb_value val);
1197
1287
  MRB_API void mrb_check_type(mrb_state *mrb, mrb_value x, enum mrb_vtype t);
1198
1288
 
1289
+ MRB_INLINE void mrb_check_frozen(mrb_state *mrb, void *o)
1290
+ {
1291
+ if (mrb_frozen_p((struct RBasic*)o)) mrb_frozen_error(mrb, o);
1292
+ }
1293
+
1199
1294
  typedef enum call_type {
1200
1295
  CALL_PUBLIC,
1201
1296
  CALL_FCALL,
@@ -1214,31 +1309,31 @@ MRB_API mrb_bool mrb_obj_is_instance_of(mrb_state *mrb, mrb_value obj, struct RC
1214
1309
  MRB_API mrb_bool mrb_func_basic_p(mrb_state *mrb, mrb_value obj, mrb_sym mid, mrb_func_t func);
1215
1310
 
1216
1311
 
1217
- /*
1312
+ /**
1218
1313
  * Resume a Fiber
1219
1314
  *
1220
- * @mrbgem mruby-fiber
1315
+ * Implemented in mruby-fiber
1221
1316
  */
1222
1317
  MRB_API mrb_value mrb_fiber_resume(mrb_state *mrb, mrb_value fib, mrb_int argc, const mrb_value *argv);
1223
1318
 
1224
- /*
1319
+ /**
1225
1320
  * Yield a Fiber
1226
1321
  *
1227
- * @mrbgem mruby-fiber
1322
+ * Implemented in mruby-fiber
1228
1323
  */
1229
1324
  MRB_API mrb_value mrb_fiber_yield(mrb_state *mrb, mrb_int argc, const mrb_value *argv);
1230
1325
 
1231
- /*
1326
+ /**
1232
1327
  * Check if a Fiber is alive
1233
1328
  *
1234
- * @mrbgem mruby-fiber
1329
+ * Implemented in mruby-fiber
1235
1330
  */
1236
1331
  MRB_API mrb_value mrb_fiber_alive_p(mrb_state *mrb, mrb_value fib);
1237
1332
 
1238
- /*
1333
+ /**
1239
1334
  * FiberError reference
1240
1335
  *
1241
- * @mrbgem mruby-fiber
1336
+ * Implemented in mruby-fiber
1242
1337
  */
1243
1338
  #define E_FIBER_ERROR (mrb_exc_get(mrb, "FiberError"))
1244
1339
  MRB_API void mrb_stack_extend(mrb_state*, mrb_int);
@@ -1250,6 +1345,7 @@ MRB_API void mrb_pool_close(struct mrb_pool*);
1250
1345
  MRB_API void* mrb_pool_alloc(struct mrb_pool*, size_t);
1251
1346
  MRB_API void* mrb_pool_realloc(struct mrb_pool*, void*, size_t oldlen, size_t newlen);
1252
1347
  MRB_API mrb_bool mrb_pool_can_realloc(struct mrb_pool*, void*, size_t);
1348
+ /* temporary memory allocation, only effective while GC arena is kept */
1253
1349
  MRB_API void* mrb_alloca(mrb_state *mrb, size_t);
1254
1350
 
1255
1351
  MRB_API void mrb_state_atexit(mrb_state *mrb, mrb_atexit_func func);