ruby2d 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +5 -5
  2. data/assets/README.md +8 -0
  3. data/assets/ios/Assets.xcassets/AppIcon.appiconset/Contents.json +98 -0
  4. data/assets/ios/Assets.xcassets/Contents.json +6 -0
  5. data/assets/ios/Base.lproj/LaunchScreen.storyboard +27 -0
  6. data/assets/ios/Info.plist +43 -0
  7. data/assets/ios/MRuby.framework/Headers/mrbconf.h +145 -0
  8. data/assets/ios/MRuby.framework/Headers/mruby.h +1279 -0
  9. data/assets/ios/MRuby.framework/Headers/mruby/array.h +279 -0
  10. data/assets/ios/MRuby.framework/Headers/mruby/boxing_nan.h +102 -0
  11. data/assets/ios/MRuby.framework/Headers/mruby/boxing_no.h +56 -0
  12. data/assets/ios/MRuby.framework/Headers/mruby/boxing_word.h +136 -0
  13. data/assets/ios/MRuby.framework/Headers/mruby/class.h +94 -0
  14. data/assets/ios/MRuby.framework/Headers/mruby/common.h +72 -0
  15. data/assets/ios/MRuby.framework/Headers/mruby/compile.h +194 -0
  16. data/assets/ios/MRuby.framework/Headers/mruby/data.h +75 -0
  17. data/assets/ios/MRuby.framework/Headers/mruby/debug.h +66 -0
  18. data/assets/ios/MRuby.framework/Headers/mruby/dump.h +196 -0
  19. data/assets/ios/MRuby.framework/Headers/mruby/error.h +75 -0
  20. data/assets/ios/MRuby.framework/Headers/mruby/gc.h +91 -0
  21. data/assets/ios/MRuby.framework/Headers/mruby/hash.h +182 -0
  22. data/assets/ios/MRuby.framework/Headers/mruby/irep.h +62 -0
  23. data/assets/ios/MRuby.framework/Headers/mruby/istruct.h +47 -0
  24. data/assets/ios/MRuby.framework/Headers/mruby/khash.h +274 -0
  25. data/assets/ios/MRuby.framework/Headers/mruby/numeric.h +161 -0
  26. data/assets/ios/MRuby.framework/Headers/mruby/object.h +45 -0
  27. data/assets/ios/MRuby.framework/Headers/mruby/opcode.h +161 -0
  28. data/assets/ios/MRuby.framework/Headers/mruby/proc.h +131 -0
  29. data/assets/ios/MRuby.framework/Headers/mruby/range.h +49 -0
  30. data/assets/ios/MRuby.framework/Headers/mruby/re.h +16 -0
  31. data/assets/ios/MRuby.framework/Headers/mruby/string.h +440 -0
  32. data/assets/ios/MRuby.framework/Headers/mruby/throw.h +55 -0
  33. data/assets/ios/MRuby.framework/Headers/mruby/value.h +309 -0
  34. data/assets/ios/MRuby.framework/Headers/mruby/variable.h +138 -0
  35. data/assets/ios/MRuby.framework/Headers/mruby/version.h +110 -0
  36. data/assets/ios/MRuby.framework/Info.plist +20 -0
  37. data/assets/ios/MRuby.framework/MRuby +0 -0
  38. data/assets/ios/MyApp.xcodeproj/project.pbxproj +362 -0
  39. data/assets/ios/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  40. data/assets/ios/MyApp.xcodeproj/project.xcworkspace/xcshareddata/MyApp.xcscmblueprint +30 -0
  41. data/assets/ios/MyApp.xcodeproj/project.xcworkspace/xcuserdata/Tom.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  42. data/assets/ios/MyApp.xcodeproj/xcuserdata/Tom.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  43. data/assets/ios/main.c +1 -0
  44. data/assets/opal.js +8434 -6329
  45. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Content.imageset/Contents.json +12 -0
  46. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Contents.json +6 -0
  47. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Contents.json +17 -0
  48. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Content.imageset/Contents.json +12 -0
  49. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Contents.json +6 -0
  50. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json +12 -0
  51. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Contents.json +6 -0
  52. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Content.imageset/Contents.json +12 -0
  53. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Contents.json +6 -0
  54. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Contents.json +17 -0
  55. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Content.imageset/Contents.json +12 -0
  56. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Contents.json +6 -0
  57. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json +12 -0
  58. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Contents.json +6 -0
  59. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Contents.json +32 -0
  60. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image Wide.imageset/Contents.json +12 -0
  61. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image.imageset/Contents.json +12 -0
  62. data/assets/tvos/Assets.xcassets/Contents.json +6 -0
  63. data/assets/tvos/Assets.xcassets/LaunchImage.launchimage/Contents.json +15 -0
  64. data/assets/tvos/Info.plist +30 -0
  65. data/assets/tvos/MRuby.framework/Headers/mrbconf.h +145 -0
  66. data/assets/tvos/MRuby.framework/Headers/mruby.h +1279 -0
  67. data/assets/tvos/MRuby.framework/Headers/mruby/array.h +279 -0
  68. data/assets/tvos/MRuby.framework/Headers/mruby/boxing_nan.h +102 -0
  69. data/assets/tvos/MRuby.framework/Headers/mruby/boxing_no.h +56 -0
  70. data/assets/tvos/MRuby.framework/Headers/mruby/boxing_word.h +136 -0
  71. data/assets/tvos/MRuby.framework/Headers/mruby/class.h +94 -0
  72. data/assets/tvos/MRuby.framework/Headers/mruby/common.h +72 -0
  73. data/assets/tvos/MRuby.framework/Headers/mruby/compile.h +194 -0
  74. data/assets/tvos/MRuby.framework/Headers/mruby/data.h +75 -0
  75. data/assets/tvos/MRuby.framework/Headers/mruby/debug.h +66 -0
  76. data/assets/tvos/MRuby.framework/Headers/mruby/dump.h +196 -0
  77. data/assets/tvos/MRuby.framework/Headers/mruby/error.h +75 -0
  78. data/assets/tvos/MRuby.framework/Headers/mruby/gc.h +91 -0
  79. data/assets/tvos/MRuby.framework/Headers/mruby/hash.h +182 -0
  80. data/assets/tvos/MRuby.framework/Headers/mruby/irep.h +62 -0
  81. data/assets/tvos/MRuby.framework/Headers/mruby/istruct.h +47 -0
  82. data/assets/tvos/MRuby.framework/Headers/mruby/khash.h +274 -0
  83. data/assets/tvos/MRuby.framework/Headers/mruby/numeric.h +161 -0
  84. data/assets/tvos/MRuby.framework/Headers/mruby/object.h +45 -0
  85. data/assets/tvos/MRuby.framework/Headers/mruby/opcode.h +161 -0
  86. data/assets/tvos/MRuby.framework/Headers/mruby/proc.h +131 -0
  87. data/assets/tvos/MRuby.framework/Headers/mruby/range.h +49 -0
  88. data/assets/tvos/MRuby.framework/Headers/mruby/re.h +16 -0
  89. data/assets/tvos/MRuby.framework/Headers/mruby/string.h +440 -0
  90. data/assets/tvos/MRuby.framework/Headers/mruby/throw.h +55 -0
  91. data/assets/tvos/MRuby.framework/Headers/mruby/value.h +309 -0
  92. data/assets/tvos/MRuby.framework/Headers/mruby/variable.h +138 -0
  93. data/assets/tvos/MRuby.framework/Headers/mruby/version.h +110 -0
  94. data/assets/tvos/MRuby.framework/Info.plist +20 -0
  95. data/assets/tvos/MRuby.framework/MRuby +0 -0
  96. data/assets/tvos/MyApp.xcodeproj/project.pbxproj +344 -0
  97. data/assets/tvos/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  98. data/assets/tvos/MyApp.xcodeproj/project.xcworkspace/xcshareddata/MyApp.xcscmblueprint +30 -0
  99. data/assets/tvos/main.c +1 -0
  100. data/bin/ruby2d +219 -64
  101. data/ext/ruby2d/extconf.rb +1 -1
  102. data/ext/ruby2d/ruby2d.c +117 -19
  103. data/lib/ruby2d/color.rb +1 -1
  104. data/lib/ruby2d/version.rb +1 -1
  105. data/lib/ruby2d/window.rb +16 -10
  106. metadata +102 -5
