ruby2d 0.11.3 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (221) hide show
  1. checksums.yaml +4 -4
  2. data/assets/include/GLES2/gl2.h +656 -0
  3. data/assets/include/GLES2/gl2ext.h +3949 -0
  4. data/assets/include/GLES2/gl2ext_angle.h +701 -0
  5. data/assets/include/GLES2/gl2platform.h +27 -0
  6. data/assets/include/GLES3/gl3.h +1192 -0
  7. data/assets/include/GLES3/gl31.h +1507 -0
  8. data/assets/include/GLES3/gl32.h +1808 -0
  9. data/assets/include/GLES3/gl3platform.h +27 -0
  10. data/assets/include/KHR/khrplatform.h +290 -0
  11. data/assets/include/SDL2/SDL.h +1 -0
  12. data/assets/include/SDL2/SDL_assert.h +4 -2
  13. data/assets/include/SDL2/SDL_atomic.h +20 -0
  14. data/assets/include/SDL2/SDL_audio.h +40 -4
  15. data/assets/include/SDL2/SDL_blendmode.h +4 -6
  16. data/assets/include/SDL2/SDL_clipboard.h +47 -0
  17. data/assets/include/SDL2/SDL_config.h +6 -2
  18. data/assets/include/SDL2/SDL_config_android.h +2 -0
  19. data/assets/include/SDL2/SDL_config_emscripten.h +2 -0
  20. data/assets/include/SDL2/SDL_config_iphoneos.h +3 -1
  21. data/assets/include/SDL2/SDL_config_macosx.h +3 -6
  22. data/assets/include/SDL2/SDL_config_minimal.h +18 -11
  23. data/assets/include/SDL2/SDL_config_ngage.h +89 -0
  24. data/assets/include/SDL2/SDL_config_os2.h +5 -3
  25. data/assets/include/SDL2/SDL_config_pandora.h +1 -0
  26. data/assets/include/SDL2/SDL_config_windows.h +71 -45
  27. data/assets/include/SDL2/SDL_config_wingdk.h +253 -0
  28. data/assets/include/SDL2/SDL_config_winrt.h +11 -49
  29. data/assets/include/SDL2/SDL_config_xbox.h +235 -0
  30. data/assets/include/SDL2/SDL_cpuinfo.h +39 -4
  31. data/assets/include/SDL2/SDL_egl.h +59 -9
  32. data/assets/include/SDL2/SDL_endian.h +34 -3
  33. data/assets/include/SDL2/SDL_events.h +32 -1
  34. data/assets/include/SDL2/SDL_filesystem.h +5 -1
  35. data/assets/include/SDL2/SDL_gamecontroller.h +78 -5
  36. data/assets/include/SDL2/SDL_guid.h +100 -0
  37. data/assets/include/SDL2/SDL_hints.h +645 -43
  38. data/assets/include/SDL2/SDL_image.h +2045 -33
  39. data/assets/include/SDL2/SDL_joystick.h +127 -7
  40. data/assets/include/SDL2/SDL_keyboard.h +38 -1
  41. data/assets/include/SDL2/SDL_keycode.h +6 -1
  42. data/assets/include/SDL2/SDL_log.h +2 -2
  43. data/assets/include/SDL2/SDL_main.h +42 -2
  44. data/assets/include/SDL2/SDL_metal.h +2 -1
  45. data/assets/include/SDL2/SDL_mixer.h +2529 -396
  46. data/assets/include/SDL2/SDL_mouse.h +12 -1
  47. data/assets/include/SDL2/SDL_opengl.h +0 -51
  48. data/assets/include/SDL2/SDL_opengl_glext.h +2260 -231
  49. data/assets/include/SDL2/SDL_opengles2_gl2.h +374 -339
  50. data/assets/include/SDL2/SDL_opengles2_gl2ext.h +3479 -1496
  51. data/assets/include/SDL2/SDL_opengles2_gl2platform.h +6 -9
  52. data/assets/include/SDL2/SDL_opengles2_khrplatform.h +43 -14
  53. data/assets/include/SDL2/SDL_platform.h +32 -6
  54. data/assets/include/SDL2/SDL_rect.h +154 -2
  55. data/assets/include/SDL2/SDL_render.h +46 -17
  56. data/assets/include/SDL2/SDL_revision.h +4 -0
  57. data/assets/include/SDL2/SDL_rwops.h +1 -15
  58. data/assets/include/SDL2/SDL_scancode.h +46 -21
  59. data/assets/include/SDL2/SDL_sensor.h +24 -3
  60. data/assets/include/SDL2/SDL_stdinc.h +119 -8
  61. data/assets/include/SDL2/SDL_surface.h +3 -1
  62. data/assets/include/SDL2/SDL_system.h +66 -6
  63. data/assets/include/SDL2/SDL_syswm.h +2 -0
  64. data/assets/include/SDL2/SDL_test_common.h +1 -0
  65. data/assets/include/SDL2/SDL_test_font.h +90 -3
  66. data/assets/include/SDL2/SDL_thread.h +3 -3
  67. data/assets/include/SDL2/SDL_touch.h +8 -0
  68. data/assets/include/SDL2/SDL_ttf.h +2084 -155
  69. data/assets/include/SDL2/SDL_version.h +19 -3
  70. data/assets/include/SDL2/SDL_video.h +71 -9
  71. data/assets/include/SDL2/begin_code.h +4 -4
  72. data/assets/include/mrbconf.h +15 -17
  73. data/assets/include/mruby/array.h +8 -21
  74. data/assets/include/mruby/boxing_nan.h +115 -86
  75. data/assets/include/mruby/boxing_word.h +104 -78
  76. data/assets/include/mruby/common.h +6 -0
  77. data/assets/include/mruby/compile.h +3 -4
  78. data/assets/include/mruby/debug.h +4 -2
  79. data/assets/include/mruby/dump.h +5 -2
  80. data/assets/include/mruby/error.h +12 -2
  81. data/assets/include/mruby/gc.h +2 -0
  82. data/assets/include/mruby/hash.h +1 -3
  83. data/assets/include/mruby/irep.h +4 -4
  84. data/assets/include/mruby/numeric.h +21 -13
  85. data/assets/include/mruby/opcode.h +30 -0
  86. data/assets/include/mruby/ops.h +99 -101
  87. data/assets/include/mruby/presym/scanning.h +15 -9
  88. data/assets/include/mruby/proc.h +4 -2
  89. data/assets/include/mruby/string.h +3 -24
  90. data/assets/include/mruby/value.h +80 -40
  91. data/assets/include/mruby/variable.h +0 -15
  92. data/assets/include/mruby/version.h +5 -5
  93. data/assets/include/mruby.h +86 -16
  94. data/assets/macos/universal/bin/mrbc +0 -0
  95. data/assets/macos/universal/lib/libFLAC.a +0 -0
  96. data/assets/macos/universal/lib/libSDL2.a +0 -0
  97. data/assets/macos/universal/lib/libSDL2_image.a +0 -0
  98. data/assets/macos/universal/lib/libSDL2_mixer.a +0 -0
  99. data/assets/macos/universal/lib/libSDL2_ttf.a +0 -0
  100. data/assets/macos/universal/lib/libavif.a +0 -0
  101. data/assets/macos/universal/lib/libbrotlicommon-static.a +0 -0
  102. data/assets/macos/universal/lib/libbrotlidec-static.a +0 -0
  103. data/assets/macos/universal/lib/libfreetype.a +0 -0
  104. data/assets/macos/universal/lib/libgraphite2.a +0 -0
  105. data/assets/macos/universal/lib/libharfbuzz.a +0 -0
  106. data/assets/macos/universal/lib/libhwy.a +0 -0
  107. data/assets/macos/universal/lib/libjpeg.a +0 -0
  108. data/assets/macos/universal/lib/libjxl.a +0 -0
  109. data/assets/macos/universal/lib/libmodplug.a +0 -0
  110. data/assets/macos/universal/lib/libmpg123.a +0 -0
  111. data/assets/macos/universal/lib/libmruby.a +0 -0
  112. data/assets/macos/universal/lib/libogg.a +0 -0
  113. data/assets/macos/universal/lib/libpng.a +0 -0
  114. data/assets/macos/universal/lib/libtiff.a +0 -0
  115. data/assets/macos/universal/lib/libvorbis.a +0 -0
  116. data/assets/macos/universal/lib/libvorbisfile.a +0 -0
  117. data/assets/macos/universal/lib/libwebp.a +0 -0
  118. data/assets/macos/universal/lib/libzstd.a +0 -0
  119. data/assets/wasm/template.html +2 -1
  120. data/assets/windows/mingw-w64-ucrt-x86_64/bin/mrbc.exe +0 -0
  121. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libFLAC.a +0 -0
  122. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libLerc.a +0 -0
  123. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2.a +0 -0
  124. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2_image.a +0 -0
  125. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2_mixer.a +0 -0
  126. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2_ttf.a +0 -0
  127. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libbrotlicommon.a +0 -0
  128. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libbrotlidec.a +0 -0
  129. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libdeflate.a +0 -0
  130. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libfreetype.a +0 -0
  131. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libglew32.a +0 -0
  132. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libharfbuzz.a +0 -0
  133. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libhwy.a +0 -0
  134. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libjpeg.a +0 -0
  135. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libjxl.a +0 -0
  136. data/assets/windows/mingw-w64-ucrt-x86_64/lib/liblzma.a +0 -0
  137. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libmpg123.a +0 -0
  138. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libmruby.a +0 -0
  139. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libopus.a +0 -0
  140. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libpng.a +0 -0
  141. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libsndfile.a +0 -0
  142. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libssp.a +0 -0
  143. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libstdc++.a +0 -0
  144. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libtiff.a +0 -0
  145. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libwebp.a +0 -0
  146. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libz.a +0 -0
  147. data/assets/windows/mingw-w64-x86_64/bin/mrbc.exe +0 -0
  148. data/assets/windows/mingw-w64-x86_64/lib/libFLAC.a +0 -0
  149. data/assets/windows/mingw-w64-x86_64/lib/libLerc.a +0 -0
  150. data/assets/windows/mingw-w64-x86_64/lib/libSDL2.a +0 -0
  151. data/assets/windows/mingw-w64-x86_64/lib/libSDL2_image.a +0 -0
  152. data/assets/windows/mingw-w64-x86_64/lib/libSDL2_mixer.a +0 -0
  153. data/assets/windows/mingw-w64-x86_64/lib/libSDL2_ttf.a +0 -0
  154. data/assets/windows/mingw-w64-x86_64/lib/libbrotlicommon.a +0 -0
  155. data/assets/windows/mingw-w64-x86_64/lib/libbrotlidec.a +0 -0
  156. data/assets/windows/mingw-w64-x86_64/lib/libdeflate.a +0 -0
  157. data/assets/windows/mingw-w64-x86_64/lib/libfreetype.a +0 -0
  158. data/assets/windows/mingw-w64-x86_64/lib/libglew32.a +0 -0
  159. data/assets/windows/mingw-w64-x86_64/lib/libharfbuzz.a +0 -0
  160. data/assets/windows/mingw-w64-x86_64/lib/libhwy.a +0 -0
  161. data/assets/windows/mingw-w64-x86_64/lib/libjpeg.a +0 -0
  162. data/assets/windows/mingw-w64-x86_64/lib/libjxl.a +0 -0
  163. data/assets/windows/mingw-w64-x86_64/lib/liblzma.a +0 -0
  164. data/assets/windows/mingw-w64-x86_64/lib/libmpg123.a +0 -0
  165. data/assets/windows/mingw-w64-x86_64/lib/libmruby.a +0 -0
  166. data/assets/windows/mingw-w64-x86_64/lib/libopus.a +0 -0
  167. data/assets/windows/mingw-w64-x86_64/lib/libpng.a +0 -0
  168. data/assets/windows/mingw-w64-x86_64/lib/libsndfile.a +0 -0
  169. data/assets/windows/mingw-w64-x86_64/lib/libssp.a +0 -0
  170. data/assets/windows/mingw-w64-x86_64/lib/libstdc++.a +0 -0
  171. data/assets/windows/mingw-w64-x86_64/lib/libtiff.a +0 -0
  172. data/assets/windows/mingw-w64-x86_64/lib/libwebp.a +0 -0
  173. data/assets/windows/mingw-w64-x86_64/lib/libz.a +0 -0
  174. data/assets/windows/mingw-w64-x86_64/lib/libzstd.a +0 -0
  175. data/ext/ruby2d/canvas.c +540 -0
  176. data/ext/ruby2d/extconf.rb +33 -20
  177. data/ext/ruby2d/gl.c +3 -3
  178. data/ext/ruby2d/image.c +7 -7
  179. data/ext/ruby2d/ruby2d.c +741 -24
  180. data/ext/ruby2d/ruby2d.h +66 -3
  181. data/ext/ruby2d/sound.c +16 -2
  182. data/lib/ruby2d/canvas.rb +315 -0
  183. data/lib/ruby2d/circle.rb +30 -15
  184. data/lib/ruby2d/cli/build.rb +5 -3
  185. data/lib/ruby2d/cli/enable_console.rb +3 -1
  186. data/lib/ruby2d/color.rb +133 -77
  187. data/lib/ruby2d/core.rb +32 -0
  188. data/lib/ruby2d/dsl.rb +38 -32
  189. data/lib/ruby2d/exceptions.rb +2 -1
  190. data/lib/ruby2d/font.rb +97 -62
  191. data/lib/ruby2d/image.rb +48 -27
  192. data/lib/ruby2d/line.rb +84 -45
  193. data/lib/ruby2d/music.rb +33 -23
  194. data/lib/ruby2d/pixel.rb +10 -9
  195. data/lib/ruby2d/pixmap.rb +39 -0
  196. data/lib/ruby2d/pixmap_atlas.rb +56 -0
  197. data/lib/ruby2d/quad.rb +98 -49
  198. data/lib/ruby2d/rectangle.rb +35 -36
  199. data/lib/ruby2d/renderable.rb +7 -6
  200. data/lib/ruby2d/sound.rb +23 -17
  201. data/lib/ruby2d/sprite.rb +181 -140
  202. data/lib/ruby2d/square.rb +21 -20
  203. data/lib/ruby2d/text.rb +47 -19
  204. data/lib/ruby2d/texture.rb +13 -3
  205. data/lib/ruby2d/tileset.rb +97 -44
  206. data/lib/ruby2d/triangle.rb +91 -42
  207. data/lib/ruby2d/version.rb +3 -1
  208. data/lib/ruby2d/vertices.rb +81 -45
  209. data/lib/ruby2d/window.rb +508 -371
  210. data/lib/ruby2d.rb +11 -29
  211. metadata +51 -16
  212. data/assets/include/SDL2/SDL_config_psp.h +0 -165
  213. data/assets/include/SDL2/SDL_config_wiz.h +0 -154
  214. data/assets/include/glew.h +0 -23686
  215. data/assets/macos/universal/lib/libpng16.a +0 -0
  216. data/assets/windows/glew/README.md +0 -10
  217. data/assets/windows/glew/glew.h +0 -23686
  218. data/assets/windows/glew/libglew32.a +0 -0
  219. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libpng16.a +0 -0
  220. data/assets/windows/mingw-w64-x86_64/lib/libpng16.a +0 -0
  221. data/lib/ruby2d/entity.rb +0 -17
