ruby2d 0.12.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE.md +7 -0
- data/README.md +141 -0
- data/USAGE.md +2435 -0
- data/assets/Rakefile +637 -0
- data/assets/build_support/CMakeLists.txt +94 -0
- data/assets/build_support/mruby/build_config.rb +34 -0
- data/assets/build_support/mruby/build_config_wasm.rb +30 -0
- data/assets/build_support/sdl_test.c +174 -0
- data/assets/deps.yaml +16 -0
- data/assets/platform/include/SDL3/SDL.h +91 -0
- data/assets/platform/include/SDL3/SDL_assert.h +705 -0
- data/assets/platform/include/SDL3/SDL_asyncio.h +550 -0
- data/assets/platform/include/SDL3/SDL_atomic.h +692 -0
- data/assets/platform/include/SDL3/SDL_audio.h +2370 -0
- data/assets/platform/include/SDL3/SDL_begin_code.h +553 -0
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_bits.h +47 -27
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_blendmode.h +59 -55
- data/assets/platform/include/SDL3/SDL_camera.h +535 -0
- data/assets/platform/include/SDL3/SDL_clipboard.h +331 -0
- data/assets/{include/SDL2/close_code.h → platform/include/SDL3/SDL_close_code.h} +9 -8
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_copying.h +3 -1
- data/assets/platform/include/SDL3/SDL_cpuinfo.h +374 -0
- data/assets/platform/include/SDL3/SDL_dialog.h +343 -0
- data/assets/platform/include/SDL3/SDL_dlopennote.h +234 -0
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_egl.h +11 -8
- data/assets/platform/include/SDL3/SDL_endian.h +645 -0
- data/assets/platform/include/SDL3/SDL_error.h +226 -0
- data/assets/platform/include/SDL3/SDL_events.h +1645 -0
- data/assets/platform/include/SDL3/SDL_filesystem.h +537 -0
- data/assets/platform/include/SDL3/SDL_gamepad.h +1656 -0
- data/assets/platform/include/SDL3/SDL_gpu.h +4608 -0
- data/assets/platform/include/SDL3/SDL_guid.h +106 -0
- data/assets/platform/include/SDL3/SDL_haptic.h +1461 -0
- data/assets/platform/include/SDL3/SDL_hidapi.h +571 -0
- data/assets/platform/include/SDL3/SDL_hints.h +5001 -0
- data/assets/platform/include/SDL3/SDL_init.h +507 -0
- data/assets/platform/include/SDL3/SDL_intrin.h +410 -0
- data/assets/platform/include/SDL3/SDL_iostream.h +1379 -0
- data/assets/platform/include/SDL3/SDL_joystick.h +1385 -0
- data/assets/platform/include/SDL3/SDL_keyboard.h +608 -0
- data/assets/platform/include/SDL3/SDL_keycode.h +347 -0
- data/assets/platform/include/SDL3/SDL_loadso.h +145 -0
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_locale.h +40 -24
- data/assets/platform/include/SDL3/SDL_log.h +541 -0
- data/assets/platform/include/SDL3/SDL_main.h +704 -0
- data/assets/platform/include/SDL3/SDL_main_impl.h +151 -0
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_messagebox.h +85 -48
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_metal.h +29 -29
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_misc.h +13 -12
- data/assets/platform/include/SDL3/SDL_mouse.h +813 -0
- data/assets/platform/include/SDL3/SDL_mutex.h +1117 -0
- data/assets/platform/include/SDL3/SDL_oldnames.h +1339 -0
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_opengl.h +1247 -278
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_opengl_glext.h +5 -1
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_opengles.h +6 -7
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_opengles2.h +10 -11
- data/assets/platform/include/SDL3/SDL_pen.h +198 -0
- data/assets/platform/include/SDL3/SDL_pixels.h +1441 -0
- data/assets/{include/SDL2/SDL_test_log.h → platform/include/SDL3/SDL_platform.h} +25 -26
- data/assets/platform/include/SDL3/SDL_platform_defines.h +497 -0
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_power.h +40 -20
- data/assets/platform/include/SDL3/SDL_process.h +441 -0
- data/assets/platform/include/SDL3/SDL_properties.h +572 -0
- data/assets/platform/include/SDL3/SDL_rect.h +528 -0
- data/assets/platform/include/SDL3/SDL_render.h +3028 -0
- data/assets/platform/include/SDL3/SDL_revision.h +59 -0
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_scancode.h +59 -68
- data/assets/platform/include/SDL3/SDL_sensor.h +321 -0
- data/assets/platform/include/SDL3/SDL_stdinc.h +6186 -0
- data/assets/platform/include/SDL3/SDL_storage.h +686 -0
- data/assets/platform/include/SDL3/SDL_surface.h +1769 -0
- data/assets/platform/include/SDL3/SDL_system.h +840 -0
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test.h +16 -22
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_assert.h +27 -34
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_common.h +109 -52
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_compare.h +22 -14
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_crc32.h +27 -30
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_font.h +50 -49
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_fuzzer.h +64 -79
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_harness.h +47 -30
- data/assets/platform/include/SDL3/SDL_test_log.h +83 -0
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_md5.h +21 -28
- data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_memory.h +19 -16
- data/assets/platform/include/SDL3/SDL_thread.h +602 -0
- data/assets/platform/include/SDL3/SDL_time.h +249 -0
- data/assets/platform/include/SDL3/SDL_timer.h +454 -0
- data/assets/platform/include/SDL3/SDL_touch.h +184 -0
- data/assets/platform/include/SDL3/SDL_tray.h +544 -0
- data/assets/platform/include/SDL3/SDL_version.h +198 -0
- data/assets/platform/include/SDL3/SDL_video.h +3497 -0
- data/assets/platform/include/SDL3/SDL_vulkan.h +287 -0
- data/assets/platform/include/SDL3_image/SDL_image.h +3328 -0
- data/assets/platform/include/SDL3_mixer/SDL_mixer.h +3369 -0
- data/assets/platform/include/SDL3_ttf/SDL_textengine.h +181 -0
- data/assets/platform/include/SDL3_ttf/SDL_ttf.h +2833 -0
- data/assets/{include → platform/include}/mrbconf.h +42 -31
- data/assets/{include → platform/include}/mruby/array.h +3 -4
- data/assets/{include → platform/include}/mruby/boxing_nan.h +10 -0
- data/assets/platform/include/mruby/boxing_no.h +59 -0
- data/assets/{include → platform/include}/mruby/boxing_word.h +72 -26
- data/assets/platform/include/mruby/class.h +157 -0
- data/assets/{include → platform/include}/mruby/common.h +30 -1
- data/assets/{include → platform/include}/mruby/compile.h +52 -74
- data/assets/{include → platform/include}/mruby/data.h +2 -2
- data/assets/{include → platform/include}/mruby/debug.h +12 -5
- data/assets/{include → platform/include}/mruby/dump.h +7 -9
- data/assets/{include → platform/include}/mruby/endian.h +1 -1
- data/assets/platform/include/mruby/error.h +173 -0
- data/assets/platform/include/mruby/gc.h +79 -0
- data/assets/{include → platform/include}/mruby/hash.h +1 -7
- data/assets/platform/include/mruby/internal.h +282 -0
- data/assets/platform/include/mruby/irep.h +143 -0
- data/assets/{include → platform/include}/mruby/istruct.h +1 -1
- data/assets/platform/include/mruby/khash.h +455 -0
- data/assets/platform/include/mruby/mempool.h +19 -0
- data/assets/{include → platform/include}/mruby/numeric.h +7 -10
- data/assets/platform/include/mruby/object.h +51 -0
- data/assets/{include → platform/include}/mruby/opcode.h +5 -5
- data/assets/{include → platform/include}/mruby/ops.h +19 -6
- data/assets/platform/include/mruby/presym/id.h +1447 -0
- data/assets/{include → platform/include}/mruby/presym/scanning.h +10 -7
- data/assets/platform/include/mruby/presym/table.h +2893 -0
- data/assets/platform/include/mruby/presym.h +65 -0
- data/assets/platform/include/mruby/proc.h +184 -0
- data/assets/{include → platform/include}/mruby/range.h +0 -2
- data/assets/{include → platform/include}/mruby/string.h +33 -53
- data/assets/platform/include/mruby/throw.h +81 -0
- data/assets/{include → platform/include}/mruby/value.h +64 -29
- data/assets/{include → platform/include}/mruby/variable.h +6 -23
- data/assets/{include → platform/include}/mruby/version.h +7 -7
- data/assets/{include → platform/include}/mruby.h +238 -116
- data/assets/platform/macos-arm64/bin/mrbc +0 -0
- data/assets/platform/macos-arm64/lib/libSDL3.a +0 -0
- data/assets/platform/macos-arm64/lib/libSDL3_image.a +0 -0
- data/assets/platform/macos-arm64/lib/libSDL3_mixer.a +0 -0
- data/assets/platform/macos-arm64/lib/libSDL3_ttf.a +0 -0
- data/assets/platform/macos-arm64/lib/libmruby.a +0 -0
- data/assets/platform/wasm/lib/libFLAC.a +0 -0
- data/assets/platform/wasm/lib/libSDL3.a +0 -0
- data/assets/platform/wasm/lib/libSDL3_image.a +0 -0
- data/assets/platform/wasm/lib/libSDL3_mixer.a +0 -0
- data/assets/platform/wasm/lib/libSDL3_ttf.a +0 -0
- data/assets/platform/wasm/lib/libfreetype.a +0 -0
- data/assets/platform/wasm/lib/libharfbuzz.a +0 -0
- data/assets/platform/wasm/lib/libmruby.a +0 -0
- data/assets/platform/wasm/lib/libogg.a +0 -0
- data/assets/platform/wasm/lib/libplutosvg.a +0 -0
- data/assets/platform/wasm/lib/libplutovg.a +0 -0
- data/assets/platform/wasm/lib/libpng.a +0 -0
- data/assets/platform/wasm/lib/libpng16.a +0 -0
- data/assets/platform/wasm/lib/libvorbis.a +0 -0
- data/assets/platform/wasm/lib/libvorbisfile.a +0 -0
- data/assets/platform/wasm/lib/libzlibstatic.a +0 -0
- data/assets/platform/windows-arm64-mingw-ucrt/bin/mrbc.exe +0 -0
- data/assets/platform/windows-arm64-mingw-ucrt/lib/libSDL3.a +0 -0
- data/assets/platform/windows-arm64-mingw-ucrt/lib/libSDL3_image.a +0 -0
- data/assets/platform/windows-arm64-mingw-ucrt/lib/libSDL3_mixer.a +0 -0
- data/assets/platform/windows-arm64-mingw-ucrt/lib/libSDL3_ttf.a +0 -0
- data/assets/platform/windows-arm64-mingw-ucrt/lib/libmruby.a +0 -0
- data/assets/platform/windows-x86_64-mingw-ucrt/bin/mrbc.exe +0 -0
- data/assets/platform/windows-x86_64-mingw-ucrt/lib/libSDL3.a +0 -0
- data/assets/platform/windows-x86_64-mingw-ucrt/lib/libSDL3_image.a +0 -0
- data/assets/platform/windows-x86_64-mingw-ucrt/lib/libSDL3_mixer.a +0 -0
- data/assets/platform/windows-x86_64-mingw-ucrt/lib/libSDL3_ttf.a +0 -0
- data/assets/platform/windows-x86_64-mingw-ucrt/lib/libmruby.a +0 -0
- data/assets/resources/fonts/outfit/OFL.txt +93 -0
- data/assets/resources/fonts/outfit/outfit.ttf +0 -0
- data/assets/resources/fonts/roboto_mono/OFL.txt +91 -0
- data/assets/resources/fonts/roboto_mono/roboto_mono.ttf +0 -0
- data/assets/resources/icons/icon.icns +0 -0
- data/assets/resources/icons/icon.png +0 -0
- data/assets/resources/spritesheets/License.txt +28 -0
- data/assets/resources/spritesheets/spritesheet-backgrounds.png +0 -0
- data/assets/resources/spritesheets/spritesheet-backgrounds.xml +16 -0
- data/assets/resources/spritesheets/spritesheet-characters.png +0 -0
- data/assets/resources/spritesheets/spritesheet-characters.xml +47 -0
- data/assets/resources/spritesheets/spritesheet-enemies.png +0 -0
- data/assets/resources/spritesheets/spritesheet-enemies.xml +62 -0
- data/assets/resources/spritesheets/spritesheet-tiles.png +0 -0
- data/assets/resources/spritesheets/spritesheet-tiles.xml +316 -0
- data/assets/{wasm → resources/web}/template.html +1 -1
- data/assets/target.rb +131 -0
- data/bin/ruby2d +281 -82
- data/examples/astar.rb +269 -0
- data/examples/asteroids.rb +403 -0
- data/examples/bezier_editor.rb +96 -0
- data/examples/boids.rb +191 -0
- data/examples/bouncing_balls.rb +119 -0
- data/examples/breakout.rb +186 -0
- data/examples/constellations.rb +100 -0
- data/examples/dashboard.rb +133 -0
- data/examples/double_pendulum.rb +254 -0
- data/examples/falling_sand.rb +291 -0
- data/examples/fireworks.rb +110 -0
- data/examples/fluid_dynamics.rb +340 -0
- data/examples/fourier_epicycles.rb +142 -0
- data/examples/fractal_tree.rb +326 -0
- data/examples/game_of_life.rb +148 -0
- data/examples/gamepads.rb +333 -0
- data/examples/hill_driver.rb +613 -0
- data/examples/logo_animation.rb +251 -0
- data/examples/lorenz_attractor.rb +115 -0
- data/examples/mandelbrot.rb +207 -0
- data/examples/marching_squares.rb +200 -0
- data/examples/maze.rb +323 -0
- data/examples/nbody.rb +338 -0
- data/examples/outrun.rb +391 -0
- data/examples/pixel_paint.rb +313 -0
- data/examples/platformer.rb +335 -0
- data/examples/ray_casting_maze.rb +175 -0
- data/examples/shadow_casting.rb +151 -0
- data/examples/shape_recognizer.rb +908 -0
- data/examples/snake.rb +144 -0
- data/examples/sprite_sheets.rb +246 -0
- data/examples/swarm.rb +206 -0
- data/examples/tsp_annealing.rb +104 -0
- data/examples/ui_controls.rb +163 -0
- data/examples/wireframe_3d.rb +139 -0
- data/ext/ruby2d/audio.c +324 -0
- data/ext/ruby2d/canvas.c +1715 -494
- data/ext/ruby2d/ext.c +541 -0
- data/ext/ruby2d/extconf.rb +122 -145
- data/ext/ruby2d/font.c +566 -20
- data/ext/ruby2d/fps.c +92 -0
- data/ext/ruby2d/image.c +466 -41
- data/ext/ruby2d/ruby2d.c +374 -1890
- data/ext/ruby2d/ruby2d.h +840 -460
- data/ext/ruby2d/shapes.c +931 -101
- data/ext/ruby2d/text.c +586 -21
- data/ext/ruby2d/window.c +1693 -283
- data/lib/ruby2d/atlas_parser.rb +194 -0
- data/lib/ruby2d/audio.rb +73 -0
- data/lib/ruby2d/benchmark.rb +259 -0
- data/lib/ruby2d/bitmap_text.rb +155 -0
- data/lib/ruby2d/button.rb +402 -0
- data/lib/ruby2d/canvas.rb +703 -279
- data/lib/ruby2d/circle.rb +206 -29
- data/lib/ruby2d/cli/browser.rb +314 -0
- data/lib/ruby2d/cli/build.rb +471 -257
- data/lib/ruby2d/cli/colorize.rb +7 -5
- data/lib/ruby2d/cli/examples.rb +127 -0
- data/lib/ruby2d/cli/launch.rb +24 -39
- data/lib/ruby2d/cli/lib_files.rb +48 -0
- data/lib/ruby2d/cli/messages.rb +40 -0
- data/lib/ruby2d/cli/setup.rb +273 -0
- data/lib/ruby2d/cli/static_server.rb +160 -0
- data/lib/ruby2d/cli/usage.rb +255 -0
- data/lib/ruby2d/color.rb +191 -69
- data/lib/ruby2d/core.rb +37 -19
- data/lib/ruby2d/deps_help.rb +89 -0
- data/lib/ruby2d/dsl.rb +51 -12
- data/lib/ruby2d/ellipse.rb +228 -0
- data/lib/ruby2d/exceptions.rb +0 -2
- data/lib/ruby2d/font.rb +34 -74
- data/lib/ruby2d/gamepad.rb +323 -0
- data/lib/ruby2d/gem_paths.rb +19 -0
- data/lib/ruby2d/image.rb +155 -52
- data/lib/ruby2d/interactive.rb +103 -0
- data/lib/ruby2d/json_parser.rb +268 -0
- data/lib/ruby2d/line.rb +194 -85
- data/lib/ruby2d/mruby_compat.rb +12 -0
- data/lib/ruby2d/polygon.rb +297 -0
- data/lib/ruby2d/polyline.rb +368 -0
- data/lib/ruby2d/quad.rb +358 -94
- data/lib/ruby2d/rectangle.rb +77 -19
- data/lib/ruby2d/renderable.rb +411 -11
- data/lib/ruby2d/sprite.rb +471 -180
- data/lib/ruby2d/sprite_sheet.rb +64 -0
- data/lib/ruby2d/square.rb +29 -17
- data/lib/ruby2d/text.rb +196 -65
- data/lib/ruby2d/tileset.rb +139 -81
- data/lib/ruby2d/triangle.rb +324 -89
- data/lib/ruby2d/version.rb +1 -3
- data/lib/ruby2d/vertices.rb +62 -85
- data/lib/ruby2d/warnings.rb +29 -0
- data/lib/ruby2d/window/class_methods.rb +218 -0
- data/lib/ruby2d/window/gamepad_events.rb +141 -0
- data/lib/ruby2d/window/key_events.rb +74 -0
- data/lib/ruby2d/window/mouse_events.rb +171 -0
- data/lib/ruby2d/window/object_events.rb +168 -0
- data/lib/ruby2d/window.rb +632 -585
- data/lib/ruby2d.rb +14 -19
- metadata +275 -443
- data/assets/app.icns +0 -0
- data/assets/include/GL/glew.h +0 -26427
- data/assets/include/GLES2/gl2.h +0 -656
- data/assets/include/GLES2/gl2ext.h +0 -3949
- data/assets/include/GLES2/gl2ext_angle.h +0 -701
- data/assets/include/GLES2/gl2platform.h +0 -27
- data/assets/include/GLES3/gl3.h +0 -1192
- data/assets/include/GLES3/gl31.h +0 -1507
- data/assets/include/GLES3/gl32.h +0 -1808
- data/assets/include/GLES3/gl3platform.h +0 -27
- data/assets/include/KHR/khrplatform.h +0 -290
- data/assets/include/SDL2/SDL.h +0 -233
- data/assets/include/SDL2/SDL_assert.h +0 -326
- data/assets/include/SDL2/SDL_atomic.h +0 -415
- data/assets/include/SDL2/SDL_audio.h +0 -1500
- data/assets/include/SDL2/SDL_clipboard.h +0 -141
- data/assets/include/SDL2/SDL_config.h +0 -61
- data/assets/include/SDL2/SDL_config_android.h +0 -194
- data/assets/include/SDL2/SDL_config_emscripten.h +0 -218
- data/assets/include/SDL2/SDL_config_iphoneos.h +0 -217
- data/assets/include/SDL2/SDL_config_macosx.h +0 -277
- data/assets/include/SDL2/SDL_config_minimal.h +0 -95
- data/assets/include/SDL2/SDL_config_ngage.h +0 -89
- data/assets/include/SDL2/SDL_config_os2.h +0 -207
- data/assets/include/SDL2/SDL_config_pandora.h +0 -141
- data/assets/include/SDL2/SDL_config_windows.h +0 -331
- data/assets/include/SDL2/SDL_config_wingdk.h +0 -253
- data/assets/include/SDL2/SDL_config_winrt.h +0 -220
- data/assets/include/SDL2/SDL_config_xbox.h +0 -235
- data/assets/include/SDL2/SDL_cpuinfo.h +0 -594
- data/assets/include/SDL2/SDL_endian.h +0 -348
- data/assets/include/SDL2/SDL_error.h +0 -163
- data/assets/include/SDL2/SDL_events.h +0 -1166
- data/assets/include/SDL2/SDL_filesystem.h +0 -149
- data/assets/include/SDL2/SDL_gamecontroller.h +0 -1074
- data/assets/include/SDL2/SDL_gesture.h +0 -117
- data/assets/include/SDL2/SDL_guid.h +0 -100
- data/assets/include/SDL2/SDL_haptic.h +0 -1341
- data/assets/include/SDL2/SDL_hidapi.h +0 -451
- data/assets/include/SDL2/SDL_hints.h +0 -2569
- data/assets/include/SDL2/SDL_image.h +0 -2173
- data/assets/include/SDL2/SDL_joystick.h +0 -1066
- data/assets/include/SDL2/SDL_keyboard.h +0 -353
- data/assets/include/SDL2/SDL_keycode.h +0 -358
- data/assets/include/SDL2/SDL_loadso.h +0 -115
- data/assets/include/SDL2/SDL_log.h +0 -404
- data/assets/include/SDL2/SDL_main.h +0 -275
- data/assets/include/SDL2/SDL_mixer.h +0 -2784
- data/assets/include/SDL2/SDL_mouse.h +0 -465
- data/assets/include/SDL2/SDL_mutex.h +0 -471
- data/assets/include/SDL2/SDL_name.h +0 -33
- data/assets/include/SDL2/SDL_pixels.h +0 -644
- data/assets/include/SDL2/SDL_platform.h +0 -261
- data/assets/include/SDL2/SDL_quit.h +0 -58
- data/assets/include/SDL2/SDL_rect.h +0 -376
- data/assets/include/SDL2/SDL_render.h +0 -1919
- data/assets/include/SDL2/SDL_revision.h +0 -6
- data/assets/include/SDL2/SDL_rwops.h +0 -841
- data/assets/include/SDL2/SDL_sensor.h +0 -322
- data/assets/include/SDL2/SDL_shape.h +0 -155
- data/assets/include/SDL2/SDL_stdinc.h +0 -830
- data/assets/include/SDL2/SDL_surface.h +0 -997
- data/assets/include/SDL2/SDL_system.h +0 -623
- data/assets/include/SDL2/SDL_syswm.h +0 -386
- data/assets/include/SDL2/SDL_test_images.h +0 -78
- data/assets/include/SDL2/SDL_test_random.h +0 -115
- data/assets/include/SDL2/SDL_thread.h +0 -464
- data/assets/include/SDL2/SDL_timer.h +0 -222
- data/assets/include/SDL2/SDL_touch.h +0 -150
- data/assets/include/SDL2/SDL_ttf.h +0 -2316
- data/assets/include/SDL2/SDL_types.h +0 -29
- data/assets/include/SDL2/SDL_version.h +0 -204
- data/assets/include/SDL2/SDL_video.h +0 -2150
- data/assets/include/SDL2/SDL_vulkan.h +0 -215
- data/assets/include/SDL2/begin_code.h +0 -187
- data/assets/include/mruby/boxing_no.h +0 -58
- data/assets/include/mruby/class.h +0 -108
- data/assets/include/mruby/error.h +0 -147
- data/assets/include/mruby/gc.h +0 -94
- data/assets/include/mruby/irep.h +0 -147
- data/assets/include/mruby/khash.h +0 -284
- data/assets/include/mruby/object.h +0 -43
- data/assets/include/mruby/presym/disable.h +0 -70
- data/assets/include/mruby/presym/enable.h +0 -37
- data/assets/include/mruby/presym.h +0 -40
- data/assets/include/mruby/proc.h +0 -211
- data/assets/include/mruby/throw.h +0 -66
- data/assets/macos/universal/bin/mrbc +0 -0
- data/assets/macos/universal/lib/libFLAC.a +0 -0
- data/assets/macos/universal/lib/libSDL2.a +0 -0
- data/assets/macos/universal/lib/libSDL2_image.a +0 -0
- data/assets/macos/universal/lib/libSDL2_mixer.a +0 -0
- data/assets/macos/universal/lib/libSDL2_ttf.a +0 -0
- data/assets/macos/universal/lib/libavif.a +0 -0
- data/assets/macos/universal/lib/libbrotlicommon-static.a +0 -0
- data/assets/macos/universal/lib/libbrotlidec-static.a +0 -0
- data/assets/macos/universal/lib/libfreetype.a +0 -0
- data/assets/macos/universal/lib/libgraphite2.a +0 -0
- data/assets/macos/universal/lib/libharfbuzz.a +0 -0
- data/assets/macos/universal/lib/libhwy.a +0 -0
- data/assets/macos/universal/lib/libjpeg.a +0 -0
- data/assets/macos/universal/lib/libjxl.a +0 -0
- data/assets/macos/universal/lib/libmodplug.a +0 -0
- data/assets/macos/universal/lib/libmpg123.a +0 -0
- data/assets/macos/universal/lib/libmruby.a +0 -0
- data/assets/macos/universal/lib/libogg.a +0 -0
- data/assets/macos/universal/lib/libpng.a +0 -0
- data/assets/macos/universal/lib/libtiff.a +0 -0
- data/assets/macos/universal/lib/libvorbis.a +0 -0
- data/assets/macos/universal/lib/libvorbisfile.a +0 -0
- data/assets/macos/universal/lib/libwebp.a +0 -0
- data/assets/macos/universal/lib/libzstd.a +0 -0
- data/assets/test_media/README.md +0 -3
- data/assets/test_media/bitstream_vera/COPYRIGHT.txt +0 -124
- data/assets/test_media/bitstream_vera/vera.ttf +0 -0
- data/assets/test_media/boom.png +0 -0
- data/assets/test_media/coin.png +0 -0
- data/assets/test_media/colors.png +0 -0
- data/assets/test_media/controller.png +0 -0
- data/assets/test_media/dial.wav +0 -0
- data/assets/test_media/hero.png +0 -0
- data/assets/test_media/image.bmp +0 -0
- data/assets/test_media/image.jpg +0 -0
- data/assets/test_media/image.png +0 -0
- data/assets/test_media/music.flac +0 -0
- data/assets/test_media/music.mp3 +0 -0
- data/assets/test_media/music.ogg +0 -0
- data/assets/test_media/music.wav +0 -0
- data/assets/test_media/originals/boom.pxm +0 -0
- data/assets/test_media/originals/coin.pxm +0 -0
- data/assets/test_media/originals/controller.sketch +0 -0
- data/assets/test_media/originals/hero.pxm +0 -0
- data/assets/test_media/originals/image.pxm +0 -0
- data/assets/test_media/originals/music.caf +0 -0
- data/assets/test_media/originals/texture_atlas.pxm +0 -0
- data/assets/test_media/rondo_alla_turka.ogg +0 -0
- data/assets/test_media/sound.flac +0 -0
- data/assets/test_media/sound.mp3 +0 -0
- data/assets/test_media/sound.ogg +0 -0
- data/assets/test_media/sound.wav +0 -0
- data/assets/test_media/sprite_sheet.png +0 -0
- data/assets/test_media/texture_atlas.png +0 -0
- data/assets/wasm/libmruby.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/bin/mrbc.exe +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libFLAC.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libLerc.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2_image.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2_mixer.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2_ttf.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libbrotlicommon.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libbrotlidec.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libbz2.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libdeflate.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libfreetype.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libglew32.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libgraphite2.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libharfbuzz.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libhwy.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libjbig.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libjpeg.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libjxl.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/liblzma.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libmodplug.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libmpg123.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libmruby.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libogg.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libopus.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libopusfile.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libpng.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libsndfile.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libssp.a +0 -1
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libstdc++.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libtiff.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libvorbis.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libvorbisfile.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libwebp.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libz.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libzstd.a +0 -0
- data/assets/windows/mingw-w64-x86_64/bin/mrbc.exe +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libFLAC.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libLerc.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libSDL2.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libSDL2_image.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libSDL2_mixer.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libSDL2_ttf.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libbrotlicommon.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libbrotlidec.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libbz2.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libdeflate.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libfreetype.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libglew32.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libgraphite2.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libharfbuzz.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libhwy.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libjbig.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libjpeg.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libjxl.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/liblzma.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libmodplug.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libmpg123.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libmruby.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libogg.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libopus.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libopusfile.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libpng.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libsndfile.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libssp.a +0 -1
- data/assets/windows/mingw-w64-x86_64/lib/libstdc++.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libtiff.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libvorbis.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libvorbisfile.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libwebp.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libz.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libzstd.a +0 -0
- data/assets/xcode/ios/Assets.xcassets/AppIcon.appiconset/Contents.json +0 -98
- data/assets/xcode/ios/Assets.xcassets/Contents.json +0 -6
- data/assets/xcode/ios/Base.lproj/LaunchScreen.storyboard +0 -27
- data/assets/xcode/ios/Info.plist +0 -43
- data/assets/xcode/ios/MRuby.framework/Headers/mrbconf.h +0 -143
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/array.h +0 -280
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/boxing_nan.h +0 -102
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/boxing_no.h +0 -56
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/boxing_word.h +0 -144
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/class.h +0 -97
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/common.h +0 -77
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/compile.h +0 -195
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/data.h +0 -75
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/debug.h +0 -67
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/dump.h +0 -196
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/error.h +0 -75
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/gc.h +0 -91
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/hash.h +0 -215
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/irep.h +0 -75
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/istruct.h +0 -47
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/khash.h +0 -274
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/numeric.h +0 -161
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/object.h +0 -44
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/opcode.h +0 -69
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/ops.h +0 -117
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/proc.h +0 -131
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/range.h +0 -49
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/re.h +0 -16
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/string.h +0 -444
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/throw.h +0 -55
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/value.h +0 -309
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/variable.h +0 -136
- data/assets/xcode/ios/MRuby.framework/Headers/mruby/version.h +0 -110
- data/assets/xcode/ios/MRuby.framework/Headers/mruby.h +0 -1282
- data/assets/xcode/ios/MRuby.framework/Info.plist +0 -20
- data/assets/xcode/ios/MRuby.framework/MRuby +0 -0
- data/assets/xcode/ios/MyApp.xcodeproj/project.pbxproj +0 -368
- data/assets/xcode/ios/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- data/assets/xcode/ios/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- data/assets/xcode/ios/MyApp.xcodeproj/project.xcworkspace/xcshareddata/MyApp.xcscmblueprint +0 -30
- data/assets/xcode/ios/main.c +0 -1
- data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Content.imageset/Contents.json +0 -16
- data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Contents.json +0 -6
- data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Contents.json +0 -17
- data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Content.imageset/Contents.json +0 -16
- data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Contents.json +0 -6
- data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json +0 -16
- data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Contents.json +0 -6
- data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Content.imageset/Contents.json +0 -16
- data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Contents.json +0 -6
- data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Contents.json +0 -17
- data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Content.imageset/Contents.json +0 -16
- data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Contents.json +0 -6
- data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json +0 -16
- data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Contents.json +0 -6
- data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Contents.json +0 -32
- data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image Wide.imageset/Contents.json +0 -16
- data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image.imageset/Contents.json +0 -16
- data/assets/xcode/tvos/Assets.xcassets/Contents.json +0 -6
- data/assets/xcode/tvos/Assets.xcassets/LaunchImage.launchimage/Contents.json +0 -22
- data/assets/xcode/tvos/Info.plist +0 -30
- data/assets/xcode/tvos/MRuby.framework/Headers/mrbconf.h +0 -143
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/array.h +0 -280
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/boxing_nan.h +0 -102
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/boxing_no.h +0 -56
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/boxing_word.h +0 -144
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/class.h +0 -97
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/common.h +0 -77
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/compile.h +0 -195
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/data.h +0 -75
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/debug.h +0 -67
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/dump.h +0 -196
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/error.h +0 -75
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/gc.h +0 -91
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/hash.h +0 -215
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/irep.h +0 -75
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/istruct.h +0 -47
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/khash.h +0 -274
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/numeric.h +0 -161
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/object.h +0 -44
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/opcode.h +0 -69
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/ops.h +0 -117
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/proc.h +0 -131
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/range.h +0 -49
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/re.h +0 -16
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/string.h +0 -444
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/throw.h +0 -55
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/value.h +0 -309
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/variable.h +0 -136
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby/version.h +0 -110
- data/assets/xcode/tvos/MRuby.framework/Headers/mruby.h +0 -1282
- data/assets/xcode/tvos/MRuby.framework/Info.plist +0 -20
- data/assets/xcode/tvos/MRuby.framework/MRuby +0 -0
- data/assets/xcode/tvos/MyApp.xcodeproj/project.pbxproj +0 -350
- data/assets/xcode/tvos/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- data/assets/xcode/tvos/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- data/assets/xcode/tvos/MyApp.xcodeproj/project.xcworkspace/xcshareddata/MyApp.xcscmblueprint +0 -30
- data/assets/xcode/tvos/main.c +0 -1
- data/ext/ruby2d/common.c +0 -185
- data/ext/ruby2d/controllers.c +0 -110
- data/ext/ruby2d/gl.c +0 -398
- data/ext/ruby2d/gl2.c +0 -86
- data/ext/ruby2d/gl3.c +0 -304
- data/ext/ruby2d/gles.c +0 -302
- data/ext/ruby2d/input.c +0 -48
- data/ext/ruby2d/music.c +0 -127
- data/ext/ruby2d/sound.c +0 -132
- data/lib/ruby2d/cli/console.rb +0 -65
- data/lib/ruby2d/cli/enable_console.rb +0 -7
- data/lib/ruby2d/cli/platform.rb +0 -17
- data/lib/ruby2d/music.rb +0 -77
- data/lib/ruby2d/pixel.rb +0 -18
- data/lib/ruby2d/pixmap.rb +0 -39
- data/lib/ruby2d/pixmap_atlas.rb +0 -56
- data/lib/ruby2d/sound.rb +0 -61
- data/lib/ruby2d/texture.rb +0 -38
- /data/assets/{include/SDL2 → platform/include/SDL3}/SDL_opengles2_gl2.h +0 -0
- /data/assets/{include/SDL2 → platform/include/SDL3}/SDL_opengles2_gl2ext.h +0 -0
- /data/assets/{include/SDL2 → platform/include/SDL3}/SDL_opengles2_gl2platform.h +0 -0
- /data/assets/{include/SDL2 → platform/include/SDL3}/SDL_opengles2_khrplatform.h +0 -0
- /data/assets/{include → platform/include}/mruby/re.h +0 -0
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
** mruby/khash.c - 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
|
-
khint_t n_occupied; \
|
|
65
|
-
uint8_t *ed_flags; \
|
|
66
|
-
khkey_t *keys; \
|
|
67
|
-
khval_t *vals; \
|
|
68
|
-
} kh_##name##_t; \
|
|
69
|
-
void kh_alloc_##name(mrb_state *mrb, kh_##name##_t *h); \
|
|
70
|
-
kh_##name##_t *kh_init_##name##_size(mrb_state *mrb, khint_t size); \
|
|
71
|
-
kh_##name##_t *kh_init_##name(mrb_state *mrb); \
|
|
72
|
-
void kh_destroy_##name(mrb_state *mrb, kh_##name##_t *h); \
|
|
73
|
-
void kh_clear_##name(mrb_state *mrb, kh_##name##_t *h); \
|
|
74
|
-
khint_t kh_get_##name(mrb_state *mrb, kh_##name##_t *h, khkey_t key); \
|
|
75
|
-
khint_t kh_put_##name(mrb_state *mrb, kh_##name##_t *h, khkey_t key, int *ret); \
|
|
76
|
-
void kh_resize_##name(mrb_state *mrb, kh_##name##_t *h, khint_t new_n_buckets); \
|
|
77
|
-
void kh_del_##name(mrb_state *mrb, kh_##name##_t *h, khint_t x); \
|
|
78
|
-
kh_##name##_t *kh_copy_##name(mrb_state *mrb, kh_##name##_t *h);
|
|
79
|
-
|
|
80
|
-
static inline void
|
|
81
|
-
kh_fill_flags(uint8_t *p, uint8_t c, size_t len)
|
|
82
|
-
{
|
|
83
|
-
while (len-- > 0) {
|
|
84
|
-
*p++ = c;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/* define kh_xxx_funcs
|
|
89
|
-
|
|
90
|
-
name: hash name
|
|
91
|
-
khkey_t: key data type
|
|
92
|
-
khval_t: value data type
|
|
93
|
-
kh_is_map: (0: hash set / 1: hash map)
|
|
94
|
-
__hash_func: hash function
|
|
95
|
-
__hash_equal: hash comparation function
|
|
96
|
-
*/
|
|
97
|
-
#define KHASH_DEFINE(name, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \
|
|
98
|
-
void kh_alloc_##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(mrb, sizeof(uint8_t)*sz/4+len*sz); \
|
|
103
|
-
h->size = h->n_occupied = 0; \
|
|
104
|
-
h->keys = (khkey_t *)p; \
|
|
105
|
-
h->vals = kh_is_map ? (khval_t *)(p+sizeof(khkey_t)*sz) : NULL; \
|
|
106
|
-
h->ed_flags = p+len*sz; \
|
|
107
|
-
kh_fill_flags(h->ed_flags, 0xaa, sz/4); \
|
|
108
|
-
} \
|
|
109
|
-
kh_##name##_t *kh_init_##name##_size(mrb_state *mrb, khint_t size) { \
|
|
110
|
-
kh_##name##_t *h = (kh_##name##_t*)mrb_calloc(mrb, 1, sizeof(kh_##name##_t)); \
|
|
111
|
-
if (size < KHASH_MIN_SIZE) \
|
|
112
|
-
size = KHASH_MIN_SIZE; \
|
|
113
|
-
khash_power2(size); \
|
|
114
|
-
h->n_buckets = size; \
|
|
115
|
-
kh_alloc_##name(mrb, h); \
|
|
116
|
-
return h; \
|
|
117
|
-
} \
|
|
118
|
-
kh_##name##_t *kh_init_##name(mrb_state *mrb) { \
|
|
119
|
-
return kh_init_##name##_size(mrb, KHASH_DEFAULT_SIZE); \
|
|
120
|
-
} \
|
|
121
|
-
void kh_destroy_##name(mrb_state *mrb, kh_##name##_t *h) \
|
|
122
|
-
{ \
|
|
123
|
-
if (h) { \
|
|
124
|
-
mrb_free(mrb, h->keys); \
|
|
125
|
-
mrb_free(mrb, h); \
|
|
126
|
-
} \
|
|
127
|
-
} \
|
|
128
|
-
void kh_clear_##name(mrb_state *mrb, kh_##name##_t *h) \
|
|
129
|
-
{ \
|
|
130
|
-
(void)mrb; \
|
|
131
|
-
if (h && h->ed_flags) { \
|
|
132
|
-
kh_fill_flags(h->ed_flags, 0xaa, h->n_buckets/4); \
|
|
133
|
-
h->size = h->n_occupied = 0; \
|
|
134
|
-
} \
|
|
135
|
-
} \
|
|
136
|
-
khint_t kh_get_##name(mrb_state *mrb, kh_##name##_t *h, khkey_t key) \
|
|
137
|
-
{ \
|
|
138
|
-
khint_t k = __hash_func(mrb,key) & khash_mask(h), step = 0; \
|
|
139
|
-
(void)mrb; \
|
|
140
|
-
while (!__ac_isempty(h->ed_flags, k)) { \
|
|
141
|
-
if (!__ac_isdel(h->ed_flags, k)) { \
|
|
142
|
-
if (__hash_equal(mrb,h->keys[k], key)) return k; \
|
|
143
|
-
} \
|
|
144
|
-
k = (k+(++step)) & khash_mask(h); \
|
|
145
|
-
} \
|
|
146
|
-
return kh_end(h); \
|
|
147
|
-
} \
|
|
148
|
-
void kh_resize_##name(mrb_state *mrb, kh_##name##_t *h, khint_t new_n_buckets) \
|
|
149
|
-
{ \
|
|
150
|
-
if (new_n_buckets < KHASH_MIN_SIZE) \
|
|
151
|
-
new_n_buckets = KHASH_MIN_SIZE; \
|
|
152
|
-
khash_power2(new_n_buckets); \
|
|
153
|
-
{ \
|
|
154
|
-
kh_##name##_t hh; \
|
|
155
|
-
uint8_t *old_ed_flags = h->ed_flags; \
|
|
156
|
-
khkey_t *old_keys = h->keys; \
|
|
157
|
-
khval_t *old_vals = h->vals; \
|
|
158
|
-
khint_t old_n_buckets = h->n_buckets; \
|
|
159
|
-
khint_t i; \
|
|
160
|
-
hh.n_buckets = new_n_buckets; \
|
|
161
|
-
kh_alloc_##name(mrb, &hh); \
|
|
162
|
-
/* relocate */ \
|
|
163
|
-
for (i=0 ; i<old_n_buckets ; i++) { \
|
|
164
|
-
if (!__ac_iseither(old_ed_flags, i)) { \
|
|
165
|
-
khint_t k = kh_put_##name(mrb, &hh, old_keys[i], NULL); \
|
|
166
|
-
if (kh_is_map) kh_value(&hh,k) = old_vals[i]; \
|
|
167
|
-
} \
|
|
168
|
-
} \
|
|
169
|
-
/* copy hh to h */ \
|
|
170
|
-
*h = hh; \
|
|
171
|
-
mrb_free(mrb, old_keys); \
|
|
172
|
-
} \
|
|
173
|
-
} \
|
|
174
|
-
khint_t kh_put_##name(mrb_state *mrb, kh_##name##_t *h, khkey_t key, int *ret) \
|
|
175
|
-
{ \
|
|
176
|
-
khint_t k, del_k, step = 0; \
|
|
177
|
-
if (h->n_occupied >= khash_upper_bound(h)) { \
|
|
178
|
-
kh_resize_##name(mrb, h, h->n_buckets*2); \
|
|
179
|
-
} \
|
|
180
|
-
k = __hash_func(mrb,key) & khash_mask(h); \
|
|
181
|
-
del_k = kh_end(h); \
|
|
182
|
-
while (!__ac_isempty(h->ed_flags, k)) { \
|
|
183
|
-
if (!__ac_isdel(h->ed_flags, k)) { \
|
|
184
|
-
if (__hash_equal(mrb,h->keys[k], key)) { \
|
|
185
|
-
if (ret) *ret = 0; \
|
|
186
|
-
return k; \
|
|
187
|
-
} \
|
|
188
|
-
} \
|
|
189
|
-
else if (del_k == kh_end(h)) { \
|
|
190
|
-
del_k = k; \
|
|
191
|
-
} \
|
|
192
|
-
k = (k+(++step)) & khash_mask(h); \
|
|
193
|
-
} \
|
|
194
|
-
if (del_k != kh_end(h)) { \
|
|
195
|
-
/* put at del */ \
|
|
196
|
-
h->keys[del_k] = key; \
|
|
197
|
-
h->ed_flags[del_k/4] &= ~__m_del[del_k%4]; \
|
|
198
|
-
h->size++; \
|
|
199
|
-
if (ret) *ret = 2; \
|
|
200
|
-
return del_k; \
|
|
201
|
-
} \
|
|
202
|
-
else { \
|
|
203
|
-
/* put at empty */ \
|
|
204
|
-
h->keys[k] = key; \
|
|
205
|
-
h->ed_flags[k/4] &= ~__m_empty[k%4]; \
|
|
206
|
-
h->size++; \
|
|
207
|
-
h->n_occupied++; \
|
|
208
|
-
if (ret) *ret = 1; \
|
|
209
|
-
return k; \
|
|
210
|
-
} \
|
|
211
|
-
} \
|
|
212
|
-
void kh_del_##name(mrb_state *mrb, kh_##name##_t *h, khint_t x) \
|
|
213
|
-
{ \
|
|
214
|
-
(void)mrb; \
|
|
215
|
-
mrb_assert(x != h->n_buckets && !__ac_iseither(h->ed_flags, x)); \
|
|
216
|
-
h->ed_flags[x/4] |= __m_del[x%4]; \
|
|
217
|
-
h->size--; \
|
|
218
|
-
} \
|
|
219
|
-
kh_##name##_t *kh_copy_##name(mrb_state *mrb, kh_##name##_t *h) \
|
|
220
|
-
{ \
|
|
221
|
-
kh_##name##_t *h2; \
|
|
222
|
-
khiter_t k, k2; \
|
|
223
|
-
\
|
|
224
|
-
h2 = kh_init_##name(mrb); \
|
|
225
|
-
for (k = kh_begin(h); k != kh_end(h); k++) { \
|
|
226
|
-
if (kh_exist(h, k)) { \
|
|
227
|
-
k2 = kh_put_##name(mrb, h2, kh_key(h, k), NULL); \
|
|
228
|
-
if (kh_is_map) kh_value(h2, k2) = kh_value(h, k); \
|
|
229
|
-
} \
|
|
230
|
-
} \
|
|
231
|
-
return h2; \
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
#define khash_t(name) kh_##name##_t
|
|
236
|
-
|
|
237
|
-
#define kh_init_size(name,mrb,size) kh_init_##name##_size(mrb,size)
|
|
238
|
-
#define kh_init(name,mrb) kh_init_##name(mrb)
|
|
239
|
-
#define kh_destroy(name, mrb, h) kh_destroy_##name(mrb, h)
|
|
240
|
-
#define kh_clear(name, mrb, h) kh_clear_##name(mrb, h)
|
|
241
|
-
#define kh_resize(name, mrb, h, s) kh_resize_##name(mrb, h, s)
|
|
242
|
-
#define kh_put(name, mrb, h, k) kh_put_##name(mrb, h, k, NULL)
|
|
243
|
-
#define kh_put2(name, mrb, h, k, r) kh_put_##name(mrb, h, k, r)
|
|
244
|
-
#define kh_get(name, mrb, h, k) kh_get_##name(mrb, h, k)
|
|
245
|
-
#define kh_del(name, mrb, h, k) kh_del_##name(mrb, h, k)
|
|
246
|
-
#define kh_copy(name, mrb, h) kh_copy_##name(mrb, h)
|
|
247
|
-
|
|
248
|
-
#define kh_exist(h, x) (!__ac_iseither((h)->ed_flags, (x)))
|
|
249
|
-
#define kh_key(h, x) ((h)->keys[x])
|
|
250
|
-
#define kh_val(h, x) ((h)->vals[x])
|
|
251
|
-
#define kh_value(h, x) ((h)->vals[x])
|
|
252
|
-
#define kh_begin(h) (khint_t)(0)
|
|
253
|
-
#define kh_end(h) ((h)->n_buckets)
|
|
254
|
-
#define kh_size(h) ((h)->size)
|
|
255
|
-
#define kh_n_buckets(h) ((h)->n_buckets)
|
|
256
|
-
|
|
257
|
-
#define kh_int_hash_func(mrb,key) (khint_t)((key)^((key)<<2)^((key)>>2))
|
|
258
|
-
#define kh_int_hash_equal(mrb,a, b) (a == b)
|
|
259
|
-
#define kh_int64_hash_func(mrb,key) (khint_t)((key)>>33^(key)^(key)<<11)
|
|
260
|
-
#define kh_int64_hash_equal(mrb,a, b) (a == b)
|
|
261
|
-
static inline khint_t __ac_X31_hash_string(const char *s)
|
|
262
|
-
{
|
|
263
|
-
khint_t h = *s;
|
|
264
|
-
if (h) for (++s ; *s; ++s) h = (h << 5) - h + *s;
|
|
265
|
-
return h;
|
|
266
|
-
}
|
|
267
|
-
#define kh_str_hash_func(mrb,key) __ac_X31_hash_string(key)
|
|
268
|
-
#define kh_str_hash_equal(mrb,a, b) (strcmp(a, b) == 0)
|
|
269
|
-
|
|
270
|
-
typedef const char *kh_cstr_t;
|
|
271
|
-
|
|
272
|
-
MRB_END_DECL
|
|
273
|
-
|
|
274
|
-
#endif /* MRUBY_KHASH_H */
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
** mruby/numeric.h - Numeric, Integer, Float, Fixnum 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, Float and Fixnum
|
|
16
|
-
*/
|
|
17
|
-
MRB_BEGIN_DECL
|
|
18
|
-
|
|
19
|
-
#define TYPED_POSFIXABLE(f,t) ((f) <= (t)MRB_INT_MAX)
|
|
20
|
-
#define TYPED_NEGFIXABLE(f,t) ((f) >= (t)MRB_INT_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_WITHOUT_FLOAT
|
|
26
|
-
#define FIXABLE_FLOAT(f) TYPED_FIXABLE(f,double)
|
|
27
|
-
#endif
|
|
28
|
-
|
|
29
|
-
#ifndef MRB_WITHOUT_FLOAT
|
|
30
|
-
MRB_API mrb_value mrb_flo_to_fixnum(mrb_state *mrb, mrb_value val);
|
|
31
|
-
#endif
|
|
32
|
-
MRB_API mrb_value mrb_fixnum_to_str(mrb_state *mrb, mrb_value x, mrb_int base);
|
|
33
|
-
/* ArgumentError if format string doesn't match /%(\.[0-9]+)?[aAeEfFgG]/ */
|
|
34
|
-
#ifndef MRB_WITHOUT_FLOAT
|
|
35
|
-
MRB_API mrb_value mrb_float_to_str(mrb_state *mrb, mrb_value x, const char *fmt);
|
|
36
|
-
MRB_API mrb_float mrb_to_flo(mrb_state *mrb, mrb_value x);
|
|
37
|
-
#endif
|
|
38
|
-
|
|
39
|
-
mrb_value mrb_fixnum_plus(mrb_state *mrb, mrb_value x, mrb_value y);
|
|
40
|
-
mrb_value mrb_fixnum_minus(mrb_state *mrb, mrb_value x, mrb_value y);
|
|
41
|
-
mrb_value mrb_fixnum_mul(mrb_state *mrb, mrb_value x, mrb_value y);
|
|
42
|
-
mrb_value mrb_num_div(mrb_state *mrb, mrb_value x, mrb_value y);
|
|
43
|
-
|
|
44
|
-
#ifndef __has_builtin
|
|
45
|
-
#define __has_builtin(x) 0
|
|
46
|
-
#endif
|
|
47
|
-
|
|
48
|
-
#if (defined(__GNUC__) && __GNUC__ >= 5) || \
|
|
49
|
-
(__has_builtin(__builtin_add_overflow) && \
|
|
50
|
-
__has_builtin(__builtin_sub_overflow) && \
|
|
51
|
-
__has_builtin(__builtin_mul_overflow))
|
|
52
|
-
# define MRB_HAVE_TYPE_GENERIC_CHECKED_ARITHMETIC_BUILTINS
|
|
53
|
-
#endif
|
|
54
|
-
|
|
55
|
-
/*
|
|
56
|
-
// Clang 3.8 and 3.9 have problem compiling mruby in 32-bit mode, when MRB_INT64 is set
|
|
57
|
-
// because of missing __mulodi4 and similar functions in its runtime. We need to use custom
|
|
58
|
-
// implementation for them.
|
|
59
|
-
*/
|
|
60
|
-
#ifdef MRB_HAVE_TYPE_GENERIC_CHECKED_ARITHMETIC_BUILTINS
|
|
61
|
-
#if defined(__clang__) && (__clang_major__ == 3) && (__clang_minor__ >= 8) && \
|
|
62
|
-
defined(MRB_32BIT) && defined(MRB_INT64)
|
|
63
|
-
#undef MRB_HAVE_TYPE_GENERIC_CHECKED_ARITHMETIC_BUILTINS
|
|
64
|
-
#endif
|
|
65
|
-
#endif
|
|
66
|
-
|
|
67
|
-
#ifdef MRB_HAVE_TYPE_GENERIC_CHECKED_ARITHMETIC_BUILTINS
|
|
68
|
-
|
|
69
|
-
#ifndef MRB_WORD_BOXING
|
|
70
|
-
# define WBCHK(x) 0
|
|
71
|
-
#else
|
|
72
|
-
# define WBCHK(x) !FIXABLE(x)
|
|
73
|
-
#endif
|
|
74
|
-
|
|
75
|
-
static inline mrb_bool
|
|
76
|
-
mrb_int_add_overflow(mrb_int augend, mrb_int addend, mrb_int *sum)
|
|
77
|
-
{
|
|
78
|
-
return __builtin_add_overflow(augend, addend, sum) || WBCHK(*sum);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
static inline mrb_bool
|
|
82
|
-
mrb_int_sub_overflow(mrb_int minuend, mrb_int subtrahend, mrb_int *difference)
|
|
83
|
-
{
|
|
84
|
-
return __builtin_sub_overflow(minuend, subtrahend, difference) || WBCHK(*difference);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
static inline mrb_bool
|
|
88
|
-
mrb_int_mul_overflow(mrb_int multiplier, mrb_int multiplicand, mrb_int *product)
|
|
89
|
-
{
|
|
90
|
-
return __builtin_mul_overflow(multiplier, multiplicand, product) || WBCHK(*product);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
#undef WBCHK
|
|
94
|
-
|
|
95
|
-
#else
|
|
96
|
-
|
|
97
|
-
#define MRB_UINT_MAKE2(n) uint ## n ## _t
|
|
98
|
-
#define MRB_UINT_MAKE(n) MRB_UINT_MAKE2(n)
|
|
99
|
-
#define mrb_uint MRB_UINT_MAKE(MRB_INT_BIT)
|
|
100
|
-
|
|
101
|
-
#define MRB_INT_OVERFLOW_MASK ((mrb_uint)1 << (MRB_INT_BIT - 1 - MRB_FIXNUM_SHIFT))
|
|
102
|
-
|
|
103
|
-
static inline mrb_bool
|
|
104
|
-
mrb_int_add_overflow(mrb_int augend, mrb_int addend, mrb_int *sum)
|
|
105
|
-
{
|
|
106
|
-
mrb_uint x = (mrb_uint)augend;
|
|
107
|
-
mrb_uint y = (mrb_uint)addend;
|
|
108
|
-
mrb_uint z = (mrb_uint)(x + y);
|
|
109
|
-
*sum = (mrb_int)z;
|
|
110
|
-
return !!(((x ^ z) & (y ^ z)) & MRB_INT_OVERFLOW_MASK);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
static inline mrb_bool
|
|
114
|
-
mrb_int_sub_overflow(mrb_int minuend, mrb_int subtrahend, mrb_int *difference)
|
|
115
|
-
{
|
|
116
|
-
mrb_uint x = (mrb_uint)minuend;
|
|
117
|
-
mrb_uint y = (mrb_uint)subtrahend;
|
|
118
|
-
mrb_uint z = (mrb_uint)(x - y);
|
|
119
|
-
*difference = (mrb_int)z;
|
|
120
|
-
return !!(((x ^ z) & (~y ^ z)) & MRB_INT_OVERFLOW_MASK);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
static inline mrb_bool
|
|
124
|
-
mrb_int_mul_overflow(mrb_int multiplier, mrb_int multiplicand, mrb_int *product)
|
|
125
|
-
{
|
|
126
|
-
#if MRB_INT_BIT == 32
|
|
127
|
-
int64_t n = (int64_t)multiplier * multiplicand;
|
|
128
|
-
*product = (mrb_int)n;
|
|
129
|
-
return !FIXABLE(n);
|
|
130
|
-
#else
|
|
131
|
-
if (multiplier > 0) {
|
|
132
|
-
if (multiplicand > 0) {
|
|
133
|
-
if (multiplier > MRB_INT_MAX / multiplicand) return TRUE;
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
if (multiplicand < MRB_INT_MAX / multiplier) return TRUE;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
if (multiplicand > 0) {
|
|
141
|
-
if (multiplier < MRB_INT_MAX / multiplicand) return TRUE;
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
if (multiplier != 0 && multiplicand < MRB_INT_MAX / multiplier) return TRUE;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
*product = multiplier * multiplicand;
|
|
148
|
-
return FALSE;
|
|
149
|
-
#endif
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
#undef MRB_INT_OVERFLOW_MASK
|
|
153
|
-
#undef mrb_uint
|
|
154
|
-
#undef MRB_UINT_MAKE
|
|
155
|
-
#undef MRB_UINT_MAKE2
|
|
156
|
-
|
|
157
|
-
#endif
|
|
158
|
-
|
|
159
|
-
MRB_END_DECL
|
|
160
|
-
|
|
161
|
-
#endif /* MRUBY_NUMERIC_H */
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
** 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
|
-
enum mrb_vtype tt:8;\
|
|
12
|
-
uint32_t color:3;\
|
|
13
|
-
uint32_t flags:21;\
|
|
14
|
-
struct RClass *c;\
|
|
15
|
-
struct RBasic *gcnext
|
|
16
|
-
|
|
17
|
-
#define MRB_FLAG_TEST(obj, flag) ((obj)->flags & flag)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
struct RBasic {
|
|
21
|
-
MRB_OBJECT_HEADER;
|
|
22
|
-
};
|
|
23
|
-
#define mrb_basic_ptr(v) ((struct RBasic*)(mrb_ptr(v)))
|
|
24
|
-
|
|
25
|
-
#define MRB_FL_OBJ_IS_FROZEN (1 << 20)
|
|
26
|
-
#define MRB_FROZEN_P(o) ((o)->flags & MRB_FL_OBJ_IS_FROZEN)
|
|
27
|
-
#define MRB_SET_FROZEN_FLAG(o) ((o)->flags |= MRB_FL_OBJ_IS_FROZEN)
|
|
28
|
-
#define MRB_UNSET_FROZEN_FLAG(o) ((o)->flags &= ~MRB_FL_OBJ_IS_FROZEN)
|
|
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_immediate_p(x) (mrb_type(x) < MRB_TT_HAS_BASIC)
|
|
37
|
-
#define mrb_special_const_p(x) mrb_immediate_p(x)
|
|
38
|
-
|
|
39
|
-
struct RFiber {
|
|
40
|
-
MRB_OBJECT_HEADER;
|
|
41
|
-
struct mrb_context *cxt;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
#endif /* MRUBY_OBJECT_H */
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
** 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_S() do {a=READ_S();} while (0)
|
|
40
|
-
#define FETCH_W() do {a=READ_W();} while (0)
|
|
41
|
-
|
|
42
|
-
/* with OP_EXT1 (1st 16bit) */
|
|
43
|
-
#define FETCH_Z_1() FETCH_Z()
|
|
44
|
-
#define FETCH_B_1() FETCH_S()
|
|
45
|
-
#define FETCH_BB_1() do {a=READ_S(); b=READ_B();} while (0)
|
|
46
|
-
#define FETCH_BBB_1() do {a=READ_S(); b=READ_B(); c=READ_B();} while (0)
|
|
47
|
-
#define FETCH_BS_1() do {a=READ_S(); b=READ_S();} while (0)
|
|
48
|
-
#define FETCH_S_1() FETCH_S()
|
|
49
|
-
#define FETCH_W_1() FETCH_W()
|
|
50
|
-
|
|
51
|
-
/* with OP_EXT2 (2nd 16bit) */
|
|
52
|
-
#define FETCH_Z_2() FETCH_Z()
|
|
53
|
-
#define FETCH_B_2() FETCH_B()
|
|
54
|
-
#define FETCH_BB_2() do {a=READ_B(); b=READ_S();} while (0)
|
|
55
|
-
#define FETCH_BBB_2() do {a=READ_B(); b=READ_S(); c=READ_B();} while (0)
|
|
56
|
-
#define FETCH_BS_2() FETCH_BS()
|
|
57
|
-
#define FETCH_S_2() FETCH_S()
|
|
58
|
-
#define FETCH_W_2() FETCH_W()
|
|
59
|
-
|
|
60
|
-
/* with OP_EXT3 (1st & 2nd 16bit) */
|
|
61
|
-
#define FETCH_Z_3() FETCH_Z()
|
|
62
|
-
#define FETCH_B_3() FETCH_B()
|
|
63
|
-
#define FETCH_BB_3() do {a=READ_S(); b=READ_S();} while (0)
|
|
64
|
-
#define FETCH_BBB_3() do {a=READ_S(); b=READ_S(); c=READ_B();} while (0)
|
|
65
|
-
#define FETCH_BS_3() do {a=READ_S(); b=READ_S();} while (0)
|
|
66
|
-
#define FETCH_S_3() FETCH_S()
|
|
67
|
-
#define FETCH_W_3() FETCH_W()
|
|
68
|
-
|
|
69
|
-
#endif /* MRUBY_OPCODE_H */
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
/* operand types:
|
|
2
|
-
+ Z: no operand (Z,Z,Z,Z)
|
|
3
|
-
+ B: 8bit (B,S,B,B)
|
|
4
|
-
+ BB: 8+8bit (BB,SB,BS,SS)
|
|
5
|
-
+ BBB: 8+8+8bit (BBB,SBB,BSB,SSB)
|
|
6
|
-
+ BS: 8+16bit (BS,SS,BS,BS)
|
|
7
|
-
+ S: 16bit (S,S,S,S)
|
|
8
|
-
+ W: 24bit (W,W,W,W)
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/*-----------------------------------------------------------------------
|
|
12
|
-
operation code operands semantics
|
|
13
|
-
------------------------------------------------------------------------*/
|
|
14
|
-
OPCODE(NOP, Z) /* no operation */
|
|
15
|
-
OPCODE(MOVE, BB) /* R(a) = R(b) */
|
|
16
|
-
OPCODE(LOADL, BB) /* R(a) = Pool(b) */
|
|
17
|
-
OPCODE(LOADI, BB) /* R(a) = mrb_int(b) */
|
|
18
|
-
OPCODE(LOADINEG, BB) /* R(a) = mrb_int(-b) */
|
|
19
|
-
OPCODE(LOADI__1, B) /* R(a) = mrb_int(-1) */
|
|
20
|
-
OPCODE(LOADI_0, B) /* R(a) = mrb_int(0) */
|
|
21
|
-
OPCODE(LOADI_1, B) /* R(a) = mrb_int(1) */
|
|
22
|
-
OPCODE(LOADI_2, B) /* R(a) = mrb_int(2) */
|
|
23
|
-
OPCODE(LOADI_3, B) /* R(a) = mrb_int(3) */
|
|
24
|
-
OPCODE(LOADI_4, B) /* R(a) = mrb_int(4) */
|
|
25
|
-
OPCODE(LOADI_5, B) /* R(a) = mrb_int(5) */
|
|
26
|
-
OPCODE(LOADI_6, B) /* R(a) = mrb_int(6) */
|
|
27
|
-
OPCODE(LOADI_7, B) /* R(a) = mrb_int(7) */
|
|
28
|
-
OPCODE(LOADSYM, BB) /* R(a) = Syms(b) */
|
|
29
|
-
OPCODE(LOADNIL, B) /* R(a) = nil */
|
|
30
|
-
OPCODE(LOADSELF, B) /* R(a) = self */
|
|
31
|
-
OPCODE(LOADT, B) /* R(a) = true */
|
|
32
|
-
OPCODE(LOADF, B) /* R(a) = false */
|
|
33
|
-
OPCODE(GETGV, BB) /* R(a) = getglobal(Syms(b)) */
|
|
34
|
-
OPCODE(SETGV, BB) /* setglobal(Syms(b), R(a)) */
|
|
35
|
-
OPCODE(GETSV, BB) /* R(a) = Special[Syms(b)] */
|
|
36
|
-
OPCODE(SETSV, BB) /* Special[Syms(b)] = R(a) */
|
|
37
|
-
OPCODE(GETIV, BB) /* R(a) = ivget(Syms(b)) */
|
|
38
|
-
OPCODE(SETIV, BB) /* ivset(Syms(b),R(a)) */
|
|
39
|
-
OPCODE(GETCV, BB) /* R(a) = cvget(Syms(b)) */
|
|
40
|
-
OPCODE(SETCV, BB) /* cvset(Syms(b),R(a)) */
|
|
41
|
-
OPCODE(GETCONST, BB) /* R(a) = constget(Syms(b)) */
|
|
42
|
-
OPCODE(SETCONST, BB) /* constset(Syms(b),R(a)) */
|
|
43
|
-
OPCODE(GETMCNST, BB) /* R(a) = R(a)::Syms(b) */
|
|
44
|
-
OPCODE(SETMCNST, BB) /* R(a+1)::Syms(b) = R(a) */
|
|
45
|
-
OPCODE(GETUPVAR, BBB) /* R(a) = uvget(b,c) */
|
|
46
|
-
OPCODE(SETUPVAR, BBB) /* uvset(b,c,R(a)) */
|
|
47
|
-
OPCODE(JMP, S) /* pc=a */
|
|
48
|
-
OPCODE(JMPIF, BS) /* if R(b) pc=a */
|
|
49
|
-
OPCODE(JMPNOT, BS) /* if !R(b) pc=a */
|
|
50
|
-
OPCODE(JMPNIL, BS) /* if R(b)==nil pc=a */
|
|
51
|
-
OPCODE(ONERR, S) /* rescue_push(a) */
|
|
52
|
-
OPCODE(EXCEPT, B) /* R(a) = exc */
|
|
53
|
-
OPCODE(RESCUE, BB) /* R(b) = R(a).isa?(R(b)) */
|
|
54
|
-
OPCODE(POPERR, B) /* a.times{rescue_pop()} */
|
|
55
|
-
OPCODE(RAISE, B) /* raise(R(a)) */
|
|
56
|
-
OPCODE(EPUSH, B) /* ensure_push(SEQ[a]) */
|
|
57
|
-
OPCODE(EPOP, B) /* A.times{ensure_pop().call} */
|
|
58
|
-
OPCODE(SENDV, BB) /* R(a) = call(R(a),Syms(b),*R(a+1)) */
|
|
59
|
-
OPCODE(SENDVB, BB) /* R(a) = call(R(a),Syms(b),*R(a+1),&R(a+2)) */
|
|
60
|
-
OPCODE(SEND, BBB) /* R(a) = call(R(a),Syms(b),R(a+1),...,R(a+c)) */
|
|
61
|
-
OPCODE(SENDB, BBB) /* R(a) = call(R(a),Syms(Bx),R(a+1),...,R(a+c),&R(a+c+1)) */
|
|
62
|
-
OPCODE(CALL, Z) /* R(0) = self.call(frame.argc, frame.argv) */
|
|
63
|
-
OPCODE(SUPER, BB) /* R(a) = super(R(a+1),... ,R(a+b+1)) */
|
|
64
|
-
OPCODE(ARGARY, BS) /* R(a) = argument array (16=m5:r1:m5:d1:lv4) */
|
|
65
|
-
OPCODE(ENTER, W) /* arg setup according to flags (23=m5:o5:r1:m5:k5:d1:b1) */
|
|
66
|
-
OPCODE(KEY_P, BB) /* R(a) = kdict.key?(Syms(b)) # todo */
|
|
67
|
-
OPCODE(KEYEND, Z) /* raise unless kdict.empty? # todo */
|
|
68
|
-
OPCODE(KARG, BB) /* R(a) = kdict[Syms(b)]; kdict.delete(Syms(b)) # todo */
|
|
69
|
-
OPCODE(RETURN, B) /* return R(a) (normal) */
|
|
70
|
-
OPCODE(RETURN_BLK, B) /* return R(a) (in-block return) */
|
|
71
|
-
OPCODE(BREAK, B) /* break R(a) */
|
|
72
|
-
OPCODE(BLKPUSH, BS) /* R(a) = block (16=m5:r1:m5:d1:lv4) */
|
|
73
|
-
OPCODE(ADD, B) /* R(a) = R(a)+R(a+1) */
|
|
74
|
-
OPCODE(ADDI, BB) /* R(a) = R(a)+mrb_int(c) */
|
|
75
|
-
OPCODE(SUB, B) /* R(a) = R(a)-R(a+1) */
|
|
76
|
-
OPCODE(SUBI, BB) /* R(a) = R(a)-C */
|
|
77
|
-
OPCODE(MUL, B) /* R(a) = R(a)*R(a+1) */
|
|
78
|
-
OPCODE(DIV, B) /* R(a) = R(a)/R(a+1) */
|
|
79
|
-
OPCODE(EQ, B) /* R(a) = R(a)==R(a+1) */
|
|
80
|
-
OPCODE(LT, B) /* R(a) = R(a)<R(a+1) */
|
|
81
|
-
OPCODE(LE, B) /* R(a) = R(a)<=R(a+1) */
|
|
82
|
-
OPCODE(GT, B) /* R(a) = R(a)>R(a+1) */
|
|
83
|
-
OPCODE(GE, B) /* R(a) = R(a)>=R(a+1) */
|
|
84
|
-
OPCODE(ARRAY, BB) /* R(a) = ary_new(R(a),R(a+1)..R(a+b)) */
|
|
85
|
-
OPCODE(ARRAY2, BBB) /* R(a) = ary_new(R(b),R(b+1)..R(b+c)) */
|
|
86
|
-
OPCODE(ARYCAT, B) /* ary_cat(R(a),R(a+1)) */
|
|
87
|
-
OPCODE(ARYPUSH, B) /* ary_push(R(a),R(a+1)) */
|
|
88
|
-
OPCODE(ARYDUP, B) /* R(a) = ary_dup(R(a)) */
|
|
89
|
-
OPCODE(AREF, BBB) /* R(a) = R(b)[c] */
|
|
90
|
-
OPCODE(ASET, BBB) /* R(a)[c] = R(b) */
|
|
91
|
-
OPCODE(APOST, BBB) /* *R(a),R(a+1)..R(a+C) = R(a)[b..] */
|
|
92
|
-
OPCODE(INTERN, B) /* R(a) = intern(R(a)) */
|
|
93
|
-
OPCODE(STRING, BB) /* R(a) = str_dup(Lit(b)) */
|
|
94
|
-
OPCODE(STRCAT, B) /* str_cat(R(a),R(a+1)) */
|
|
95
|
-
OPCODE(HASH, BB) /* R(a) = hash_new(R(a),R(a+1)..R(a+b)) */
|
|
96
|
-
OPCODE(HASHADD, BB) /* R(a) = hash_push(R(a),R(a+1)..R(a+b)) */
|
|
97
|
-
OPCODE(HASHCAT, B) /* R(a) = hash_cat(R(a),R(a+1)) */
|
|
98
|
-
OPCODE(LAMBDA, BB) /* R(a) = lambda(SEQ[b],L_LAMBDA) */
|
|
99
|
-
OPCODE(BLOCK, BB) /* R(a) = lambda(SEQ[b],L_BLOCK) */
|
|
100
|
-
OPCODE(METHOD, BB) /* R(a) = lambda(SEQ[b],L_METHOD) */
|
|
101
|
-
OPCODE(RANGE_INC, B) /* R(a) = range_new(R(a),R(a+1),FALSE) */
|
|
102
|
-
OPCODE(RANGE_EXC, B) /* R(a) = range_new(R(a),R(a+1),TRUE) */
|
|
103
|
-
OPCODE(OCLASS, B) /* R(a) = ::Object */
|
|
104
|
-
OPCODE(CLASS, BB) /* R(a) = newclass(R(a),Syms(b),R(a+1)) */
|
|
105
|
-
OPCODE(MODULE, BB) /* R(a) = newmodule(R(a),Syms(b)) */
|
|
106
|
-
OPCODE(EXEC, BB) /* R(a) = blockexec(R(a),SEQ[b]) */
|
|
107
|
-
OPCODE(DEF, BB) /* R(a).newmethod(Syms(b),R(a+1)) */
|
|
108
|
-
OPCODE(ALIAS, BB) /* alias_method(target_class,Syms(a),Syms(b)) */
|
|
109
|
-
OPCODE(UNDEF, B) /* undef_method(target_class,Syms(a)) */
|
|
110
|
-
OPCODE(SCLASS, B) /* R(a) = R(a).singleton_class */
|
|
111
|
-
OPCODE(TCLASS, B) /* R(a) = target_class */
|
|
112
|
-
OPCODE(DEBUG, BBB) /* print a,b,c */
|
|
113
|
-
OPCODE(ERR, B) /* raise(LocalJumpError, Lit(a)) */
|
|
114
|
-
OPCODE(EXT1, Z) /* make 1st operand 16bit */
|
|
115
|
-
OPCODE(EXT2, Z) /* make 2nd operand 16bit */
|
|
116
|
-
OPCODE(EXT3, Z) /* make 1st and 2nd operands 16bit */
|
|
117
|
-
OPCODE(STOP, Z) /* stop VM */
|