@@ -0,0 +1,55 @@
1
+ /*
2
+ ** mruby/throw.h - mruby exception throwing handler
3
+ **
4
+ ** See Copyright Notice in mruby.h
5
+ */
6
+
7
+ #ifndef MRB_THROW_H
8
+ #define MRB_THROW_H
9
+
10
+ #if defined(MRB_ENABLE_CXX_ABI)
11
+ # if !defined(__cplusplus)
12
+ # error Trying to use C++ exception handling in C code
13
+ # endif
14
+ #endif
15
+
16
+ #if defined(MRB_ENABLE_CXX_EXCEPTION) && defined(__cplusplus)
17
+
18
+ #define MRB_TRY(buf) do { try {
19
+ #define MRB_CATCH(buf) } catch(mrb_jmpbuf_impl e) { if (e != (buf)->impl) { throw e; }
20
+ #define MRB_END_EXC(buf) } } while(0)
21
+
22
+ #define MRB_THROW(buf) throw((buf)->impl)
23
+ typedef mrb_int mrb_jmpbuf_impl;
24
+
25
+ #else
26
+
27
+ #include <setjmp.h>
28
+
29
+ #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
30
+ #define MRB_SETJMP _setjmp
31
+ #define MRB_LONGJMP _longjmp
32
+ #else
33
+ #define MRB_SETJMP setjmp
34
+ #define MRB_LONGJMP longjmp
35
+ #endif
36
+
37
+ #define MRB_TRY(buf) do { if (MRB_SETJMP((buf)->impl) == 0) {
38
+ #define MRB_CATCH(buf) } else {
39
+ #define MRB_END_EXC(buf) } } while(0)
40
+
41
+ #define MRB_THROW(buf) MRB_LONGJMP((buf)->impl, 1);
42
+ #define mrb_jmpbuf_impl jmp_buf
43
+
44
+ #endif
45
+
46
+ struct mrb_jmpbuf {
47
+ mrb_jmpbuf_impl impl;
48
+
49
+ #if defined(MRB_ENABLE_CXX_EXCEPTION) && defined(__cplusplus)
50
+ static mrb_int jmpbuf_id;
51
+ mrb_jmpbuf() : impl(jmpbuf_id++) {}
52
+ #endif
53
+ };
54
+
55
+ #endif /* MRB_THROW_H */
@@ -0,0 +1,309 @@
1
+ /*
2
+ ** mruby/value.h - mruby value definitions
3
+ **
4
+ ** See Copyright Notice in mruby.h
5
+ */
6
+
7
+ #ifndef MRUBY_VALUE_H
8
+ #define MRUBY_VALUE_H
9
+
10
+ #include "common.h"
11
+
12
+ /**
13
+ * MRuby Value definition functions and macros.
14
+ */
15
+ MRB_BEGIN_DECL
16
+
17
+ typedef uint32_t mrb_sym;
18
+ typedef uint8_t mrb_bool;
19
+ struct mrb_state;
20
+
21
+ #if defined(MRB_INT16) && defined(MRB_INT64)
22
+ # error "You can't define MRB_INT16 and MRB_INT64 at the same time."
23
+ #endif
24
+
25
+ #if defined _MSC_VER && _MSC_VER < 1800
26
+ # define PRIo64 "llo"
27
+ # define PRId64 "lld"
28
+ # define PRIx64 "llx"
29
+ # define PRIo16 "ho"
30
+ # define PRId16 "hd"
31
+ # define PRIx16 "hx"
32
+ # define PRIo32 "o"
33
+ # define PRId32 "d"
34
+ # define PRIx32 "x"
35
+ #else
36
+ # include <inttypes.h>
37
+ #endif
38
+
39
+ #if defined(MRB_INT64)
40
+ typedef int64_t mrb_int;
41
+ # define MRB_INT_BIT 64
42
+ # define MRB_INT_MIN (INT64_MIN>>MRB_FIXNUM_SHIFT)
43
+ # define MRB_INT_MAX (INT64_MAX>>MRB_FIXNUM_SHIFT)
44
+ # define MRB_PRIo PRIo64
45
+ # define MRB_PRId PRId64
46
+ # define MRB_PRIx PRIx64
47
+ #elif defined(MRB_INT16)
48
+ typedef int16_t mrb_int;
49
+ # define MRB_INT_BIT 16
50
+ # define MRB_INT_MIN (INT16_MIN>>MRB_FIXNUM_SHIFT)
51
+ # define MRB_INT_MAX (INT16_MAX>>MRB_FIXNUM_SHIFT)
52
+ # define MRB_PRIo PRIo16
53
+ # define MRB_PRId PRId16
54
+ # define MRB_PRIx PRIx16
55
+ #else
56
+ typedef int32_t mrb_int;
57
+ # define MRB_INT_BIT 32
58
+ # define MRB_INT_MIN (INT32_MIN>>MRB_FIXNUM_SHIFT)
59
+ # define MRB_INT_MAX (INT32_MAX>>MRB_FIXNUM_SHIFT)
60
+ # define MRB_PRIo PRIo32
61
+ # define MRB_PRId PRId32
62
+ # define MRB_PRIx PRIx32
63
+ #endif
64
+
65
+
66
+ #ifndef MRB_WITHOUT_FLOAT
67
+ MRB_API double mrb_float_read(const char*, char**);
68
+ #ifdef MRB_USE_FLOAT
69
+ typedef float mrb_float;
70
+ #else
71
+ typedef double mrb_float;
72
+ #endif
73
+ #endif
74
+
75
+ #if defined _MSC_VER && _MSC_VER < 1900
76
+ # ifndef __cplusplus
77
+ # define inline __inline
78
+ # endif
79
+ # include <stdarg.h>
80
+ MRB_API int mrb_msvc_vsnprintf(char *s, size_t n, const char *format, va_list arg);
81
+ MRB_API int mrb_msvc_snprintf(char *s, size_t n, const char *format, ...);
82
+ # define vsnprintf(s, n, format, arg) mrb_msvc_vsnprintf(s, n, format, arg)
83
+ # define snprintf(s, n, format, ...) mrb_msvc_snprintf(s, n, format, __VA_ARGS__)
84
+ # if _MSC_VER < 1800 && !defined MRB_WITHOUT_FLOAT
85
+ # include <float.h>
86
+ # define isfinite(n) _finite(n)
87
+ # define isnan _isnan
88
+ # define isinf(n) (!_finite(n) && !_isnan(n))
89
+ # define signbit(n) (_copysign(1.0, (n)) < 0.0)
90
+ static const unsigned int IEEE754_INFINITY_BITS_SINGLE = 0x7F800000;
91
+ # define INFINITY (*(float *)&IEEE754_INFINITY_BITS_SINGLE)
92
+ # define NAN ((float)(INFINITY - INFINITY))
93
+ # endif
94
+ #endif
95
+
96
+ enum mrb_vtype {
97
+ MRB_TT_FALSE = 0, /* 0 */
98
+ MRB_TT_FREE, /* 1 */
99
+ MRB_TT_TRUE, /* 2 */
100
+ MRB_TT_FIXNUM, /* 3 */
101
+ MRB_TT_SYMBOL, /* 4 */
102
+ MRB_TT_UNDEF, /* 5 */
103
+ MRB_TT_FLOAT, /* 6 */
104
+ MRB_TT_CPTR, /* 7 */
105
+ MRB_TT_OBJECT, /* 8 */
106
+ MRB_TT_CLASS, /* 9 */
107
+ MRB_TT_MODULE, /* 10 */
108
+ MRB_TT_ICLASS, /* 11 */
109
+ MRB_TT_SCLASS, /* 12 */
110
+ MRB_TT_PROC, /* 13 */
111
+ MRB_TT_ARRAY, /* 14 */
112
+ MRB_TT_HASH, /* 15 */
113
+ MRB_TT_STRING, /* 16 */
114
+ MRB_TT_RANGE, /* 17 */
115
+ MRB_TT_EXCEPTION, /* 18 */
116
+ MRB_TT_FILE, /* 19 */
117
+ MRB_TT_ENV, /* 20 */
118
+ MRB_TT_DATA, /* 21 */
119
+ MRB_TT_FIBER, /* 22 */
120
+ MRB_TT_ISTRUCT, /* 23 */
121
+ MRB_TT_BREAK, /* 24 */
122
+ MRB_TT_MAXDEFINE /* 25 */
123
+ };
124
+
125
+ #include <mruby/object.h>
126
+
127
+ #ifdef MRB_DOCUMENTATION_BLOCK
128
+
129
+ /**
130
+ * @abstract
131
+ * MRuby value boxing.
132
+ *
133
+ * Actual implementation depends on configured boxing type.
134
+ *
135
+ * @see mruby/boxing_no.h Default boxing representation
136
+ * @see mruby/boxing_word.h Word representation
137
+ * @see mruby/boxing_nan.h Boxed double representation
138
+ */
139
+ typedef void mrb_value;
140
+
141
+ #endif
142
+
143
+ #if defined(MRB_NAN_BOXING)
144
+ #include "boxing_nan.h"
145
+ #elif defined(MRB_WORD_BOXING)
146
+ #include "boxing_word.h"
147
+ #else
148
+ #include "boxing_no.h"
149
+ #endif
150
+
151
+ #ifndef mrb_fixnum_p
152
+ #define mrb_fixnum_p(o) (mrb_type(o) == MRB_TT_FIXNUM)
153
+ #endif
154
+ #ifndef mrb_undef_p
155
+ #define mrb_undef_p(o) (mrb_type(o) == MRB_TT_UNDEF)
156
+ #endif
157
+ #ifndef mrb_nil_p
158
+ #define mrb_nil_p(o) (mrb_type(o) == MRB_TT_FALSE && !mrb_fixnum(o))
159
+ #endif
160
+ #ifndef mrb_bool
161
+ #define mrb_bool(o) (mrb_type(o) != MRB_TT_FALSE)
162
+ #endif
163
+ #ifndef MRB_WITHOUT_FLOAT
164
+ #define mrb_float_p(o) (mrb_type(o) == MRB_TT_FLOAT)
165
+ #endif
166
+ #define mrb_symbol_p(o) (mrb_type(o) == MRB_TT_SYMBOL)
167
+ #define mrb_array_p(o) (mrb_type(o) == MRB_TT_ARRAY)
168
+ #define mrb_string_p(o) (mrb_type(o) == MRB_TT_STRING)
169
+ #define mrb_hash_p(o) (mrb_type(o) == MRB_TT_HASH)
170
+ #define mrb_cptr_p(o) (mrb_type(o) == MRB_TT_CPTR)
171
+ #define mrb_exception_p(o) (mrb_type(o) == MRB_TT_EXCEPTION)
172
+ #define mrb_test(o) mrb_bool(o)
173
+ MRB_API mrb_bool mrb_regexp_p(struct mrb_state*, mrb_value);
174
+
175
+ /*
176
+ * Returns a float in Ruby.
177
+ */
178
+ #ifndef MRB_WITHOUT_FLOAT
179
+ MRB_INLINE mrb_value mrb_float_value(struct mrb_state *mrb, mrb_float f)
180
+ {
181
+ mrb_value v;
182
+ (void) mrb;
183
+ SET_FLOAT_VALUE(mrb, v, f);
184
+ return v;
185
+ }
186
+ #endif
187
+
188
+ static inline mrb_value
189
+ mrb_cptr_value(struct mrb_state *mrb, void *p)
190
+ {
191
+ mrb_value v;
192
+ (void) mrb;
193
+ SET_CPTR_VALUE(mrb,v,p);
194
+ return v;
195
+ }
196
+
197
+ /*
198
+ * Returns a fixnum in Ruby.
199
+ */
200
+ MRB_INLINE mrb_value mrb_fixnum_value(mrb_int i)
201
+ {
202
+ mrb_value v;
203
+ SET_INT_VALUE(v, i);
204
+ return v;
205
+ }
206
+
207
+ static inline mrb_value
208
+ mrb_symbol_value(mrb_sym i)
209
+ {
210
+ mrb_value v;
211
+ SET_SYM_VALUE(v, i);
212
+ return v;
213
+ }
214
+
215
+ static inline mrb_value
216
+ mrb_obj_value(void *p)
217
+ {
218
+ mrb_value v;
219
+ SET_OBJ_VALUE(v, (struct RBasic*)p);
220
+ mrb_assert(p == mrb_ptr(v));
221
+ mrb_assert(((struct RBasic*)p)->tt == mrb_type(v));
222
+ return v;
223
+ }
224
+
225
+
226
+ /*
227
+ * Get a nil mrb_value object.
228
+ *
229
+ * @return
230
+ * nil mrb_value object reference.
231
+ */
232
+ MRB_INLINE mrb_value mrb_nil_value(void)
233
+ {
234
+ mrb_value v;
235
+ SET_NIL_VALUE(v);
236
+ return v;
237
+ }
238
+
239
+ /*
240
+ * Returns false in Ruby.
241
+ */
242
+ MRB_INLINE mrb_value mrb_false_value(void)
243
+ {
244
+ mrb_value v;
245
+ SET_FALSE_VALUE(v);
246
+ return v;
247
+ }
248
+
249
+ /*
250
+ * Returns true in Ruby.
251
+ */
252
+ MRB_INLINE mrb_value mrb_true_value(void)
253
+ {
254
+ mrb_value v;
255
+ SET_TRUE_VALUE(v);
256
+ return v;
257
+ }
258
+
259
+ static inline mrb_value
260
+ mrb_bool_value(mrb_bool boolean)
261
+ {
262
+ mrb_value v;
263
+ SET_BOOL_VALUE(v, boolean);
264
+ return v;
265
+ }
266
+
267
+ static inline mrb_value
268
+ mrb_undef_value(void)
269
+ {
270
+ mrb_value v;
271
+ SET_UNDEF_VALUE(v);
272
+ return v;
273
+ }
274
+
275
+ #ifdef MRB_USE_ETEXT_EDATA
276
+ #if (defined(__APPLE__) && defined(__MACH__))
277
+ #include <mach-o/getsect.h>
278
+ static inline mrb_bool
279
+ mrb_ro_data_p(const char *p)
280
+ {
281
+ return (const char*)get_etext() < p && p < (const char*)get_edata();
282
+ }
283
+ #else
284
+ extern char _etext[];
285
+ #ifdef MRB_NO_INIT_ARRAY_START
286
+ extern char _edata[];
287
+
288
+ static inline mrb_bool
289
+ mrb_ro_data_p(const char *p)
290
+ {
291
+ return _etext < p && p < _edata;
292
+ }
293
+ #else
294
+ extern char __init_array_start[];
295
+
296
+ static inline mrb_bool
297
+ mrb_ro_data_p(const char *p)
298
+ {
299
+ return _etext < p && p < (char*)&__init_array_start;
300
+ }
301
+ #endif
302
+ #endif
303
+ #else
304
+ # define mrb_ro_data_p(p) FALSE
305
+ #endif
306
+
307
+ MRB_END_DECL
308
+
309
+ #endif /* MRUBY_VALUE_H */
@@ -0,0 +1,138 @@
1
+ /*
2
+ ** mruby/variable.h - mruby variables
3
+ **
4
+ ** See Copyright Notice in mruby.h
5
+ */
6
+
7
+ #ifndef MRUBY_VARIABLE_H
8
+ #define MRUBY_VARIABLE_H
9
+
10
+ #include "common.h"
11
+
12
+ /**
13
+ * Functions to access mruby variables.
14
+ */
15
+ MRB_BEGIN_DECL
16
+
17
+ typedef struct global_variable {
18
+ int counter;
19
+ mrb_value *data;
20
+ mrb_value (*getter)(void);
21
+ void (*setter)(void);
22
+ /* void (*marker)(); */
23
+ /* int block_trace; */
24
+ /* struct trace_var *trace; */
25
+ } global_variable;
26
+
27
+ struct global_entry {
28
+ global_variable *var;
29
+ mrb_sym id;
30
+ };
31
+
32
+ mrb_value mrb_vm_special_get(mrb_state*, mrb_sym);
33
+ void mrb_vm_special_set(mrb_state*, mrb_sym, mrb_value);
34
+ mrb_value mrb_vm_iv_get(mrb_state*, mrb_sym);
35
+ void mrb_vm_iv_set(mrb_state*, mrb_sym, mrb_value);
36
+ mrb_value mrb_vm_cv_get(mrb_state*, mrb_sym);
37
+ void mrb_vm_cv_set(mrb_state*, mrb_sym, mrb_value);
38
+ mrb_value mrb_vm_const_get(mrb_state*, mrb_sym);
39
+ void mrb_vm_const_set(mrb_state*, mrb_sym, mrb_value);
40
+ MRB_API mrb_value mrb_const_get(mrb_state*, mrb_value, mrb_sym);
41
+ MRB_API void mrb_const_set(mrb_state*, mrb_value, mrb_sym, mrb_value);
42
+ MRB_API mrb_bool mrb_const_defined(mrb_state*, mrb_value, mrb_sym);
43
+ MRB_API void mrb_const_remove(mrb_state*, mrb_value, mrb_sym);
44
+
45
+ MRB_API mrb_bool mrb_iv_p(mrb_state *mrb, mrb_sym sym);
46
+ MRB_API void mrb_iv_check(mrb_state *mrb, mrb_sym sym);
47
+ MRB_API mrb_value mrb_obj_iv_get(mrb_state *mrb, struct RObject *obj, mrb_sym sym);
48
+ MRB_API void mrb_obj_iv_set(mrb_state *mrb, struct RObject *obj, mrb_sym sym, mrb_value v);
49
+ MRB_API mrb_bool mrb_obj_iv_defined(mrb_state *mrb, struct RObject *obj, mrb_sym sym);
50
+ MRB_API mrb_value mrb_iv_get(mrb_state *mrb, mrb_value obj, mrb_sym sym);
51
+ MRB_API void mrb_iv_set(mrb_state *mrb, mrb_value obj, mrb_sym sym, mrb_value v);
52
+ MRB_API mrb_bool mrb_iv_defined(mrb_state*, mrb_value, mrb_sym);
53
+ MRB_API mrb_value mrb_iv_remove(mrb_state *mrb, mrb_value obj, mrb_sym sym);
54
+ MRB_API void mrb_iv_copy(mrb_state *mrb, mrb_value dst, mrb_value src);
55
+ MRB_API mrb_bool mrb_const_defined_at(mrb_state *mrb, mrb_value mod, mrb_sym id);
56
+
57
+ /**
58
+ * Get a global variable. Will return nil if the var does not exist
59
+ *
60
+ * Example:
61
+ *
62
+ * !!!ruby
63
+ * # Ruby style
64
+ * var = $value
65
+ *
66
+ * !!!c
67
+ * // C style
68
+ * mrb_sym sym = mrb_intern_lit(mrb, "$value");
69
+ * mrb_value var = mrb_gv_get(mrb, sym);
70
+ *
71
+ * @param mrb The mruby state reference
72
+ * @param sym The name of the global variable
73
+ * @return The value of that global variable. May be nil
74
+ */
75
+ MRB_API mrb_value mrb_gv_get(mrb_state *mrb, mrb_sym sym);
76
+
77
+ /**
78
+ * Set a global variable
79
+ *
80
+ * Example:
81
+ *
82
+ * !!!ruby
83
+ * # Ruby style
84
+ * $value = "foo"
85
+ *
86
+ * !!!c
87
+ * // C style
88
+ * mrb_sym sym = mrb_intern_lit(mrb, "$value");
89
+ * mrb_gv_set(mrb, sym, mrb_str_new_lit("foo"));
90
+ *
91
+ * @param mrb The mruby state reference
92
+ * @param sym The name of the global variable
93
+ * @param val The value of the global variable
94
+ */
95
+ MRB_API void mrb_gv_set(mrb_state *mrb, mrb_sym sym, mrb_value val);
96
+
97
+ /**
98
+ * Remove a global variable.
99
+ *
100
+ * Example:
101
+ *
102
+ * !!!ruby
103
+ * # Ruby style
104
+ * $value = nil
105
+ *
106
+ * !!!c
107
+ * // C style
108
+ * mrb_sym sym = mrb_intern_lit(mrb, "$value");
109
+ * mrb_gv_remove(mrb, sym);
110
+ *
111
+ * @param mrb The mruby state reference
112
+ * @param sym The name of the global variable
113
+ * @param val The value of the global variable
114
+ */
115
+ MRB_API void mrb_gv_remove(mrb_state *mrb, mrb_sym sym);
116
+
117
+ MRB_API mrb_value mrb_cv_get(mrb_state *mrb, mrb_value mod, mrb_sym sym);
118
+ MRB_API void mrb_mod_cv_set(mrb_state *mrb, struct RClass * c, mrb_sym sym, mrb_value v);
119
+ MRB_API void mrb_cv_set(mrb_state *mrb, mrb_value mod, mrb_sym sym, mrb_value v);
120
+ MRB_API mrb_bool mrb_cv_defined(mrb_state *mrb, mrb_value mod, mrb_sym sym);
121
+ mrb_value mrb_obj_iv_inspect(mrb_state*, struct RObject*);
122
+ mrb_value mrb_mod_constants(mrb_state *mrb, mrb_value mod);
123
+ mrb_value mrb_f_global_variables(mrb_state *mrb, mrb_value self);
124
+ mrb_value mrb_obj_instance_variables(mrb_state*, mrb_value);
125
+ mrb_value mrb_mod_class_variables(mrb_state*, mrb_value);
126
+ mrb_value mrb_mod_cv_get(mrb_state *mrb, struct RClass * c, mrb_sym sym);
127
+ mrb_bool mrb_mod_cv_defined(mrb_state *mrb, struct RClass * c, mrb_sym sym);
128
+
129
+ /* GC functions */
130
+ void mrb_gc_mark_gv(mrb_state*);
131
+ void mrb_gc_free_gv(mrb_state*);
132
+ void mrb_gc_mark_iv(mrb_state*, struct RObject*);
133
+ size_t mrb_gc_mark_iv_size(mrb_state*, struct RObject*);
134
+ void mrb_gc_free_iv(mrb_state*, struct RObject*);
135
+
136
+ MRB_END_DECL
137
+
138
+ #endif /* MRUBY_VARIABLE_H */