@@ -13,110 +13,108 @@
13
13
  operation code operands semantics
14
14
  ------------------------------------------------------------------------*/
15
15
  OPCODE(NOP, Z) /* no operation */
16
- OPCODE(MOVE, BB) /* R(a) = R(b) */
17
- OPCODE(LOADL, BB) /* R(a) = Pool(b) */
18
- OPCODE(LOADL16, BS) /* R(a) = Pool(b) */
19
- OPCODE(LOADI, BB) /* R(a) = mrb_int(b) */
20
- OPCODE(LOADINEG, BB) /* R(a) = mrb_int(-b) */
21
- OPCODE(LOADI__1, B) /* R(a) = mrb_int(-1) */
22
- OPCODE(LOADI_0, B) /* R(a) = mrb_int(0) */
23
- OPCODE(LOADI_1, B) /* R(a) = mrb_int(1) */
24
- OPCODE(LOADI_2, B) /* R(a) = mrb_int(2) */
25
- OPCODE(LOADI_3, B) /* R(a) = mrb_int(3) */
26
- OPCODE(LOADI_4, B) /* R(a) = mrb_int(4) */
27
- OPCODE(LOADI_5, B) /* R(a) = mrb_int(5) */
28
- OPCODE(LOADI_6, B) /* R(a) = mrb_int(6) */
29
- OPCODE(LOADI_7, B) /* R(a) = mrb_int(7) */
30
- OPCODE(LOADI16, BS) /* R(a) = mrb_int(b) */
31
- OPCODE(LOADI32, BSS) /* R(a) = mrb_int((b<<16)+c) */
32
- OPCODE(LOADSYM, BB) /* R(a) = Syms(b) */
33
- OPCODE(LOADSYM16, BS) /* R(a) = Syms(b) */
34
- OPCODE(LOADNIL, B) /* R(a) = nil */
35
- OPCODE(LOADSELF, B) /* R(a) = self */
36
- OPCODE(LOADT, B) /* R(a) = true */
37
- OPCODE(LOADF, B) /* R(a) = false */
38
- OPCODE(GETGV, BB) /* R(a) = getglobal(Syms(b)) */
39
- OPCODE(SETGV, BB) /* setglobal(Syms(b), R(a)) */
40
- OPCODE(GETSV, BB) /* R(a) = Special[Syms(b)] */
41
- OPCODE(SETSV, BB) /* Special[Syms(b)] = R(a) */
42
- OPCODE(GETIV, BB) /* R(a) = ivget(Syms(b)) */
43
- OPCODE(SETIV, BB) /* ivset(Syms(b),R(a)) */
44
- OPCODE(GETCV, BB) /* R(a) = cvget(Syms(b)) */
45
- OPCODE(SETCV, BB) /* cvset(Syms(b),R(a)) */
46
- OPCODE(GETCONST, BB) /* R(a) = constget(Syms(b)) */
47
- OPCODE(SETCONST, BB) /* constset(Syms(b),R(a)) */
48
- OPCODE(GETMCNST, BB) /* R(a) = R(a)::Syms(b) */
49
- OPCODE(SETMCNST, BB) /* R(a+1)::Syms(b) = R(a) */
50
- OPCODE(GETUPVAR, BBB) /* R(a) = uvget(b,c) */
51
- OPCODE(SETUPVAR, BBB) /* uvset(b,c,R(a)) */
16
+ OPCODE(MOVE, BB) /* R[a] = R[b] */
17
+ OPCODE(LOADL, BB) /* R[a] = Pool[b] */
18
+ OPCODE(LOADI, BB) /* R[a] = mrb_int(b) */
19
+ OPCODE(LOADINEG, BB) /* R[a] = mrb_int(-b) */
20
+ OPCODE(LOADI__1, B) /* R[a] = mrb_int(-1) */
21
+ OPCODE(LOADI_0, B) /* R[a] = mrb_int(0) */
22
+ OPCODE(LOADI_1, B) /* R[a] = mrb_int(1) */
23
+ OPCODE(LOADI_2, B) /* R[a] = mrb_int(2) */
24
+ OPCODE(LOADI_3, B) /* R[a] = mrb_int(3) */
25
+ OPCODE(LOADI_4, B) /* R[a] = mrb_int(4) */
26
+ OPCODE(LOADI_5, B) /* R[a] = mrb_int(5) */
27
+ OPCODE(LOADI_6, B) /* R[a] = mrb_int(6) */
28
+ OPCODE(LOADI_7, B) /* R[a] = mrb_int(7) */
29
+ OPCODE(LOADI16, BS) /* R[a] = mrb_int(b) */
30
+ OPCODE(LOADI32, BSS) /* R[a] = mrb_int((b<<16)+c) */
31
+ OPCODE(LOADSYM, BB) /* R[a] = Syms[b] */
32
+ OPCODE(LOADNIL, B) /* R[a] = nil */
33
+ OPCODE(LOADSELF, B) /* R[a] = self */
34
+ OPCODE(LOADT, B) /* R[a] = true */
35
+ OPCODE(LOADF, B) /* R[a] = false */
36
+ OPCODE(GETGV, BB) /* R[a] = getglobal(Syms[b]) */
37
+ OPCODE(SETGV, BB) /* setglobal(Syms[b], R[a]) */
38
+ OPCODE(GETSV, BB) /* R[a] = Special[Syms[b]] */
39
+ OPCODE(SETSV, BB) /* Special[Syms[b]] = R[a] */
40
+ OPCODE(GETIV, BB) /* R[a] = ivget(Syms[b]) */
41
+ OPCODE(SETIV, BB) /* ivset(Syms[b],R[a]) */
42
+ OPCODE(GETCV, BB) /* R[a] = cvget(Syms[b]) */
43
+ OPCODE(SETCV, BB) /* cvset(Syms[b],R[a]) */
44
+ OPCODE(GETCONST, BB) /* R[a] = constget(Syms[b]) */
45
+ OPCODE(SETCONST, BB) /* constset(Syms[b],R[a]) */
46
+ OPCODE(GETMCNST, BB) /* R[a] = R[a]::Syms[b] */
47
+ OPCODE(SETMCNST, BB) /* R[a+1]::Syms[b] = R[a] */
48
+ OPCODE(GETUPVAR, BBB) /* R[a] = uvget(b,c) */
49
+ OPCODE(SETUPVAR, BBB) /* uvset(b,c,R[a]) */
50
+ OPCODE(GETIDX, B) /* R[a] = R[a][R[a+1]] */
51
+ OPCODE(SETIDX, B) /* R[a][R[a+1]] = R[a+2] */
52
52
  OPCODE(JMP, S) /* pc+=a */
