ruby2d 0.8.1 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. checksums.yaml +4 -4
  2. data/assets/README.md +20 -7
  3. data/assets/include/SDL2/SDL.h +135 -0
  4. data/assets/include/SDL2/SDL_assert.h +291 -0
  5. data/assets/include/SDL2/SDL_atomic.h +277 -0
  6. data/assets/include/SDL2/SDL_audio.h +826 -0
  7. data/assets/include/SDL2/SDL_bits.h +112 -0
  8. data/assets/include/SDL2/SDL_blendmode.h +120 -0
  9. data/assets/include/SDL2/SDL_clipboard.h +71 -0
  10. data/assets/include/SDL2/SDL_config.h +421 -0
  11. data/assets/include/SDL2/SDL_cpuinfo.h +188 -0
  12. data/assets/include/SDL2/SDL_egl.h +1673 -0
  13. data/assets/include/SDL2/SDL_endian.h +260 -0
  14. data/assets/include/SDL2/SDL_error.h +76 -0
  15. data/assets/include/SDL2/SDL_events.h +788 -0
  16. data/assets/include/SDL2/SDL_filesystem.h +136 -0
  17. data/assets/include/SDL2/SDL_gamecontroller.h +390 -0
  18. data/assets/include/SDL2/SDL_gesture.h +87 -0
  19. data/assets/include/SDL2/SDL_haptic.h +1238 -0
  20. data/assets/include/SDL2/SDL_hints.h +1135 -0
  21. data/assets/include/SDL2/SDL_image.h +161 -0
  22. data/assets/include/SDL2/SDL_joystick.h +408 -0
  23. data/assets/include/SDL2/SDL_keyboard.h +217 -0
  24. data/assets/include/SDL2/SDL_keycode.h +349 -0
  25. data/assets/include/SDL2/SDL_loadso.h +81 -0
  26. data/assets/include/SDL2/SDL_log.h +211 -0
  27. data/assets/include/SDL2/SDL_main.h +168 -0
  28. data/assets/include/SDL2/SDL_messagebox.h +144 -0
  29. data/assets/include/SDL2/SDL_mixer.h +651 -0
  30. data/assets/include/SDL2/SDL_mouse.h +302 -0
  31. data/assets/include/SDL2/SDL_mutex.h +251 -0
  32. data/assets/include/SDL2/SDL_name.h +33 -0
  33. data/assets/include/SDL2/SDL_opengl.h +2183 -0
  34. data/assets/include/SDL2/SDL_opengl_glext.h +11177 -0
  35. data/assets/include/SDL2/SDL_opengles.h +39 -0
  36. data/assets/include/SDL2/SDL_opengles2.h +52 -0
  37. data/assets/include/SDL2/SDL_opengles2_gl2.h +621 -0
  38. data/assets/include/SDL2/SDL_opengles2_gl2ext.h +2050 -0
  39. data/assets/include/SDL2/SDL_opengles2_gl2platform.h +30 -0
  40. data/assets/include/SDL2/SDL_opengles2_khrplatform.h +282 -0
  41. data/assets/include/SDL2/SDL_pixels.h +470 -0
  42. data/assets/include/SDL2/SDL_platform.h +198 -0
  43. data/assets/include/SDL2/SDL_power.h +75 -0
  44. data/assets/include/SDL2/SDL_quit.h +58 -0
  45. data/assets/include/SDL2/SDL_rect.h +148 -0
  46. data/assets/include/SDL2/SDL_render.h +931 -0
  47. data/assets/include/SDL2/SDL_revision.h +2 -0
  48. data/assets/include/SDL2/SDL_rwops.h +254 -0
  49. data/assets/include/SDL2/SDL_scancode.h +413 -0
  50. data/assets/include/SDL2/SDL_sensor.h +251 -0
  51. data/assets/include/SDL2/SDL_shape.h +144 -0
  52. data/assets/include/SDL2/SDL_stdinc.h +607 -0
  53. data/assets/include/SDL2/SDL_surface.h +553 -0
  54. data/assets/include/SDL2/SDL_system.h +279 -0
  55. data/assets/include/SDL2/SDL_syswm.h +324 -0
  56. data/assets/include/SDL2/SDL_test.h +69 -0
  57. data/assets/include/SDL2/SDL_test_assert.h +105 -0
  58. data/assets/include/SDL2/SDL_test_common.h +188 -0
  59. data/assets/include/SDL2/SDL_test_compare.h +69 -0
  60. data/assets/include/SDL2/SDL_test_crc32.h +124 -0
  61. data/assets/include/SDL2/SDL_test_font.h +81 -0
  62. data/assets/include/SDL2/SDL_test_fuzzer.h +384 -0
  63. data/assets/include/SDL2/SDL_test_harness.h +134 -0
  64. data/assets/include/SDL2/SDL_test_images.h +78 -0
  65. data/assets/include/SDL2/SDL_test_log.h +67 -0
  66. data/assets/include/SDL2/SDL_test_md5.h +129 -0
  67. data/assets/include/SDL2/SDL_test_memory.h +63 -0
  68. data/assets/include/SDL2/SDL_test_random.h +115 -0
  69. data/assets/include/SDL2/SDL_thread.h +343 -0
  70. data/assets/include/SDL2/SDL_timer.h +115 -0
  71. data/assets/include/SDL2/SDL_touch.h +86 -0
  72. data/assets/include/SDL2/SDL_ttf.h +294 -0
  73. data/assets/include/SDL2/SDL_types.h +29 -0
  74. data/assets/include/SDL2/SDL_version.h +162 -0
  75. data/assets/include/SDL2/SDL_video.h +1276 -0
  76. data/assets/include/SDL2/SDL_vulkan.h +278 -0
  77. data/assets/include/SDL2/begin_code.h +167 -0
  78. data/assets/include/SDL2/close_code.h +37 -0
  79. data/assets/include/glew.h +23686 -0
  80. data/assets/include/simple2d.h +735 -0
  81. data/assets/ios/MRuby.framework/Headers/mrbconf.h +3 -5
  82. data/assets/ios/MRuby.framework/Headers/mruby.h +35 -32
  83. data/assets/ios/MRuby.framework/Headers/mruby/array.h +1 -0
  84. data/assets/ios/MRuby.framework/Headers/mruby/boxing_word.h +9 -1
  85. data/assets/ios/MRuby.framework/Headers/mruby/class.h +14 -11
  86. data/assets/ios/MRuby.framework/Headers/mruby/common.h +5 -0
  87. data/assets/ios/MRuby.framework/Headers/mruby/compile.h +4 -3
  88. data/assets/ios/MRuby.framework/Headers/mruby/debug.h +3 -2
  89. data/assets/ios/MRuby.framework/Headers/mruby/dump.h +2 -2
  90. data/assets/ios/MRuby.framework/Headers/mruby/hash.h +38 -5
  91. data/assets/ios/MRuby.framework/Headers/mruby/irep.h +17 -4
  92. data/assets/ios/MRuby.framework/Headers/mruby/object.h +4 -5
  93. data/assets/ios/MRuby.framework/Headers/mruby/opcode.h +47 -139
  94. data/assets/ios/MRuby.framework/Headers/mruby/ops.h +117 -0
  95. data/assets/ios/MRuby.framework/Headers/mruby/proc.h +4 -4
  96. data/assets/ios/MRuby.framework/Headers/mruby/string.h +11 -7
  97. data/assets/ios/MRuby.framework/Headers/mruby/throw.h +4 -4
  98. data/assets/ios/MRuby.framework/Headers/mruby/variable.h +2 -4
  99. data/assets/ios/MRuby.framework/Headers/mruby/version.h +6 -6
  100. data/assets/ios/MRuby.framework/MRuby +0 -0
  101. data/assets/ios/MyApp.xcodeproj/project.pbxproj +24 -18
  102. data/assets/ios/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  103. data/assets/ios/main.c +1 -1
  104. data/assets/macos/lib/libFLAC.a +0 -0
  105. data/assets/macos/lib/libSDL2.a +0 -0
  106. data/assets/macos/lib/libSDL2_image.a +0 -0
  107. data/assets/macos/lib/libSDL2_mixer.a +0 -0
  108. data/assets/macos/lib/libSDL2_ttf.a +0 -0
  109. data/assets/macos/lib/libfreetype.a +0 -0
  110. data/assets/macos/lib/libjpeg.a +0 -0
  111. data/assets/macos/lib/libmpg123.a +0 -0
  112. data/assets/macos/lib/libogg.a +0 -0
  113. data/assets/macos/lib/libpng16.a +0 -0
  114. data/assets/macos/lib/libsimple2d.a +0 -0
  115. data/assets/macos/lib/libtiff.a +0 -0
  116. data/assets/macos/lib/libvorbis.a +0 -0
  117. data/assets/macos/lib/libvorbisfile.a +0 -0
  118. data/assets/macos/lib/libwebp.a +0 -0
  119. data/assets/mingw/bin/SDL2.dll +0 -0
  120. data/assets/mingw/bin/SDL2_image.dll +0 -0
  121. data/assets/mingw/bin/SDL2_mixer.dll +0 -0
  122. data/assets/mingw/bin/SDL2_ttf.dll +0 -0
  123. data/assets/mingw/bin/glew32.dll +0 -0
  124. data/assets/mingw/bin/libFLAC-8.dll +0 -0
  125. data/assets/mingw/bin/libfreetype-6.dll +0 -0
  126. data/assets/mingw/bin/libjpeg-9.dll +0 -0
  127. data/assets/mingw/bin/libmodplug-1.dll +0 -0
  128. data/assets/mingw/bin/libmpg123-0.dll +0 -0
  129. data/assets/mingw/bin/libogg-0.dll +0 -0
  130. data/assets/mingw/bin/libopus-0.dll +0 -0
  131. data/assets/mingw/bin/libopusfile-0.dll +0 -0
  132. data/assets/mingw/bin/libpng16-16.dll +0 -0
  133. data/assets/mingw/bin/libtiff-5.dll +0 -0
  134. data/assets/mingw/bin/libvorbis-0.dll +0 -0
  135. data/assets/mingw/bin/libvorbisfile-3.dll +0 -0
  136. data/assets/mingw/bin/libwebp-7.dll +0 -0
  137. data/assets/mingw/bin/zlib1.dll +0 -0
  138. data/assets/mingw/lib/libSDL2.a +0 -0
  139. data/assets/mingw/lib/libSDL2.dll.a +0 -0
  140. data/assets/mingw/lib/libSDL2_image.a +0 -0
  141. data/assets/mingw/lib/libSDL2_image.dll.a +0 -0
  142. data/assets/mingw/lib/libSDL2_mixer.a +0 -0
  143. data/assets/mingw/lib/libSDL2_mixer.dll.a +0 -0
  144. data/assets/mingw/lib/libSDL2_test.a +0 -0
  145. data/assets/mingw/lib/libSDL2_ttf.a +0 -0
  146. data/assets/mingw/lib/libSDL2_ttf.dll.a +0 -0
  147. data/assets/mingw/lib/libSDL2main.a +0 -0
  148. data/assets/mingw/lib/libglew32.a +0 -0
  149. data/assets/mingw/lib/libglew32.dll.a +0 -0
  150. data/assets/mingw/lib/libsimple2d.a +0 -0
  151. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Content.imageset/Contents.json +4 -0
  152. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Content.imageset/Contents.json +4 -0
  153. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json +4 -0
  154. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Content.imageset/Contents.json +4 -0
  155. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Content.imageset/Contents.json +4 -0
  156. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json +4 -0
  157. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image Wide.imageset/Contents.json +4 -0
  158. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image.imageset/Contents.json +4 -0
  159. data/assets/tvos/Assets.xcassets/LaunchImage.launchimage/Contents.json +7 -0
  160. data/assets/tvos/MRuby.framework/Headers/mrbconf.h +3 -5
  161. data/assets/tvos/MRuby.framework/Headers/mruby.h +35 -32
  162. data/assets/tvos/MRuby.framework/Headers/mruby/array.h +1 -0
  163. data/assets/tvos/MRuby.framework/Headers/mruby/boxing_word.h +9 -1
  164. data/assets/tvos/MRuby.framework/Headers/mruby/class.h +14 -11
  165. data/assets/tvos/MRuby.framework/Headers/mruby/common.h +5 -0
  166. data/assets/tvos/MRuby.framework/Headers/mruby/compile.h +4 -3
  167. data/assets/tvos/MRuby.framework/Headers/mruby/debug.h +3 -2
  168. data/assets/tvos/MRuby.framework/Headers/mruby/dump.h +2 -2
  169. data/assets/tvos/MRuby.framework/Headers/mruby/hash.h +38 -5
  170. data/assets/tvos/MRuby.framework/Headers/mruby/irep.h +17 -4
  171. data/assets/tvos/MRuby.framework/Headers/mruby/object.h +4 -5
  172. data/assets/tvos/MRuby.framework/Headers/mruby/opcode.h +47 -139
  173. data/assets/tvos/MRuby.framework/Headers/mruby/ops.h +117 -0
  174. data/assets/tvos/MRuby.framework/Headers/mruby/proc.h +4 -4
  175. data/assets/tvos/MRuby.framework/Headers/mruby/string.h +11 -7
  176. data/assets/tvos/MRuby.framework/Headers/mruby/throw.h +4 -4
  177. data/assets/tvos/MRuby.framework/Headers/mruby/variable.h +2 -4
  178. data/assets/tvos/MRuby.framework/Headers/mruby/version.h +6 -6
  179. data/assets/tvos/MRuby.framework/MRuby +0 -0
  180. data/assets/tvos/MyApp.xcodeproj/project.pbxproj +25 -19
  181. data/assets/tvos/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  182. data/assets/tvos/main.c +1 -1
  183. data/ext/ruby2d/extconf.rb +59 -50
  184. data/ext/ruby2d/ruby2d.c +0 -1
  185. data/lib/ruby2d.rb +1 -7
  186. data/lib/ruby2d/cli/launch.rb +1 -1
  187. data/lib/ruby2d/font.rb +32 -7
  188. data/lib/ruby2d/version.rb +1 -1
  189. metadata +132 -6
  190. data/assets/opal.js +0 -21637
  191. data/assets/simple2d.js +0 -1379
  192. data/assets/template.html +0 -18
