did_you_mean 0.5.0 → 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/.travis.yml +12 -4
- data/Appraisals +6 -0
- data/Gemfile +14 -0
- data/README.md +69 -13
- data/Rakefile +47 -22
- data/did_you_mean.gemspec +3 -5
- data/docs/did_you_mean_example.png +0 -0
- data/ext/did_you_mean/extconf.rb +16 -11
- data/ext/did_you_mean/org/yukinishijima/ReceiverCapturer.java +58 -0
- data/ext/did_you_mean/ruby_headers/210/id.h +11 -9
- data/ext/did_you_mean/ruby_headers/210/version.h +6 -6
- data/ext/did_you_mean/ruby_headers/211/addr2line.h +21 -0
- data/ext/did_you_mean/ruby_headers/211/constant.h +36 -0
- data/ext/did_you_mean/ruby_headers/211/dln.h +51 -0
- data/ext/did_you_mean/ruby_headers/211/encdb.h +170 -0
- data/ext/did_you_mean/ruby_headers/211/eval_intern.h +260 -0
- data/ext/did_you_mean/ruby_headers/211/gc.h +101 -0
- data/ext/did_you_mean/ruby_headers/211/id.h +173 -0
- data/ext/did_you_mean/ruby_headers/211/internal.h +889 -0
- data/ext/did_you_mean/ruby_headers/211/iseq.h +136 -0
- data/ext/did_you_mean/ruby_headers/211/method.h +142 -0
- data/ext/did_you_mean/ruby_headers/211/node.h +543 -0
- data/ext/did_you_mean/ruby_headers/211/parse.h +183 -0
- data/ext/did_you_mean/ruby_headers/211/probes.h +83 -0
- data/ext/did_you_mean/ruby_headers/211/probes_helper.h +67 -0
- data/ext/did_you_mean/ruby_headers/211/regenc.h +223 -0
- data/ext/did_you_mean/ruby_headers/211/regint.h +911 -0
- data/ext/did_you_mean/ruby_headers/211/regparse.h +363 -0
- data/ext/did_you_mean/ruby_headers/211/revision.h +1 -0
- data/ext/did_you_mean/ruby_headers/211/ruby_atomic.h +170 -0
- data/ext/did_you_mean/ruby_headers/211/siphash.h +48 -0
- data/ext/did_you_mean/ruby_headers/211/thread_native.h +23 -0
- data/ext/did_you_mean/ruby_headers/211/thread_pthread.h +56 -0
- data/ext/did_you_mean/ruby_headers/211/thread_win32.h +45 -0
- data/ext/did_you_mean/ruby_headers/211/timev.h +42 -0
- data/ext/did_you_mean/ruby_headers/211/transcode_data.h +123 -0
- data/ext/did_you_mean/ruby_headers/211/transdb.h +190 -0
- data/ext/did_you_mean/ruby_headers/211/verconf.h +13 -0
- data/ext/did_you_mean/ruby_headers/211/version.h +52 -0
- data/ext/did_you_mean/ruby_headers/211/vm_core.h +1043 -0
- data/ext/did_you_mean/ruby_headers/211/vm_debug.h +37 -0
- data/ext/did_you_mean/ruby_headers/211/vm_exec.h +182 -0
- data/ext/did_you_mean/ruby_headers/211/vm_insnhelper.h +273 -0
- data/ext/did_you_mean/ruby_headers/211/vm_opts.h +56 -0
- data/ext/did_you_mean/ruby_headers/212/addr2line.h +21 -0
- data/ext/did_you_mean/ruby_headers/212/constant.h +36 -0
- data/ext/did_you_mean/ruby_headers/212/dln.h +51 -0
- data/ext/did_you_mean/ruby_headers/212/encdb.h +170 -0
- data/ext/did_you_mean/ruby_headers/212/eval_intern.h +260 -0
- data/ext/did_you_mean/ruby_headers/212/gc.h +101 -0
- data/ext/did_you_mean/ruby_headers/212/id.h +173 -0
- data/ext/did_you_mean/ruby_headers/212/internal.h +889 -0
- data/ext/did_you_mean/ruby_headers/212/iseq.h +136 -0
- data/ext/did_you_mean/ruby_headers/212/method.h +142 -0
- data/ext/did_you_mean/ruby_headers/212/node.h +543 -0
- data/ext/did_you_mean/ruby_headers/212/parse.h +183 -0
- data/ext/did_you_mean/ruby_headers/212/probes.h +83 -0
- data/ext/did_you_mean/ruby_headers/212/probes_helper.h +67 -0
- data/ext/did_you_mean/ruby_headers/212/regenc.h +223 -0
- data/ext/did_you_mean/ruby_headers/212/regint.h +911 -0
- data/ext/did_you_mean/ruby_headers/212/regparse.h +363 -0
- data/ext/did_you_mean/ruby_headers/212/revision.h +1 -0
- data/ext/did_you_mean/ruby_headers/212/ruby_atomic.h +170 -0
- data/ext/did_you_mean/ruby_headers/212/siphash.h +48 -0
- data/ext/did_you_mean/ruby_headers/212/thread_native.h +23 -0
- data/ext/did_you_mean/ruby_headers/212/thread_pthread.h +56 -0
- data/ext/did_you_mean/ruby_headers/212/thread_win32.h +45 -0
- data/ext/did_you_mean/ruby_headers/212/timev.h +42 -0
- data/ext/did_you_mean/ruby_headers/212/transcode_data.h +123 -0
- data/ext/did_you_mean/ruby_headers/212/transdb.h +190 -0
- data/ext/did_you_mean/ruby_headers/212/verconf.h +13 -0
- data/ext/did_you_mean/ruby_headers/212/version.h +52 -0
- data/ext/did_you_mean/ruby_headers/212/vm_core.h +1043 -0
- data/ext/did_you_mean/ruby_headers/212/vm_debug.h +37 -0
- data/ext/did_you_mean/ruby_headers/212/vm_exec.h +182 -0
- data/ext/did_you_mean/ruby_headers/212/vm_insnhelper.h +273 -0
- data/ext/did_you_mean/ruby_headers/212/vm_opts.h +56 -0
- data/ext/did_you_mean/ruby_headers/213/addr2line.h +21 -0
- data/ext/did_you_mean/ruby_headers/213/constant.h +36 -0
- data/ext/did_you_mean/ruby_headers/213/dln.h +51 -0
- data/ext/did_you_mean/ruby_headers/213/encdb.h +170 -0
- data/ext/did_you_mean/ruby_headers/213/eval_intern.h +270 -0
- data/ext/did_you_mean/ruby_headers/213/gc.h +101 -0
- data/ext/did_you_mean/ruby_headers/213/id.h +173 -0
- data/ext/did_you_mean/ruby_headers/213/internal.h +892 -0
- data/ext/did_you_mean/ruby_headers/213/iseq.h +136 -0
- data/ext/did_you_mean/ruby_headers/213/method.h +142 -0
- data/ext/did_you_mean/ruby_headers/213/node.h +543 -0
- data/ext/did_you_mean/ruby_headers/213/parse.h +183 -0
- data/ext/did_you_mean/ruby_headers/213/probes.h +83 -0
- data/ext/did_you_mean/ruby_headers/213/probes_helper.h +67 -0
- data/ext/did_you_mean/ruby_headers/213/regenc.h +223 -0
- data/ext/did_you_mean/ruby_headers/213/regint.h +911 -0
- data/ext/did_you_mean/ruby_headers/213/regparse.h +363 -0
- data/ext/did_you_mean/ruby_headers/213/revision.h +1 -0
- data/ext/did_you_mean/ruby_headers/213/ruby_atomic.h +170 -0
- data/ext/did_you_mean/ruby_headers/213/siphash.h +48 -0
- data/ext/did_you_mean/ruby_headers/213/thread_native.h +23 -0
- data/ext/did_you_mean/ruby_headers/213/thread_pthread.h +56 -0
- data/ext/did_you_mean/ruby_headers/213/thread_win32.h +45 -0
- data/ext/did_you_mean/ruby_headers/213/timev.h +42 -0
- data/ext/did_you_mean/ruby_headers/213/transcode_data.h +123 -0
- data/ext/did_you_mean/ruby_headers/213/transdb.h +190 -0
- data/ext/did_you_mean/ruby_headers/213/verconf.h +13 -0
- data/ext/did_you_mean/ruby_headers/213/version.h +52 -0
- data/ext/did_you_mean/ruby_headers/213/vm_core.h +1052 -0
- data/ext/did_you_mean/ruby_headers/213/vm_debug.h +37 -0
- data/ext/did_you_mean/ruby_headers/213/vm_exec.h +182 -0
- data/ext/did_you_mean/ruby_headers/213/vm_insnhelper.h +273 -0
- data/ext/did_you_mean/ruby_headers/213/vm_opts.h +56 -0
- data/ext/did_you_mean/ruby_headers/214/addr2line.h +21 -0
- data/ext/did_you_mean/ruby_headers/214/constant.h +36 -0
- data/ext/did_you_mean/ruby_headers/214/dln.h +51 -0
- data/ext/did_you_mean/ruby_headers/214/encdb.h +170 -0
- data/ext/did_you_mean/ruby_headers/214/eval_intern.h +270 -0
- data/ext/did_you_mean/ruby_headers/214/gc.h +101 -0
- data/ext/did_you_mean/ruby_headers/214/id.h +173 -0
- data/ext/did_you_mean/ruby_headers/214/internal.h +892 -0
- data/ext/did_you_mean/ruby_headers/214/iseq.h +136 -0
- data/ext/did_you_mean/ruby_headers/214/method.h +142 -0
- data/ext/did_you_mean/ruby_headers/214/node.h +543 -0
- data/ext/did_you_mean/ruby_headers/214/parse.h +183 -0
- data/ext/did_you_mean/ruby_headers/214/probes.h +83 -0
- data/ext/did_you_mean/ruby_headers/214/probes_helper.h +67 -0
- data/ext/did_you_mean/ruby_headers/214/regenc.h +223 -0
- data/ext/did_you_mean/ruby_headers/214/regint.h +911 -0
- data/ext/did_you_mean/ruby_headers/214/regparse.h +363 -0
- data/ext/did_you_mean/ruby_headers/214/revision.h +1 -0
- data/ext/did_you_mean/ruby_headers/214/ruby_atomic.h +170 -0
- data/ext/did_you_mean/ruby_headers/214/siphash.h +48 -0
- data/ext/did_you_mean/ruby_headers/214/thread_native.h +23 -0
- data/ext/did_you_mean/ruby_headers/214/thread_pthread.h +56 -0
- data/ext/did_you_mean/ruby_headers/214/thread_win32.h +45 -0
- data/ext/did_you_mean/ruby_headers/214/timev.h +42 -0
- data/ext/did_you_mean/ruby_headers/214/transcode_data.h +123 -0
- data/ext/did_you_mean/ruby_headers/214/transdb.h +190 -0
- data/ext/did_you_mean/ruby_headers/214/verconf.h +13 -0
- data/ext/did_you_mean/ruby_headers/214/version.h +52 -0
- data/ext/did_you_mean/ruby_headers/214/vm_core.h +1055 -0
- data/ext/did_you_mean/ruby_headers/214/vm_debug.h +37 -0
- data/ext/did_you_mean/ruby_headers/214/vm_exec.h +182 -0
- data/ext/did_you_mean/ruby_headers/214/vm_insnhelper.h +273 -0
- data/ext/did_you_mean/ruby_headers/214/vm_opts.h +56 -0
- data/ext/did_you_mean/ruby_headers/220/addr2line.h +1 -1
- data/ext/did_you_mean/ruby_headers/220/ccan/build_assert/build_assert.h +40 -0
- data/ext/did_you_mean/ruby_headers/220/ccan/check_type/check_type.h +63 -0
- data/ext/did_you_mean/ruby_headers/220/ccan/container_of/container_of.h +106 -0
- data/ext/did_you_mean/ruby_headers/220/ccan/licenses/BSD-MIT +17 -0
- data/ext/did_you_mean/ruby_headers/220/ccan/licenses/CC0 +28 -0
- data/ext/did_you_mean/ruby_headers/220/ccan/list/list.h +602 -0
- data/ext/did_you_mean/ruby_headers/220/ccan/str/str.h +16 -0
- data/ext/did_you_mean/ruby_headers/220/constant.h +10 -3
- data/ext/did_you_mean/ruby_headers/220/eval_intern.h +24 -5
- data/ext/did_you_mean/ruby_headers/220/gc.h +5 -0
- data/ext/did_you_mean/ruby_headers/220/id.h +11 -9
- data/ext/did_you_mean/ruby_headers/220/internal.h +116 -21
- data/ext/did_you_mean/ruby_headers/220/iseq.h +28 -7
- data/ext/did_you_mean/ruby_headers/220/method.h +0 -1
- data/ext/did_you_mean/ruby_headers/220/node.h +5 -4
- data/ext/did_you_mean/ruby_headers/220/regenc.h +18 -7
- data/ext/did_you_mean/ruby_headers/220/regint.h +72 -11
- data/ext/did_you_mean/ruby_headers/220/regparse.h +2 -2
- data/ext/did_you_mean/ruby_headers/220/ruby_atomic.h +2 -2
- data/ext/did_you_mean/ruby_headers/220/symbol.h +87 -0
- data/ext/did_you_mean/ruby_headers/220/thread_pthread.h +4 -6
- data/ext/did_you_mean/ruby_headers/220/thread_win32.h +0 -9
- data/ext/did_you_mean/ruby_headers/220/timev.h +2 -2
- data/ext/did_you_mean/ruby_headers/220/version.h +3 -3
- data/ext/did_you_mean/ruby_headers/220/vm_core.h +200 -65
- data/ext/did_you_mean/ruby_headers/220/vm_insnhelper.h +0 -40
- data/gemfiles/activerecord_30.gemfile +14 -0
- data/gemfiles/activerecord_31.gemfile +14 -0
- data/gemfiles/activerecord_32.gemfile +14 -0
- data/gemfiles/activerecord_40.gemfile +14 -0
- data/gemfiles/activerecord_41.gemfile +14 -0
- data/gemfiles/activerecord_42.gemfile +21 -0
- data/gemfiles/activerecord_edge.gemfile +16 -0
- data/lib/did_you_mean.rb +14 -4
- data/lib/did_you_mean/core_ext/name_error.rb +11 -44
- data/lib/did_you_mean/finders.rb +31 -0
- data/lib/did_you_mean/finders/name_error_finders.rb +24 -0
- data/lib/did_you_mean/finders/name_error_finders/similar_class_finder.rb +50 -0
- data/lib/did_you_mean/finders/name_error_finders/similar_name_finder.rb +61 -0
- data/lib/did_you_mean/finders/similar_attribute_finder.rb +26 -0
- data/lib/did_you_mean/finders/similar_method_finder.rb +42 -0
- data/lib/did_you_mean/levenshtein.rb +49 -0
- data/lib/did_you_mean/test_helper.rb +11 -0
- data/lib/did_you_mean/version.rb +1 -1
- data/lib/did_you_mean/word_collection.rb +27 -0
- data/test/all_test.rb +16 -2
- data/test/name_error_extension_test.rb +24 -0
- data/test/no_method_error_extension_test.rb +20 -0
- data/test/null_finder_test.rb +19 -0
- data/test/similar_attribute_finder_test.rb +2 -6
- data/test/similar_class_finder_test.rb +85 -0
- data/test/similar_method_finder_test.rb +16 -35
- data/test/similar_name_finder_test.rb +31 -23
- data/test/test_helper.rb +19 -11
- metadata +168 -45
- data/docs/better_errors_example.png +0 -0
- data/docs/irb_example.png +0 -0
- data/docs/rspec_example.png +0 -0
- data/lib/did_you_mean/method_finder.rb +0 -24
- data/lib/did_you_mean/strategies.rb +0 -23
- data/lib/did_you_mean/strategies/similar_attribute_finder.rb +0 -41
- data/lib/did_you_mean/strategies/similar_method_finder.rb +0 -46
- data/lib/did_you_mean/strategies/similar_name_finder.rb +0 -57
- data/test.sh +0 -18
@@ -0,0 +1,16 @@
|
|
1
|
+
/* CC0 (Public domain) - see ccan/licenses/CC0 file for details */
|
2
|
+
#ifndef CCAN_STR_H
|
3
|
+
#define CCAN_STR_H
|
4
|
+
/**
|
5
|
+
* stringify - Turn expression into a string literal
|
6
|
+
* @expr: any C expression
|
7
|
+
*
|
8
|
+
* Example:
|
9
|
+
* #define PRINT_COND_IF_FALSE(cond) \
|
10
|
+
* ((cond) || printf("%s is false!", stringify(cond)))
|
11
|
+
*/
|
12
|
+
#define stringify(expr) stringify_1(expr)
|
13
|
+
/* Double-indirection required to stringify expansions */
|
14
|
+
#define stringify_1(expr) #expr
|
15
|
+
|
16
|
+
#endif /* CCAN_STR_H */
|
@@ -13,9 +13,15 @@
|
|
13
13
|
|
14
14
|
typedef enum {
|
15
15
|
CONST_PUBLIC = 0x00,
|
16
|
-
CONST_PRIVATE
|
16
|
+
CONST_PRIVATE,
|
17
|
+
CONST_VISIBILITY_MAX
|
17
18
|
} rb_const_flag_t;
|
18
19
|
|
20
|
+
#define RB_CONST_PRIVATE_P(ce) \
|
21
|
+
((ce)->flag == CONST_PRIVATE)
|
22
|
+
#define RB_CONST_PUBLIC_P(ce) \
|
23
|
+
((ce)->flag == CONST_PUBLIC)
|
24
|
+
|
19
25
|
typedef struct rb_const_entry_struct {
|
20
26
|
rb_const_flag_t flag;
|
21
27
|
int line;
|
@@ -23,8 +29,8 @@ typedef struct rb_const_entry_struct {
|
|
23
29
|
const VALUE file; /* should be mark */
|
24
30
|
} rb_const_entry_t;
|
25
31
|
|
26
|
-
VALUE rb_mod_private_constant(int argc, VALUE *argv, VALUE obj);
|
27
|
-
VALUE rb_mod_public_constant(int argc, VALUE *argv, VALUE obj);
|
32
|
+
VALUE rb_mod_private_constant(int argc, const VALUE *argv, VALUE obj);
|
33
|
+
VALUE rb_mod_public_constant(int argc, const VALUE *argv, VALUE obj);
|
28
34
|
void rb_free_const_table(st_table *tbl);
|
29
35
|
VALUE rb_public_const_get(VALUE klass, ID id);
|
30
36
|
VALUE rb_public_const_get_at(VALUE klass, ID id);
|
@@ -32,5 +38,6 @@ VALUE rb_public_const_get_from(VALUE klass, ID id);
|
|
32
38
|
int rb_public_const_defined(VALUE klass, ID id);
|
33
39
|
int rb_public_const_defined_at(VALUE klass, ID id);
|
34
40
|
int rb_public_const_defined_from(VALUE klass, ID id);
|
41
|
+
rb_const_entry_t *rb_const_lookup(VALUE klass, ID id);
|
35
42
|
|
36
43
|
#endif /* CONSTANT_H */
|
@@ -95,6 +95,15 @@ extern int select_large_fdset(int, fd_set *, fd_set *, fd_set *, struct timeval
|
|
95
95
|
EXCEPTION_CONTINUE_SEARCH) { \
|
96
96
|
/* never reaches here */ \
|
97
97
|
}
|
98
|
+
#elif defined(__MINGW32__)
|
99
|
+
LONG WINAPI rb_w32_stack_overflow_handler(struct _EXCEPTION_POINTERS *);
|
100
|
+
#define SAVE_ROOT_JMPBUF_BEFORE_STMT \
|
101
|
+
do { \
|
102
|
+
PVOID _handler = AddVectoredExceptionHandler(1, rb_w32_stack_overflow_handler);
|
103
|
+
|
104
|
+
#define SAVE_ROOT_JMPBUF_AFTER_STMT \
|
105
|
+
RemoveVectoredExceptionHandler(_handler); \
|
106
|
+
} while (0);
|
98
107
|
#else
|
99
108
|
#define SAVE_ROOT_JMPBUF_BEFORE_STMT
|
100
109
|
#define SAVE_ROOT_JMPBUF_AFTER_STMT
|
@@ -128,6 +137,14 @@ extern int select_large_fdset(int, fd_set *, fd_set *, fd_set *, struct timeval
|
|
128
137
|
#define PUSH_TAG() TH_PUSH_TAG(GET_THREAD())
|
129
138
|
#define POP_TAG() TH_POP_TAG()
|
130
139
|
|
140
|
+
#if defined __GNUC__ && __GNUC__ == 4 && (__GNUC_MINOR__ >= 6 && __GNUC_MINOR__ <= 8)
|
141
|
+
# define VAR_FROM_MEMORY(var) __extension__(*(__typeof__(var) volatile *)&(var))
|
142
|
+
# define VAR_INITIALIZED(var) ((var) = VAR_FROM_MEMORY(var))
|
143
|
+
#else
|
144
|
+
# define VAR_FROM_MEMORY(var) (var)
|
145
|
+
# define VAR_INITIALIZED(var) ((void)&(var))
|
146
|
+
#endif
|
147
|
+
|
131
148
|
/* clear th->state, and return the value */
|
132
149
|
static inline int
|
133
150
|
rb_threadptr_tag_state(rb_thread_t *th)
|
@@ -141,7 +158,8 @@ NORETURN(static inline void rb_threadptr_tag_jump(rb_thread_t *, int));
|
|
141
158
|
static inline void
|
142
159
|
rb_threadptr_tag_jump(rb_thread_t *th, int st)
|
143
160
|
{
|
144
|
-
|
161
|
+
th->state = st;
|
162
|
+
ruby_longjmp(th->tag->buf, 1);
|
145
163
|
}
|
146
164
|
|
147
165
|
/*
|
@@ -149,7 +167,7 @@ rb_threadptr_tag_jump(rb_thread_t *th, int st)
|
|
149
167
|
[ISO/IEC 9899:1999] 7.13.1.1
|
150
168
|
*/
|
151
169
|
#define TH_EXEC_TAG() \
|
152
|
-
(ruby_setjmp(_tag.buf) ? rb_threadptr_tag_state(_th) : (TH_REPUSH_TAG(), 0))
|
170
|
+
(ruby_setjmp(_tag.buf) ? rb_threadptr_tag_state(VAR_FROM_MEMORY(_th)) : (TH_REPUSH_TAG(), 0))
|
153
171
|
|
154
172
|
#define EXEC_TAG() \
|
155
173
|
TH_EXEC_TAG()
|
@@ -211,8 +229,8 @@ int rb_threadptr_reset_raised(rb_thread_t *th);
|
|
211
229
|
#define rb_thread_raised_p(th, f) (((th)->raised_flag & (f)) != 0)
|
212
230
|
#define rb_thread_raised_clear(th) ((th)->raised_flag = 0)
|
213
231
|
|
214
|
-
VALUE rb_f_eval(int argc, VALUE *argv, VALUE self);
|
215
|
-
VALUE rb_make_exception(int argc, VALUE *argv);
|
232
|
+
VALUE rb_f_eval(int argc, const VALUE *argv, VALUE self);
|
233
|
+
VALUE rb_make_exception(int argc, const VALUE *argv);
|
216
234
|
|
217
235
|
NORETURN(void rb_method_name_error(VALUE, VALUE));
|
218
236
|
|
@@ -220,9 +238,10 @@ NORETURN(void rb_fiber_start(void));
|
|
220
238
|
|
221
239
|
NORETURN(void rb_print_undef(VALUE, ID, int));
|
222
240
|
NORETURN(void rb_print_undef_str(VALUE, VALUE));
|
241
|
+
NORETURN(void rb_print_inaccessible(VALUE, ID, int));
|
223
242
|
NORETURN(void rb_vm_localjump_error(const char *,VALUE, int));
|
224
243
|
NORETURN(void rb_vm_jump_tag_but_local_jump(int));
|
225
|
-
NORETURN(void rb_raise_method_missing(rb_thread_t *th, int argc, VALUE *argv,
|
244
|
+
NORETURN(void rb_raise_method_missing(rb_thread_t *th, int argc, const VALUE *argv,
|
226
245
|
VALUE obj, int call_status));
|
227
246
|
|
228
247
|
VALUE rb_vm_make_jump_tag_but_local_jump(int state, VALUE val);
|
@@ -92,11 +92,16 @@ void rb_objspace_reachable_objects_from_root(void (func)(const char *category, V
|
|
92
92
|
int rb_objspace_markable_object_p(VALUE obj);
|
93
93
|
int rb_objspace_internal_object_p(VALUE obj);
|
94
94
|
int rb_objspace_marked_object_p(VALUE obj);
|
95
|
+
int rb_objspace_garbage_object_p(VALUE obj);
|
95
96
|
|
96
97
|
void rb_objspace_each_objects(
|
97
98
|
int (*callback)(void *start, void *end, size_t stride, void *data),
|
98
99
|
void *data);
|
99
100
|
|
101
|
+
void rb_objspace_each_objects_without_setup(
|
102
|
+
int (*callback)(void *, void *, size_t, void *),
|
103
|
+
void *data);
|
104
|
+
|
100
105
|
RUBY_SYMBOL_EXPORT_END
|
101
106
|
|
102
107
|
#endif /* RUBY_GC_H */
|
@@ -14,18 +14,20 @@
|
|
14
14
|
#define RUBY_ID_H
|
15
15
|
|
16
16
|
enum ruby_id_types {
|
17
|
+
RUBY_ID_STATIC_SYM = 0x01,
|
17
18
|
RUBY_ID_LOCAL = 0x00,
|
18
|
-
RUBY_ID_INSTANCE = 0x01,
|
19
|
-
RUBY_ID_GLOBAL = 0x03,
|
20
|
-
RUBY_ID_ATTRSET = 0x04,
|
21
|
-
RUBY_ID_CONST = 0x05,
|
22
|
-
RUBY_ID_CLASS = 0x06,
|
23
|
-
RUBY_ID_JUNK = 0x07,
|
19
|
+
RUBY_ID_INSTANCE = (0x01<<1),
|
20
|
+
RUBY_ID_GLOBAL = (0x03<<1),
|
21
|
+
RUBY_ID_ATTRSET = (0x04<<1),
|
22
|
+
RUBY_ID_CONST = (0x05<<1),
|
23
|
+
RUBY_ID_CLASS = (0x06<<1),
|
24
|
+
RUBY_ID_JUNK = (0x07<<1),
|
24
25
|
RUBY_ID_INTERNAL = RUBY_ID_JUNK,
|
25
|
-
RUBY_ID_SCOPE_SHIFT =
|
26
|
-
RUBY_ID_SCOPE_MASK = ~(~0U<<RUBY_ID_SCOPE_SHIFT)
|
26
|
+
RUBY_ID_SCOPE_SHIFT = 4,
|
27
|
+
RUBY_ID_SCOPE_MASK = (~(~0U<<(RUBY_ID_SCOPE_SHIFT-1))<<1)
|
27
28
|
};
|
28
29
|
|
30
|
+
#define ID_STATIC_SYM RUBY_ID_STATIC_SYM
|
29
31
|
#define ID_SCOPE_SHIFT RUBY_ID_SCOPE_SHIFT
|
30
32
|
#define ID_SCOPE_MASK RUBY_ID_SCOPE_MASK
|
31
33
|
#define ID_LOCAL RUBY_ID_LOCAL
|
@@ -136,7 +138,7 @@ enum ruby_method_ids {
|
|
136
138
|
tInitialize_clone,
|
137
139
|
tInitialize_dup,
|
138
140
|
tUScore,
|
139
|
-
#define TOKEN2LOCALID(n) id##n = ((t##n<<ID_SCOPE_SHIFT)|ID_LOCAL)
|
141
|
+
#define TOKEN2LOCALID(n) id##n = ((t##n<<ID_SCOPE_SHIFT)|ID_LOCAL|ID_STATIC_SYM)
|
140
142
|
TOKEN2LOCALID(Freeze),
|
141
143
|
TOKEN2LOCALID(Inspect),
|
142
144
|
TOKEN2LOCALID(Intern),
|
@@ -40,6 +40,14 @@ extern "C" {
|
|
40
40
|
#define UNINITIALIZED_VAR(x) x
|
41
41
|
#endif
|
42
42
|
|
43
|
+
#if __has_attribute(warn_unused_result)
|
44
|
+
#define WARN_UNUSED_RESULT(x) x __attribute__((warn_unused_result))
|
45
|
+
#elif defined(__GNUC__) && (__GNUC__ * 1000 + __GNUC_MINOR__) >= 3004
|
46
|
+
#define WARN_UNUSED_RESULT(x) x __attribute__((warn_unused_result))
|
47
|
+
#else
|
48
|
+
#define WARN_UNUSED_RESULT(x) x
|
49
|
+
#endif
|
50
|
+
|
43
51
|
#ifdef HAVE_VALGRIND_MEMCHECK_H
|
44
52
|
# include <valgrind/memcheck.h>
|
45
53
|
# ifndef VALGRIND_MAKE_MEM_DEFINED
|
@@ -55,7 +63,8 @@ extern "C" {
|
|
55
63
|
|
56
64
|
#define numberof(array) ((int)(sizeof(array) / sizeof((array)[0])))
|
57
65
|
|
58
|
-
#define
|
66
|
+
#define STATIC_ASSERT_TYPE(name) static_assert_##name##_check
|
67
|
+
#define STATIC_ASSERT(name, expr) typedef int STATIC_ASSERT_TYPE(name)[1 - 2*!(expr)]
|
59
68
|
|
60
69
|
#define GCC_VERSION_SINCE(major, minor, patchlevel) \
|
61
70
|
(defined(__GNUC__) && !defined(__INTEL_COMPILER) && \
|
@@ -308,28 +317,28 @@ struct method_table_wrapper {
|
|
308
317
|
#ifndef BDIGIT
|
309
318
|
# if SIZEOF_INT*2 <= SIZEOF_LONG_LONG
|
310
319
|
# define BDIGIT unsigned int
|
311
|
-
# define
|
320
|
+
# define SIZEOF_BDIGIT SIZEOF_INT
|
312
321
|
# define BDIGIT_DBL unsigned LONG_LONG
|
313
322
|
# define BDIGIT_DBL_SIGNED LONG_LONG
|
314
323
|
# define PRI_BDIGIT_PREFIX ""
|
315
324
|
# define PRI_BDIGIT_DBL_PREFIX PRI_LL_PREFIX
|
316
325
|
# elif SIZEOF_INT*2 <= SIZEOF_LONG
|
317
326
|
# define BDIGIT unsigned int
|
318
|
-
# define
|
327
|
+
# define SIZEOF_BDIGIT SIZEOF_INT
|
319
328
|
# define BDIGIT_DBL unsigned long
|
320
329
|
# define BDIGIT_DBL_SIGNED long
|
321
330
|
# define PRI_BDIGIT_PREFIX ""
|
322
331
|
# define PRI_BDIGIT_DBL_PREFIX "l"
|
323
332
|
# elif SIZEOF_SHORT*2 <= SIZEOF_LONG
|
324
333
|
# define BDIGIT unsigned short
|
325
|
-
# define
|
334
|
+
# define SIZEOF_BDIGIT SIZEOF_SHORT
|
326
335
|
# define BDIGIT_DBL unsigned long
|
327
336
|
# define BDIGIT_DBL_SIGNED long
|
328
337
|
# define PRI_BDIGIT_PREFIX "h"
|
329
338
|
# define PRI_BDIGIT_DBL_PREFIX "l"
|
330
339
|
# else
|
331
340
|
# define BDIGIT unsigned short
|
332
|
-
# define
|
341
|
+
# define SIZEOF_BDIGIT (SIZEOF_LONG/2)
|
333
342
|
# define SIZEOF_ACTUAL_BDIGIT SIZEOF_LONG
|
334
343
|
# define BDIGIT_DBL unsigned long
|
335
344
|
# define BDIGIT_DBL_SIGNED long
|
@@ -338,7 +347,7 @@ struct method_table_wrapper {
|
|
338
347
|
# endif
|
339
348
|
#endif
|
340
349
|
#ifndef SIZEOF_ACTUAL_BDIGIT
|
341
|
-
# define SIZEOF_ACTUAL_BDIGIT
|
350
|
+
# define SIZEOF_ACTUAL_BDIGIT SIZEOF_BDIGIT
|
342
351
|
#endif
|
343
352
|
|
344
353
|
#ifdef PRI_BDIGIT_PREFIX
|
@@ -372,7 +381,7 @@ struct RBignum {
|
|
372
381
|
struct RBasic basic;
|
373
382
|
union {
|
374
383
|
struct {
|
375
|
-
|
384
|
+
size_t len;
|
376
385
|
BDIGIT *digits;
|
377
386
|
} heap;
|
378
387
|
BDIGIT ary[BIGNUM_EMBED_LEN_MAX];
|
@@ -404,6 +413,54 @@ struct RBignum {
|
|
404
413
|
|
405
414
|
#define RBIGNUM(obj) (R_CAST(RBignum)(obj))
|
406
415
|
|
416
|
+
struct RRational {
|
417
|
+
struct RBasic basic;
|
418
|
+
const VALUE num;
|
419
|
+
const VALUE den;
|
420
|
+
};
|
421
|
+
|
422
|
+
#define RRATIONAL(obj) (R_CAST(RRational)(obj))
|
423
|
+
|
424
|
+
struct RFloat {
|
425
|
+
struct RBasic basic;
|
426
|
+
double float_value;
|
427
|
+
};
|
428
|
+
|
429
|
+
#define RFLOAT(obj) (R_CAST(RFloat)(obj))
|
430
|
+
|
431
|
+
struct RComplex {
|
432
|
+
struct RBasic basic;
|
433
|
+
const VALUE real;
|
434
|
+
const VALUE imag;
|
435
|
+
};
|
436
|
+
|
437
|
+
#define RCOMPLEX(obj) (R_CAST(RComplex)(obj))
|
438
|
+
|
439
|
+
#ifdef RCOMPLEX_SET_REAL /* shortcut macro for internal only */
|
440
|
+
#undef RCOMPLEX_SET_REAL
|
441
|
+
#undef RCOMPLEX_SET_REAL
|
442
|
+
#define RCOMPLEX_SET_REAL(cmp, r) RB_OBJ_WRITE((cmp), &((struct RComplex *)(cmp))->real,(r))
|
443
|
+
#define RCOMPLEX_SET_IMAG(cmp, i) RB_OBJ_WRITE((cmp), &((struct RComplex *)(cmp))->imag,(i))
|
444
|
+
#endif
|
445
|
+
|
446
|
+
struct RHash {
|
447
|
+
struct RBasic basic;
|
448
|
+
struct st_table *ntbl; /* possibly 0 */
|
449
|
+
int iter_lev;
|
450
|
+
const VALUE ifnone;
|
451
|
+
};
|
452
|
+
|
453
|
+
#define RHASH(obj) (R_CAST(RHash)(obj))
|
454
|
+
|
455
|
+
#ifdef RHASH_ITER_LEV
|
456
|
+
#undef RHASH_ITER_LEV
|
457
|
+
#undef RHASH_IFNONE
|
458
|
+
#undef RHASH_SIZE
|
459
|
+
#define RHASH_ITER_LEV(h) (RHASH(h)->iter_lev)
|
460
|
+
#define RHASH_IFNONE(h) (RHASH(h)->ifnone)
|
461
|
+
#define RHASH_SIZE(h) (RHASH(h)->ntbl ? (st_index_t)RHASH(h)->ntbl->num_entries : 0)
|
462
|
+
#endif
|
463
|
+
|
407
464
|
/* class.c */
|
408
465
|
void rb_class_subclass_add(VALUE super, VALUE klass);
|
409
466
|
void rb_class_remove_from_super_subclasses(VALUE);
|
@@ -449,9 +506,21 @@ RCLASS_SET_SUPER(VALUE klass, VALUE super)
|
|
449
506
|
struct vtm; /* defined by timev.h */
|
450
507
|
|
451
508
|
/* array.c */
|
452
|
-
VALUE rb_ary_last(int, VALUE *, VALUE);
|
509
|
+
VALUE rb_ary_last(int, const VALUE *, VALUE);
|
453
510
|
void rb_ary_set_len(VALUE, long);
|
454
511
|
void rb_ary_delete_same(VALUE, VALUE);
|
512
|
+
VALUE rb_ary_tmp_new_fill(long capa);
|
513
|
+
#ifdef __GNUC__
|
514
|
+
#define rb_ary_new_from_args(n, ...) \
|
515
|
+
__extension__ ({ \
|
516
|
+
const VALUE args_to_new_ary[] = {__VA_ARGS__}; \
|
517
|
+
if (__builtin_constant_p(n)) { \
|
518
|
+
STATIC_ASSERT(rb_ary_new_from_args, numberof(args_to_new_ary) == (n)); \
|
519
|
+
(void)sizeof(STATIC_ASSERT_TYPE(rb_ary_new_from_args)); /* suppress warnings by gcc 4.8 or later */ \
|
520
|
+
} \
|
521
|
+
rb_ary_new_from_values(numberof(args_to_new_ary), args_to_new_ary); \
|
522
|
+
})
|
523
|
+
#endif
|
455
524
|
|
456
525
|
/* bignum.c */
|
457
526
|
VALUE rb_big_fdiv(VALUE x, VALUE y);
|
@@ -464,10 +533,10 @@ void rb_class_foreach_subclass(VALUE klass, void(*f)(VALUE));
|
|
464
533
|
void rb_class_detach_subclasses(VALUE);
|
465
534
|
void rb_class_detach_module_subclasses(VALUE);
|
466
535
|
void rb_class_remove_from_module_subclasses(VALUE);
|
467
|
-
VALUE rb_obj_methods(int argc, VALUE *argv, VALUE obj);
|
468
|
-
VALUE rb_obj_protected_methods(int argc, VALUE *argv, VALUE obj);
|
469
|
-
VALUE rb_obj_private_methods(int argc, VALUE *argv, VALUE obj);
|
470
|
-
VALUE rb_obj_public_methods(int argc, VALUE *argv, VALUE obj);
|
536
|
+
VALUE rb_obj_methods(int argc, const VALUE *argv, VALUE obj);
|
537
|
+
VALUE rb_obj_protected_methods(int argc, const VALUE *argv, VALUE obj);
|
538
|
+
VALUE rb_obj_private_methods(int argc, const VALUE *argv, VALUE obj);
|
539
|
+
VALUE rb_obj_public_methods(int argc, const VALUE *argv, VALUE obj);
|
471
540
|
int rb_obj_basic_to_s_p(VALUE);
|
472
541
|
VALUE rb_special_singleton_class(VALUE);
|
473
542
|
VALUE rb_singleton_class_clone_and_attach(VALUE obj, VALUE attach);
|
@@ -576,7 +645,11 @@ void Init_heap(void);
|
|
576
645
|
void *ruby_mimmalloc(size_t size);
|
577
646
|
void ruby_mimfree(void *ptr);
|
578
647
|
void rb_objspace_set_event_hook(const rb_event_flag_t event);
|
579
|
-
|
648
|
+
#if USE_RGENGC
|
649
|
+
void rb_gc_writebarrier_remember(VALUE obj);
|
650
|
+
#else
|
651
|
+
#define rb_gc_writebarrier_remember(obj) 0
|
652
|
+
#endif
|
580
653
|
void ruby_gc_set_params(int safe_level);
|
581
654
|
|
582
655
|
#if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE) || defined(_WIN32)
|
@@ -595,7 +668,10 @@ void rb_gc_resurrect(VALUE ptr);
|
|
595
668
|
|
596
669
|
/* hash.c */
|
597
670
|
struct st_table *rb_hash_tbl_raw(VALUE hash);
|
671
|
+
VALUE rb_hash_has_key(VALUE hash, VALUE key);
|
672
|
+
|
598
673
|
#define RHASH_TBL_RAW(h) rb_hash_tbl_raw(h)
|
674
|
+
VALUE rb_hash_keys(VALUE hash);
|
599
675
|
VALUE rb_hash_values(VALUE hash);
|
600
676
|
#define HASH_DELETED FL_USER1
|
601
677
|
#define HASH_PROC_DEFAULT FL_USER2
|
@@ -632,10 +708,12 @@ VALUE rb_math_cos(VALUE);
|
|
632
708
|
VALUE rb_math_cosh(VALUE);
|
633
709
|
VALUE rb_math_exp(VALUE);
|
634
710
|
VALUE rb_math_hypot(VALUE, VALUE);
|
635
|
-
VALUE rb_math_log(int argc, VALUE *argv);
|
711
|
+
VALUE rb_math_log(int argc, const VALUE *argv);
|
636
712
|
VALUE rb_math_sin(VALUE);
|
637
713
|
VALUE rb_math_sinh(VALUE);
|
714
|
+
#if 0
|
638
715
|
VALUE rb_math_sqrt(VALUE);
|
716
|
+
#endif
|
639
717
|
|
640
718
|
/* newline.c */
|
641
719
|
void Init_newline(void);
|
@@ -714,7 +792,9 @@ rb_float_new_inline(double d)
|
|
714
792
|
#define rb_float_new(d) rb_float_new_inline(d)
|
715
793
|
|
716
794
|
/* object.c */
|
795
|
+
void rb_obj_copy_ivar(VALUE dest, VALUE obj);
|
717
796
|
VALUE rb_obj_equal(VALUE obj1, VALUE obj2);
|
797
|
+
VALUE rb_class_search_ancestor(VALUE klass, VALUE super);
|
718
798
|
|
719
799
|
struct RBasicRaw {
|
720
800
|
VALUE flags;
|
@@ -729,6 +809,9 @@ struct RBasicRaw {
|
|
729
809
|
} while (0)
|
730
810
|
|
731
811
|
/* parse.y */
|
812
|
+
#ifndef USE_SYMBOL_GC
|
813
|
+
#define USE_SYMBOL_GC 1
|
814
|
+
#endif
|
732
815
|
VALUE rb_parser_get_yydebug(VALUE);
|
733
816
|
VALUE rb_parser_set_yydebug(VALUE, VALUE);
|
734
817
|
int rb_is_const_name(VALUE name);
|
@@ -739,14 +822,15 @@ int rb_is_attrset_name(VALUE name);
|
|
739
822
|
int rb_is_local_name(VALUE name);
|
740
823
|
int rb_is_method_name(VALUE name);
|
741
824
|
int rb_is_junk_name(VALUE name);
|
742
|
-
void rb_gc_mark_parser(void);
|
743
|
-
void rb_gc_mark_symbols(int full_mark);
|
744
825
|
ID rb_make_internal_id(void);
|
826
|
+
void rb_gc_free_dsymbol(VALUE);
|
827
|
+
ID rb_id_attrget(ID id);
|
745
828
|
|
746
829
|
/* proc.c */
|
747
830
|
VALUE rb_proc_location(VALUE self);
|
748
831
|
st_index_t rb_hash_proc(st_index_t hash, VALUE proc);
|
749
832
|
int rb_block_arity(void);
|
833
|
+
VALUE rb_block_clear_env_self(VALUE proc);
|
750
834
|
|
751
835
|
/* process.c */
|
752
836
|
#define RB_MAX_GROUPS (65536)
|
@@ -810,6 +894,8 @@ VALUE rb_rational_reciprocal(VALUE x);
|
|
810
894
|
/* re.c */
|
811
895
|
VALUE rb_reg_compile(VALUE str, int options, const char *sourcefile, int sourceline);
|
812
896
|
VALUE rb_reg_check_preprocess(VALUE);
|
897
|
+
long rb_reg_search0(VALUE, VALUE, long, int, int);
|
898
|
+
void rb_backref_set_string(VALUE string, long pos, long len);
|
813
899
|
|
814
900
|
/* signal.c */
|
815
901
|
int rb_get_next_signal(void);
|
@@ -824,7 +910,9 @@ size_t rb_strftime(char *s, size_t maxsize, const char *format, rb_encoding *enc
|
|
824
910
|
#endif
|
825
911
|
|
826
912
|
/* string.c */
|
913
|
+
void Init_frozen_strings(void);
|
827
914
|
VALUE rb_fstring(VALUE);
|
915
|
+
VALUE rb_fstring_new(const char *ptr, long len);
|
828
916
|
int rb_str_buf_cat_escaped_char(VALUE result, unsigned int c, int unicode_p);
|
829
917
|
int rb_str_symname_p(VALUE);
|
830
918
|
VALUE rb_str_quote_unprintable(VALUE);
|
@@ -874,6 +962,7 @@ rb_serial_t rb_next_class_serial(void);
|
|
874
962
|
VALUE rb_obj_is_thread(VALUE obj);
|
875
963
|
void rb_vm_mark(void *ptr);
|
876
964
|
void Init_BareVM(void);
|
965
|
+
void Init_vm_objects(void);
|
877
966
|
VALUE rb_vm_top_self(void);
|
878
967
|
void rb_thread_recycle_stack_release(VALUE *);
|
879
968
|
void rb_vm_change_state(void);
|
@@ -884,7 +973,6 @@ VALUE rb_sourcefilename(void);
|
|
884
973
|
void rb_vm_pop_cfunc_frame(void);
|
885
974
|
|
886
975
|
/* vm_dump.c */
|
887
|
-
void rb_vm_bugreport(void);
|
888
976
|
void rb_print_backtrace(void);
|
889
977
|
|
890
978
|
/* vm_eval.c */
|
@@ -910,8 +998,8 @@ void Init_prelude(void);
|
|
910
998
|
|
911
999
|
/* vm_backtrace.c */
|
912
1000
|
void Init_vm_backtrace(void);
|
913
|
-
VALUE rb_vm_thread_backtrace(int argc, VALUE *argv, VALUE thval);
|
914
|
-
VALUE rb_vm_thread_backtrace_locations(int argc, VALUE *argv, VALUE thval);
|
1001
|
+
VALUE rb_vm_thread_backtrace(int argc, const VALUE *argv, VALUE thval);
|
1002
|
+
VALUE rb_vm_thread_backtrace_locations(int argc, const VALUE *argv, VALUE thval);
|
915
1003
|
|
916
1004
|
VALUE rb_make_backtrace(void);
|
917
1005
|
void rb_backtrace_print_as_bugreport(void);
|
@@ -963,9 +1051,9 @@ VALUE rb_int_positive_pow(long x, unsigned long y);
|
|
963
1051
|
/* process.c */
|
964
1052
|
int rb_exec_async_signal_safe(const struct rb_execarg *e, char *errmsg, size_t errmsg_buflen);
|
965
1053
|
rb_pid_t rb_fork_async_signal_safe(int *status, int (*chfunc)(void*, char *, size_t), void *charg, VALUE fds, char *errmsg, size_t errmsg_buflen);
|
966
|
-
VALUE rb_execarg_new(int argc, VALUE *argv, int accept_shell);
|
1054
|
+
VALUE rb_execarg_new(int argc, const VALUE *argv, int accept_shell);
|
967
1055
|
struct rb_execarg *rb_execarg_get(VALUE execarg_obj); /* dangerous. needs GC guard. */
|
968
|
-
VALUE rb_execarg_init(int argc, VALUE *argv, int accept_shell, VALUE execarg_obj);
|
1056
|
+
VALUE rb_execarg_init(int argc, const VALUE *argv, int accept_shell, VALUE execarg_obj);
|
969
1057
|
int rb_execarg_addopt(VALUE execarg_obj, VALUE key, VALUE val);
|
970
1058
|
void rb_execarg_fixup(VALUE execarg_obj);
|
971
1059
|
int rb_execarg_run_options(const struct rb_execarg *e, struct rb_execarg *s, char* errmsg, size_t errmsg_buflen);
|
@@ -978,6 +1066,12 @@ VALUE rb_gcd_normal(VALUE self, VALUE other);
|
|
978
1066
|
VALUE rb_gcd_gmp(VALUE x, VALUE y);
|
979
1067
|
#endif
|
980
1068
|
|
1069
|
+
/* string.c */
|
1070
|
+
#ifdef RUBY_ENCODING_H
|
1071
|
+
/* internal use */
|
1072
|
+
VALUE rb_setup_fake_str(struct RString *fake_str, const char *name, long len, rb_encoding *enc);
|
1073
|
+
#endif
|
1074
|
+
|
981
1075
|
/* util.c */
|
982
1076
|
extern const signed char ruby_digit36_to_number_table[];
|
983
1077
|
|
@@ -993,6 +1087,7 @@ st_table *rb_st_copy(VALUE obj, struct st_table *orig_tbl);
|
|
993
1087
|
size_t rb_obj_memsize_of(VALUE);
|
994
1088
|
#define RB_OBJ_GC_FLAGS_MAX 5
|
995
1089
|
size_t rb_obj_gc_flags(VALUE, ID[], size_t);
|
1090
|
+
void rb_gc_mark_values(long n, const VALUE *values);
|
996
1091
|
|
997
1092
|
RUBY_SYMBOL_EXPORT_END
|
998
1093
|
|