53
- OPCODE(JMPIF, BS) /* if R(a) pc+=b */
54
- OPCODE(JMPNOT, BS) /* if !R(a) pc+=b */
55
- OPCODE(JMPNIL, BS) /* if R(a)==nil pc+=b */
53
+ OPCODE(JMPIF, BS) /* if R[a] pc+=b */
54
+ OPCODE(JMPNOT, BS) /* if !R[a] pc+=b */
55
+ OPCODE(JMPNIL, BS) /* if R[a]==nil pc+=b */
56
56
  OPCODE(JMPUW, S) /* unwind_and_jump_to(a) */
57
- OPCODE(EXCEPT, B) /* R(a) = exc */
58
- OPCODE(RESCUE, BB) /* R(b) = R(a).isa?(R(b)) */
59
- OPCODE(RAISEIF, B) /* raise(R(a)) if R(a) */
60
- OPCODE(SENDV, BB) /* R(a) = call(R(a),Syms(b),*R(a+1)) */
61
- OPCODE(SENDVB, BB) /* R(a) = call(R(a),Syms(b),*R(a+1),&R(a+2)) */
62
- OPCODE(SEND, BBB) /* R(a) = call(R(a),Syms(b),R(a+1),...,R(a+c)) */
63
- OPCODE(SENDB, BBB) /* R(a) = call(R(a),Syms(b),R(a+1),...,R(a+c),&R(a+c+1)) */
64
- OPCODE(SENDVK, BB) /* R(a) = call(R(a),Syms(b),*R(a+1),**(a+2),&R(a+3)) # todo */
65
- OPCODE(CALL, Z) /* R(0) = self.call(frame.argc, frame.argv) */
66
- OPCODE(SUPER, BB) /* R(a) = super(R(a+1),... ,R(a+b+1)) */
67
- OPCODE(ARGARY, BS) /* R(a) = argument array (16=m5:r1:m5:d1:lv4) */
57
+ OPCODE(EXCEPT, B) /* R[a] = exc */
58
+ OPCODE(RESCUE, BB) /* R[b] = R[a].isa?(R[b]) */
59
+ OPCODE(RAISEIF, B) /* raise(R[a]) if R[a] */
60
+ OPCODE(SSEND, BBB) /* R[a] = self.send(Syms[b],R[a+1]..,R[a+n+1]:R[a+n+2]..) (c=n|k<<4) */
61
+ OPCODE(SSENDB, BBB) /* R[a] = self.send(Syms[b],R[a+1]..,R[a+n+1]:R[a+n+2]..,&R[a+n+2k+1]) */
62
+ OPCODE(SEND, BBB) /* R[a] = R[a].send(Syms[b],R[a+1]..,R[a+n+1]:R[a+n+2]..) (c=n|k<<4) */
63
+ OPCODE(SENDB, BBB) /* R[a] = R[a].send(Syms[b],R[a+1]..,R[a+n+1]:R[a+n+2]..,&R[a+n+2k+1]) */
64
+ OPCODE(CALL, Z) /* R[0] = self.call(frame.argc, frame.argv) */
65
+ OPCODE(SUPER, BB) /* R[a] = super(R[a+1],... ,R[a+b+1]) */
66
+ OPCODE(ARGARY, BS) /* R[a] = argument array (16=m5:r1:m5:d1:lv4) */
68
67
  OPCODE(ENTER, W) /* arg setup according to flags (23=m5:o5:r1:m5:k5:d1:b1) */
