ruby2d 0.10.0 → 0.11.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (387) hide show
  1. checksums.yaml +4 -4
  2. data/assets/include/SDL2/SDL.h +108 -14
  3. data/assets/include/SDL2/SDL_assert.h +81 -50
  4. data/assets/include/SDL2/SDL_atomic.h +135 -35
  5. data/assets/include/SDL2/SDL_audio.h +960 -355
  6. data/assets/include/SDL2/SDL_bits.h +11 -6
  7. data/assets/include/SDL2/SDL_blendmode.h +91 -14
  8. data/assets/include/SDL2/SDL_clipboard.h +30 -7
  9. data/assets/include/SDL2/SDL_config.h +3 -1
  10. data/assets/include/SDL2/SDL_config_android.h +11 -1
  11. data/assets/include/SDL2/SDL_config_emscripten.h +216 -0
  12. data/assets/include/SDL2/SDL_config_iphoneos.h +9 -1
  13. data/assets/include/SDL2/SDL_config_macosx.h +16 -2
  14. data/assets/include/SDL2/SDL_config_minimal.h +4 -1
  15. data/assets/include/SDL2/SDL_config_os2.h +37 -20
  16. data/assets/include/SDL2/SDL_config_pandora.h +6 -1
  17. data/assets/include/SDL2/SDL_config_psp.h +8 -8
  18. data/assets/include/SDL2/SDL_config_windows.h +39 -22
  19. data/assets/include/SDL2/SDL_config_winrt.h +23 -8
  20. data/assets/include/SDL2/SDL_config_wiz.h +6 -1
  21. data/assets/include/SDL2/SDL_copying.h +1 -1
  22. data/assets/include/SDL2/SDL_cpuinfo.h +331 -71
  23. data/assets/include/SDL2/SDL_egl.h +906 -280
  24. data/assets/include/SDL2/SDL_endian.h +101 -47
  25. data/assets/include/SDL2/SDL_error.h +70 -19
  26. data/assets/include/SDL2/SDL_events.h +387 -79
  27. data/assets/include/SDL2/SDL_filesystem.h +73 -64
  28. data/assets/include/SDL2/SDL_gamecontroller.h +585 -125
  29. data/assets/include/SDL2/SDL_gesture.h +36 -6
  30. data/assets/include/SDL2/SDL_haptic.h +304 -210
  31. data/assets/include/SDL2/SDL_hidapi.h +451 -0
  32. data/assets/include/SDL2/SDL_hints.h +1286 -897
  33. data/assets/include/SDL2/SDL_joystick.h +577 -130
  34. data/assets/include/SDL2/SDL_keyboard.h +162 -63
  35. data/assets/include/SDL2/SDL_keycode.h +7 -5
  36. data/assets/include/SDL2/SDL_loadso.h +42 -8
  37. data/assets/include/SDL2/SDL_locale.h +34 -32
  38. data/assets/include/SDL2/SDL_log.h +212 -19
  39. data/assets/include/SDL2/SDL_main.h +72 -17
  40. data/assets/include/SDL2/SDL_messagebox.h +70 -23
  41. data/assets/include/SDL2/SDL_metal.h +27 -32
  42. data/assets/include/SDL2/SDL_misc.h +19 -15
  43. data/assets/include/SDL2/SDL_mouse.h +262 -110
  44. data/assets/include/SDL2/SDL_mutex.h +286 -66
  45. data/assets/include/SDL2/SDL_name.h +1 -1
  46. data/assets/include/SDL2/SDL_opengl.h +1 -1
  47. data/assets/include/SDL2/SDL_opengles.h +1 -1
  48. data/assets/include/SDL2/SDL_opengles2.h +2 -2
  49. data/assets/include/SDL2/SDL_pixels.h +199 -34
  50. data/assets/include/SDL2/SDL_platform.h +39 -2
  51. data/assets/include/SDL2/SDL_power.h +23 -10
  52. data/assets/include/SDL2/SDL_quit.h +1 -1
  53. data/assets/include/SDL2/SDL_rect.h +78 -28
  54. data/assets/include/SDL2/SDL_render.h +1204 -472
  55. data/assets/include/SDL2/SDL_revision.h +2 -2
  56. data/assets/include/SDL2/SDL_rwops.h +605 -33
  57. data/assets/include/SDL2/SDL_scancode.h +1 -1
  58. data/assets/include/SDL2/SDL_sensor.h +76 -42
  59. data/assets/include/SDL2/SDL_shape.h +38 -27
  60. data/assets/include/SDL2/SDL_stdinc.h +96 -24
  61. data/assets/include/SDL2/SDL_surface.h +571 -139
  62. data/assets/include/SDL2/SDL_system.h +339 -101
  63. data/assets/include/SDL2/SDL_syswm.h +50 -20
  64. data/assets/include/SDL2/SDL_test.h +1 -1
  65. data/assets/include/SDL2/SDL_test_assert.h +2 -2
  66. data/assets/include/SDL2/SDL_test_common.h +23 -6
  67. data/assets/include/SDL2/SDL_test_compare.h +1 -1
  68. data/assets/include/SDL2/SDL_test_crc32.h +1 -1
  69. data/assets/include/SDL2/SDL_test_font.h +3 -3
  70. data/assets/include/SDL2/SDL_test_fuzzer.h +28 -26
  71. data/assets/include/SDL2/SDL_test_harness.h +6 -6
  72. data/assets/include/SDL2/SDL_test_images.h +1 -1
  73. data/assets/include/SDL2/SDL_test_log.h +1 -1
  74. data/assets/include/SDL2/SDL_test_md5.h +1 -1
  75. data/assets/include/SDL2/SDL_test_memory.h +1 -1
  76. data/assets/include/SDL2/SDL_test_random.h +2 -2
  77. data/assets/include/SDL2/SDL_thread.h +226 -128
  78. data/assets/include/SDL2/SDL_timer.h +129 -22
  79. data/assets/include/SDL2/SDL_touch.h +48 -8
  80. data/assets/include/SDL2/SDL_ttf.h +102 -9
  81. data/assets/include/SDL2/SDL_types.h +1 -1
  82. data/assets/include/SDL2/SDL_version.h +72 -46
  83. data/assets/include/SDL2/SDL_video.h +1266 -460
  84. data/assets/include/SDL2/SDL_vulkan.h +100 -161
  85. data/assets/include/SDL2/begin_code.h +22 -1
  86. data/assets/include/SDL2/close_code.h +1 -1
  87. data/assets/include/mrbconf.h +234 -0
  88. data/assets/include/mruby/array.h +317 -0
  89. data/assets/include/mruby/boxing_nan.h +130 -0
  90. data/assets/include/mruby/boxing_no.h +58 -0
  91. data/assets/include/mruby/boxing_word.h +205 -0
  92. data/assets/include/mruby/class.h +108 -0
  93. data/assets/include/mruby/common.h +92 -0
  94. data/assets/include/mruby/compile.h +210 -0
  95. data/assets/include/mruby/data.h +76 -0
  96. data/assets/include/mruby/debug.h +66 -0
  97. data/assets/include/mruby/dump.h +158 -0
  98. data/assets/include/mruby/endian.h +44 -0
  99. data/assets/include/mruby/error.h +137 -0
  100. data/assets/include/mruby/gc.h +92 -0
  101. data/assets/include/mruby/hash.h +242 -0
  102. data/assets/include/mruby/irep.h +147 -0
  103. data/assets/include/mruby/istruct.h +50 -0
  104. data/assets/include/mruby/khash.h +284 -0
  105. data/assets/include/mruby/numeric.h +169 -0
  106. data/assets/include/mruby/object.h +43 -0
  107. data/assets/include/mruby/opcode.h +43 -0
  108. data/assets/include/mruby/ops.h +122 -0
  109. data/assets/include/mruby/presym/disable.h +70 -0
  110. data/assets/include/mruby/presym/enable.h +37 -0
  111. data/assets/include/mruby/presym/scanning.h +73 -0
  112. data/assets/include/mruby/presym.h +40 -0
  113. data/assets/include/mruby/proc.h +209 -0
  114. data/assets/include/mruby/range.h +79 -0
  115. data/assets/include/mruby/re.h +16 -0
  116. data/assets/include/mruby/string.h +469 -0
  117. data/assets/include/mruby/throw.h +66 -0
  118. data/assets/include/mruby/value.h +400 -0
  119. data/assets/include/mruby/variable.h +140 -0
  120. data/assets/include/mruby/version.h +143 -0
  121. data/assets/include/mruby.h +1444 -0
  122. data/assets/macos/universal/bin/mrbc +0 -0
  123. data/assets/macos/universal/lib/libFLAC.a +0 -0
  124. data/assets/macos/universal/lib/libSDL2.a +0 -0
  125. data/assets/macos/universal/lib/libSDL2_image.a +0 -0
  126. data/assets/macos/{lib → universal/lib}/libSDL2_mixer.a +0 -0
  127. data/assets/macos/universal/lib/libSDL2_ttf.a +0 -0
  128. data/assets/macos/universal/lib/libfreetype.a +0 -0
  129. data/assets/macos/universal/lib/libgraphite2.a +0 -0
  130. data/assets/macos/universal/lib/libharfbuzz.a +0 -0
  131. data/assets/macos/universal/lib/libjpeg.a +0 -0
  132. data/assets/macos/universal/lib/libmodplug.a +0 -0
  133. data/assets/macos/{lib → universal/lib}/libmpg123.a +0 -0
  134. data/assets/{mingw/lib/libSDL2.a → macos/universal/lib/libmruby.a} +0 -0
  135. data/assets/macos/{lib → universal/lib}/libogg.a +0 -0
  136. data/assets/macos/universal/lib/libpng16.a +0 -0
  137. data/assets/macos/universal/lib/libtiff.a +0 -0
  138. data/assets/macos/universal/lib/libvorbis.a +0 -0
  139. data/assets/macos/universal/lib/libvorbisfile.a +0 -0
  140. data/assets/macos/universal/lib/libwebp.a +0 -0
  141. data/assets/test_media/README.md +3 -0
  142. data/assets/test_media/bitstream_vera/COPYRIGHT.txt +124 -0
  143. data/assets/test_media/bitstream_vera/vera.ttf +0 -0
  144. data/assets/test_media/boom.png +0 -0
  145. data/assets/test_media/coin.png +0 -0
  146. data/assets/test_media/colors.png +0 -0
  147. data/assets/test_media/controller.png +0 -0
  148. data/assets/test_media/dial.wav +0 -0
  149. data/assets/test_media/hero.png +0 -0
  150. data/assets/test_media/image.bmp +0 -0
  151. data/assets/test_media/image.jpg +0 -0
  152. data/assets/test_media/image.png +0 -0
  153. data/assets/test_media/music.flac +0 -0
  154. data/assets/test_media/music.mp3 +0 -0
  155. data/assets/test_media/music.ogg +0 -0
  156. data/assets/test_media/music.wav +0 -0
  157. data/assets/test_media/originals/boom.pxm +0 -0
  158. data/assets/test_media/originals/coin.pxm +0 -0
  159. data/assets/test_media/originals/controller.sketch +0 -0
  160. data/assets/test_media/originals/hero.pxm +0 -0
  161. data/assets/test_media/originals/image.pxm +0 -0
  162. data/assets/test_media/originals/music.caf +0 -0
  163. data/assets/test_media/originals/texture_atlas.pxm +0 -0
  164. data/assets/test_media/rondo_alla_turka.ogg +0 -0
  165. data/assets/test_media/sound.flac +0 -0
  166. data/assets/test_media/sound.mp3 +0 -0
  167. data/assets/test_media/sound.ogg +0 -0
  168. data/assets/test_media/sound.wav +0 -0
  169. data/assets/test_media/sprite_sheet.png +0 -0
  170. data/assets/test_media/texture_atlas.png +0 -0
  171. data/assets/wasm/build_config.rb +13 -0
  172. data/assets/wasm/libmruby.a +0 -0
  173. data/assets/wasm/template.html +17 -0
  174. data/assets/windows/glew/README.md +10 -0
  175. data/assets/windows/glew/glew.h +23686 -0
  176. data/assets/{mingw/lib → windows/glew}/libglew32.a +0 -0
  177. data/assets/windows/mingw-w64-x86_64/bin/mrbc.exe +0 -0
  178. data/assets/windows/mingw-w64-x86_64/lib/libFLAC.a +0 -0
  179. data/assets/windows/mingw-w64-x86_64/lib/libLerc.a +0 -0
  180. data/assets/windows/mingw-w64-x86_64/lib/libSDL2.a +0 -0
  181. data/assets/windows/mingw-w64-x86_64/lib/libSDL2_image.a +0 -0
  182. data/assets/windows/mingw-w64-x86_64/lib/libSDL2_mixer.a +0 -0
  183. data/assets/windows/mingw-w64-x86_64/lib/libSDL2_ttf.a +0 -0
  184. data/assets/windows/mingw-w64-x86_64/lib/libbrotlicommon.a +0 -0
  185. data/assets/windows/mingw-w64-x86_64/lib/libbrotlidec.a +0 -0
  186. data/assets/windows/mingw-w64-x86_64/lib/libbz2.a +0 -0
  187. data/assets/windows/mingw-w64-x86_64/lib/libdeflate.a +0 -0
  188. data/assets/windows/mingw-w64-x86_64/lib/libfreetype.a +0 -0
  189. data/assets/windows/mingw-w64-x86_64/lib/libglew32.a +0 -0
  190. data/assets/windows/mingw-w64-x86_64/lib/libgraphite2.a +0 -0
  191. data/assets/windows/mingw-w64-x86_64/lib/libharfbuzz.a +0 -0
  192. data/assets/windows/mingw-w64-x86_64/lib/libjbig.a +0 -0
  193. data/assets/windows/mingw-w64-x86_64/lib/libjpeg.a +0 -0
  194. data/assets/windows/mingw-w64-x86_64/lib/liblzma.a +0 -0
  195. data/assets/windows/mingw-w64-x86_64/lib/libmodplug.a +0 -0
  196. data/assets/windows/mingw-w64-x86_64/lib/libmpg123.a +0 -0
  197. data/assets/windows/mingw-w64-x86_64/lib/libmruby.a +0 -0
  198. data/assets/windows/mingw-w64-x86_64/lib/libogg.a +0 -0
  199. data/assets/windows/mingw-w64-x86_64/lib/libopus.a +0 -0
  200. data/assets/windows/mingw-w64-x86_64/lib/libopusfile.a +0 -0
  201. data/assets/windows/mingw-w64-x86_64/lib/libpng16.a +0 -0
  202. data/assets/windows/mingw-w64-x86_64/lib/libsndfile.a +0 -0
  203. data/assets/windows/mingw-w64-x86_64/lib/libssp.a +0 -0
  204. data/assets/windows/mingw-w64-x86_64/lib/libstdc++.a +0 -0
  205. data/assets/windows/mingw-w64-x86_64/lib/libtiff.a +0 -0
  206. data/assets/windows/mingw-w64-x86_64/lib/libvorbis.a +0 -0
  207. data/assets/windows/mingw-w64-x86_64/lib/libvorbisfile.a +0 -0
  208. data/assets/windows/mingw-w64-x86_64/lib/libwebp.a +0 -0
  209. data/assets/windows/mingw-w64-x86_64/lib/libz.a +0 -0
  210. data/assets/windows/mingw-w64-x86_64/lib/libzstd.a +0 -0
  211. data/assets/{ios → xcode/ios}/Assets.xcassets/AppIcon.appiconset/Contents.json +0 -0
  212. data/assets/{ios → xcode/ios}/Assets.xcassets/Contents.json +0 -0
  213. data/assets/{ios → xcode/ios}/Base.lproj/LaunchScreen.storyboard +0 -0
  214. data/assets/{ios → xcode/ios}/Info.plist +0 -0
  215. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mrbconf.h +0 -0
  216. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/array.h +0 -0
  217. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/boxing_nan.h +0 -0
  218. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/boxing_no.h +0 -0
  219. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/boxing_word.h +0 -0
  220. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/class.h +0 -0
  221. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/common.h +0 -0
  222. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/compile.h +0 -0
  223. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/data.h +0 -0
  224. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/debug.h +0 -0
  225. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/dump.h +0 -0
  226. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/error.h +0 -0
  227. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/gc.h +0 -0
  228. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/hash.h +0 -0
  229. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/irep.h +0 -0
  230. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/istruct.h +0 -0
  231. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/khash.h +0 -0
  232. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/numeric.h +0 -0
  233. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/object.h +0 -0
  234. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/opcode.h +0 -0
  235. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/ops.h +0 -0
  236. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/proc.h +0 -0
  237. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/range.h +0 -0
  238. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/re.h +0 -0
  239. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/string.h +0 -0
  240. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/throw.h +0 -0
  241. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/value.h +0 -0
  242. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/variable.h +0 -0
  243. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/version.h +0 -0
  244. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby.h +0 -0
  245. data/assets/{ios → xcode/ios}/MRuby.framework/Info.plist +0 -0
  246. data/assets/{ios → xcode/ios}/MRuby.framework/MRuby +0 -0
  247. data/assets/{ios → xcode/ios}/MyApp.xcodeproj/project.pbxproj +0 -0
  248. data/assets/{ios → xcode/ios}/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -0
  249. data/assets/{ios → xcode/ios}/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -0
  250. data/assets/{ios → xcode/ios}/MyApp.xcodeproj/project.xcworkspace/xcshareddata/MyApp.xcscmblueprint +0 -0
  251. data/assets/{ios → xcode/ios}/main.c +0 -0
  252. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Content.imageset/Contents.json +0 -0
  253. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Contents.json +0 -0
  254. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Contents.json +0 -0
  255. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Content.imageset/Contents.json +0 -0
  256. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Contents.json +0 -0
  257. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json +0 -0
  258. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Contents.json +0 -0
  259. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Content.imageset/Contents.json +0 -0
  260. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Contents.json +0 -0
  261. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Contents.json +0 -0
  262. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Content.imageset/Contents.json +0 -0
  263. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Contents.json +0 -0
  264. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json +0 -0
  265. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Contents.json +0 -0
  266. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Contents.json +0 -0
  267. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image Wide.imageset/Contents.json +0 -0
  268. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image.imageset/Contents.json +0 -0
  269. data/assets/{tvos → xcode/tvos}/Assets.xcassets/Contents.json +0 -0
  270. data/assets/{tvos → xcode/tvos}/Assets.xcassets/LaunchImage.launchimage/Contents.json +0 -0
  271. data/assets/{tvos → xcode/tvos}/Info.plist +0 -0
  272. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mrbconf.h +0 -0
  273. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/array.h +0 -0
  274. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/boxing_nan.h +0 -0
  275. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/boxing_no.h +0 -0
  276. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/boxing_word.h +0 -0
  277. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/class.h +0 -0
  278. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/common.h +0 -0
  279. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/compile.h +0 -0
  280. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/data.h +0 -0
  281. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/debug.h +0 -0
  282. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/dump.h +0 -0
  283. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/error.h +0 -0
  284. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/gc.h +0 -0
  285. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/hash.h +0 -0
  286. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/irep.h +0 -0
  287. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/istruct.h +0 -0
  288. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/khash.h +0 -0
  289. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/numeric.h +0 -0
  290. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/object.h +0 -0
  291. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/opcode.h +0 -0
  292. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/ops.h +0 -0
  293. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/proc.h +0 -0
  294. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/range.h +0 -0
  295. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/re.h +0 -0
  296. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/string.h +0 -0
  297. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/throw.h +0 -0
  298. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/value.h +0 -0
  299. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/variable.h +0 -0
  300. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/version.h +0 -0
  301. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby.h +0 -0
  302. data/assets/{tvos → xcode/tvos}/MRuby.framework/Info.plist +0 -0
  303. data/assets/{tvos → xcode/tvos}/MRuby.framework/MRuby +0 -0
  304. data/assets/{tvos → xcode/tvos}/MyApp.xcodeproj/project.pbxproj +0 -0
  305. data/assets/{tvos → xcode/tvos}/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -0
  306. data/assets/{tvos → xcode/tvos}/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -0
  307. data/assets/{tvos → xcode/tvos}/MyApp.xcodeproj/project.xcworkspace/xcshareddata/MyApp.xcscmblueprint +0 -0
  308. data/assets/{tvos → xcode/tvos}/main.c +0 -0
  309. data/bin/ruby2d +3 -4
  310. data/ext/ruby2d/extconf.rb +68 -46
  311. data/ext/ruby2d/font.c +35 -0
  312. data/ext/ruby2d/gl.c +9 -58
  313. data/ext/ruby2d/gl2.c +8 -83
  314. data/ext/ruby2d/gl3.c +57 -116
  315. data/ext/ruby2d/gles.c +130 -151
  316. data/ext/ruby2d/image.c +16 -96
  317. data/ext/ruby2d/ruby2d.c +265 -298
  318. data/ext/ruby2d/ruby2d.h +69 -159
  319. data/ext/ruby2d/sound.c +1 -1
  320. data/ext/ruby2d/text.c +20 -114
  321. data/ext/ruby2d/window.c +257 -219
  322. data/lib/ruby2d/circle.rb +3 -1
  323. data/lib/ruby2d/cli/build.rb +239 -59
  324. data/lib/ruby2d/cli/colorize.rb +5 -4
  325. data/lib/ruby2d/cli/platform.rb +17 -0
  326. data/lib/ruby2d/font.rb +26 -1
  327. data/lib/ruby2d/image.rb +22 -17
  328. data/lib/ruby2d/line.rb +3 -1
  329. data/lib/ruby2d/quad.rb +3 -1
  330. data/lib/ruby2d/rectangle.rb +1 -1
  331. data/lib/ruby2d/renderable.rb +0 -12
  332. data/lib/ruby2d/sound.rb +25 -0
  333. data/lib/ruby2d/sprite.rb +44 -89
  334. data/lib/ruby2d/square.rb +1 -1
  335. data/lib/ruby2d/text.rb +40 -20
  336. data/lib/ruby2d/texture.rb +28 -0
  337. data/lib/ruby2d/tileset.rb +47 -28
  338. data/lib/ruby2d/triangle.rb +3 -1
  339. data/lib/ruby2d/version.rb +1 -1
  340. data/lib/ruby2d/vertices.rb +89 -0
  341. data/lib/ruby2d/window.rb +13 -3
  342. data/lib/ruby2d.rb +16 -20
  343. metadata +249 -153
  344. data/assets/README.md +0 -22
  345. data/assets/Rakefile +0 -85
  346. data/assets/macos/lib/libFLAC.a +0 -0
  347. data/assets/macos/lib/libSDL2.a +0 -0
  348. data/assets/macos/lib/libSDL2_image.a +0 -0
  349. data/assets/macos/lib/libSDL2_ttf.a +0 -0
  350. data/assets/macos/lib/libfreetype.a +0 -0
  351. data/assets/macos/lib/libjpeg.a +0 -0
  352. data/assets/macos/lib/libpng16.a +0 -0
  353. data/assets/macos/lib/libtiff.a +0 -0
  354. data/assets/macos/lib/libvorbis.a +0 -0
  355. data/assets/macos/lib/libvorbisfile.a +0 -0
  356. data/assets/macos/lib/libwebp.a +0 -0
  357. data/assets/mingw/bin/SDL2.dll +0 -0
  358. data/assets/mingw/bin/SDL2_image.dll +0 -0
  359. data/assets/mingw/bin/SDL2_mixer.dll +0 -0
  360. data/assets/mingw/bin/SDL2_ttf.dll +0 -0
  361. data/assets/mingw/bin/glew32.dll +0 -0
  362. data/assets/mingw/bin/libFLAC-8.dll +0 -0
  363. data/assets/mingw/bin/libfreetype-6.dll +0 -0
  364. data/assets/mingw/bin/libjpeg-9.dll +0 -0
  365. data/assets/mingw/bin/libmodplug-1.dll +0 -0
  366. data/assets/mingw/bin/libmpg123-0.dll +0 -0
  367. data/assets/mingw/bin/libogg-0.dll +0 -0
  368. data/assets/mingw/bin/libopus-0.dll +0 -0
  369. data/assets/mingw/bin/libopusfile-0.dll +0 -0
  370. data/assets/mingw/bin/libpng16-16.dll +0 -0
  371. data/assets/mingw/bin/libtiff-5.dll +0 -0
  372. data/assets/mingw/bin/libvorbis-0.dll +0 -0
  373. data/assets/mingw/bin/libvorbisfile-3.dll +0 -0
  374. data/assets/mingw/bin/libwebp-7.dll +0 -0
  375. data/assets/mingw/bin/zlib1.dll +0 -0
  376. data/assets/mingw/lib/libSDL2.dll.a +0 -0
  377. data/assets/mingw/lib/libSDL2_image.a +0 -0
  378. data/assets/mingw/lib/libSDL2_image.dll.a +0 -0
  379. data/assets/mingw/lib/libSDL2_mixer.a +0 -0
  380. data/assets/mingw/lib/libSDL2_mixer.dll.a +0 -0
  381. data/assets/mingw/lib/libSDL2_test.a +0 -0
  382. data/assets/mingw/lib/libSDL2_ttf.a +0 -0
  383. data/assets/mingw/lib/libSDL2_ttf.dll.a +0 -0
  384. data/assets/mingw/lib/libSDL2main.a +0 -0
  385. data/assets/mingw/lib/libglew32.dll.a +0 -0
  386. data/ext/ruby2d/sprite.c +0 -147
  387. data/ext/ruby2d/tileset.c +0 -30