@@ -1,5 +1,12 @@
1
1
  {
2
2
  "images" : [
3
+ {
4
+ "orientation" : "landscape",
5
+ "idiom" : "tv",
6
+ "extent" : "full-screen",
7
+ "minimum-system-version" : "11.0",
8
+ "scale" : "2x"
9
+ },
3
10
  {
4
11
  "orientation" : "landscape",
5
12
  "idiom" : "tv",
@@ -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 unless platform uses MSB of pointers */
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-2017
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 uint32_t mrb_code;
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
- int nregs;
127
- int ridx;
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
- mrb_code **rescue; /* exception handler stack */
156
- int rsize;
154
+ uint16_t *rescue; /* exception handler stack */
155
+ uint16_t rsize;
157
156
  struct RProc **ensure; /* ensure handler stack */
158
- int esize, eidx;
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
- mrb_int atexit_stack_len;
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 fuction.
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*] constchar* The name of the method to be undefined.
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 instace of c class.
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
- * Funtion takes n optional arguments
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
- * Funtion takes n1 mandatory arguments and n2 optional arguments
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} | Receive two arguments; `s!` gives (`NULL`,`0`) for `nil` |
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
  * | &vert; | 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 *klass, const char *name1, const char *name2);
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 : (sizeof(mrb_sym) * CHAR_BIT);
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
- /* TODO: figure out where to put user flags */
57
- /* flags bits >= 18 is reserved */
58
- #define MRB_FLAG_IS_PREPENDED (1 << 19)
59
- #define MRB_FLAG_IS_ORIGIN (1 << 20)
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 & MRB_FLAG_IS_PREPENDED) {\
64
+ if (c->flags & MRB_FL_CLASS_IS_PREPENDED) {\
62
65
  c = c->super;\
63
- while (!(c->flags & MRB_FLAG_IS_ORIGIN)) {\
66
+ while (!(c->flags & MRB_FL_CLASS_IS_ORIGIN)) {\
64
67
  c = c->super;\
65
68
  }\
66
69
  }\
67
70
  } while (0)
68
- #define MRB_FLAG_IS_INHERITED (1 << 21)
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 *mrb, struct RClass *c, mrb_sym a, mrb_sym b);
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);
@@ -7,6 +7,11 @@
7
7
  #ifndef MRUBY_COMMON_H
8
8
  #define MRUBY_COMMON_H
9
9
 
10
+ #ifdef __APPLE__
11
+ #ifndef __TARGETCONDITIONALS__
12
+ #include "TargetConditionals.h"
13
+ #endif
14
+ #endif
10
15
 
11
16
  #ifdef __cplusplus
12
17
  #ifdef MRB_ENABLE_CXX_ABI
@@ -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
- size_t filename_table_length;
160
- int current_filename_index;
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, mrb_irep *irep,
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 "0004"
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 "0000"
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 kh_ht *ht;
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.hash_key?(key) ? hash[key] : def
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
- MRB_API mrb_value mrb_check_hash_type(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);
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 mrb_value mrb_hash_empty_p(mrb_state *mrb, mrb_value self);
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