69
- OPCODE(KEY_P, BB) /* R(a) = kdict.key?(Syms(b)) */
68
+ OPCODE(KEY_P, BB) /* R[a] = kdict.key?(Syms[b]) */
70
69
  OPCODE(KEYEND, Z) /* raise unless kdict.empty? */
71
- OPCODE(KARG, BB) /* R(a) = kdict[Syms(b)]; kdict.delete(Syms(b)) */
72
- OPCODE(RETURN, B) /* return R(a) (normal) */
73
- OPCODE(RETURN_BLK, B) /* return R(a) (in-block return) */
74
- OPCODE(BREAK, B) /* break R(a) */
75
- OPCODE(BLKPUSH, BS) /* R(a) = block (16=m5:r1:m5:d1:lv4) */
76
- OPCODE(ADD, B) /* R(a) = R(a)+R(a+1) */
77
- OPCODE(ADDI, BB) /* R(a) = R(a)+mrb_int(b) */
78
- OPCODE(SUB, B) /* R(a) = R(a)-R(a+1) */
79
- OPCODE(SUBI, BB) /* R(a) = R(a)-mrb_int(b) */
80
- OPCODE(MUL, B) /* R(a) = R(a)*R(a+1) */
81
- OPCODE(DIV, B) /* R(a) = R(a)/R(a+1) */
82
- OPCODE(EQ, B) /* R(a) = R(a)==R(a+1) */
83
- OPCODE(LT, B) /* R(a) = R(a)<R(a+1) */
84
- OPCODE(LE, B) /* R(a) = R(a)<=R(a+1) */
85
- OPCODE(GT, B) /* R(a) = R(a)>R(a+1) */
86
- OPCODE(GE, B) /* R(a) = R(a)>=R(a+1) */
87
- OPCODE(ARRAY, BB) /* R(a) = ary_new(R(a),R(a+1)..R(a+b)) */
88
- OPCODE(ARRAY2, BBB) /* R(a) = ary_new(R(b),R(b+1)..R(b+c)) */
89
- OPCODE(ARYCAT, B) /* ary_cat(R(a),R(a+1)) */
90
- OPCODE(ARYPUSH, B) /* ary_push(R(a),R(a+1)) */
91
- OPCODE(ARYDUP, B) /* R(a) = ary_dup(R(a)) */
92
- OPCODE(AREF, BBB) /* R(a) = R(b)[c] */
93
- OPCODE(ASET, BBB) /* R(a)[c] = R(b) */
94
- OPCODE(APOST, BBB) /* *R(a),R(a+1)..R(a+c) = R(a)[b..] */
95
- OPCODE(INTERN, B) /* R(a) = intern(R(a)) */
96
- OPCODE(STRING, BB) /* R(a) = str_dup(Lit(b)) */
97
- OPCODE(STRING16, BS) /* R(a) = str_dup(Lit(b)) */
98
- OPCODE(STRCAT, B) /* str_cat(R(a),R(a+1)) */
99
- OPCODE(HASH, BB) /* R(a) = hash_new(R(a),R(a+1)..R(a+b*2-1)) */
100
- OPCODE(HASHADD, BB) /* R(a) = hash_push(R(a),R(a+1)..R(a+b*2)) */
101
- OPCODE(HASHCAT, B) /* R(a) = hash_cat(R(a),R(a+1)) */
102
- OPCODE(LAMBDA, BB) /* R(a) = lambda(SEQ[b],L_LAMBDA) */
103
- OPCODE(LAMBDA16, BS) /* R(a) = lambda(SEQ[b],L_LAMBDA) */
104
- OPCODE(BLOCK, BB) /* R(a) = lambda(SEQ[b],L_BLOCK) */
105
- OPCODE(BLOCK16, BS) /* R(a) = lambda(SEQ[b],L_BLOCK) */
106
- OPCODE(METHOD, BB) /* R(a) = lambda(SEQ[b],L_METHOD) */
107
- OPCODE(METHOD16, BS) /* R(a) = lambda(SEQ[b],L_METHOD) */
108
- OPCODE(RANGE_INC, B) /* R(a) = range_new(R(a),R(a+1),FALSE) */
109
- OPCODE(RANGE_EXC, B) /* R(a) = range_new(R(a),R(a+1),TRUE) */
110
- OPCODE(OCLASS, B) /* R(a) = ::Object */
111
- OPCODE(CLASS, BB) /* R(a) = newclass(R(a),Syms(b),R(a+1)) */
112
- OPCODE(MODULE, BB) /* R(a) = newmodule(R(a),Syms(b)) */
113
- OPCODE(EXEC, BB) /* R(a) = blockexec(R(a),SEQ[b]) */
114
- OPCODE(EXEC16, BS) /* R(a) = blockexec(R(a),SEQ[b]) */
115
- OPCODE(DEF, BB) /* R(a).newmethod(Syms(b),R(a+1)) */
116
- OPCODE(ALIAS, BB) /* alias_method(target_class,Syms(a),Syms(b)) */
117
- OPCODE(UNDEF, B) /* undef_method(target_class,Syms(a)) */
118
- OPCODE(SCLASS, B) /* R(a) = R(a).singleton_class */
119
- OPCODE(TCLASS, B) /* R(a) = target_class */
70
+ OPCODE(KARG, BB) /* R[a] = kdict[Syms[b]]; kdict.delete(Syms[b]) */
71
+ OPCODE(RETURN, B) /* return R[a] (normal) */
72
+ OPCODE(RETURN_BLK, B) /* return R[a] (in-block return) */
73
+ OPCODE(BREAK, B) /* break R[a] */
74
+ OPCODE(BLKPUSH, BS) /* R[a] = block (16=m5:r1:m5:d1:lv4) */
75
+ OPCODE(ADD, B) /* R[a] = R[a]+R[a+1] */
76
+ OPCODE(ADDI, BB) /* R[a] = R[a]+mrb_int(b) */
77
+ OPCODE(SUB, B) /* R[a] = R[a]-R[a+1] */
78
+ OPCODE(SUBI, BB) /* R[a] = R[a]-mrb_int(b) */
79
+ OPCODE(MUL, B) /* R[a] = R[a]*R[a+1] */
80
+ OPCODE(DIV, B) /* R[a] = R[a]/R[a+1] */
81
+ OPCODE(EQ, B) /* R[a] = R[a]==R[a+1] */
82
+ OPCODE(LT, B) /* R[a] = R[a]<R[a+1] */
83
+ OPCODE(LE, B) /* R[a] = R[a]<=R[a+1] */
84
+ OPCODE(GT, B) /* R[a] = R[a]>R[a+1] */
85
+ OPCODE(GE, B) /* R[a] = R[a]>=R[a+1] */
86
+ OPCODE(ARRAY, BB) /* R[a] = ary_new(R[a],R[a+1]..R[a+b]) */
87
+ OPCODE(ARRAY2, BBB) /* R[a] = ary_new(R[b],R[b+1]..R[b+c]) */
88
+ OPCODE(ARYCAT, B) /* ary_cat(R[a],R[a+1]) */
89
+ OPCODE(ARYPUSH, BB) /* ary_push(R[a],R[a+1]..R[a+b]) */
90
+ OPCODE(ARYDUP, B) /* R[a] = ary_dup(R[a]) */
91
+ OPCODE(AREF, BBB) /* R[a] = R[b][c] */
92
+ OPCODE(ASET, BBB) /* R[b][c] = R[a] */
93
+ OPCODE(APOST, BBB) /* *R[a],R[a+1]..R[a+c] = R[a][b..] */
94
+ OPCODE(INTERN, B) /* R[a] = intern(R[a]) */
95
+ OPCODE(SYMBOL, BB) /* R[a] = intern(Pool[b]) */
96
+ OPCODE(STRING, BB) /* R[a] = str_dup(Pool[b]) */
97
+ OPCODE(STRCAT, B) /* str_cat(R[a],R[a+1]) */
98
+ OPCODE(HASH, BB) /* R[a] = hash_new(R[a],R[a+1]..R[a+b*2-1]) */
99
+ OPCODE(HASHADD, BB) /* hash_push(R[a],R[a+1]..R[a+b*2]) */
100
+ OPCODE(HASHCAT, B) /* R[a] = hash_cat(R[a],R[a+1]) */
101
+ OPCODE(LAMBDA, BB) /* R[a] = lambda(Irep[b],L_LAMBDA) */
102
+ OPCODE(BLOCK, BB) /* R[a] = lambda(Irep[b],L_BLOCK) */
103
+ OPCODE(METHOD, BB) /* R[a] = lambda(Irep[b],L_METHOD) */
104
+ OPCODE(RANGE_INC, B) /* R[a] = range_new(R[a],R[a+1],FALSE) */
105
+ OPCODE(RANGE_EXC, B) /* R[a] = range_new(R[a],R[a+1],TRUE) */
106
+ OPCODE(OCLASS, B) /* R[a] = ::Object */
107
+ OPCODE(CLASS, BB) /* R[a] = newclass(R[a],Syms[b],R[a+1]) */
108
+ OPCODE(MODULE, BB) /* R[a] = newmodule(R[a],Syms[b]) */
109
+ OPCODE(EXEC, BB) /* R[a] = blockexec(R[a],Irep[b]) */
110
+ OPCODE(DEF, BB) /* R[a].newmethod(Syms[b],R[a+1]); R[a] = Syms[b] */
111
+ OPCODE(ALIAS, BB) /* alias_method(target_class,Syms[a],Syms[b]) */
112
+ OPCODE(UNDEF, B) /* undef_method(target_class,Syms[a]) */
113
+ OPCODE(SCLASS, B) /* R[a] = R[a].singleton_class */
114
+ OPCODE(TCLASS, B) /* R[a] = target_class */
120
115
  OPCODE(DEBUG, BBB) /* print a,b,c */
