ruby2d-rpeck-windows 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/assets/README.md +22 -0
- data/assets/Rakefile +85 -0
- data/assets/app.icns +0 -0
- data/assets/include/SDL2/SDL.h +138 -0
- data/assets/include/SDL2/SDL_assert.h +293 -0
- data/assets/include/SDL2/SDL_atomic.h +295 -0
- data/assets/include/SDL2/SDL_audio.h +859 -0
- data/assets/include/SDL2/SDL_bits.h +121 -0
- data/assets/include/SDL2/SDL_blendmode.h +123 -0
- data/assets/include/SDL2/SDL_clipboard.h +71 -0
- data/assets/include/SDL2/SDL_config.h +55 -0
- data/assets/include/SDL2/SDL_config_android.h +182 -0
- data/assets/include/SDL2/SDL_config_iphoneos.h +207 -0
- data/assets/include/SDL2/SDL_config_macosx.h +266 -0
- data/assets/include/SDL2/SDL_config_minimal.h +85 -0
- data/assets/include/SDL2/SDL_config_os2.h +188 -0
- data/assets/include/SDL2/SDL_config_pandora.h +135 -0
- data/assets/include/SDL2/SDL_config_psp.h +165 -0
- data/assets/include/SDL2/SDL_config_windows.h +288 -0
- data/assets/include/SDL2/SDL_config_winrt.h +243 -0
- data/assets/include/SDL2/SDL_config_wiz.h +149 -0
- data/assets/include/SDL2/SDL_copying.h +20 -0
- data/assets/include/SDL2/SDL_cpuinfo.h +299 -0
- data/assets/include/SDL2/SDL_egl.h +1676 -0
- data/assets/include/SDL2/SDL_endian.h +263 -0
- data/assets/include/SDL2/SDL_error.h +112 -0
- data/assets/include/SDL2/SDL_events.h +827 -0
- data/assets/include/SDL2/SDL_filesystem.h +136 -0
- data/assets/include/SDL2/SDL_gamecontroller.h +541 -0
- data/assets/include/SDL2/SDL_gesture.h +87 -0
- data/assets/include/SDL2/SDL_haptic.h +1247 -0
- data/assets/include/SDL2/SDL_hints.h +1578 -0
- data/assets/include/SDL2/SDL_image.h +161 -0
- data/assets/include/SDL2/SDL_joystick.h +499 -0
- data/assets/include/SDL2/SDL_keyboard.h +217 -0
- data/assets/include/SDL2/SDL_keycode.h +351 -0
- data/assets/include/SDL2/SDL_loadso.h +81 -0
- data/assets/include/SDL2/SDL_locale.h +101 -0
- data/assets/include/SDL2/SDL_log.h +211 -0
- data/assets/include/SDL2/SDL_main.h +180 -0
- data/assets/include/SDL2/SDL_messagebox.h +146 -0
- data/assets/include/SDL2/SDL_metal.h +117 -0
- data/assets/include/SDL2/SDL_misc.h +75 -0
- data/assets/include/SDL2/SDL_mixer.h +651 -0
- data/assets/include/SDL2/SDL_mouse.h +302 -0
- data/assets/include/SDL2/SDL_mutex.h +251 -0
- data/assets/include/SDL2/SDL_name.h +33 -0
- data/assets/include/SDL2/SDL_opengl.h +2183 -0
- data/assets/include/SDL2/SDL_opengl_glext.h +11180 -0
- data/assets/include/SDL2/SDL_opengles.h +39 -0
- data/assets/include/SDL2/SDL_opengles2.h +52 -0
- data/assets/include/SDL2/SDL_opengles2_gl2.h +621 -0
- data/assets/include/SDL2/SDL_opengles2_gl2ext.h +2050 -0
- data/assets/include/SDL2/SDL_opengles2_gl2platform.h +30 -0
- data/assets/include/SDL2/SDL_opengles2_khrplatform.h +282 -0
- data/assets/include/SDL2/SDL_pixels.h +479 -0
- data/assets/include/SDL2/SDL_platform.h +198 -0
- data/assets/include/SDL2/SDL_power.h +75 -0
- data/assets/include/SDL2/SDL_quit.h +58 -0
- data/assets/include/SDL2/SDL_rect.h +174 -0
- data/assets/include/SDL2/SDL_render.h +1158 -0
- data/assets/include/SDL2/SDL_revision.h +2 -0
- data/assets/include/SDL2/SDL_rwops.h +283 -0
- data/assets/include/SDL2/SDL_scancode.h +413 -0
- data/assets/include/SDL2/SDL_sensor.h +267 -0
- data/assets/include/SDL2/SDL_shape.h +144 -0
- data/assets/include/SDL2/SDL_stdinc.h +647 -0
- data/assets/include/SDL2/SDL_surface.h +563 -0
- data/assets/include/SDL2/SDL_system.h +325 -0
- data/assets/include/SDL2/SDL_syswm.h +354 -0
- data/assets/include/SDL2/SDL_test.h +69 -0
- data/assets/include/SDL2/SDL_test_assert.h +105 -0
- data/assets/include/SDL2/SDL_test_common.h +218 -0
- data/assets/include/SDL2/SDL_test_compare.h +69 -0
- data/assets/include/SDL2/SDL_test_crc32.h +124 -0
- data/assets/include/SDL2/SDL_test_font.h +81 -0
- data/assets/include/SDL2/SDL_test_fuzzer.h +384 -0
- data/assets/include/SDL2/SDL_test_harness.h +134 -0
- data/assets/include/SDL2/SDL_test_images.h +78 -0
- data/assets/include/SDL2/SDL_test_log.h +67 -0
- data/assets/include/SDL2/SDL_test_md5.h +129 -0
- data/assets/include/SDL2/SDL_test_memory.h +63 -0
- data/assets/include/SDL2/SDL_test_random.h +115 -0
- data/assets/include/SDL2/SDL_thread.h +366 -0
- data/assets/include/SDL2/SDL_timer.h +115 -0
- data/assets/include/SDL2/SDL_touch.h +102 -0
- data/assets/include/SDL2/SDL_ttf.h +294 -0
- data/assets/include/SDL2/SDL_types.h +29 -0
- data/assets/include/SDL2/SDL_version.h +162 -0
- data/assets/include/SDL2/SDL_video.h +1282 -0
- data/assets/include/SDL2/SDL_vulkan.h +276 -0
- data/assets/include/SDL2/begin_code.h +166 -0
- data/assets/include/SDL2/close_code.h +40 -0
- data/assets/include/glew.h +23686 -0
- data/assets/ios/Assets.xcassets/AppIcon.appiconset/Contents.json +98 -0
- data/assets/ios/Assets.xcassets/Contents.json +6 -0
- data/assets/ios/Base.lproj/LaunchScreen.storyboard +27 -0
- data/assets/ios/Info.plist +43 -0
- data/assets/ios/MRuby.framework/Headers/mrbconf.h +143 -0
- data/assets/ios/MRuby.framework/Headers/mruby/array.h +280 -0
- data/assets/ios/MRuby.framework/Headers/mruby/boxing_nan.h +102 -0
- data/assets/ios/MRuby.framework/Headers/mruby/boxing_no.h +56 -0
- data/assets/ios/MRuby.framework/Headers/mruby/boxing_word.h +144 -0
- data/assets/ios/MRuby.framework/Headers/mruby/class.h +97 -0
- data/assets/ios/MRuby.framework/Headers/mruby/common.h +77 -0
- data/assets/ios/MRuby.framework/Headers/mruby/compile.h +195 -0
- data/assets/ios/MRuby.framework/Headers/mruby/data.h +75 -0
- data/assets/ios/MRuby.framework/Headers/mruby/debug.h +67 -0
- data/assets/ios/MRuby.framework/Headers/mruby/dump.h +196 -0
- data/assets/ios/MRuby.framework/Headers/mruby/error.h +75 -0
- data/assets/ios/MRuby.framework/Headers/mruby/gc.h +91 -0
- data/assets/ios/MRuby.framework/Headers/mruby/hash.h +215 -0
- data/assets/ios/MRuby.framework/Headers/mruby/irep.h +75 -0
- data/assets/ios/MRuby.framework/Headers/mruby/istruct.h +47 -0
- data/assets/ios/MRuby.framework/Headers/mruby/khash.h +274 -0
- data/assets/ios/MRuby.framework/Headers/mruby/numeric.h +161 -0
- data/assets/ios/MRuby.framework/Headers/mruby/object.h +44 -0
- data/assets/ios/MRuby.framework/Headers/mruby/opcode.h +69 -0
- data/assets/ios/MRuby.framework/Headers/mruby/ops.h +117 -0
- data/assets/ios/MRuby.framework/Headers/mruby/proc.h +131 -0
- data/assets/ios/MRuby.framework/Headers/mruby/range.h +49 -0
- data/assets/ios/MRuby.framework/Headers/mruby/re.h +16 -0
- data/assets/ios/MRuby.framework/Headers/mruby/string.h +444 -0
- data/assets/ios/MRuby.framework/Headers/mruby/throw.h +55 -0
- data/assets/ios/MRuby.framework/Headers/mruby/value.h +309 -0
- data/assets/ios/MRuby.framework/Headers/mruby/variable.h +136 -0
- data/assets/ios/MRuby.framework/Headers/mruby/version.h +110 -0
- data/assets/ios/MRuby.framework/Headers/mruby.h +1282 -0
- data/assets/ios/MRuby.framework/Info.plist +20 -0
- data/assets/ios/MRuby.framework/MRuby +0 -0
- data/assets/ios/MyApp.xcodeproj/project.pbxproj +368 -0
- data/assets/ios/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- data/assets/ios/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- data/assets/ios/MyApp.xcodeproj/project.xcworkspace/xcshareddata/MyApp.xcscmblueprint +30 -0
- data/assets/ios/main.c +1 -0
- data/assets/macos/lib/libFLAC.a +0 -0
- data/assets/macos/lib/libSDL2.a +0 -0
- data/assets/macos/lib/libSDL2_image.a +0 -0
- data/assets/macos/lib/libSDL2_mixer.a +0 -0
- data/assets/macos/lib/libSDL2_ttf.a +0 -0
- data/assets/macos/lib/libfreetype.a +0 -0
- data/assets/macos/lib/libjpeg.a +0 -0
- data/assets/macos/lib/libmodplug.a +0 -0
- data/assets/macos/lib/libmpg123.a +0 -0
- data/assets/macos/lib/libogg.a +0 -0
- data/assets/macos/lib/libpng16.a +0 -0
- data/assets/macos/lib/libtiff.a +0 -0
- data/assets/macos/lib/libvorbis.a +0 -0
- data/assets/macos/lib/libvorbisfile.a +0 -0
- data/assets/macos/lib/libwebp.a +0 -0
- data/assets/mingw/bin/SDL2.dll +0 -0
- data/assets/mingw/bin/SDL2_image.dll +0 -0
- data/assets/mingw/bin/SDL2_mixer.dll +0 -0
- data/assets/mingw/bin/SDL2_ttf.dll +0 -0
- data/assets/mingw/bin/glew32.dll +0 -0
- data/assets/mingw/bin/libFLAC-8.dll +0 -0
- data/assets/mingw/bin/libfreetype-6.dll +0 -0
- data/assets/mingw/bin/libjpeg-9.dll +0 -0
- data/assets/mingw/bin/libmodplug-1.dll +0 -0
- data/assets/mingw/bin/libmpg123-0.dll +0 -0
- data/assets/mingw/bin/libogg-0.dll +0 -0
- data/assets/mingw/bin/libopus-0.dll +0 -0
- data/assets/mingw/bin/libopusfile-0.dll +0 -0
- data/assets/mingw/bin/libpng16-16.dll +0 -0
- data/assets/mingw/bin/libtiff-5.dll +0 -0
- data/assets/mingw/bin/libvorbis-0.dll +0 -0
- data/assets/mingw/bin/libvorbisfile-3.dll +0 -0
- data/assets/mingw/bin/libwebp-7.dll +0 -0
- data/assets/mingw/bin/libwinpthread-1.dll +0 -0
- data/assets/mingw/bin/zlib1.dll +0 -0
- data/assets/mingw/lib/libSDL2.a +0 -0
- data/assets/mingw/lib/libSDL2.dll.a +0 -0
- data/assets/mingw/lib/libSDL2_image.a +0 -0
- data/assets/mingw/lib/libSDL2_image.dll.a +0 -0
- data/assets/mingw/lib/libSDL2_mixer.a +0 -0
- data/assets/mingw/lib/libSDL2_mixer.dll.a +0 -0
- data/assets/mingw/lib/libSDL2_test.a +0 -0
- data/assets/mingw/lib/libSDL2_ttf.a +0 -0
- data/assets/mingw/lib/libSDL2_ttf.dll.a +0 -0
- data/assets/mingw/lib/libSDL2main.a +0 -0
- data/assets/mingw/lib/libglew32.a +0 -0
- data/assets/mingw/lib/libglew32.dll.a +0 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Content.imageset/Contents.json +16 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Contents.json +6 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Contents.json +17 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Content.imageset/Contents.json +16 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Contents.json +6 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json +16 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Contents.json +6 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Content.imageset/Contents.json +16 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Contents.json +6 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Contents.json +17 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Content.imageset/Contents.json +16 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Contents.json +6 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json +16 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Contents.json +6 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Contents.json +32 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image Wide.imageset/Contents.json +16 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image.imageset/Contents.json +16 -0
- data/assets/tvos/Assets.xcassets/Contents.json +6 -0
- data/assets/tvos/Assets.xcassets/LaunchImage.launchimage/Contents.json +22 -0
- data/assets/tvos/Info.plist +30 -0
- data/assets/tvos/MRuby.framework/Headers/mrbconf.h +143 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/array.h +280 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/boxing_nan.h +102 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/boxing_no.h +56 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/boxing_word.h +144 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/class.h +97 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/common.h +77 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/compile.h +195 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/data.h +75 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/debug.h +67 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/dump.h +196 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/error.h +75 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/gc.h +91 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/hash.h +215 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/irep.h +75 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/istruct.h +47 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/khash.h +274 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/numeric.h +161 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/object.h +44 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/opcode.h +69 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/ops.h +117 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/proc.h +131 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/range.h +49 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/re.h +16 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/string.h +444 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/throw.h +55 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/value.h +309 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/variable.h +136 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/version.h +110 -0
- data/assets/tvos/MRuby.framework/Headers/mruby.h +1282 -0
- data/assets/tvos/MRuby.framework/Info.plist +20 -0
- data/assets/tvos/MRuby.framework/MRuby +0 -0
- data/assets/tvos/MyApp.xcodeproj/project.pbxproj +350 -0
- data/assets/tvos/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- data/assets/tvos/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- data/assets/tvos/MyApp.xcodeproj/project.xcworkspace/xcshareddata/MyApp.xcscmblueprint +30 -0
- data/assets/tvos/main.c +1 -0
- data/bin/ruby2d +142 -0
- data/ext/ruby2d/common.c +185 -0
- data/ext/ruby2d/controllers.c +110 -0
- data/ext/ruby2d/extconf.rb +147 -0
- data/ext/ruby2d/font.c +35 -0
- data/ext/ruby2d/gl.c +398 -0
- data/ext/ruby2d/gl2.c +86 -0
- data/ext/ruby2d/gl3.c +305 -0
- data/ext/ruby2d/gles.c +249 -0
- data/ext/ruby2d/image.c +58 -0
- data/ext/ruby2d/input.c +48 -0
- data/ext/ruby2d/music.c +127 -0
- data/ext/ruby2d/ruby2d.c +1374 -0
- data/ext/ruby2d/ruby2d.h +656 -0
- data/ext/ruby2d/shapes.c +154 -0
- data/ext/ruby2d/sound.c +118 -0
- data/ext/ruby2d/text.c +22 -0
- data/ext/ruby2d/window.c +414 -0
- data/lib/ruby2d/circle.rb +43 -0
- data/lib/ruby2d/cli/build.rb +237 -0
- data/lib/ruby2d/cli/colorize.rb +10 -0
- data/lib/ruby2d/cli/console.rb +65 -0
- data/lib/ruby2d/cli/enable_console.rb +5 -0
- data/lib/ruby2d/cli/launch.rb +50 -0
- data/lib/ruby2d/color.rb +136 -0
- data/lib/ruby2d/dsl.rb +46 -0
- data/lib/ruby2d/entity.rb +17 -0
- data/lib/ruby2d/exceptions.rb +6 -0
- data/lib/ruby2d/font.rb +96 -0
- data/lib/ruby2d/image.rb +58 -0
- data/lib/ruby2d/line.rb +89 -0
- data/lib/ruby2d/music.rb +67 -0
- data/lib/ruby2d/pixel.rb +17 -0
- data/lib/ruby2d/quad.rb +96 -0
- data/lib/ruby2d/rectangle.rb +65 -0
- data/lib/ruby2d/renderable.rb +40 -0
- data/lib/ruby2d/ruby2d.so +0 -0
- data/lib/ruby2d/sound.rb +55 -0
- data/lib/ruby2d/sprite.rb +232 -0
- data/lib/ruby2d/square.rb +37 -0
- data/lib/ruby2d/text.rb +76 -0
- data/lib/ruby2d/texture.rb +28 -0
- data/lib/ruby2d/tileset.rb +87 -0
- data/lib/ruby2d/triangle.rb +82 -0
- data/lib/ruby2d/version.rb +5 -0
- data/lib/ruby2d/vertices.rb +84 -0
- data/lib/ruby2d/window.rb +673 -0
- data/lib/ruby2d.rb +69 -0
- metadata +346 -0
@@ -0,0 +1,75 @@
|
|
1
|
+
/*
|
2
|
+
** mruby/data.h - Data class
|
3
|
+
**
|
4
|
+
** See Copyright Notice in mruby.h
|
5
|
+
*/
|
6
|
+
|
7
|
+
#ifndef MRUBY_DATA_H
|
8
|
+
#define MRUBY_DATA_H
|
9
|
+
|
10
|
+
#include "common.h"
|
11
|
+
|
12
|
+
/**
|
13
|
+
* Custom C wrapped data.
|
14
|
+
*
|
15
|
+
* Defining Ruby wrappers around native objects.
|
16
|
+
*/
|
17
|
+
MRB_BEGIN_DECL
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Custom data type description.
|
21
|
+
*/
|
22
|
+
typedef struct mrb_data_type {
|
23
|
+
/** data type name */
|
24
|
+
const char *struct_name;
|
25
|
+
|
26
|
+
/** data type release function pointer */
|
27
|
+
void (*dfree)(mrb_state *mrb, void*);
|
28
|
+
} mrb_data_type;
|
29
|
+
|
30
|
+
struct RData {
|
31
|
+
MRB_OBJECT_HEADER;
|
32
|
+
struct iv_tbl *iv;
|
33
|
+
const mrb_data_type *type;
|
34
|
+
void *data;
|
35
|
+
};
|
36
|
+
|
37
|
+
MRB_API struct RData *mrb_data_object_alloc(mrb_state *mrb, struct RClass* klass, void *datap, const mrb_data_type *type);
|
38
|
+
|
39
|
+
#define Data_Wrap_Struct(mrb,klass,type,ptr)\
|
40
|
+
mrb_data_object_alloc(mrb,klass,ptr,type)
|
41
|
+
|
42
|
+
#define Data_Make_Struct(mrb,klass,strct,type,sval,data) do { \
|
43
|
+
sval = mrb_malloc(mrb, sizeof(strct)); \
|
44
|
+
{ static const strct zero = { 0 }; *sval = zero; };\
|
45
|
+
data = Data_Wrap_Struct(mrb,klass,type,sval);\
|
46
|
+
} while (0)
|
47
|
+
|
48
|
+
#define RDATA(obj) ((struct RData *)(mrb_ptr(obj)))
|
49
|
+
#define DATA_PTR(d) (RDATA(d)->data)
|
50
|
+
#define DATA_TYPE(d) (RDATA(d)->type)
|
51
|
+
MRB_API void mrb_data_check_type(mrb_state *mrb, mrb_value, const mrb_data_type*);
|
52
|
+
MRB_API void *mrb_data_get_ptr(mrb_state *mrb, mrb_value, const mrb_data_type*);
|
53
|
+
#define DATA_GET_PTR(mrb,obj,dtype,type) (type*)mrb_data_get_ptr(mrb,obj,dtype)
|
54
|
+
MRB_API void *mrb_data_check_get_ptr(mrb_state *mrb, mrb_value, const mrb_data_type*);
|
55
|
+
#define DATA_CHECK_GET_PTR(mrb,obj,dtype,type) (type*)mrb_data_check_get_ptr(mrb,obj,dtype)
|
56
|
+
|
57
|
+
/* obsolete functions and macros */
|
58
|
+
#define mrb_data_check_and_get(mrb,obj,dtype) mrb_data_get_ptr(mrb,obj,dtype)
|
59
|
+
#define mrb_get_datatype(mrb,val,type) mrb_data_get_ptr(mrb, val, type)
|
60
|
+
#define mrb_check_datatype(mrb,val,type) mrb_data_get_ptr(mrb, val, type)
|
61
|
+
#define Data_Get_Struct(mrb,obj,type,sval) do {\
|
62
|
+
*(void**)&sval = mrb_data_get_ptr(mrb, obj, type); \
|
63
|
+
} while (0)
|
64
|
+
|
65
|
+
static inline void
|
66
|
+
mrb_data_init(mrb_value v, void *ptr, const mrb_data_type *type)
|
67
|
+
{
|
68
|
+
mrb_assert(mrb_type(v) == MRB_TT_DATA);
|
69
|
+
DATA_PTR(v) = ptr;
|
70
|
+
DATA_TYPE(v) = type;
|
71
|
+
}
|
72
|
+
|
73
|
+
MRB_END_DECL
|
74
|
+
|
75
|
+
#endif /* MRUBY_DATA_H */
|
@@ -0,0 +1,67 @@
|
|
1
|
+
/*
|
2
|
+
** mruby/debug.h - mruby debug info
|
3
|
+
**
|
4
|
+
** See Copyright Notice in mruby.h
|
5
|
+
*/
|
6
|
+
|
7
|
+
#ifndef MRUBY_DEBUG_H
|
8
|
+
#define MRUBY_DEBUG_H
|
9
|
+
|
10
|
+
#include "common.h"
|
11
|
+
|
12
|
+
/**
|
13
|
+
* MRuby Debugging.
|
14
|
+
*/
|
15
|
+
MRB_BEGIN_DECL
|
16
|
+
|
17
|
+
typedef enum mrb_debug_line_type {
|
18
|
+
mrb_debug_line_ary = 0,
|
19
|
+
mrb_debug_line_flat_map = 1
|
20
|
+
} mrb_debug_line_type;
|
21
|
+
|
22
|
+
typedef struct mrb_irep_debug_info_line {
|
23
|
+
uint32_t start_pos;
|
24
|
+
uint16_t line;
|
25
|
+
} mrb_irep_debug_info_line;
|
26
|
+
|
27
|
+
typedef struct mrb_irep_debug_info_file {
|
28
|
+
uint32_t start_pos;
|
29
|
+
const char *filename;
|
30
|
+
mrb_sym filename_sym;
|
31
|
+
uint32_t line_entry_count;
|
32
|
+
mrb_debug_line_type line_type;
|
33
|
+
union {
|
34
|
+
void *ptr;
|
35
|
+
mrb_irep_debug_info_line *flat_map;
|
36
|
+
uint16_t *ary;
|
37
|
+
} lines;
|
38
|
+
} mrb_irep_debug_info_file;
|
39
|
+
|
40
|
+
typedef struct mrb_irep_debug_info {
|
41
|
+
uint32_t pc_count;
|
42
|
+
uint16_t flen;
|
43
|
+
mrb_irep_debug_info_file **files;
|
44
|
+
} mrb_irep_debug_info;
|
45
|
+
|
46
|
+
/*
|
47
|
+
* get line from irep's debug info and program counter
|
48
|
+
* @return returns NULL if not found
|
49
|
+
*/
|
50
|
+
MRB_API const char *mrb_debug_get_filename(mrb_irep *irep, ptrdiff_t pc);
|
51
|
+
|
52
|
+
/*
|
53
|
+
* get line from irep's debug info and program counter
|
54
|
+
* @return returns -1 if not found
|
55
|
+
*/
|
56
|
+
MRB_API int32_t mrb_debug_get_line(mrb_irep *irep, ptrdiff_t pc);
|
57
|
+
|
58
|
+
MRB_API mrb_irep_debug_info *mrb_debug_info_alloc(mrb_state *mrb, mrb_irep *irep);
|
59
|
+
MRB_API mrb_irep_debug_info_file *mrb_debug_info_append_file(
|
60
|
+
mrb_state *mrb, mrb_irep_debug_info *info,
|
61
|
+
const char *filename, uint16_t *lines,
|
62
|
+
uint32_t start_pos, uint32_t end_pos);
|
63
|
+
MRB_API void mrb_debug_info_free(mrb_state *mrb, mrb_irep_debug_info *d);
|
64
|
+
|
65
|
+
MRB_END_DECL
|
66
|
+
|
67
|
+
#endif /* MRUBY_DEBUG_H */
|
@@ -0,0 +1,196 @@
|
|
1
|
+
/*
|
2
|
+
** mruby/dump.h - mruby binary dumper (mrbc binary format)
|
3
|
+
**
|
4
|
+
** See Copyright Notice in mruby.h
|
5
|
+
*/
|
6
|
+
|
7
|
+
#ifndef MRUBY_DUMP_H
|
8
|
+
#define MRUBY_DUMP_H
|
9
|
+
|
10
|
+
#include <mruby.h>
|
11
|
+
#include <mruby/irep.h>
|
12
|
+
#include "common.h"
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Dumping compiled mruby script.
|
16
|
+
*/
|
17
|
+
MRB_BEGIN_DECL
|
18
|
+
|
19
|
+
#define DUMP_DEBUG_INFO 1
|
20
|
+
#define DUMP_ENDIAN_BIG 2
|
21
|
+
#define DUMP_ENDIAN_LIL 4
|
22
|
+
#define DUMP_ENDIAN_NAT 6
|
23
|
+
#define DUMP_ENDIAN_MASK 6
|
24
|
+
|
25
|
+
int mrb_dump_irep(mrb_state *mrb, mrb_irep *irep, uint8_t flags, uint8_t **bin, size_t *bin_size);
|
26
|
+
#ifndef MRB_DISABLE_STDIO
|
27
|
+
int mrb_dump_irep_binary(mrb_state*, mrb_irep*, uint8_t, FILE*);
|
28
|
+
int mrb_dump_irep_cfunc(mrb_state *mrb, mrb_irep*, uint8_t flags, FILE *f, const char *initname);
|
29
|
+
mrb_irep *mrb_read_irep_file(mrb_state*, FILE*);
|
30
|
+
MRB_API mrb_value mrb_load_irep_file(mrb_state*,FILE*);
|
31
|
+
MRB_API mrb_value mrb_load_irep_file_cxt(mrb_state*, FILE*, mrbc_context*);
|
32
|
+
#endif
|
33
|
+
MRB_API mrb_irep *mrb_read_irep(mrb_state*, const uint8_t*);
|
34
|
+
|
35
|
+
/* dump/load error code
|
36
|
+
*
|
37
|
+
* NOTE: MRB_DUMP_GENERAL_FAILURE is caused by
|
38
|
+
* unspecified issues like malloc failed.
|
39
|
+
*/
|
40
|
+
#define MRB_DUMP_OK 0
|
41
|
+
#define MRB_DUMP_GENERAL_FAILURE (-1)
|
42
|
+
#define MRB_DUMP_WRITE_FAULT (-2)
|
43
|
+
#define MRB_DUMP_READ_FAULT (-3)
|
44
|
+
#define MRB_DUMP_CRC_ERROR (-4)
|
45
|
+
#define MRB_DUMP_INVALID_FILE_HEADER (-5)
|
46
|
+
#define MRB_DUMP_INVALID_IREP (-6)
|
47
|
+
#define MRB_DUMP_INVALID_ARGUMENT (-7)
|
48
|
+
|
49
|
+
/* null symbol length */
|
50
|
+
#define MRB_DUMP_NULL_SYM_LEN 0xFFFF
|
51
|
+
|
52
|
+
/* Rite Binary File header */
|
53
|
+
#define RITE_BINARY_IDENT "RITE"
|
54
|
+
#define RITE_BINARY_IDENT_LIL "ETIR"
|
55
|
+
#define RITE_BINARY_FORMAT_VER "0005"
|
56
|
+
#define RITE_COMPILER_NAME "MATZ"
|
57
|
+
#define RITE_COMPILER_VERSION "0000"
|
58
|
+
|
59
|
+
#define RITE_VM_VER "0002"
|
60
|
+
|
61
|
+
#define RITE_BINARY_EOF "END\0"
|
62
|
+
#define RITE_SECTION_IREP_IDENT "IREP"
|
63
|
+
#define RITE_SECTION_LINENO_IDENT "LINE"
|
64
|
+
#define RITE_SECTION_DEBUG_IDENT "DBG\0"
|
65
|
+
#define RITE_SECTION_LV_IDENT "LVAR"
|
66
|
+
|
67
|
+
#define MRB_DUMP_DEFAULT_STR_LEN 128
|
68
|
+
#define MRB_DUMP_ALIGNMENT sizeof(uint32_t)
|
69
|
+
|
70
|
+
/* binary header */
|
71
|
+
struct rite_binary_header {
|
72
|
+
uint8_t binary_ident[4]; /* Binary Identifier */
|
73
|
+
uint8_t binary_version[4]; /* Binary Format Version */
|
74
|
+
uint8_t binary_crc[2]; /* Binary CRC */
|
75
|
+
uint8_t binary_size[4]; /* Binary Size */
|
76
|
+
uint8_t compiler_name[4]; /* Compiler name */
|
77
|
+
uint8_t compiler_version[4];
|
78
|
+
};
|
79
|
+
|
80
|
+
/* section header */
|
81
|
+
#define RITE_SECTION_HEADER \
|
82
|
+
uint8_t section_ident[4]; \
|
83
|
+
uint8_t section_size[4]
|
84
|
+
|
85
|
+
struct rite_section_header {
|
86
|
+
RITE_SECTION_HEADER;
|
87
|
+
};
|
88
|
+
|
89
|
+
struct rite_section_irep_header {
|
90
|
+
RITE_SECTION_HEADER;
|
91
|
+
|
92
|
+
uint8_t rite_version[4]; /* Rite Instruction Specification Version */
|
93
|
+
};
|
94
|
+
|
95
|
+
struct rite_section_lineno_header {
|
96
|
+
RITE_SECTION_HEADER;
|
97
|
+
};
|
98
|
+
|
99
|
+
struct rite_section_debug_header {
|
100
|
+
RITE_SECTION_HEADER;
|
101
|
+
};
|
102
|
+
|
103
|
+
struct rite_section_lv_header {
|
104
|
+
RITE_SECTION_HEADER;
|
105
|
+
};
|
106
|
+
|
107
|
+
#define RITE_LV_NULL_MARK UINT16_MAX
|
108
|
+
|
109
|
+
struct rite_binary_footer {
|
110
|
+
RITE_SECTION_HEADER;
|
111
|
+
};
|
112
|
+
|
113
|
+
static inline int
|
114
|
+
bigendian_p()
|
115
|
+
{
|
116
|
+
int i;
|
117
|
+
char *p;
|
118
|
+
|
119
|
+
i = 1;
|
120
|
+
p = (char*)&i;
|
121
|
+
return p[0]?0:1;
|
122
|
+
}
|
123
|
+
|
124
|
+
static inline size_t
|
125
|
+
uint8_to_bin(uint8_t s, uint8_t *bin)
|
126
|
+
{
|
127
|
+
*bin = s;
|
128
|
+
return sizeof(uint8_t);
|
129
|
+
}
|
130
|
+
|
131
|
+
static inline size_t
|
132
|
+
uint16_to_bin(uint16_t s, uint8_t *bin)
|
133
|
+
{
|
134
|
+
*bin++ = (s >> 8) & 0xff;
|
135
|
+
*bin = s & 0xff;
|
136
|
+
return sizeof(uint16_t);
|
137
|
+
}
|
138
|
+
|
139
|
+
static inline size_t
|
140
|
+
uint32_to_bin(uint32_t l, uint8_t *bin)
|
141
|
+
{
|
142
|
+
*bin++ = (l >> 24) & 0xff;
|
143
|
+
*bin++ = (l >> 16) & 0xff;
|
144
|
+
*bin++ = (l >> 8) & 0xff;
|
145
|
+
*bin = l & 0xff;
|
146
|
+
return sizeof(uint32_t);
|
147
|
+
}
|
148
|
+
|
149
|
+
static inline size_t
|
150
|
+
uint32l_to_bin(uint32_t l, uint8_t *bin)
|
151
|
+
{
|
152
|
+
bin[3] = (l >> 24) & 0xff;
|
153
|
+
bin[2] = (l >> 16) & 0xff;
|
154
|
+
bin[1] = (l >> 8) & 0xff;
|
155
|
+
bin[0] = l & 0xff;
|
156
|
+
return sizeof(uint32_t);
|
157
|
+
}
|
158
|
+
|
159
|
+
static inline uint32_t
|
160
|
+
bin_to_uint32(const uint8_t *bin)
|
161
|
+
{
|
162
|
+
return (uint32_t)bin[0] << 24 |
|
163
|
+
(uint32_t)bin[1] << 16 |
|
164
|
+
(uint32_t)bin[2] << 8 |
|
165
|
+
(uint32_t)bin[3];
|
166
|
+
}
|
167
|
+
|
168
|
+
static inline uint32_t
|
169
|
+
bin_to_uint32l(const uint8_t *bin)
|
170
|
+
{
|
171
|
+
return (uint32_t)bin[3] << 24 |
|
172
|
+
(uint32_t)bin[2] << 16 |
|
173
|
+
(uint32_t)bin[1] << 8 |
|
174
|
+
(uint32_t)bin[0];
|
175
|
+
}
|
176
|
+
|
177
|
+
static inline uint16_t
|
178
|
+
bin_to_uint16(const uint8_t *bin)
|
179
|
+
{
|
180
|
+
return (uint16_t)bin[0] << 8 |
|
181
|
+
(uint16_t)bin[1];
|
182
|
+
}
|
183
|
+
|
184
|
+
static inline uint8_t
|
185
|
+
bin_to_uint8(const uint8_t *bin)
|
186
|
+
{
|
187
|
+
return (uint8_t)bin[0];
|
188
|
+
}
|
189
|
+
|
190
|
+
MRB_END_DECL
|
191
|
+
|
192
|
+
/** @internal crc.c */
|
193
|
+
uint16_t
|
194
|
+
calc_crc_16_ccitt(const uint8_t *src, size_t nbytes, uint16_t crc);
|
195
|
+
|
196
|
+
#endif /* MRUBY_DUMP_H */
|
@@ -0,0 +1,75 @@
|
|
1
|
+
/*
|
2
|
+
** mruby/error.h - Exception class
|
3
|
+
**
|
4
|
+
** See Copyright Notice in mruby.h
|
5
|
+
*/
|
6
|
+
|
7
|
+
#ifndef MRUBY_ERROR_H
|
8
|
+
#define MRUBY_ERROR_H
|
9
|
+
|
10
|
+
#include "common.h"
|
11
|
+
|
12
|
+
/**
|
13
|
+
* MRuby error handling.
|
14
|
+
*/
|
15
|
+
MRB_BEGIN_DECL
|
16
|
+
|
17
|
+
struct RException {
|
18
|
+
MRB_OBJECT_HEADER;
|
19
|
+
struct iv_tbl *iv;
|
20
|
+
};
|
21
|
+
|
22
|
+
#define mrb_exc_ptr(v) ((struct RException*)mrb_ptr(v))
|
23
|
+
|
24
|
+
MRB_API void mrb_sys_fail(mrb_state *mrb, const char *mesg);
|
25
|
+
MRB_API mrb_value mrb_exc_new_str(mrb_state *mrb, struct RClass* c, mrb_value str);
|
26
|
+
#define mrb_exc_new_str_lit(mrb, c, lit) mrb_exc_new_str(mrb, c, mrb_str_new_lit(mrb, lit))
|
27
|
+
MRB_API mrb_value mrb_make_exception(mrb_state *mrb, mrb_int argc, const mrb_value *argv);
|
28
|
+
MRB_API mrb_value mrb_exc_backtrace(mrb_state *mrb, mrb_value exc);
|
29
|
+
MRB_API mrb_value mrb_get_backtrace(mrb_state *mrb);
|
30
|
+
MRB_API mrb_noreturn void mrb_no_method_error(mrb_state *mrb, mrb_sym id, mrb_value args, const char *fmt, ...);
|
31
|
+
|
32
|
+
/* declaration for fail method */
|
33
|
+
MRB_API mrb_value mrb_f_raise(mrb_state*, mrb_value);
|
34
|
+
|
35
|
+
struct RBreak {
|
36
|
+
MRB_OBJECT_HEADER;
|
37
|
+
struct RProc *proc;
|
38
|
+
mrb_value val;
|
39
|
+
};
|
40
|
+
|
41
|
+
/**
|
42
|
+
* Protect
|
43
|
+
*
|
44
|
+
* @mrbgem mruby-error
|
45
|
+
*/
|
46
|
+
MRB_API mrb_value mrb_protect(mrb_state *mrb, mrb_func_t body, mrb_value data, mrb_bool *state);
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Ensure
|
50
|
+
*
|
51
|
+
* @mrbgem mruby-error
|
52
|
+
*/
|
53
|
+
MRB_API mrb_value mrb_ensure(mrb_state *mrb, mrb_func_t body, mrb_value b_data,
|
54
|
+
mrb_func_t ensure, mrb_value e_data);
|
55
|
+
|
56
|
+
/**
|
57
|
+
* Rescue
|
58
|
+
*
|
59
|
+
* @mrbgem mruby-error
|
60
|
+
*/
|
61
|
+
MRB_API mrb_value mrb_rescue(mrb_state *mrb, mrb_func_t body, mrb_value b_data,
|
62
|
+
mrb_func_t rescue, mrb_value r_data);
|
63
|
+
|
64
|
+
/**
|
65
|
+
* Rescue exception
|
66
|
+
*
|
67
|
+
* @mrbgem mruby-error
|
68
|
+
*/
|
69
|
+
MRB_API mrb_value mrb_rescue_exceptions(mrb_state *mrb, mrb_func_t body, mrb_value b_data,
|
70
|
+
mrb_func_t rescue, mrb_value r_data,
|
71
|
+
mrb_int len, struct RClass **classes);
|
72
|
+
|
73
|
+
MRB_END_DECL
|
74
|
+
|
75
|
+
#endif /* MRUBY_ERROR_H */
|
@@ -0,0 +1,91 @@
|
|
1
|
+
/*
|
2
|
+
** mruby/gc.h - garbage collector for mruby
|
3
|
+
**
|
4
|
+
** See Copyright Notice in mruby.h
|
5
|
+
*/
|
6
|
+
|
7
|
+
#ifndef MRUBY_GC_H
|
8
|
+
#define MRUBY_GC_H
|
9
|
+
|
10
|
+
#include "common.h"
|
11
|
+
|
12
|
+
/**
|
13
|
+
* Uncommon memory management stuffs.
|
14
|
+
*/
|
15
|
+
MRB_BEGIN_DECL
|
16
|
+
|
17
|
+
|
18
|
+
struct mrb_state;
|
19
|
+
|
20
|
+
#define MRB_EACH_OBJ_OK 0
|
21
|
+
#define MRB_EACH_OBJ_BREAK 1
|
22
|
+
typedef int (mrb_each_object_callback)(struct mrb_state *mrb, struct RBasic *obj, void *data);
|
23
|
+
void mrb_objspace_each_objects(struct mrb_state *mrb, mrb_each_object_callback *callback, void *data);
|
24
|
+
MRB_API void mrb_free_context(struct mrb_state *mrb, struct mrb_context *c);
|
25
|
+
|
26
|
+
#ifndef MRB_GC_ARENA_SIZE
|
27
|
+
#define MRB_GC_ARENA_SIZE 100
|
28
|
+
#endif
|
29
|
+
|
30
|
+
typedef enum {
|
31
|
+
MRB_GC_STATE_ROOT = 0,
|
32
|
+
MRB_GC_STATE_MARK,
|
33
|
+
MRB_GC_STATE_SWEEP
|
34
|
+
} mrb_gc_state;
|
35
|
+
|
36
|
+
/* Disable MSVC warning "C4200: nonstandard extension used: zero-sized array
|
37
|
+
* in struct/union" when in C++ mode */
|
38
|
+
#ifdef _MSC_VER
|
39
|
+
#pragma warning(push)
|
40
|
+
#pragma warning(disable : 4200)
|
41
|
+
#endif
|
42
|
+
|
43
|
+
typedef struct mrb_heap_page {
|
44
|
+
struct RBasic *freelist;
|
45
|
+
struct mrb_heap_page *prev;
|
46
|
+
struct mrb_heap_page *next;
|
47
|
+
struct mrb_heap_page *free_next;
|
48
|
+
struct mrb_heap_page *free_prev;
|
49
|
+
mrb_bool old:1;
|
50
|
+
void *objects[];
|
51
|
+
} mrb_heap_page;
|
52
|
+
|
53
|
+
#ifdef _MSC_VER
|
54
|
+
#pragma warning(pop)
|
55
|
+
#endif
|
56
|
+
|
57
|
+
typedef struct mrb_gc {
|
58
|
+
mrb_heap_page *heaps; /* heaps for GC */
|
59
|
+
mrb_heap_page *sweeps;
|
60
|
+
mrb_heap_page *free_heaps;
|
61
|
+
size_t live; /* count of live objects */
|
62
|
+
#ifdef MRB_GC_FIXED_ARENA
|
63
|
+
struct RBasic *arena[MRB_GC_ARENA_SIZE]; /* GC protection array */
|
64
|
+
#else
|
65
|
+
struct RBasic **arena; /* GC protection array */
|
66
|
+
int arena_capa;
|
67
|
+
#endif
|
68
|
+
int arena_idx;
|
69
|
+
|
70
|
+
mrb_gc_state state; /* state of gc */
|
71
|
+
int current_white_part; /* make white object by white_part */
|
72
|
+
struct RBasic *gray_list; /* list of gray objects to be traversed incrementally */
|
73
|
+
struct RBasic *atomic_gray_list; /* list of objects to be traversed atomically */
|
74
|
+
size_t live_after_mark;
|
75
|
+
size_t threshold;
|
76
|
+
int interval_ratio;
|
77
|
+
int step_ratio;
|
78
|
+
mrb_bool iterating :1;
|
79
|
+
mrb_bool disabled :1;
|
80
|
+
mrb_bool full :1;
|
81
|
+
mrb_bool generational :1;
|
82
|
+
mrb_bool out_of_memory :1;
|
83
|
+
size_t majorgc_old_threshold;
|
84
|
+
} mrb_gc;
|
85
|
+
|
86
|
+
MRB_API mrb_bool
|
87
|
+
mrb_object_dead_p(struct mrb_state *mrb, struct RBasic *object);
|
88
|
+
|
89
|
+
MRB_END_DECL
|
90
|
+
|
91
|
+
#endif /* MRUBY_GC_H */
|
@@ -0,0 +1,215 @@
|
|
1
|
+
/*
|
2
|
+
** mruby/hash.h - Hash class
|
3
|
+
**
|
4
|
+
** See Copyright Notice in mruby.h
|
5
|
+
*/
|
6
|
+
|
7
|
+
#ifndef MRUBY_HASH_H
|
8
|
+
#define MRUBY_HASH_H
|
9
|
+
|
10
|
+
#include "common.h"
|
11
|
+
#include <mruby/khash.h>
|
12
|
+
|
13
|
+
/**
|
14
|
+
* Hash class
|
15
|
+
*/
|
16
|
+
MRB_BEGIN_DECL
|
17
|
+
|
18
|
+
struct RHash {
|
19
|
+
MRB_OBJECT_HEADER;
|
20
|
+
struct iv_tbl *iv;
|
21
|
+
struct htable *ht;
|
22
|
+
};
|
23
|
+
|
24
|
+
#define mrb_hash_ptr(v) ((struct RHash*)(mrb_ptr(v)))
|
25
|
+
#define mrb_hash_value(p) mrb_obj_value((void*)(p))
|
26
|
+
|
27
|
+
MRB_API mrb_value mrb_hash_new_capa(mrb_state*, mrb_int);
|
28
|
+
MRB_API mrb_value mrb_ensure_hash_type(mrb_state *mrb, mrb_value hash);
|
29
|
+
MRB_API mrb_value mrb_check_hash_type(mrb_state *mrb, mrb_value hash);
|
30
|
+
|
31
|
+
/*
|
32
|
+
* Initializes a new hash.
|
33
|
+
*
|
34
|
+
* Equivalent to:
|
35
|
+
*
|
36
|
+
* Hash.new
|
37
|
+
*
|
38
|
+
* @param mrb The mruby state reference.
|
39
|
+
* @return The initialized hash.
|
40
|
+
*/
|
41
|
+
MRB_API mrb_value mrb_hash_new(mrb_state *mrb);
|
42
|
+
|
43
|
+
/*
|
44
|
+
* Sets a keys and values to hashes.
|
45
|
+
*
|
46
|
+
* Equivalent to:
|
47
|
+
*
|
48
|
+
* hash[key] = val
|
49
|
+
*
|
50
|
+
* @param mrb The mruby state reference.
|
51
|
+
* @param hash The target hash.
|
52
|
+
* @param key The key to set.
|
53
|
+
* @param val The value to set.
|
54
|
+
* @return The value.
|
55
|
+
*/
|
56
|
+
MRB_API void mrb_hash_set(mrb_state *mrb, mrb_value hash, mrb_value key, mrb_value val);
|
57
|
+
|
58
|
+
/*
|
59
|
+
* Gets a value from a key. If the key is not found, the default of the
|
60
|
+
* hash is used.
|
61
|
+
*
|
62
|
+
* Equivalent to:
|
63
|
+
*
|
64
|
+
* hash[key]
|
65
|
+
*
|
66
|
+
* @param mrb The mruby state reference.
|
67
|
+
* @param hash The target hash.
|
68
|
+
* @param key The key to get.
|
69
|
+
* @return The found value.
|
70
|
+
*/
|
71
|
+
MRB_API mrb_value mrb_hash_get(mrb_state *mrb, mrb_value hash, mrb_value key);
|
72
|
+
|
73
|
+
/*
|
74
|
+
* Gets a value from a key. If the key is not found, the default parameter is
|
75
|
+
* used.
|
76
|
+
*
|
77
|
+
* Equivalent to:
|
78
|
+
*
|
79
|
+
* hash.key?(key) ? hash[key] : def
|
80
|
+
*
|
81
|
+
* @param mrb The mruby state reference.
|
82
|
+
* @param hash The target hash.
|
83
|
+
* @param key The key to get.
|
84
|
+
* @param def The default value.
|
85
|
+
* @return The found value.
|
86
|
+
*/
|
87
|
+
MRB_API mrb_value mrb_hash_fetch(mrb_state *mrb, mrb_value hash, mrb_value key, mrb_value def);
|
88
|
+
|
89
|
+
/*
|
90
|
+
* Deletes hash key and value pair.
|
91
|
+
*
|
92
|
+
* Equivalent to:
|
93
|
+
*
|
94
|
+
* hash.delete(key)
|
95
|
+
*
|
96
|
+
* @param mrb The mruby state reference.
|
97
|
+
* @param hash The target hash.
|
98
|
+
* @param key The key to delete.
|
99
|
+
* @return The deleted value.
|
100
|
+
*/
|
101
|
+
MRB_API mrb_value mrb_hash_delete_key(mrb_state *mrb, mrb_value hash, mrb_value key);
|
102
|
+
|
103
|
+
/*
|
104
|
+
* Gets an array of keys.
|
105
|
+
*
|
106
|
+
* Equivalent to:
|
107
|
+
*
|
108
|
+
* hash.keys
|
109
|
+
*
|
110
|
+
* @param mrb The mruby state reference.
|
111
|
+
* @param hash The target hash.
|
112
|
+
* @return An array with the keys of the hash.
|
113
|
+
*/
|
114
|
+
MRB_API mrb_value mrb_hash_keys(mrb_state *mrb, mrb_value hash);
|
115
|
+
/*
|
116
|
+
* Check if the hash has the key.
|
117
|
+
*
|
118
|
+
* Equivalent to:
|
119
|
+
*
|
120
|
+
* hash.key?(key)
|
121
|
+
*
|
122
|
+
* @param mrb The mruby state reference.
|
123
|
+
* @param hash The target hash.
|
124
|
+
* @param key The key to check existence.
|
125
|
+
* @return True if the hash has the key
|
126
|
+
*/
|
127
|
+
MRB_API mrb_bool mrb_hash_key_p(mrb_state *mrb, mrb_value hash, mrb_value key);
|
128
|
+
|
129
|
+
/*
|
130
|
+
* Check if the hash is empty
|
131
|
+
*
|
132
|
+
* Equivalent to:
|
133
|
+
*
|
134
|
+
* hash.empty?
|
135
|
+
*
|
136
|
+
* @param mrb The mruby state reference.
|
137
|
+
* @param self The target hash.
|
138
|
+
* @return True if the hash is empty, false otherwise.
|
139
|
+
*/
|
140
|
+
MRB_API mrb_bool mrb_hash_empty_p(mrb_state *mrb, mrb_value self);
|
141
|
+
|
142
|
+
/*
|
143
|
+
* Gets an array of values.
|
144
|
+
*
|
145
|
+
* Equivalent to:
|
146
|
+
*
|
147
|
+
* hash.values
|
148
|
+
*
|
149
|
+
* @param mrb The mruby state reference.
|
150
|
+
* @param hash The target hash.
|
151
|
+
* @return An array with the values of the hash.
|
152
|
+
*/
|
153
|
+
MRB_API mrb_value mrb_hash_values(mrb_state *mrb, mrb_value hash);
|
154
|
+
|
155
|
+
/*
|
156
|
+
* Clears the hash.
|
157
|
+
*
|
158
|
+
* Equivalent to:
|
159
|
+
*
|
160
|
+
* hash.clear
|
161
|
+
*
|
162
|
+
* @param mrb The mruby state reference.
|
163
|
+
* @param hash The target hash.
|
164
|
+
* @return The hash
|
165
|
+
*/
|
166
|
+
MRB_API mrb_value mrb_hash_clear(mrb_state *mrb, mrb_value hash);
|
167
|
+
|
168
|
+
/*
|
169
|
+
* Copies the hash.
|
170
|
+
*
|
171
|
+
*
|
172
|
+
* @param mrb The mruby state reference.
|
173
|
+
* @param hash The target hash.
|
174
|
+
* @return The copy of the hash
|
175
|
+
*/
|
176
|
+
MRB_API mrb_value mrb_hash_dup(mrb_state *mrb, mrb_value hash);
|
177
|
+
|
178
|
+
/*
|
179
|
+
* Merges two hashes. The first hash will be modified by the
|
180
|
+
* second hash.
|
181
|
+
*
|
182
|
+
* @param mrb The mruby state reference.
|
183
|
+
* @param hash1 The target hash.
|
184
|
+
* @param hash2 Updating hash
|
185
|
+
*/
|
186
|
+
MRB_API void mrb_hash_merge(mrb_state *mrb, mrb_value hash1, mrb_value hash2);
|
187
|
+
|
188
|
+
/* declaration of struct kh_ht */
|
189
|
+
/* be careful when you touch the internal */
|
190
|
+
typedef struct {
|
191
|
+
mrb_value v;
|
192
|
+
mrb_int n;
|
193
|
+
} mrb_hash_value;
|
194
|
+
|
195
|
+
KHASH_DECLARE(ht, mrb_value, mrb_hash_value, TRUE)
|
196
|
+
|
197
|
+
/* RHASH_TBL allocates st_table if not available. */
|
198
|
+
#define RHASH(obj) ((struct RHash*)(mrb_ptr(obj)))
|
199
|
+
#define RHASH_TBL(h) (RHASH(h)->ht)
|
200
|
+
#define RHASH_IFNONE(h) mrb_iv_get(mrb, (h), mrb_intern_lit(mrb, "ifnone"))
|
201
|
+
#define RHASH_PROCDEFAULT(h) RHASH_IFNONE(h)
|
202
|
+
|
203
|
+
#define MRB_HASH_DEFAULT 1
|
204
|
+
#define MRB_HASH_PROC_DEFAULT 2
|
205
|
+
#define MRB_RHASH_DEFAULT_P(h) (RHASH(h)->flags & MRB_HASH_DEFAULT)
|
206
|
+
#define MRB_RHASH_PROCDEFAULT_P(h) (RHASH(h)->flags & MRB_HASH_PROC_DEFAULT)
|
207
|
+
|
208
|
+
/* GC functions */
|
209
|
+
void mrb_gc_mark_hash(mrb_state*, struct RHash*);
|
210
|
+
size_t mrb_gc_mark_hash_size(mrb_state*, struct RHash*);
|
211
|
+
void mrb_gc_free_hash(mrb_state*, struct RHash*);
|
212
|
+
|
213
|
+
MRB_END_DECL
|
214
|
+
|
215
|
+
#endif /* MRUBY_HASH_H */
|