ruby2d 0.8.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/assets/README.md +20 -7
- data/assets/include/SDL2/SDL.h +135 -0
- data/assets/include/SDL2/SDL_assert.h +291 -0
- data/assets/include/SDL2/SDL_atomic.h +277 -0
- data/assets/include/SDL2/SDL_audio.h +826 -0
- data/assets/include/SDL2/SDL_bits.h +112 -0
- data/assets/include/SDL2/SDL_blendmode.h +120 -0
- data/assets/include/SDL2/SDL_clipboard.h +71 -0
- data/assets/include/SDL2/SDL_config.h +421 -0
- data/assets/include/SDL2/SDL_cpuinfo.h +188 -0
- data/assets/include/SDL2/SDL_egl.h +1673 -0
- data/assets/include/SDL2/SDL_endian.h +260 -0
- data/assets/include/SDL2/SDL_error.h +76 -0
- data/assets/include/SDL2/SDL_events.h +788 -0
- data/assets/include/SDL2/SDL_filesystem.h +136 -0
- data/assets/include/SDL2/SDL_gamecontroller.h +390 -0
- data/assets/include/SDL2/SDL_gesture.h +87 -0
- data/assets/include/SDL2/SDL_haptic.h +1238 -0
- data/assets/include/SDL2/SDL_hints.h +1135 -0
- data/assets/include/SDL2/SDL_image.h +161 -0
- data/assets/include/SDL2/SDL_joystick.h +408 -0
- data/assets/include/SDL2/SDL_keyboard.h +217 -0
- data/assets/include/SDL2/SDL_keycode.h +349 -0
- data/assets/include/SDL2/SDL_loadso.h +81 -0
- data/assets/include/SDL2/SDL_log.h +211 -0
- data/assets/include/SDL2/SDL_main.h +168 -0
- data/assets/include/SDL2/SDL_messagebox.h +144 -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 +11177 -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 +470 -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 +148 -0
- data/assets/include/SDL2/SDL_render.h +931 -0
- data/assets/include/SDL2/SDL_revision.h +2 -0
- data/assets/include/SDL2/SDL_rwops.h +254 -0
- data/assets/include/SDL2/SDL_scancode.h +413 -0
- data/assets/include/SDL2/SDL_sensor.h +251 -0
- data/assets/include/SDL2/SDL_shape.h +144 -0
- data/assets/include/SDL2/SDL_stdinc.h +607 -0
- data/assets/include/SDL2/SDL_surface.h +553 -0
- data/assets/include/SDL2/SDL_system.h +279 -0
- data/assets/include/SDL2/SDL_syswm.h +324 -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 +188 -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 +343 -0
- data/assets/include/SDL2/SDL_timer.h +115 -0
- data/assets/include/SDL2/SDL_touch.h +86 -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 +1276 -0
- data/assets/include/SDL2/SDL_vulkan.h +278 -0
- data/assets/include/SDL2/begin_code.h +167 -0
- data/assets/include/SDL2/close_code.h +37 -0
- data/assets/include/glew.h +23686 -0
- data/assets/include/simple2d.h +735 -0
- data/assets/ios/MRuby.framework/Headers/mrbconf.h +3 -5
- data/assets/ios/MRuby.framework/Headers/mruby.h +35 -32
- data/assets/ios/MRuby.framework/Headers/mruby/array.h +1 -0
- data/assets/ios/MRuby.framework/Headers/mruby/boxing_word.h +9 -1
- data/assets/ios/MRuby.framework/Headers/mruby/class.h +14 -11
- data/assets/ios/MRuby.framework/Headers/mruby/common.h +5 -0
- data/assets/ios/MRuby.framework/Headers/mruby/compile.h +4 -3
- data/assets/ios/MRuby.framework/Headers/mruby/debug.h +3 -2
- data/assets/ios/MRuby.framework/Headers/mruby/dump.h +2 -2
- data/assets/ios/MRuby.framework/Headers/mruby/hash.h +38 -5
- data/assets/ios/MRuby.framework/Headers/mruby/irep.h +17 -4
- data/assets/ios/MRuby.framework/Headers/mruby/object.h +4 -5
- data/assets/ios/MRuby.framework/Headers/mruby/opcode.h +47 -139
- data/assets/ios/MRuby.framework/Headers/mruby/ops.h +117 -0
- data/assets/ios/MRuby.framework/Headers/mruby/proc.h +4 -4
- data/assets/ios/MRuby.framework/Headers/mruby/string.h +11 -7
- data/assets/ios/MRuby.framework/Headers/mruby/throw.h +4 -4
- data/assets/ios/MRuby.framework/Headers/mruby/variable.h +2 -4
- data/assets/ios/MRuby.framework/Headers/mruby/version.h +6 -6
- data/assets/ios/MRuby.framework/MRuby +0 -0
- data/assets/ios/MyApp.xcodeproj/project.pbxproj +24 -18
- data/assets/ios/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- data/assets/ios/main.c +1 -1
- 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/libmpg123.a +0 -0
- data/assets/macos/lib/libogg.a +0 -0
- data/assets/macos/lib/libpng16.a +0 -0
- data/assets/macos/lib/libsimple2d.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/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/mingw/lib/libsimple2d.a +0 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Content.imageset/Contents.json +4 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Content.imageset/Contents.json +4 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json +4 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Content.imageset/Contents.json +4 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Content.imageset/Contents.json +4 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json +4 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image Wide.imageset/Contents.json +4 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image.imageset/Contents.json +4 -0
- data/assets/tvos/Assets.xcassets/LaunchImage.launchimage/Contents.json +7 -0
- data/assets/tvos/MRuby.framework/Headers/mrbconf.h +3 -5
- data/assets/tvos/MRuby.framework/Headers/mruby.h +35 -32
- data/assets/tvos/MRuby.framework/Headers/mruby/array.h +1 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/boxing_word.h +9 -1
- data/assets/tvos/MRuby.framework/Headers/mruby/class.h +14 -11
- data/assets/tvos/MRuby.framework/Headers/mruby/common.h +5 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/compile.h +4 -3
- data/assets/tvos/MRuby.framework/Headers/mruby/debug.h +3 -2
- data/assets/tvos/MRuby.framework/Headers/mruby/dump.h +2 -2
- data/assets/tvos/MRuby.framework/Headers/mruby/hash.h +38 -5
- data/assets/tvos/MRuby.framework/Headers/mruby/irep.h +17 -4
- data/assets/tvos/MRuby.framework/Headers/mruby/object.h +4 -5
- data/assets/tvos/MRuby.framework/Headers/mruby/opcode.h +47 -139
- data/assets/tvos/MRuby.framework/Headers/mruby/ops.h +117 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/proc.h +4 -4
- data/assets/tvos/MRuby.framework/Headers/mruby/string.h +11 -7
- data/assets/tvos/MRuby.framework/Headers/mruby/throw.h +4 -4
- data/assets/tvos/MRuby.framework/Headers/mruby/variable.h +2 -4
- data/assets/tvos/MRuby.framework/Headers/mruby/version.h +6 -6
- data/assets/tvos/MRuby.framework/MRuby +0 -0
- data/assets/tvos/MyApp.xcodeproj/project.pbxproj +25 -19
- data/assets/tvos/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- data/assets/tvos/main.c +1 -1
- data/ext/ruby2d/extconf.rb +59 -50
- data/ext/ruby2d/ruby2d.c +0 -1
- data/lib/ruby2d.rb +1 -7
- data/lib/ruby2d/cli/launch.rb +1 -1
- data/lib/ruby2d/font.rb +32 -7
- data/lib/ruby2d/version.rb +1 -1
- metadata +132 -6
- data/assets/opal.js +0 -21637
- data/assets/simple2d.js +0 -1379
- data/assets/template.html +0 -18
@@ -36,12 +36,10 @@
|
|
36
36
|
/* size of the method cache (need to be the power of 2) */
|
37
37
|
//#define MRB_METHOD_CACHE_SIZE (1<<7)
|
38
38
|
|
39
|
-
/* add -DMRB_METHOD_TABLE_INLINE
|
39
|
+
/* add -DMRB_METHOD_TABLE_INLINE to reduce the size of method table */
|
40
|
+
/* MRB_METHOD_TABLE_INLINE requires LSB of function pointers to be zero */
|
41
|
+
/* you might need to specify --falign-functions=n (where n>1) */
|
40
42
|
//#define MRB_METHOD_TABLE_INLINE
|
41
|
-
/* turn MRB_METHOD_TABLE_INLINE on for linux by default */
|
42
|
-
#if !defined(MRB_METHOD_TABLE_INLINE) && defined(__linux__)
|
43
|
-
# define MRB_METHOD_TABLE_INLINE
|
44
|
-
#endif
|
45
43
|
|
46
44
|
/* add -DMRB_INT16 to use 16bit integer for mrb_int; conflict with MRB_INT64 */
|
47
45
|
//#define MRB_INT16
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
** mruby - An embeddable Ruby implementation
|
3
3
|
**
|
4
|
-
** Copyright (c) mruby developers 2010-
|
4
|
+
** Copyright (c) mruby developers 2010-2018
|
5
5
|
**
|
6
6
|
** Permission is hereby granted, free of charge, to any person obtaining
|
7
7
|
** a copy of this software and associated documentation files (the
|
@@ -93,7 +93,7 @@
|
|
93
93
|
*/
|
94
94
|
MRB_BEGIN_DECL
|
95
95
|
|
96
|
-
typedef
|
96
|
+
typedef uint8_t mrb_code;
|
97
97
|
|
98
98
|
/**
|
99
99
|
* Required arguments signature type.
|
@@ -123,9 +123,8 @@ typedef struct {
|
|
123
123
|
mrb_sym mid;
|
124
124
|
struct RProc *proc;
|
125
125
|
mrb_value *stackent;
|
126
|
-
|
127
|
-
|
128
|
-
int epos;
|
126
|
+
uint16_t ridx;
|
127
|
+
uint16_t epos;
|
129
128
|
struct REnv *env;
|
130
129
|
mrb_code *pc; /* return address */
|
131
130
|
mrb_code *err; /* error position */
|
@@ -152,10 +151,10 @@ struct mrb_context {
|
|
152
151
|
mrb_callinfo *ci;
|
153
152
|
mrb_callinfo *cibase, *ciend;
|
154
153
|
|
155
|
-
|
156
|
-
|
154
|
+
uint16_t *rescue; /* exception handler stack */
|
155
|
+
uint16_t rsize;
|
157
156
|
struct RProc **ensure; /* ensure handler stack */
|
158
|
-
|
157
|
+
uint16_t esize, eidx;
|
159
158
|
|
160
159
|
enum mrb_fiber_state status;
|
161
160
|
mrb_bool vmexec;
|
@@ -186,7 +185,7 @@ typedef struct {
|
|
186
185
|
|
187
186
|
#ifdef MRB_METHOD_CACHE
|
188
187
|
struct mrb_cache_entry {
|
189
|
-
struct RClass *c;
|
188
|
+
struct RClass *c, *c0;
|
190
189
|
mrb_sym mid;
|
191
190
|
mrb_method_t m;
|
192
191
|
};
|
@@ -268,7 +267,8 @@ typedef struct mrb_state {
|
|
268
267
|
#else
|
269
268
|
mrb_atexit_func *atexit_stack;
|
270
269
|
#endif
|
271
|
-
|
270
|
+
uint16_t atexit_stack_len;
|
271
|
+
uint16_t ecall_nest; /* prevent infinite recursive ecall() */
|
272
272
|
} mrb_state;
|
273
273
|
|
274
274
|
/**
|
@@ -386,7 +386,7 @@ MRB_API void mrb_define_class_method(mrb_state *, struct RClass *, const char *,
|
|
386
386
|
MRB_API void mrb_define_singleton_method(mrb_state*, struct RObject*, const char*, mrb_func_t, mrb_aspec);
|
387
387
|
|
388
388
|
/**
|
389
|
-
* Defines a module
|
389
|
+
* Defines a module function.
|
390
390
|
*
|
391
391
|
* Example:
|
392
392
|
*
|
@@ -486,9 +486,10 @@ MRB_API void mrb_define_const(mrb_state*, struct RClass*, const char *name, mrb_
|
|
486
486
|
* }
|
487
487
|
* @param [mrb_state*] mrb_state* The mruby state reference.
|
488
488
|
* @param [struct RClass*] RClass* A class the method will be undefined from.
|
489
|
-
* @param [const char
|
489
|
+
* @param [const char] const char* The name of the method to be undefined.
|
490
490
|
*/
|
491
491
|
MRB_API void mrb_undef_method(mrb_state*, struct RClass*, const char*);
|
492
|
+
MRB_API void mrb_undef_method_id(mrb_state*, struct RClass*, mrb_sym);
|
492
493
|
|
493
494
|
/**
|
494
495
|
* Undefine a class method.
|
@@ -530,7 +531,7 @@ MRB_API void mrb_undef_method(mrb_state*, struct RClass*, const char*);
|
|
530
531
|
MRB_API void mrb_undef_class_method(mrb_state*, struct RClass*, const char*);
|
531
532
|
|
532
533
|
/**
|
533
|
-
* Initialize a new object
|
534
|
+
* Initialize a new object instance of c class.
|
534
535
|
*
|
535
536
|
* Example:
|
536
537
|
*
|
@@ -716,7 +717,6 @@ MRB_API mrb_value mrb_notimplement_m(mrb_state*, mrb_value);
|
|
716
717
|
* @return [mrb_value] The newly duplicated object.
|
717
718
|
*/
|
718
719
|
MRB_API mrb_value mrb_obj_dup(mrb_state *mrb, mrb_value obj);
|
719
|
-
MRB_API mrb_value mrb_check_to_integer(mrb_state *mrb, mrb_value val, const char *method);
|
720
720
|
|
721
721
|
/**
|
722
722
|
* Returns true if obj responds to the given method. If the method was defined for that
|
@@ -783,7 +783,7 @@ MRB_API struct RClass * mrb_define_module_under(mrb_state *mrb, struct RClass *o
|
|
783
783
|
#define MRB_ARGS_REQ(n) ((mrb_aspec)((n)&0x1f) << 18)
|
784
784
|
|
785
785
|
/**
|
786
|
-
*
|
786
|
+
* Function takes n optional arguments
|
787
787
|
*
|
788
788
|
* @param n
|
789
789
|
* The number of optional arguments.
|
@@ -791,7 +791,7 @@ MRB_API struct RClass * mrb_define_module_under(mrb_state *mrb, struct RClass *o
|
|
791
791
|
#define MRB_ARGS_OPT(n) ((mrb_aspec)((n)&0x1f) << 13)
|
792
792
|
|
793
793
|
/**
|
794
|
-
*
|
794
|
+
* Function takes n1 mandatory arguments and n2 optional arguments
|
795
795
|
*
|
796
796
|
* @param n1
|
797
797
|
* The number of required arguments.
|
@@ -829,22 +829,22 @@ MRB_API struct RClass * mrb_define_module_under(mrb_state *mrb, struct RClass *o
|
|
829
829
|
*
|
830
830
|
* Must be a C string composed of the following format specifiers:
|
831
831
|
*
|
832
|
-
* | char | Ruby type | C types | Notes
|
832
|
+
* | char | Ruby type | C types | Notes |
|
833
833
|
* |:----:|----------------|-------------------|----------------------------------------------------|
|
834
834
|
* | `o` | {Object} | {mrb_value} | Could be used to retrieve any type of argument |
|
835
835
|
* | `C` | {Class}/{Module} | {mrb_value} | |
|
836
836
|
* | `S` | {String} | {mrb_value} | when `!` follows, the value may be `nil` |
|
837
837
|
* | `A` | {Array} | {mrb_value} | when `!` follows, the value may be `nil` |
|
838
838
|
* | `H` | {Hash} | {mrb_value} | when `!` follows, the value may be `nil` |
|
839
|
-
* | `s` | {String} | char *, {mrb_int} |
|
839
|
+
* | `s` | {String} | char *, {mrb_int} | Receive two arguments; `s!` gives (`NULL`,`0`) for `nil` |
|
840
840
|
* | `z` | {String} | char * | `NULL` terminated string; `z!` gives `NULL` for `nil` |
|
841
841
|
* | `a` | {Array} | {mrb_value} *, {mrb_int} | Receive two arguments; `a!` gives (`NULL`,`0`) for `nil` |
|
842
842
|
* | `f` | {Float} | {mrb_float} | |
|
843
843
|
* | `i` | {Integer} | {mrb_int} | |
|
844
844
|
* | `b` | boolean | {mrb_bool} | |
|
845
845
|
* | `n` | {Symbol} | {mrb_sym} | |
|
846
|
-
* | `&` | block | {mrb_value} |
|
847
|
-
* | `*` | rest arguments | {mrb_value} *, {mrb_int} | Receive the rest of arguments as an array. |
|
846
|
+
* | `&` | block | {mrb_value} | &! raises exception if no block given. |
|
847
|
+
* | `*` | rest arguments | {mrb_value} *, {mrb_int} | Receive the rest of arguments as an array; *! avoid copy of the stack. |
|
848
848
|
* | | | optional | | After this spec following specs would be optional. |
|
849
849
|
* | `?` | optional given | {mrb_bool} | `TRUE` if preceding argument is given. Used to check optional argument is given. |
|
850
850
|
*
|
@@ -855,10 +855,6 @@ typedef const char *mrb_args_format;
|
|
855
855
|
/**
|
856
856
|
* Retrieve arguments from mrb_state.
|
857
857
|
*
|
858
|
-
* When applicable, implicit conversions (such as `to_str`, `to_ary`, `to_hash`) are
|
859
|
-
* applied to received arguments.
|
860
|
-
* Used inside a function of mrb_func_t type.
|
861
|
-
*
|
862
858
|
* @param mrb The current MRuby state.
|
863
859
|
* @param format [mrb_args_format] is a list of format specifiers
|
864
860
|
* @param ... The passing variadic arguments must be a pointer of retrieving type.
|
@@ -994,13 +990,13 @@ MRB_API mrb_value mrb_str_new_static(mrb_state *mrb, const char *p, size_t len);
|
|
994
990
|
#define mrb_str_new_lit(mrb, lit) mrb_str_new_static(mrb, (lit), mrb_strlen_lit(lit))
|
995
991
|
|
996
992
|
#ifdef _WIN32
|
997
|
-
char* mrb_utf8_from_locale(const char *p, int len);
|
998
|
-
char* mrb_locale_from_utf8(const char *p, int len);
|
993
|
+
MRB_API char* mrb_utf8_from_locale(const char *p, int len);
|
994
|
+
MRB_API char* mrb_locale_from_utf8(const char *p, int len);
|
999
995
|
#define mrb_locale_free(p) free(p)
|
1000
996
|
#define mrb_utf8_free(p) free(p)
|
1001
997
|
#else
|
1002
|
-
#define mrb_utf8_from_locale(p, l) (p)
|
1003
|
-
#define mrb_locale_from_utf8(p, l) (p)
|
998
|
+
#define mrb_utf8_from_locale(p, l) ((char*)p)
|
999
|
+
#define mrb_locale_from_utf8(p, l) ((char*)p)
|
1004
1000
|
#define mrb_locale_free(p)
|
1005
1001
|
#define mrb_utf8_free(p)
|
1006
1002
|
#endif
|
@@ -1095,9 +1091,6 @@ mrb_gc_arena_restore(mrb_state *mrb, int idx)
|
|
1095
1091
|
mrb->gc.arena_idx = idx;
|
1096
1092
|
}
|
1097
1093
|
|
1098
|
-
MRB_API int mrb_gc_arena_save(mrb_state*);
|
1099
|
-
MRB_API void mrb_gc_arena_restore(mrb_state*,int);
|
1100
|
-
|
1101
1094
|
MRB_API void mrb_garbage_collect(mrb_state*);
|
1102
1095
|
MRB_API void mrb_full_gc(mrb_state*);
|
1103
1096
|
MRB_API void mrb_incremental_gc(mrb_state *);
|
@@ -1164,6 +1157,7 @@ MRB_API void mrb_print_error(mrb_state *mrb);
|
|
1164
1157
|
#define E_SYNTAX_ERROR (mrb_exc_get(mrb, "SyntaxError"))
|
1165
1158
|
#define E_LOCALJUMP_ERROR (mrb_exc_get(mrb, "LocalJumpError"))
|
1166
1159
|
#define E_REGEXP_ERROR (mrb_exc_get(mrb, "RegexpError"))
|
1160
|
+
#define E_FROZEN_ERROR (mrb_exc_get(mrb, "FrozenError"))
|
1167
1161
|
|
1168
1162
|
#define E_NOTIMP_ERROR (mrb_exc_get(mrb, "NotImplementedError"))
|
1169
1163
|
#ifndef MRB_WITHOUT_FLOAT
|
@@ -1190,6 +1184,7 @@ MRB_API void mrb_gc_unregister(mrb_state *mrb, mrb_value obj);
|
|
1190
1184
|
|
1191
1185
|
MRB_API mrb_value mrb_to_int(mrb_state *mrb, mrb_value val);
|
1192
1186
|
#define mrb_int(mrb, val) mrb_fixnum(mrb_to_int(mrb, val))
|
1187
|
+
MRB_API mrb_value mrb_to_str(mrb_state *mrb, mrb_value val);
|
1193
1188
|
MRB_API void mrb_check_type(mrb_state *mrb, mrb_value x, enum mrb_vtype t);
|
1194
1189
|
|
1195
1190
|
typedef enum call_type {
|
@@ -1199,7 +1194,7 @@ typedef enum call_type {
|
|
1199
1194
|
CALL_TYPE_MAX
|
1200
1195
|
} call_type;
|
1201
1196
|
|
1202
|
-
MRB_API void mrb_define_alias(mrb_state *mrb, struct RClass *
|
1197
|
+
MRB_API void mrb_define_alias(mrb_state *mrb, struct RClass *c, const char *a, const char *b);
|
1203
1198
|
MRB_API const char *mrb_class_name(mrb_state *mrb, struct RClass* klass);
|
1204
1199
|
MRB_API void mrb_define_global_const(mrb_state *mrb, const char *name, mrb_value val);
|
1205
1200
|
|
@@ -1224,12 +1219,20 @@ MRB_API mrb_value mrb_fiber_resume(mrb_state *mrb, mrb_value fib, mrb_int argc,
|
|
1224
1219
|
*/
|
1225
1220
|
MRB_API mrb_value mrb_fiber_yield(mrb_state *mrb, mrb_int argc, const mrb_value *argv);
|
1226
1221
|
|
1222
|
+
/*
|
1223
|
+
* Check if a Fiber is alive
|
1224
|
+
*
|
1225
|
+
* @mrbgem mruby-fiber
|
1226
|
+
*/
|
1227
|
+
MRB_API mrb_value mrb_fiber_alive_p(mrb_state *mrb, mrb_value fib);
|
1228
|
+
|
1227
1229
|
/*
|
1228
1230
|
* FiberError reference
|
1229
1231
|
*
|
1230
1232
|
* @mrbgem mruby-fiber
|
1231
1233
|
*/
|
1232
1234
|
#define E_FIBER_ERROR (mrb_exc_get(mrb, "FiberError"))
|
1235
|
+
MRB_API void mrb_stack_extend(mrb_state*, mrb_int);
|
1233
1236
|
|
1234
1237
|
/* memory pool implementation */
|
1235
1238
|
typedef struct mrb_pool mrb_pool;
|
@@ -199,6 +199,7 @@ MRB_API void mrb_ary_set(mrb_state *mrb, mrb_value ary, mrb_int n, mrb_value val
|
|
199
199
|
* @param other The array to replace it with.
|
200
200
|
*/
|
201
201
|
MRB_API void mrb_ary_replace(mrb_state *mrb, mrb_value self, mrb_value other);
|
202
|
+
MRB_API mrb_value mrb_ensure_array_type(mrb_state *mrb, mrb_value self);
|
202
203
|
MRB_API mrb_value mrb_check_array_type(mrb_state *mrb, mrb_value self);
|
203
204
|
|
204
205
|
/*
|
@@ -45,6 +45,14 @@ enum mrb_special_consts {
|
|
45
45
|
#define MRB_SYMBOL_FLAG 0x0e
|
46
46
|
#define MRB_SPECIAL_SHIFT 8
|
47
47
|
|
48
|
+
#if defined(MRB_64BIT)
|
49
|
+
#define MRB_SYMBOL_BITSIZE (sizeof(mrb_sym) * CHAR_BIT)
|
50
|
+
#define MRB_SYMBOL_MAX UINT32_MAX
|
51
|
+
#else
|
52
|
+
#define MRB_SYMBOL_BITSIZE (sizeof(mrb_sym) * CHAR_BIT - MRB_SPECIAL_SHIFT)
|
53
|
+
#define MRB_SYMBOL_MAX (UINT32_MAX >> MRB_SPECIAL_SHIFT)
|
54
|
+
#endif
|
55
|
+
|
48
56
|
typedef union mrb_value {
|
49
57
|
union {
|
50
58
|
void *p;
|
@@ -54,7 +62,7 @@ typedef union mrb_value {
|
|
54
62
|
};
|
55
63
|
struct {
|
56
64
|
unsigned int sym_flag : MRB_SPECIAL_SHIFT;
|
57
|
-
mrb_sym sym :
|
65
|
+
mrb_sym sym : MRB_SYMBOL_BITSIZE;
|
58
66
|
};
|
59
67
|
struct RBasic *bp;
|
60
68
|
#ifndef MRB_WITHOUT_FLOAT
|
@@ -22,9 +22,6 @@ struct RClass {
|
|
22
22
|
};
|
23
23
|
|
24
24
|
#define mrb_class_ptr(v) ((struct RClass*)(mrb_ptr(v)))
|
25
|
-
#define RCLASS_SUPER(v) (((struct RClass*)(mrb_ptr(v)))->super)
|
26
|
-
#define RCLASS_IV_TBL(v) (((struct RClass*)(mrb_ptr(v)))->iv)
|
27
|
-
#define RCLASS_M_TBL(v) (((struct RClass*)(mrb_ptr(v)))->mt)
|
28
25
|
|
29
26
|
static inline struct RClass*
|
30
27
|
mrb_class(mrb_state *mrb, mrb_value v)
|
@@ -53,19 +50,25 @@ mrb_class(mrb_state *mrb, mrb_value v)
|
|
53
50
|
}
|
54
51
|
}
|
55
52
|
|
56
|
-
/*
|
57
|
-
|
58
|
-
|
59
|
-
|
53
|
+
/* flags:
|
54
|
+
20: frozen
|
55
|
+
19: is_prepended
|
56
|
+
18: is_origin
|
57
|
+
17: is_inherited (used by method cache)
|
58
|
+
16: unused
|
59
|
+
0-15: instance type
|
60
|
+
*/
|
61
|
+
#define MRB_FL_CLASS_IS_PREPENDED (1 << 19)
|
62
|
+
#define MRB_FL_CLASS_IS_ORIGIN (1 << 18)
|
60
63
|
#define MRB_CLASS_ORIGIN(c) do {\
|
61
|
-
if (c->flags &
|
64
|
+
if (c->flags & MRB_FL_CLASS_IS_PREPENDED) {\
|
62
65
|
c = c->super;\
|
63
|
-
while (!(c->flags &
|
66
|
+
while (!(c->flags & MRB_FL_CLASS_IS_ORIGIN)) {\
|
64
67
|
c = c->super;\
|
65
68
|
}\
|
66
69
|
}\
|
67
70
|
} while (0)
|
68
|
-
#define
|
71
|
+
#define MRB_FL_CLASS_IS_INHERITED (1 << 17)
|
69
72
|
#define MRB_INSTANCE_TT_MASK (0xFF)
|
70
73
|
#define MRB_SET_INSTANCE_TT(c, tt) c->flags = ((c->flags & ~MRB_INSTANCE_TT_MASK) | (char)tt)
|
71
74
|
#define MRB_INSTANCE_TT(c) (enum mrb_vtype)(c->flags & MRB_INSTANCE_TT_MASK)
|
@@ -76,7 +79,7 @@ MRB_API struct RClass *mrb_vm_define_class(mrb_state*, mrb_value, mrb_value, mrb
|
|
76
79
|
MRB_API struct RClass *mrb_vm_define_module(mrb_state*, mrb_value, mrb_sym);
|
77
80
|
MRB_API void mrb_define_method_raw(mrb_state*, struct RClass*, mrb_sym, mrb_method_t);
|
78
81
|
MRB_API void mrb_define_method_id(mrb_state *mrb, struct RClass *c, mrb_sym mid, mrb_func_t func, mrb_aspec aspec);
|
79
|
-
MRB_API void mrb_alias_method(mrb_state
|
82
|
+
MRB_API void mrb_alias_method(mrb_state*, struct RClass *c, mrb_sym a, mrb_sym b);
|
80
83
|
|
81
84
|
MRB_API mrb_method_t mrb_method_search_vm(mrb_state*, struct RClass**, mrb_sym);
|
82
85
|
MRB_API mrb_method_t mrb_method_search(mrb_state*, struct RClass*, mrb_sym);
|
@@ -33,6 +33,7 @@ typedef struct mrbc_context {
|
|
33
33
|
mrb_bool no_exec:1;
|
34
34
|
mrb_bool keep_lv:1;
|
35
35
|
mrb_bool no_optimize:1;
|
36
|
+
mrb_bool on_eval:1;
|
36
37
|
|
37
38
|
size_t parser_nerr;
|
38
39
|
} mrbc_context;
|
@@ -142,7 +143,6 @@ struct mrb_parser_state {
|
|
142
143
|
mrb_ast_node *heredocs_from_nextline;
|
143
144
|
mrb_ast_node *parsing_heredoc;
|
144
145
|
mrb_ast_node *lex_strterm_before_heredoc;
|
145
|
-
mrb_bool heredoc_end_now:1; /* for mirb */
|
146
146
|
|
147
147
|
void *ylval;
|
148
148
|
|
@@ -151,13 +151,14 @@ struct mrb_parser_state {
|
|
151
151
|
mrb_ast_node *tree;
|
152
152
|
|
153
153
|
mrb_bool no_optimize:1;
|
154
|
+
mrb_bool on_eval:1;
|
154
155
|
mrb_bool capture_errors:1;
|
155
156
|
struct mrb_parser_message error_buffer[10];
|
156
157
|
struct mrb_parser_message warn_buffer[10];
|
157
158
|
|
158
159
|
mrb_sym* filename_table;
|
159
|
-
|
160
|
-
|
160
|
+
uint16_t filename_table_length;
|
161
|
+
uint16_t current_filename_index;
|
161
162
|
|
162
163
|
struct mrb_jmpbuf* jmp;
|
163
164
|
};
|
@@ -55,10 +55,11 @@ MRB_API const char *mrb_debug_get_filename(mrb_irep *irep, ptrdiff_t pc);
|
|
55
55
|
*/
|
56
56
|
MRB_API int32_t mrb_debug_get_line(mrb_irep *irep, ptrdiff_t pc);
|
57
57
|
|
58
|
+
MRB_API mrb_irep_debug_info *mrb_debug_info_alloc(mrb_state *mrb, mrb_irep *irep);
|
58
59
|
MRB_API mrb_irep_debug_info_file *mrb_debug_info_append_file(
|
59
|
-
mrb_state *mrb,
|
60
|
+
mrb_state *mrb, mrb_irep_debug_info *info,
|
61
|
+
const char *filename, uint16_t *lines,
|
60
62
|
uint32_t start_pos, uint32_t end_pos);
|
61
|
-
MRB_API mrb_irep_debug_info *mrb_debug_info_alloc(mrb_state *mrb, mrb_irep *irep);
|
62
63
|
MRB_API void mrb_debug_info_free(mrb_state *mrb, mrb_irep_debug_info *d);
|
63
64
|
|
64
65
|
MRB_END_DECL
|
@@ -52,11 +52,11 @@ MRB_API mrb_irep *mrb_read_irep(mrb_state*, const uint8_t*);
|
|
52
52
|
/* Rite Binary File header */
|
53
53
|
#define RITE_BINARY_IDENT "RITE"
|
54
54
|
#define RITE_BINARY_IDENT_LIL "ETIR"
|
55
|
-
#define RITE_BINARY_FORMAT_VER "
|
55
|
+
#define RITE_BINARY_FORMAT_VER "0005"
|
56
56
|
#define RITE_COMPILER_NAME "MATZ"
|
57
57
|
#define RITE_COMPILER_VERSION "0000"
|
58
58
|
|
59
|
-
#define RITE_VM_VER "
|
59
|
+
#define RITE_VM_VER "0002"
|
60
60
|
|
61
61
|
#define RITE_BINARY_EOF "END\0"
|
62
62
|
#define RITE_SECTION_IREP_IDENT "IREP"
|
@@ -18,13 +18,15 @@ MRB_BEGIN_DECL
|
|
18
18
|
struct RHash {
|
19
19
|
MRB_OBJECT_HEADER;
|
20
20
|
struct iv_tbl *iv;
|
21
|
-
struct
|
21
|
+
struct htable *ht;
|
22
22
|
};
|
23
23
|
|
24
24
|
#define mrb_hash_ptr(v) ((struct RHash*)(mrb_ptr(v)))
|
25
25
|
#define mrb_hash_value(p) mrb_obj_value((void*)(p))
|
26
26
|
|
27
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);
|
28
30
|
|
29
31
|
/*
|
30
32
|
* Initializes a new hash.
|
@@ -74,7 +76,7 @@ MRB_API mrb_value mrb_hash_get(mrb_state *mrb, mrb_value hash, mrb_value key);
|
|
74
76
|
*
|
75
77
|
* Equivalent to:
|
76
78
|
*
|
77
|
-
* hash.
|
79
|
+
* hash.key?(key) ? hash[key] : def
|
78
80
|
*
|
79
81
|
* @param mrb The mruby state reference.
|
80
82
|
* @param hash The target hash.
|
@@ -110,7 +112,19 @@ MRB_API mrb_value mrb_hash_delete_key(mrb_state *mrb, mrb_value hash, mrb_value
|
|
110
112
|
* @return An array with the keys of the hash.
|
111
113
|
*/
|
112
114
|
MRB_API mrb_value mrb_hash_keys(mrb_state *mrb, mrb_value hash);
|
113
|
-
|
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);
|
114
128
|
|
115
129
|
/*
|
116
130
|
* Check if the hash is empty
|
@@ -123,7 +137,7 @@ MRB_API mrb_value mrb_check_hash_type(mrb_state *mrb, mrb_value hash);
|
|
123
137
|
* @param self The target hash.
|
124
138
|
* @return True if the hash is empty, false otherwise.
|
125
139
|
*/
|
126
|
-
MRB_API
|
140
|
+
MRB_API mrb_bool mrb_hash_empty_p(mrb_state *mrb, mrb_value self);
|
127
141
|
|
128
142
|
/*
|
129
143
|
* Gets an array of values.
|
@@ -151,6 +165,26 @@ MRB_API mrb_value mrb_hash_values(mrb_state *mrb, mrb_value hash);
|
|
151
165
|
*/
|
152
166
|
MRB_API mrb_value mrb_hash_clear(mrb_state *mrb, mrb_value hash);
|
153
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
|
+
|
154
188
|
/* declaration of struct kh_ht */
|
155
189
|
/* be careful when you touch the internal */
|
156
190
|
typedef struct {
|
@@ -165,7 +199,6 @@ KHASH_DECLARE(ht, mrb_value, mrb_hash_value, TRUE)
|
|
165
199
|
#define RHASH_TBL(h) (RHASH(h)->ht)
|
166
200
|
#define RHASH_IFNONE(h) mrb_iv_get(mrb, (h), mrb_intern_lit(mrb, "ifnone"))
|
167
201
|
#define RHASH_PROCDEFAULT(h) RHASH_IFNONE(h)
|
168
|
-
MRB_API struct kh_ht * mrb_hash_tbl(mrb_state *mrb, mrb_value hash);
|
169
202
|
|
170
203
|
#define MRB_HASH_DEFAULT 1
|
171
204
|
#define MRB_HASH_PROC_DEFAULT 2
|