121
- OPCODE(ERR, B) /* raise(LocalJumpError, Lit(a)) */
116
+ OPCODE(ERR, B) /* raise(LocalJumpError, Pool[a]) */
117
+ OPCODE(EXT1, Z) /* make 1st operand (a) 16bit */
118
+ OPCODE(EXT2, Z) /* make 2nd operand (b) 16bit */
119
+ OPCODE(EXT3, Z) /* make 1st and 2nd operands 16bit */
122
120
  OPCODE(STOP, Z) /* stop VM */
@@ -12,16 +12,22 @@
12
12
  #undef mrb_intern_lit
13
13
  #define mrb_intern_lit(mrb, name) MRB_PRESYM_SCANNING_TAGGED(name)
14
14
  #define mrb_intern_cstr(mrb, name) MRB_PRESYM_SCANNING_TAGGED(name)
15
- #define mrb_define_method(mrb, c, name, f, a) MRB_PRESYM_SCANNING_TAGGED(name)
16
- #define mrb_define_class_method(mrb, c, name, f, a) MRB_PRESYM_SCANNING_TAGGED(name)
17
- #define mrb_define_singleton_method(mrb, c, name, f, a) MRB_PRESYM_SCANNING_TAGGED(name)
18
- #define mrb_define_class(mrb, name, s) MRB_PRESYM_SCANNING_TAGGED(name)
19
- #define mrb_define_class_under(mrb, o, name, s) MRB_PRESYM_SCANNING_TAGGED(name)
15
+ #define mrb_define_method(mrb, c, name, ...) MRB_PRESYM_SCANNING_TAGGED(name) (c) (__VA_ARGS__)
16
+ #define mrb_define_class_method(mrb, c, name, ...) MRB_PRESYM_SCANNING_TAGGED(name) (c) (__VA_ARGS__)
17
+ #define mrb_define_singleton_method(mrb, c, name, ...) MRB_PRESYM_SCANNING_TAGGED(name) (c) (__VA_ARGS__)
18
+ #define mrb_define_class(mrb, name, s) MRB_PRESYM_SCANNING_TAGGED(name) (s)
19
+ #define mrb_define_class_under(mrb, o, name, s) MRB_PRESYM_SCANNING_TAGGED(name) (o) (s)
20
20
  #define mrb_define_module(mrb, name) MRB_PRESYM_SCANNING_TAGGED(name)