@@ -0,0 +1,284 @@
1
+ /**
2
+ ** @file mruby/khash.h - Hash for mruby
3
+ **
4
+ ** See Copyright Notice in mruby.h
5
+ */
6
+
7
+ #ifndef MRUBY_KHASH_H
8
+ #define MRUBY_KHASH_H
9
+
10
+ #include <string.h>
11
+
12
+ #include <mruby.h>
13
+ #include "common.h"
14
+
15
+ /**
16
+ * khash definitions used in mruby's hash table.
17
+ */
18
+ MRB_BEGIN_DECL
19
+
20
+ typedef uint32_t khint_t;
21
+ typedef khint_t khiter_t;
22
+
23
+ #ifndef KHASH_DEFAULT_SIZE
24
+ # define KHASH_DEFAULT_SIZE 32
25
+ #endif
26
+ #define KHASH_MIN_SIZE 8
27
+
28
+ #define UPPER_BOUND(x) ((x)>>2|(x)>>1)
29
+
30
+ /* extern uint8_t __m[]; */
31
+
32
+ /* mask for flags */
33
+ static const uint8_t __m_empty[] = {0x02, 0x08, 0x20, 0x80};
34
+ static const uint8_t __m_del[] = {0x01, 0x04, 0x10, 0x40};
35
+ static const uint8_t __m_either[] = {0x03, 0x0c, 0x30, 0xc0};
36
+
37
+
38
+ #define __ac_isempty(ed_flag, i) (ed_flag[(i)/4]&__m_empty[(i)%4])
39
+ #define __ac_isdel(ed_flag, i) (ed_flag[(i)/4]&__m_del[(i)%4])
40
+ #define __ac_iseither(ed_flag, i) (ed_flag[(i)/4]&__m_either[(i)%4])
41
+ #define khash_power2(v) do { \
42
+ v--;\
43
+ v |= v >> 1;\
44
+ v |= v >> 2;\
45
+ v |= v >> 4;\
46
+ v |= v >> 8;\
47
+ v |= v >> 16;\
48
+ v++;\
49
+ } while (0)
50
+ #define khash_mask(h) ((h)->n_buckets-1)
51
+ #define khash_upper_bound(h) (UPPER_BOUND((h)->n_buckets))
52
+
53
+ /* declare struct kh_xxx and kh_xxx_funcs
54
+
55
+ name: hash name
56
+ khkey_t: key data type
57
+ khval_t: value data type
58
+ kh_is_map: (0: hash set / 1: hash map)
59
+ */
60
+ #define KHASH_DECLARE(name, khkey_t, khval_t, kh_is_map) \
61
+ typedef struct kh_##name { \
62
+ khint_t n_buckets; \
63
+ khint_t size; \
64
+ uint8_t *ed_flags; \
65
+ khkey_t *keys; \
66
+ khval_t *vals; \
67
+ } kh_##name##_t; \
68
+ void kh_alloc_##name(mrb_state *mrb, kh_##name##_t *h); \
69
+ kh_##name##_t *kh_init_##name##_size(mrb_state *mrb, khint_t size); \
70
+ kh_##name##_t *kh_init_##name(mrb_state *mrb); \
71
+ void kh_destroy_##name(mrb_state *mrb, kh_##name##_t *h); \
72
+ void kh_clear_##name(mrb_state *mrb, kh_##name##_t *h); \
73
+ khint_t kh_get_##name(mrb_state *mrb, kh_##name##_t *h, khkey_t key); \
74
+ khint_t kh_put_##name(mrb_state *mrb, kh_##name##_t *h, khkey_t key, int *ret); \
75
+ void kh_resize_##name(mrb_state *mrb, kh_##name##_t *h, khint_t new_n_buckets); \
76
+ void kh_del_##name(mrb_state *mrb, kh_##name##_t *h, khint_t x); \
77
+ kh_##name##_t *kh_copy_##name(mrb_state *mrb, kh_##name##_t *h);
78
+
79
+ static inline void
80
+ kh_fill_flags(uint8_t *p, uint8_t c, size_t len)
81
+ {
82
+ while (len-- > 0) {
83
+ *p++ = c;
84
+ }
85
+ }
86
+
87
+ /* define kh_xxx_funcs
88
+
89
+ name: hash name
90
+ khkey_t: key data type
91
+ khval_t: value data type
92
+ kh_is_map: (0: hash set / 1: hash map)
93
+ __hash_func: hash function
94
+ __hash_equal: hash comparison function
95
+ */
96
+ #define KHASH_DEFINE(name, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \
97
+ mrb_noreturn void mrb_raise_nomemory(mrb_state *mrb); \
98
+ int kh_alloc_simple_##name(mrb_state *mrb, kh_##name##_t *h) \
99
+ { \
100
+ khint_t sz = h->n_buckets; \
101
+ size_t len = sizeof(khkey_t) + (kh_is_map ? sizeof(khval_t) : 0); \
102
+ uint8_t *p = (uint8_t*)mrb_malloc_simple(mrb, sizeof(uint8_t)*sz/4+len*sz); \
103
+ if (!p) { return 1; } \
104
+ h->size = 0; \
105
+ h->keys = (khkey_t *)p; \
106
+ h->vals = kh_is_map ? (khval_t *)(p+sizeof(khkey_t)*sz) : NULL; \
107
+ h->ed_flags = p+len*sz; \
108
+ kh_fill_flags(h->ed_flags, 0xaa, sz/4); \
109
+ return 0; \
110
+ } \
111
+ void kh_alloc_##name(mrb_state *mrb, kh_##name##_t *h) \
112
+ { \
113
+ if (kh_alloc_simple_##name(mrb, h)) { \
114
+ mrb_raise_nomemory(mrb); \
115
+ } \
116
+ } \
117
+ kh_##name##_t *kh_init_##name##_size(mrb_state *mrb, khint_t size) { \
118
+ kh_##name##_t *h = (kh_##name##_t*)mrb_calloc(mrb, 1, sizeof(kh_##name##_t)); \
119
+ if (size < KHASH_MIN_SIZE) \
120
+ size = KHASH_MIN_SIZE; \
121
+ khash_power2(size); \
122
+ h->n_buckets = size; \
123
+ if (kh_alloc_simple_##name(mrb, h)) { \
124
+ mrb_free(mrb, h); \
125
+ mrb_raise_nomemory(mrb); \
126
+ } \
127
+ return h; \
128
+ } \
129
+ kh_##name##_t *kh_init_##name(mrb_state *mrb) { \
130
+ return kh_init_##name##_size(mrb, KHASH_DEFAULT_SIZE); \
131
+ } \
132
+ void kh_destroy_##name(mrb_state *mrb, kh_##name##_t *h) \
133
+ { \
134
+ if (h) { \
135
+ mrb_free(mrb, h->keys); \
136
+ mrb_free(mrb, h); \
137
+ } \
138
+ } \
139
+ void kh_clear_##name(mrb_state *mrb, kh_##name##_t *h) \
140
+ { \
141
+ (void)mrb; \
142
+ if (h && h->ed_flags) { \
143
+ kh_fill_flags(h->ed_flags, 0xaa, h->n_buckets/4); \
144
+ h->size = 0; \
145
+ } \
146
+ } \
147
+ khint_t kh_get_##name(mrb_state *mrb, kh_##name##_t *h, khkey_t key) \
148
+ { \
149
+ khint_t k = __hash_func(mrb,key) & khash_mask(h), step = 0; \
150
+ (void)mrb; \
151
+ while (!__ac_isempty(h->ed_flags, k)) { \
152
+ if (!__ac_isdel(h->ed_flags, k)) { \
153
+ if (__hash_equal(mrb,h->keys[k], key)) return k; \
154
+ } \
155
+ k = (k+(++step)) & khash_mask(h); \
156
+ } \
157
+ return kh_end(h); \
158
+ } \
159
+ void kh_resize_##name(mrb_state *mrb, kh_##name##_t *h, khint_t new_n_buckets) \
160
+ { \
161
+ if (new_n_buckets < KHASH_MIN_SIZE) \
162
+ new_n_buckets = KHASH_MIN_SIZE; \
163
+ khash_power2(new_n_buckets); \
164
+ { \
165
+ kh_##name##_t hh; \
166
+ uint8_t *old_ed_flags = h->ed_flags; \
167
+ khkey_t *old_keys = h->keys; \
168
+ khval_t *old_vals = h->vals; \
169
+ khint_t old_n_buckets = h->n_buckets; \
170
+ khint_t i; \
171
+ hh.n_buckets = new_n_buckets; \
172
+ kh_alloc_##name(mrb, &hh); \
173
+ /* relocate */ \
174
+ for (i=0 ; i<old_n_buckets ; i++) { \
175
+ if (!__ac_iseither(old_ed_flags, i)) { \
176
+ khint_t k = kh_put_##name(mrb, &hh, old_keys[i], NULL); \
177
+ if (kh_is_map) kh_value(&hh,k) = old_vals[i]; \
178
+ } \
179
+ } \
180
+ /* copy hh to h */ \
181
+ *h = hh; \
182
+ mrb_free(mrb, old_keys); \
183
+ } \
184
+ } \
185
+ khint_t kh_put_##name(mrb_state *mrb, kh_##name##_t *h, khkey_t key, int *ret) \
186
+ { \
187
+ khint_t k, del_k, step = 0; \
188
+ if (h->size >= khash_upper_bound(h)) { \
189
+ kh_resize_##name(mrb, h, h->n_buckets*2); \
190
+ } \
191
+ k = __hash_func(mrb,key) & khash_mask(h); \
192
+ del_k = kh_end(h); \
193
+ while (!__ac_isempty(h->ed_flags, k)) { \
194
+ if (!__ac_isdel(h->ed_flags, k)) { \
195
+ if (__hash_equal(mrb,h->keys[k], key)) { \
196
+ if (ret) *ret = 0; \
197
+ return k; \
198
+ } \
199
+ } \
200
+ else if (del_k == kh_end(h)) { \
201
+ del_k = k; \
202
+ } \
203
+ k = (k+(++step)) & khash_mask(h); \
204
+ } \
205
+ if (del_k != kh_end(h)) { \
206
+ /* put at del */ \
207
+ h->keys[del_k] = key; \
208
+ h->ed_flags[del_k/4] &= ~__m_del[del_k%4]; \
209
+ h->size++; \
210
+ if (ret) *ret = 2; \
211
+ return del_k; \
212
+ } \
213
+ else { \
214
+ /* put at empty */ \
215
+ h->keys[k] = key; \
216
+ h->ed_flags[k/4] &= ~__m_empty[k%4]; \
217
+ h->size++; \
218
+ if (ret) *ret = 1; \
219
+ return k; \
220
+ } \
221
+ } \
222
+ void kh_del_##name(mrb_state *mrb, kh_##name##_t *h, khint_t x) \
223
+ { \
224
+ (void)mrb; \
225
+ mrb_assert(x != h->n_buckets && !__ac_iseither(h->ed_flags, x)); \
226
+ h->ed_flags[x/4] |= __m_del[x%4]; \
227
+ h->size--; \
228
+ } \
229
+ kh_##name##_t *kh_copy_##name(mrb_state *mrb, kh_##name##_t *h) \
230
+ { \
231
+ kh_##name##_t *h2; \
232
+ khiter_t k, k2; \
233
+ \
234
+ h2 = kh_init_##name(mrb); \
235
+ for (k = kh_begin(h); k != kh_end(h); k++) { \
236
+ if (kh_exist(h, k)) { \
237
+ k2 = kh_put_##name(mrb, h2, kh_key(h, k), NULL); \
238
+ if (kh_is_map) kh_value(h2, k2) = kh_value(h, k); \
239
+ } \
240
+ } \
241
+ return h2; \
242
+ }
243
+
244
+
245
+ #define khash_t(name) kh_##name##_t
246
+
247
+ #define kh_init_size(name,mrb,size) kh_init_##name##_size(mrb,size)
248
+ #define kh_init(name,mrb) kh_init_##name(mrb)
249
+ #define kh_destroy(name, mrb, h) kh_destroy_##name(mrb, h)
250
+ #define kh_clear(name, mrb, h) kh_clear_##name(mrb, h)
251
+ #define kh_resize(name, mrb, h, s) kh_resize_##name(mrb, h, s)
252
+ #define kh_put(name, mrb, h, k) kh_put_##name(mrb, h, k, NULL)
253
+ #define kh_put2(name, mrb, h, k, r) kh_put_##name(mrb, h, k, r)
254
+ #define kh_get(name, mrb, h, k) kh_get_##name(mrb, h, k)
255
+ #define kh_del(name, mrb, h, k) kh_del_##name(mrb, h, k)
256
+ #define kh_copy(name, mrb, h) kh_copy_##name(mrb, h)
257
+
258
+ #define kh_exist(h, x) (!__ac_iseither((h)->ed_flags, (x)))
259
+ #define kh_key(h, x) ((h)->keys[x])
260
+ #define kh_val(h, x) ((h)->vals[x])
261
+ #define kh_value(h, x) ((h)->vals[x])
262
+ #define kh_begin(h) (khint_t)(0)
263
+ #define kh_end(h) ((h)->n_buckets)
264
+ #define kh_size(h) ((h)->size)
265
+ #define kh_n_buckets(h) ((h)->n_buckets)
266
+
267
+ #define kh_int_hash_func(mrb,key) (khint_t)((key)^((key)<<2)^((key)>>2))
268
+ #define kh_int_hash_equal(mrb,a, b) (a == b)
269
+ #define kh_int64_hash_func(mrb,key) (khint_t)((key)>>33^(key)^(key)<<11)
270
+ #define kh_int64_hash_equal(mrb,a, b) (a == b)
271
+ static inline khint_t __ac_X31_hash_string(const char *s)
272
+ {
273
+ khint_t h = *s;
274
+ if (h) for (++s ; *s; ++s) h = (h << 5) - h + *s;
275
+ return h;
276
+ }
277
+ #define kh_str_hash_func(mrb,key) __ac_X31_hash_string(key)
278
+ #define kh_str_hash_equal(mrb,a, b) (strcmp(a, b) == 0)
279
+
280
+ typedef const char *kh_cstr_t;
281
+
282
+ MRB_END_DECL
283
+
284
+ #endif /* MRUBY_KHASH_H */
@@ -0,0 +1,169 @@
1
+ /**
2
+ ** @file mruby/numeric.h - Numeric, Integer, Float class
3
+ **
4
+ ** See Copyright Notice in mruby.h
5
+ */
6
+
7
+ #ifndef MRUBY_NUMERIC_H
8
+ #define MRUBY_NUMERIC_H
9
+
10
+ #include "common.h"
11
+
12
+ /**
13
+ * Numeric class and it's sub-classes.
14
+ *
15
+ * Integer and Float
16
+ */
17
+ MRB_BEGIN_DECL
18
+
19
+ #define TYPED_POSFIXABLE(f,t) ((f) <= (t)MRB_FIXNUM_MAX)
20
+ #define TYPED_NEGFIXABLE(f,t) ((f) >= (t)MRB_FIXNUM_MIN)
21
+ #define TYPED_FIXABLE(f,t) (TYPED_POSFIXABLE(f,t) && TYPED_NEGFIXABLE(f,t))
22
+ #define POSFIXABLE(f) TYPED_POSFIXABLE(f,mrb_int)
23
+ #define NEGFIXABLE(f) TYPED_NEGFIXABLE(f,mrb_int)
24
+ #define FIXABLE(f) TYPED_FIXABLE(f,mrb_int)
25
+ #ifndef MRB_NO_FLOAT
26
+ #ifdef MRB_INT64
27
+ #define FIXABLE_FLOAT(f) ((f)>=-9223372036854775808.0 && (f)<9223372036854775808.0)
28
+ #else
29
+ #define FIXABLE_FLOAT(f) TYPED_FIXABLE(f,mrb_float)
30
+ #endif
31
+ #endif
32
+
33
+ #ifndef MRB_NO_FLOAT
34
+ MRB_API mrb_value mrb_flo_to_fixnum(mrb_state *mrb, mrb_value val);
35
+ #endif
36
+ MRB_API mrb_value mrb_fixnum_to_str(mrb_state *mrb, mrb_value x, mrb_int base);
37
+ /* ArgumentError if format string doesn't match /%(\.[0-9]+)?[aAeEfFgG]/ */
38
+ #ifndef MRB_NO_FLOAT
39
+ MRB_API mrb_value mrb_float_to_str(mrb_state *mrb, mrb_value x, const char *fmt);
40
+ MRB_API int mrb_float_to_cstr(mrb_state *mrb, char *buf, size_t len, const char *fmt, mrb_float f);
41
+ MRB_API mrb_float mrb_to_flo(mrb_state *mrb, mrb_value x);
42
+ #endif
43
+
44
+ MRB_API mrb_value mrb_num_plus(mrb_state *mrb, mrb_value x, mrb_value y);
45
+ MRB_API mrb_value mrb_num_minus(mrb_state *mrb, mrb_value x, mrb_value y);
46
+ MRB_API mrb_value mrb_num_mul(mrb_state *mrb, mrb_value x, mrb_value y);
47
+
48
+ #ifndef __has_builtin
49
+ #define __has_builtin(x) 0
50
+ #endif
51
+
52
+ #if (defined(__GNUC__) && __GNUC__ >= 5) || \
53
+ (__has_builtin(__builtin_add_overflow) && \
54
+ __has_builtin(__builtin_sub_overflow) && \
55
+ __has_builtin(__builtin_mul_overflow))
56
+ # define MRB_HAVE_TYPE_GENERIC_CHECKED_ARITHMETIC_BUILTINS
57
+ #endif
58
+
59
+ /*
60
+ // Clang 3.8 and 3.9 have problem compiling mruby in 32-bit mode, when MRB_INT64 is set
61
+ // because of missing __mulodi4 and similar functions in its runtime. We need to use custom
62
+ // implementation for them.
63
+ */
64
+ #ifdef MRB_HAVE_TYPE_GENERIC_CHECKED_ARITHMETIC_BUILTINS
65
+ #if defined(__clang__) && (__clang_major__ == 3) && (__clang_minor__ >= 8) && \
66
+ defined(MRB_32BIT) && defined(MRB_INT64)
67
+ #undef MRB_HAVE_TYPE_GENERIC_CHECKED_ARITHMETIC_BUILTINS
68
+ #endif
69
+ #endif
70
+
71
+ #ifdef MRB_HAVE_TYPE_GENERIC_CHECKED_ARITHMETIC_BUILTINS
72
+
73
+ static inline mrb_bool
74
+ mrb_int_add_overflow(mrb_int augend, mrb_int addend, mrb_int *sum)
75
+ {
76
+ return __builtin_add_overflow(augend, addend, sum);
77
+ }
78
+
79
+ static inline mrb_bool
80
+ mrb_int_sub_overflow(mrb_int minuend, mrb_int subtrahend, mrb_int *difference)
81
+ {
82
+ return __builtin_sub_overflow(minuend, subtrahend, difference);
83
+ }
84
+
85
+ static inline mrb_bool
86
+ mrb_int_mul_overflow(mrb_int multiplier, mrb_int multiplicand, mrb_int *product)
87
+ {
88
+ return __builtin_mul_overflow(multiplier, multiplicand, product);
89
+ }
90
+
91
+ #else
92
+
93
+ #define MRB_INT_OVERFLOW_MASK ((mrb_uint)1 << (MRB_INT_BIT - 1))
94
+
95
+ static inline mrb_bool
96
+ mrb_int_add_overflow(mrb_int a, mrb_int b, mrb_int *c)
97
+ {
98
+ mrb_uint x = (mrb_uint)a;
99
+ mrb_uint y = (mrb_uint)b;
100
+ mrb_uint z = (mrb_uint)(x + y);
101
+ *c = (mrb_int)z;
102
+ return !!(((x ^ z) & (y ^ z)) & MRB_INT_OVERFLOW_MASK);
103
+ }
104
+
105
+ static inline mrb_bool
106
+ mrb_int_sub_overflow(mrb_int a, mrb_int b, mrb_int *c)
107
+ {
108
+ mrb_uint x = (mrb_uint)a;
109
+ mrb_uint y = (mrb_uint)b;
110
+ mrb_uint z = (mrb_uint)(x - y);
111
+ *c = (mrb_int)z;
112
+ return !!(((x ^ z) & (~y ^ z)) & MRB_INT_OVERFLOW_MASK);
113
+ }
114
+
115
+ static inline mrb_bool
116
+ mrb_int_mul_overflow(mrb_int a, mrb_int b, mrb_int *c)
117
+ {
118
+ #ifdef MRB_INT32
119
+ int64_t n = (int64_t)a * b;
120
+ *c = (mrb_int)n;
121
+ return n > MRB_INT_MAX || n < MRB_INT_MIN;
122
+ #else /* MRB_INT64 */
123
+ if (a > 0 && b > 0 && a > MRB_INT_MAX / b) return TRUE;
124
+ if (a < 0 && b > 0 && a < MRB_INT_MIN / b) return TRUE;
125
+ if (a > 0 && b < 0 && b < MRB_INT_MIN / a) return TRUE;
126
+ if (a < 0 && b < 0 && (a <= MRB_INT_MIN || b <= MRB_INT_MIN || -a > MRB_INT_MAX / -b))
127
+ return TRUE;
128
+ *c = a * b;
129
+ return FALSE;
130
+ #endif
131
+ }
132
+
133
+ #undef MRB_INT_OVERFLOW_MASK
134
+
135
+ #endif
136
+
137
+ #ifndef MRB_NO_FLOAT
138
+ # include <stdint.h>
139
+ # include <float.h>
140
+
141
+ # define MRB_FLT_RADIX FLT_RADIX
142
+
143
+ # ifdef MRB_USE_FLOAT32
144
+ # define MRB_FLT_MANT_DIG FLT_MANT_DIG
145
+ # define MRB_FLT_EPSILON FLT_EPSILON
146
+ # define MRB_FLT_DIG FLT_DIG
147
+ # define MRB_FLT_MIN_EXP FLT_MIN_EXP
148
+ # define MRB_FLT_MIN FLT_MIN
149
+ # define MRB_FLT_MIN_10_EXP FLT_MIN_10_EXP
150
+ # define MRB_FLT_MAX_EXP FLT_MAX_EXP
151
+ # define MRB_FLT_MAX FLT_MAX
152
+ # define MRB_FLT_MAX_10_EXP FLT_MAX_10_EXP
153
+
154
+ # else /* not MRB_USE_FLOAT32 */
155
+ # define MRB_FLT_MANT_DIG DBL_MANT_DIG
156
+ # define MRB_FLT_EPSILON DBL_EPSILON
157
+ # define MRB_FLT_DIG DBL_DIG
158
+ # define MRB_FLT_MIN_EXP DBL_MIN_EXP
159
+ # define MRB_FLT_MIN DBL_MIN
160
+ # define MRB_FLT_MIN_10_EXP DBL_MIN_10_EXP
161
+ # define MRB_FLT_MAX_EXP DBL_MAX_EXP
162
+ # define MRB_FLT_MAX DBL_MAX
163
+ # define MRB_FLT_MAX_10_EXP DBL_MAX_10_EXP
164
+ # endif /* MRB_USE_FLOAT32 */
165
+ #endif /* MRB_NO_FLOAT */
166
+
167
+ MRB_END_DECL
168
+
169
+ #endif /* MRUBY_NUMERIC_H */
@@ -0,0 +1,43 @@
1
+ /**
2
+ ** @file mruby/object.h - mruby object definition
3
+ **
4
+ ** See Copyright Notice in mruby.h
5
+ */
6
+
7
+ #ifndef MRUBY_OBJECT_H
8
+ #define MRUBY_OBJECT_H
9
+
10
+ #define MRB_OBJECT_HEADER \
11
+ struct RClass *c; \
12
+ struct RBasic *gcnext; \
13
+ enum mrb_vtype tt:8; \
14
+ uint32_t color:3; \
15
+ uint32_t flags:21
16
+
17
+ #define MRB_FLAG_TEST(obj, flag) ((obj)->flags & (flag))
18
+
19
+ struct RBasic {
20
+ MRB_OBJECT_HEADER;
21
+ };
22
+ #define mrb_basic_ptr(v) ((struct RBasic*)(mrb_ptr(v)))
23
+
24
+ #define MRB_FL_OBJ_IS_FROZEN (1 << 20)
25
+ #define MRB_FROZEN_P(o) ((o)->flags & MRB_FL_OBJ_IS_FROZEN)
26
+ #define MRB_SET_FROZEN_FLAG(o) ((o)->flags |= MRB_FL_OBJ_IS_FROZEN)
27
+ #define MRB_UNSET_FROZEN_FLAG(o) ((o)->flags &= ~MRB_FL_OBJ_IS_FROZEN)
28
+ #define mrb_frozen_p(o) MRB_FROZEN_P(o)
29
+
30
+ struct RObject {
31
+ MRB_OBJECT_HEADER;
32
+ struct iv_tbl *iv;
33
+ };
34
+ #define mrb_obj_ptr(v) ((struct RObject*)(mrb_ptr(v)))
35
+
36
+ #define mrb_special_const_p(x) mrb_immediate_p(x)
37
+
38
+ struct RFiber {
39
+ MRB_OBJECT_HEADER;
40
+ struct mrb_context *cxt;
41
+ };
42
+
43
+ #endif /* MRUBY_OBJECT_H */
@@ -0,0 +1,43 @@
1
+ /**
2
+ ** @file mruby/opcode.h - RiteVM operation codes
3
+ **
4
+ ** See Copyright Notice in mruby.h
5
+ */
6
+
7
+ #ifndef MRUBY_OPCODE_H
8
+ #define MRUBY_OPCODE_H
9
+
10
+ enum mrb_insn {
11
+ #define OPCODE(x,_) OP_ ## x,
12
+ #include "mruby/ops.h"
13
+ #undef OPCODE
14
+ };
15
+
16
+ #define OP_L_STRICT 1
17
+ #define OP_L_CAPTURE 2
18
+ #define OP_L_METHOD OP_L_STRICT
19
+ #define OP_L_LAMBDA (OP_L_STRICT|OP_L_CAPTURE)
20
+ #define OP_L_BLOCK OP_L_CAPTURE
21
+
22
+ #define OP_R_NORMAL 0
23
+ #define OP_R_BREAK 1
24
+ #define OP_R_RETURN 2
25
+
26
+ #define PEEK_B(pc) (*(pc))
27
+ #define PEEK_S(pc) ((pc)[0]<<8|(pc)[1])
28
+ #define PEEK_W(pc) ((pc)[0]<<16|(pc)[1]<<8|(pc)[2])
29
+
30
+ #define READ_B() PEEK_B(pc++)
31
+ #define READ_S() (pc+=2, PEEK_S(pc-2))
32
+ #define READ_W() (pc+=3, PEEK_W(pc-3))
33
+
34
+ #define FETCH_Z() /* nothing */
35
+ #define FETCH_B() do {a=READ_B();} while (0)
36
+ #define FETCH_BB() do {a=READ_B(); b=READ_B();} while (0)
37
+ #define FETCH_BBB() do {a=READ_B(); b=READ_B(); c=READ_B();} while (0)
38
+ #define FETCH_BS() do {a=READ_B(); b=READ_S();} while (0)
39
+ #define FETCH_BSS() do {a=READ_B(); b=READ_S(); c=READ_S();} while (0)
40
+ #define FETCH_S() do {a=READ_S();} while (0)
41
+ #define FETCH_W() do {a=READ_W();} while (0)
42
+
43
+ #endif /* MRUBY_OPCODE_H */
@@ -0,0 +1,122 @@
1
+ /* operand types:
2
+ + Z: no operand
3
+ + B: 8bit
4
+ + BB: 8+8bit
5
+ + BBB: 8+8+8bit
6
+ + BS: 8+16bit
7
+ + BSS: 8+16+16bit
8
+ + S: 16bit
9
+ + W: 24bit
10
+ */
11
+
12
+ /*-----------------------------------------------------------------------
13
+ operation code operands semantics
14
+ ------------------------------------------------------------------------*/
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)) */
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 */
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) */
68
+ 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)) */
70
+ 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 */
120
+ OPCODE(DEBUG, BBB) /* print a,b,c */
121
+ OPCODE(ERR, B) /* raise(LocalJumpError, Lit(a)) */
122
+ OPCODE(STOP, Z) /* stop VM */