21
- #define mrb_define_module_under(mrb, o, name) MRB_PRESYM_SCANNING_TAGGED(name)
22
- #define mrb_define_module_function(mrb, c, name, f, s) MRB_PRESYM_SCANNING_TAGGED(name)
23
- #define mrb_define_const(mrb, c, name, v) MRB_PRESYM_SCANNING_TAGGED(name)
24
- #define mrb_define_global_const(mrb, name, v) MRB_PRESYM_SCANNING_TAGGED(name)
21
+ #define mrb_define_module_under(mrb, o, name) MRB_PRESYM_SCANNING_TAGGED(name) (o)
22
+ #define mrb_define_module_function(mrb, c, name, ...) MRB_PRESYM_SCANNING_TAGGED(name) (c) (__VA_ARGS__)
23
+ #define mrb_define_const(mrb, c, name, v) MRB_PRESYM_SCANNING_TAGGED(name) (c) (v)
24
+ #define mrb_define_global_const(mrb, name, v) MRB_PRESYM_SCANNING_TAGGED(name) (v)
25
+ #define mrb_define_alias(mrb, c, a, b) MRB_PRESYM_SCANNING_TAGGED(a) MRB_PRESYM_SCANNING_TAGGED(b) (c)
26
+ #define mrb_class_get(mrb, name) MRB_PRESYM_SCANNING_TAGGED(name)
27
+ #define mrb_class_get_under(mrb, outer, name) MRB_PRESYM_SCANNING_TAGGED(name) (outer)
28
+ #define mrb_module_get(mrb, name) MRB_PRESYM_SCANNING_TAGGED(name)
29
+ #define mrb_module_get_under(mrb, outer, name) MRB_PRESYM_SCANNING_TAGGED(name) (outer)
30
+ #define mrb_funcall(mrb, v, name, ...) MRB_PRESYM_SCANNING_TAGGED(name) (v) (__VA_ARGS__)
25
31
 
26
32
  #define MRB_OPSYM(name) MRB_OPSYM__##name(mrb)
27
33
  #define MRB_CVSYM(name) MRB_PRESYM_SCANNING_TAGGED("@@" #name)
@@ -83,6 +83,8 @@ struct RProc {
83
83
  } while (0)
84
84
  #define MRB_PROC_SCOPE 2048
85
85
  #define MRB_PROC_SCOPE_P(p) (((p)->flags & MRB_PROC_SCOPE) != 0)
86
+ #define MRB_PROC_NOARG 4096 /* for MRB_PROC_CFUNC_FL, it would be something like MRB_ARGS_NONE() or MRB_METHOD_NOARG_FL */
87
+ #define MRB_PROC_NOARG_P(p) (((p)->flags & MRB_PROC_NOARG) != 0)
86
88
 
87
89
  #define mrb_proc_ptr(v) ((struct RProc*)(mrb_ptr(v)))
88
90
 
@@ -90,7 +92,7 @@ struct RProc *mrb_proc_new(mrb_state*, const mrb_irep*);
90
92
  struct RProc *mrb_closure_new(mrb_state*, const mrb_irep*);
91
93
  MRB_API struct RProc *mrb_proc_new_cfunc(mrb_state*, mrb_func_t);
92
94
  MRB_API struct RProc *mrb_closure_new_cfunc(mrb_state *mrb, mrb_func_t func, int nlocals);
93
- void mrb_proc_copy(struct RProc *a, struct RProc *b);
95
+ void mrb_proc_copy(mrb_state *mrb, struct RProc *a, struct RProc *b);
94
96
  mrb_int mrb_proc_arity(const struct RProc *p);
95
97
 
96
98
  /* following functions are defined in mruby-proc-ext so please include it when using */
@@ -121,7 +123,7 @@ MRB_API mrb_value mrb_proc_cfunc_env_get(mrb_state *mrb, mrb_int idx);
121
123
  #define MRB_METHOD_FUNC(m) ((m).func)
122
124
  #define MRB_METHOD_NOARG_SET(m) do{(m).flags|=MRB_METHOD_NOARG_FL;}while(0)
123
125
  #define MRB_METHOD_FROM_FUNC(m,fn) do{(m).flags=MRB_METHOD_FUNC_FL;(m).func=(fn);}while(0)
124
- #define MRB_METHOD_FROM_PROC(m,pr) do{(m).flags=0;(m).proc=(pr);}while(0)
126
+ #define MRB_METHOD_FROM_PROC(m,pr) do{(m).flags=0;(m).proc=(struct RProc*)(pr);}while(0)
125
127
  #define MRB_METHOD_PROC_P(m) (!MRB_METHOD_FUNC_P(m))
126
128
  #define MRB_METHOD_PROC(m) ((m).proc)
127
129
  #define MRB_METHOD_UNDEF_P(m) ((m).proc==NULL)
@@ -324,20 +324,6 @@ MRB_API mrb_value mrb_str_resize(mrb_state *mrb, mrb_value str, mrb_int len);
324
324
  */
325
325
  MRB_API mrb_value mrb_str_substr(mrb_state *mrb, mrb_value str, mrb_int beg, mrb_int len);
326
326
 
327
- /**
328
- * Returns a Ruby string type.
329
- *
330
- *
331
- * @param mrb The current mruby state.
332
- * @param str Ruby string.
333
- * @return [mrb_value] A Ruby string.
334
- */
335
- MRB_API mrb_value mrb_ensure_string_type(mrb_state *mrb, mrb_value str);
336
- MRB_API mrb_value mrb_check_string_type(mrb_state *mrb, mrb_value str);
337
- /* obsolete: use mrb_ensure_string_type() instead */
338
- MRB_API mrb_value mrb_string_type(mrb_state *mrb, mrb_value str);
339
-
340
-
341
327
  MRB_API mrb_value mrb_str_new_capa(mrb_state *mrb, size_t capa);
342
328
  #define mrb_str_buf_new(mrb, capa) mrb_str_new_capa(mrb, (capa))
343
329
 
@@ -369,17 +355,10 @@ MRB_API mrb_value mrb_str_dup(mrb_state *mrb, mrb_value str);
369
355
  */
370
356
  MRB_API mrb_value mrb_str_intern(mrb_state *mrb, mrb_value self);
371
357
 
372
- MRB_API mrb_value mrb_str_to_inum(mrb_state *mrb, mrb_value str, mrb_int base, mrb_bool badcheck);
373
- MRB_API mrb_value mrb_cstr_to_inum(mrb_state *mrb, const char *s, mrb_int base, mrb_bool badcheck);
358
+ MRB_API mrb_value mrb_str_to_integer(mrb_state *mrb, mrb_value str, mrb_int base, mrb_bool badcheck);
359
+ /* obsolete: use mrb_str_to_integer() */
360
+ #define mrb_str_to_inum(mrb, str, base, badcheck) mrb_str_to_integer(mrb, str, base, badcheck)
374
361
  MRB_API double mrb_str_to_dbl(mrb_state *mrb, mrb_value str, mrb_bool badcheck);
375
- MRB_API double mrb_cstr_to_dbl(mrb_state *mrb, const char *s, mrb_bool badcheck);
376
-
377
- /**
378
- * Returns a converted string type.
379
- * For type checking, non converting `mrb_to_str` is recommended.
380
- * obsolete: use `mrb_obj_as_string()` instead.
381
- */
382
- #define mrb_str_to_str(mrb, str) mrb_obj_as_string(mrb, str)
383
362
 
384
363
  /**
385
364
  * Returns true if the strings match and false if the strings don't match.
@@ -31,7 +31,30 @@ typedef uint32_t mrb_sym;
31
31
  * Not to be confused with Ruby's boolean classes, which can be
32
32
  * obtained using mrb_false_value() and mrb_true_value()
33
33
  */
34
+ #if defined(__cplusplus) || (defined(__bool_true_false_are_defined) && __bool_true_false_are_defined)
35
+ typedef bool mrb_bool;
36
+
37
+ # ifndef FALSE
38
+ # define FALSE false
39
+ # endif
40
+ # ifndef TRUE
41
+ # define TRUE true
42
+ # endif
43
+ #else
44
+ # if __STDC_VERSION__ >= 199901L
45
+ typedef _Bool mrb_bool;
46
+ # else
34
47
  typedef uint8_t mrb_bool;
48
+ # endif
49
+
50
+ # ifndef FALSE
51
+ # define FALSE 0
52
+ # endif
53
+ # ifndef TRUE
54
+ # define TRUE 1
55
+ # endif
56
+ #endif
57
+
35
58
  struct mrb_state;
36
59
 
37
60
  #if defined _MSC_VER && _MSC_VER < 1800
@@ -77,6 +100,7 @@ struct mrb_state;
77
100
  # define MRB_ENDIAN_LOHI(a,b) b a
78
101
  #endif
79
102
 
103
+ MRB_API mrb_int mrb_int_read(const char *p, const char *e, char **endp);
80
104
  #ifndef MRB_NO_FLOAT
81
105
  MRB_API double mrb_float_read(const char*, char**);
82
106
  #ifdef MRB_USE_FLOAT32
@@ -87,13 +111,11 @@ MRB_API double mrb_float_read(const char*, char**);
87
111
  #endif
88
112
 
89
113
  #if defined _MSC_VER && _MSC_VER < 1900
90
- # include <stdarg.h>
91
114
  MRB_API int mrb_msvc_vsnprintf(char *s, size_t n, const char *format, va_list arg);
92
115
  MRB_API int mrb_msvc_snprintf(char *s, size_t n, const char *format, ...);
93
116
  # define vsnprintf(s, n, format, arg) mrb_msvc_vsnprintf(s, n, format, arg)
94
117
  # define snprintf(s, n, format, ...) mrb_msvc_snprintf(s, n, format, __VA_ARGS__)
95
118
  # if _MSC_VER < 1800 && !defined MRB_NO_FLOAT
96
- # include <float.h>
97
119
  # define isfinite(n) _finite(n)
98
120
  # define isnan _isnan
99
121
  # define isinf(n) (!_finite(n) && !_isnan(n))
@@ -104,34 +126,49 @@ static const unsigned int IEEE754_INFINITY_BITS_SINGLE = 0x7F800000;
104
126
  # endif
105
127
  #endif
106
128
 
129
+ #define MRB_VTYPE_FOREACH(f) \
130
+ /* mrb_vtype */ /* c type */ /* ruby class */ \
131
+ f(MRB_TT_FALSE, void, "false") \
132
+ f(MRB_TT_TRUE, void, "true") \
133
+ f(MRB_TT_SYMBOL, void, "Symbol") \
134
+ f(MRB_TT_UNDEF, void, "undefined") \
135
+ f(MRB_TT_FREE, void, "free") \
136
+ f(MRB_TT_FLOAT, struct RFloat, "Float") \
137
+ f(MRB_TT_INTEGER, struct RInteger, "Integer") \
138
+ f(MRB_TT_CPTR, struct RCptr, "cptr") \
139
+ f(MRB_TT_OBJECT, struct RObject, "Object") \
140
+ f(MRB_TT_CLASS, struct RClass, "Class") \
141
+ f(MRB_TT_MODULE, struct RClass, "Module") \
142
+ f(MRB_TT_ICLASS, struct RClass, "iClass") \
143
+ f(MRB_TT_SCLASS, struct RClass, "SClass") \
144
+ f(MRB_TT_PROC, struct RProc, "Proc") \
145
+ f(MRB_TT_ARRAY, struct RArray, "Array") \
146
+ f(MRB_TT_HASH, struct RHash, "Hash") \
147
+ f(MRB_TT_STRING, struct RString, "String") \
148
+ f(MRB_TT_RANGE, struct RRange, "Range") \
149
+ f(MRB_TT_EXCEPTION, struct RException, "Exception") \
150
+ f(MRB_TT_ENV, struct REnv, "env") \
151
+ f(MRB_TT_DATA, struct RData, "Data") \
152
+ f(MRB_TT_FIBER, struct RFiber, "Fiber") \
153
+ f(MRB_TT_STRUCT, struct RArray, "Struct") \
154
+ f(MRB_TT_ISTRUCT, struct RIStruct, "istruct") \
155
+ f(MRB_TT_BREAK, struct RBreak, "break") \
156
+ f(MRB_TT_COMPLEX, struct RComplex, "Complex") \
157
+ f(MRB_TT_RATIONAL, struct RRational, "Rational")
158
+
107
159
  enum mrb_vtype {
108
- MRB_TT_FALSE = 0,
109
- MRB_TT_TRUE,
110
- MRB_TT_FLOAT,
111
- MRB_TT_INTEGER,
112
- MRB_TT_SYMBOL,
113
- MRB_TT_UNDEF,
114
- MRB_TT_CPTR,
115
- MRB_TT_FREE,
116
- MRB_TT_OBJECT,
117
- MRB_TT_CLASS,
118
- MRB_TT_MODULE,
119
- MRB_TT_ICLASS,
120
- MRB_TT_SCLASS,
121
- MRB_TT_PROC,
122
- MRB_TT_ARRAY,
123
- MRB_TT_HASH,
124
- MRB_TT_STRING,
125
- MRB_TT_RANGE,
126
- MRB_TT_EXCEPTION,
127
- MRB_TT_ENV,
128
- MRB_TT_DATA,
129
- MRB_TT_FIBER,
130
- MRB_TT_ISTRUCT,
131
- MRB_TT_BREAK,
160
+ #define MRB_VTYPE_DEFINE(tt, type, name) tt,
161
+ MRB_VTYPE_FOREACH(MRB_VTYPE_DEFINE)
162
+ #undef MRB_VTYPE_DEFINE
132
163
  MRB_TT_MAXDEFINE
133
164
  };
134
165
 
166
+ #define MRB_VTYPE_TYPEOF(tt) MRB_TYPEOF_##tt
167
+
168
+ #define MRB_VTYPE_TYPEDEF(tt, type, name) typedef type MRB_VTYPE_TYPEOF(tt);
169
+ MRB_VTYPE_FOREACH(MRB_VTYPE_TYPEDEF)
170
+ #undef MRB_VTYPE_TYPEDEF
171
+
135
172
  /* for compatibility */
136
173
  #define MRB_TT_FIXNUM MRB_TT_INTEGER
137
174
 
@@ -177,7 +214,7 @@ struct RCptr {
177
214
  #endif
178
215
 
179
216
  #ifndef mrb_immediate_p
180
- #define mrb_immediate_p(o) (mrb_type(o) < MRB_TT_FREE)
217
+ #define mrb_immediate_p(o) (mrb_type(o) <= MRB_TT_CPTR)
181
218
  #endif
182
219
  #ifndef mrb_integer_p
183
220
  #define mrb_integer_p(o) (mrb_type(o) == MRB_TT_INTEGER)
@@ -372,26 +409,29 @@ mrb_undef_value(void)
372
409
  return v;
373
410
  }
374
411
 
375
- #if defined(MRB_USE_ETEXT_EDATA) && !defined(MRB_USE_LINK_TIME_RO_DATA_P)
376
- # ifdef __GNUC__
377
- # warning MRB_USE_ETEXT_EDATA is deprecated. Define MRB_USE_LINK_TIME_RO_DATA_P instead.
378
- # endif
379
- # define MRB_USE_LINK_TIME_RO_DATA_P
380
- #endif
381
-
382
412
  #if defined(MRB_USE_CUSTOM_RO_DATA_P)
383
413
  /* If you define `MRB_USE_CUSTOM_RO_DATA_P`, you must implement `mrb_ro_data_p()`. */
384
414
  mrb_bool mrb_ro_data_p(const char *p);
385
- #elif defined(MRB_USE_LINK_TIME_RO_DATA_P)
386
- extern char __ehdr_start[];
387
- extern char __init_array_start[];
388
-
415
+ #elif !defined(MRB_NO_DEFAULT_RO_DATA_P)
416
+ #if defined(MRB_USE_ETEXT_RO_DATA_P)
417
+ #define MRB_LINK_TIME_RO_DATA_P
418
+ extern char etext, edata;
389
419
  static inline mrb_bool
390
420
  mrb_ro_data_p(const char *p)
391
421
  {
392
- return __ehdr_start < p && p < __init_array_start;
422
+ return &etext < p && p < &edata;
393
423
  }
394
- #else
424
+ #elif defined(__APPLE__)
425
+ #define MRB_LINK_TIME_RO_DATA_P
426
+ #include <mach-o/getsect.h>
427
+ static inline mrb_bool
428
+ mrb_ro_data_p(const char *p)
429
+ {
430
+ return (char*)get_etext() < p && p < (char*)get_edata();
431
+ }
432
+ #endif /* Linux or macOS */
433
+ #endif /* MRB_NO_DEFAULT_RO_DATA_P */
434
+ #ifndef MRB_LINK_TIME_RO_DATA_P
395
435
  # define mrb_ro_data_p(p) FALSE
396
436
  #endif
397
437
 
@@ -14,21 +14,6 @@
14
14
  */
15
15
  MRB_BEGIN_DECL
16
16
 
17
- typedef struct global_variable {
18
- int counter;
19
- mrb_value *data;
20
- mrb_value (*getter)(void);
21
- void (*setter)(void);
22
- /* void (*marker)(); */
23
- /* int block_trace; */
24
- /* struct trace_var *trace; */
25
- } global_variable;
26
-
27
- struct global_entry {
28
- global_variable *var;
29
- mrb_sym id;
30
- };
31
-
32
17
  mrb_value mrb_vm_special_get(mrb_state*, mrb_sym);
33
18
  void mrb_vm_special_set(mrb_state*, mrb_sym, mrb_value);
34
19
  mrb_value mrb_vm_cv_get(mrb_state*, mrb_sym);
@@ -27,7 +27,7 @@ MRB_BEGIN_DECL
27
27
  /*
28
28
  * The version of Ruby used by mruby.
29
29
  */
30
- #define MRUBY_RUBY_VERSION "3.0"
30
+ #define MRUBY_RUBY_VERSION "3.1"
31
31
 
32
32
  /*
33
33
  * Ruby engine.
@@ -42,7 +42,7 @@ MRB_BEGIN_DECL
42
42
  /*
43
43
  * Minor release version number.
44
44
  */
45
- #define MRUBY_RELEASE_MINOR 0
45
+ #define MRUBY_RELEASE_MINOR 1
46
46
 
47
47
  /*
48
48
  * Tiny release version number.
@@ -80,17 +80,17 @@ MRB_BEGIN_DECL
80
80
  /*
81
81
  * Release year.
82
82
  */
83
- #define MRUBY_RELEASE_YEAR 2021
83
+ #define MRUBY_RELEASE_YEAR 2022
84
84
 
85
85
  /*
86
86
  * Release month.
87
87
  */
88
- #define MRUBY_RELEASE_MONTH 3
88
+ #define MRUBY_RELEASE_MONTH 5
89
89
 
90
90
  /*
91
91
  * Release day.
92
92
  */
93
- #define MRUBY_RELEASE_DAY 5
93
+ #define MRUBY_RELEASE_DAY 12
94
94
 
95
95
  /*
96
96
  * Release date as a string.