looksee 4.4.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 600194bca92f1417cef56f15fb778bf97169424c779269d16dc87afde159013b
4
- data.tar.gz: a9548afb11a7e6ebbe7fa43d7155d6258871530d135197f93ed79573d899432a
3
+ metadata.gz: 48ef0a2047045795c76025fd0544aaa9c2c2545903cad6c944fffcfcb2ee75d0
4
+ data.tar.gz: 23493fa986e3b3eb584db4d50d921aa036ee260dc69a6a87f03fe194aed4c26a
5
5
  SHA512:
6
- metadata.gz: '08f3978dbed48efa7daaba8fe778b9dfdf3032748dc2cdfd9ac5d36667bfd2ea7eff4b3662d660f97784d99459d082c0228c188bd2b3261e3ed5935d06a45460'
7
- data.tar.gz: ec4dbddc1ca894b843d0ad187ea4ce35a4a1c6890a920790479d01e35ccb81f19bf321dff7001060d5f3280dd312d27b7c74494a756fad02613ad30b96dcae86
6
+ metadata.gz: 3e286370942fed7ed9b420e5448639a1a7a3903afcb092d6777f974632ba78c347fc146f95b0dd0b9bb215743d94a498a7402ee17a84d95bcfb4638da14efb6f
7
+ data.tar.gz: e96734ae3281967a23a13c287c39e1ea2469782348886936ba63827de8cdbeb2e0fa0a0698658351078f31accb6efeabcc3152eab71917b5412602056c9f0055
data/CHANGELOG CHANGED
@@ -1,3 +1,14 @@
1
+ == 5.0.0 2022-11-08
2
+
3
+ * Rename #ls to #look. Sorry! irb now defines an ls built-in, though, and the
4
+ old name emits a warning on startup.
5
+ * Support for MRI 3.2.0 preview2. From 3.2 onwards, we once again display
6
+ undef'd methods.
7
+ * Remove support for MRI < 2.7. (2.6 is EOL anyway.)
8
+ * Remove support for Rubinius.
9
+ * Fix showing modules included in singleton classes with no direct methods.
10
+ * Fix ANSI color escaping in ruby >= 3.0.
11
+
1
12
  == 4.4.0 2021-01-17
2
13
 
3
14
  * Support for MRI 3.0. [Mathieu Jobin]
data/Rakefile CHANGED
@@ -11,3 +11,30 @@ end
11
11
  task :default => [:clobber, :ext] do
12
12
  sh 'bundle exec rspec -I. spec'
13
13
  end
14
+
15
+ task :test_all do
16
+ docker_configs.each do |config|
17
+ docker_run(config, 'rspec')
18
+ end
19
+ end
20
+
21
+ task :console, :config do |task, args|
22
+ docker_run(args[:config], nil)
23
+ end
24
+
25
+ task :test, :config do |task, args|
26
+ docker_run(args[:config], 'rspec')
27
+ end
28
+
29
+ task :shell, :config do |task, args|
30
+ docker_run(args[:config], '/bin/bash')
31
+ end
32
+
33
+ def docker_configs
34
+ Dir['Dockerfile.*'].map { |path| path[/(?<=\.).*?\z/] }
35
+ end
36
+
37
+ def docker_run(config, command)
38
+ sh "docker build -f Dockerfile.#{config} -t looksee:#{config} ."
39
+ sh "docker run -it looksee:#{config} #{command}"
40
+ end
data/ext/extconf.rb CHANGED
@@ -4,16 +4,13 @@ extension = ruby_engine == 'ruby' ? 'mri' : ruby_engine
4
4
  require 'mkmf'
5
5
  $CPPFLAGS << " -DRUBY_VERSION=#{RUBY_VERSION.tr('.', '')}"
6
6
  if extension == 'mri'
7
- if RUBY_VERSION >= '3.0.0'
7
+ if RUBY_VERSION >= '3.2.0'
8
+ $CPPFLAGS << " -Imri/3.2.0"
9
+ elsif RUBY_VERSION >= '3.0.0'
8
10
  $CPPFLAGS << " -Imri/3.0.0"
9
- elsif RUBY_VERSION >= '2.7.0'
11
+ else
10
12
  $CPPFLAGS << " -Imri/2.7.0"
11
- elsif RUBY_VERSION >= '2.3.0'
12
- $CPPFLAGS << " -Imri/2.3.0"
13
- elsif RUBY_VERSION >= '2.2.0'
14
- $CPPFLAGS << " -Imri/2.2.0"
15
- elsif RUBY_VERSION >= '2.1.0'
16
- $CPPFLAGS << " -Imri/2.1.0"
17
13
  end
18
14
  end
15
+
19
16
  create_makefile "looksee/#{extension}", extension
@@ -0,0 +1,36 @@
1
+ #ifndef RUBY_ID_TABLE_H
2
+ #define RUBY_ID_TABLE_H 1
3
+ #include "ruby/internal/config.h"
4
+ #include <stddef.h>
5
+ #include "ruby/ruby.h"
6
+
7
+ struct rb_id_table;
8
+
9
+ /* compatible with ST_* */
10
+ enum rb_id_table_iterator_result {
11
+ ID_TABLE_CONTINUE = ST_CONTINUE,
12
+ ID_TABLE_STOP = ST_STOP,
13
+ ID_TABLE_DELETE = ST_DELETE,
14
+ ID_TABLE_REPLACE = ST_REPLACE,
15
+ ID_TABLE_ITERATOR_RESULT_END
16
+ };
17
+
18
+ struct rb_id_table *rb_id_table_create(size_t size);
19
+ void rb_id_table_free(struct rb_id_table *tbl);
20
+ void rb_id_table_clear(struct rb_id_table *tbl);
21
+
22
+ size_t rb_id_table_size(const struct rb_id_table *tbl);
23
+ size_t rb_id_table_memsize(const struct rb_id_table *tbl);
24
+
25
+ int rb_id_table_insert(struct rb_id_table *tbl, ID id, VALUE val);
26
+ int rb_id_table_lookup(struct rb_id_table *tbl, ID id, VALUE *valp);
27
+ int rb_id_table_delete(struct rb_id_table *tbl, ID id);
28
+
29
+ typedef enum rb_id_table_iterator_result rb_id_table_update_value_callback_func_t(VALUE *val, void *data, int existing);
30
+ typedef enum rb_id_table_iterator_result rb_id_table_foreach_func_t(ID id, VALUE val, void *data);
31
+ typedef enum rb_id_table_iterator_result rb_id_table_foreach_values_func_t(VALUE val, void *data);
32
+ void rb_id_table_foreach(struct rb_id_table *tbl, rb_id_table_foreach_func_t *func, void *data);
33
+ void rb_id_table_foreach_values(struct rb_id_table *tbl, rb_id_table_foreach_values_func_t *func, void *data);
34
+ void rb_id_table_foreach_values_with_replace(struct rb_id_table *tbl, rb_id_table_foreach_values_func_t *func, rb_id_table_update_value_callback_func_t *replace, void *data);
35
+
36
+ #endif /* RUBY_ID_TABLE_H */
@@ -0,0 +1,162 @@
1
+ #ifndef INTERNAL_ARRAY_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_ARRAY_H
3
+ /**
4
+ * @author Ruby developers <ruby-core@ruby-lang.org>
5
+ * @copyright This file is a part of the programming language Ruby.
6
+ * Permission is hereby granted, to either redistribute and/or
7
+ * modify this file, provided that the conditions mentioned in the
8
+ * file COPYING are met. Consult the file for details.
9
+ * @brief Internal header for Array.
10
+ */
11
+ #include "ruby/internal/config.h"
12
+ #include <stddef.h> /* for size_t */
13
+ #include "internal/static_assert.h" /* for STATIC_ASSERT */
14
+ #include "ruby/internal/stdbool.h" /* for bool */
15
+ #include "ruby/ruby.h" /* for RARRAY_LEN */
16
+
17
+ #ifndef ARRAY_DEBUG
18
+ # define ARRAY_DEBUG (0+RUBY_DEBUG)
19
+ #endif
20
+
21
+ #define RARRAY_SHARED_FLAG ELTS_SHARED
22
+ #define RARRAY_SHARED_ROOT_FLAG FL_USER12
23
+ #define RARRAY_PTR_IN_USE_FLAG FL_USER14
24
+
25
+ /* array.c */
26
+ VALUE rb_ary_last(int, const VALUE *, VALUE);
27
+ void rb_ary_set_len(VALUE, long);
28
+ void rb_ary_delete_same(VALUE, VALUE);
29
+ VALUE rb_ary_hidden_new_fill(long capa);
30
+ VALUE rb_ary_at(VALUE, VALUE);
31
+ size_t rb_ary_memsize(VALUE);
32
+ VALUE rb_to_array_type(VALUE obj);
33
+ VALUE rb_to_array(VALUE obj);
34
+ void rb_ary_cancel_sharing(VALUE ary);
35
+ size_t rb_ary_size_as_embedded(VALUE ary);
36
+ void rb_ary_make_embedded(VALUE ary);
37
+ bool rb_ary_embeddable_p(VALUE ary);
38
+
39
+ static inline VALUE rb_ary_entry_internal(VALUE ary, long offset);
40
+ static inline bool ARY_PTR_USING_P(VALUE ary);
41
+ static inline void RARY_TRANSIENT_SET(VALUE ary);
42
+ static inline void RARY_TRANSIENT_UNSET(VALUE ary);
43
+
44
+ MJIT_SYMBOL_EXPORT_BEGIN
45
+ VALUE rb_ary_tmp_new_from_values(VALUE, long, const VALUE *);
46
+ VALUE rb_check_to_array(VALUE ary);
47
+ VALUE rb_ary_behead(VALUE, long);
48
+ VALUE rb_ary_aref1(VALUE ary, VALUE i);
49
+
50
+ struct rb_execution_context_struct;
51
+ VALUE rb_ec_ary_new_from_values(struct rb_execution_context_struct *ec, long n, const VALUE *elts);
52
+ MJIT_SYMBOL_EXPORT_END
53
+
54
+ // YJIT needs this function to never allocate and never raise
55
+ static inline VALUE
56
+ rb_ary_entry_internal(VALUE ary, long offset)
57
+ {
58
+ long len = RARRAY_LEN(ary);
59
+ const VALUE *ptr = RARRAY_CONST_PTR_TRANSIENT(ary);
60
+ if (len == 0) return Qnil;
61
+ if (offset < 0) {
62
+ offset += len;
63
+ if (offset < 0) return Qnil;
64
+ }
65
+ else if (len <= offset) {
66
+ return Qnil;
67
+ }
68
+ return ptr[offset];
69
+ }
70
+
71
+ static inline bool
72
+ ARY_PTR_USING_P(VALUE ary)
73
+ {
74
+ return FL_TEST_RAW(ary, RARRAY_PTR_IN_USE_FLAG);
75
+ }
76
+
77
+ RBIMPL_ATTR_MAYBE_UNUSED()
78
+ static inline int
79
+ ary_should_not_be_shared_and_embedded(VALUE ary)
80
+ {
81
+ return !FL_ALL_RAW(ary, RARRAY_SHARED_FLAG|RARRAY_EMBED_FLAG);
82
+ }
83
+
84
+ static inline bool
85
+ ARY_SHARED_P(VALUE ary)
86
+ {
87
+ assert(RB_TYPE_P(ary, T_ARRAY));
88
+ assert(ary_should_not_be_shared_and_embedded(ary));
89
+ return FL_TEST_RAW(ary, RARRAY_SHARED_FLAG);
90
+ }
91
+
92
+ static inline bool
93
+ ARY_EMBED_P(VALUE ary)
94
+ {
95
+ assert(RB_TYPE_P(ary, T_ARRAY));
96
+ assert(ary_should_not_be_shared_and_embedded(ary));
97
+ return FL_TEST_RAW(ary, RARRAY_EMBED_FLAG);
98
+ }
99
+
100
+ static inline VALUE
101
+ ARY_SHARED_ROOT(VALUE ary)
102
+ {
103
+ assert(ARY_SHARED_P(ary));
104
+ return RARRAY(ary)->as.heap.aux.shared_root;
105
+ }
106
+
107
+ static inline bool
108
+ ARY_SHARED_ROOT_P(VALUE ary)
109
+ {
110
+ assert(RB_TYPE_P(ary, T_ARRAY));
111
+ return FL_TEST_RAW(ary, RARRAY_SHARED_ROOT_FLAG);
112
+ }
113
+
114
+ static inline long
115
+ ARY_SHARED_ROOT_REFCNT(VALUE ary)
116
+ {
117
+ assert(ARY_SHARED_ROOT_P(ary));
118
+ return RARRAY(ary)->as.heap.aux.capa;
119
+ }
120
+
121
+ static inline void
122
+ RARY_TRANSIENT_SET(VALUE ary)
123
+ {
124
+ #if USE_TRANSIENT_HEAP
125
+ FL_SET_RAW(ary, RARRAY_TRANSIENT_FLAG);
126
+ #endif
127
+ }
128
+
129
+ static inline void
130
+ RARY_TRANSIENT_UNSET(VALUE ary)
131
+ {
132
+ #if USE_TRANSIENT_HEAP
133
+ FL_UNSET_RAW(ary, RARRAY_TRANSIENT_FLAG);
134
+ #endif
135
+ }
136
+
137
+ #undef rb_ary_new_from_args
138
+ #if RBIMPL_HAS_WARNING("-Wgnu-zero-variadic-macro-arguments")
139
+ # /* Skip it; clang -pedantic doesn't like the following */
140
+ #elif defined(__GNUC__) && defined(HAVE_VA_ARGS_MACRO)
141
+ #define rb_ary_new_from_args(n, ...) \
142
+ __extension__ ({ \
143
+ const VALUE args_to_new_ary[] = {__VA_ARGS__}; \
144
+ if (__builtin_constant_p(n)) { \
145
+ STATIC_ASSERT(rb_ary_new_from_args, numberof(args_to_new_ary) == (n)); \
146
+ } \
147
+ rb_ary_new_from_values(numberof(args_to_new_ary), args_to_new_ary); \
148
+ })
149
+ #endif
150
+
151
+ #undef RARRAY_AREF
152
+ RBIMPL_ATTR_PURE_UNLESS_DEBUG()
153
+ RBIMPL_ATTR_ARTIFICIAL()
154
+ static inline VALUE
155
+ RARRAY_AREF(VALUE ary, long i)
156
+ {
157
+ RBIMPL_ASSERT_TYPE(ary, RUBY_T_ARRAY);
158
+
159
+ return RARRAY_CONST_PTR_TRANSIENT(ary)[i];
160
+ }
161
+
162
+ #endif /* INTERNAL_ARRAY_H */
@@ -0,0 +1,212 @@
1
+ #ifndef INTERNAL_CLASS_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_CLASS_H
3
+ /**
4
+ * @author Ruby developers <ruby-core@ruby-lang.org>
5
+ * @copyright This file is a part of the programming language Ruby.
6
+ * Permission is hereby granted, to either redistribute and/or
7
+ * modify this file, provided that the conditions mentioned in the
8
+ * file COPYING are met. Consult the file for details.
9
+ * @brief Internal header for Class.
10
+ */
11
+ #include "id_table.h" /* for struct rb_id_table */
12
+ #include "internal/gc.h" /* for RB_OBJ_WRITE */
13
+ #include "internal/serial.h" /* for rb_serial_t */
14
+ #include "ruby/internal/stdbool.h" /* for bool */
15
+ #include "ruby/intern.h" /* for rb_alloc_func_t */
16
+ #include "ruby/ruby.h" /* for struct RBasic */
17
+
18
+ #ifdef RCLASS_SUPER
19
+ # undef RCLASS_SUPER
20
+ #endif
21
+
22
+ struct rb_subclass_entry {
23
+ VALUE klass;
24
+ struct rb_subclass_entry *next;
25
+ struct rb_subclass_entry *prev;
26
+ };
27
+
28
+ struct rb_iv_index_tbl_entry {
29
+ uint32_t index;
30
+ rb_serial_t class_serial;
31
+ VALUE class_value;
32
+ };
33
+
34
+ struct rb_cvar_class_tbl_entry {
35
+ uint32_t index;
36
+ rb_serial_t global_cvar_state;
37
+ VALUE class_value;
38
+ };
39
+
40
+ struct rb_classext_struct {
41
+ struct st_table *iv_index_tbl; // ID -> struct rb_iv_index_tbl_entry
42
+ struct st_table *iv_tbl;
43
+ #if SIZEOF_SERIAL_T == SIZEOF_VALUE /* otherwise m_tbl is in struct RClass */
44
+ struct rb_id_table *m_tbl;
45
+ #endif
46
+ struct rb_id_table *const_tbl;
47
+ struct rb_id_table *callable_m_tbl;
48
+ struct rb_id_table *cc_tbl; /* ID -> [[ci, cc1], cc2, ...] */
49
+ struct rb_id_table *cvc_tbl;
50
+ size_t superclass_depth;
51
+ VALUE *superclasses;
52
+ struct rb_subclass_entry *subclasses;
53
+ struct rb_subclass_entry *subclass_entry;
54
+ /**
55
+ * In the case that this is an `ICLASS`, `module_subclasses` points to the link
56
+ * in the module's `subclasses` list that indicates that the klass has been
57
+ * included. Hopefully that makes sense.
58
+ */
59
+ struct rb_subclass_entry *module_subclass_entry;
60
+ #if SIZEOF_SERIAL_T != SIZEOF_VALUE && !USE_RVARGC /* otherwise class_serial is in struct RClass */
61
+ rb_serial_t class_serial;
62
+ #endif
63
+ const VALUE origin_;
64
+ const VALUE refined_class;
65
+ rb_alloc_func_t allocator;
66
+ const VALUE includer;
67
+ };
68
+
69
+ struct RClass {
70
+ struct RBasic basic;
71
+ VALUE super;
72
+ #if !USE_RVARGC
73
+ struct rb_classext_struct *ptr;
74
+ #endif
75
+ #if SIZEOF_SERIAL_T == SIZEOF_VALUE
76
+ /* Class serial is as wide as VALUE. Place it here. */
77
+ rb_serial_t class_serial;
78
+ #else
79
+ /* Class serial does not fit into struct RClass. Place m_tbl instead. */
80
+ struct rb_id_table *m_tbl;
81
+ # if USE_RVARGC
82
+ rb_serial_t *class_serial_ptr;
83
+ # endif
84
+ #endif
85
+ };
86
+
87
+ typedef struct rb_subclass_entry rb_subclass_entry_t;
88
+ typedef struct rb_classext_struct rb_classext_t;
89
+
90
+ #if USE_RVARGC
91
+ # define RCLASS_EXT(c) ((rb_classext_t *)((char *)(c) + sizeof(struct RClass)))
92
+ #else
93
+ # define RCLASS_EXT(c) (RCLASS(c)->ptr)
94
+ #endif
95
+ #define RCLASS_IV_TBL(c) (RCLASS_EXT(c)->iv_tbl)
96
+ #define RCLASS_CONST_TBL(c) (RCLASS_EXT(c)->const_tbl)
97
+ #if SIZEOF_SERIAL_T == SIZEOF_VALUE
98
+ # define RCLASS_M_TBL(c) (RCLASS_EXT(c)->m_tbl)
99
+ #else
100
+ # define RCLASS_M_TBL(c) (RCLASS(c)->m_tbl)
101
+ #endif
102
+ #define RCLASS_CALLABLE_M_TBL(c) (RCLASS_EXT(c)->callable_m_tbl)
103
+ #define RCLASS_CC_TBL(c) (RCLASS_EXT(c)->cc_tbl)
104
+ #define RCLASS_CVC_TBL(c) (RCLASS_EXT(c)->cvc_tbl)
105
+ #define RCLASS_IV_INDEX_TBL(c) (RCLASS_EXT(c)->iv_index_tbl)
106
+ #define RCLASS_ORIGIN(c) (RCLASS_EXT(c)->origin_)
107
+ #define RCLASS_REFINED_CLASS(c) (RCLASS_EXT(c)->refined_class)
108
+ #if SIZEOF_SERIAL_T == SIZEOF_VALUE
109
+ # define RCLASS_SERIAL(c) (RCLASS(c)->class_serial)
110
+ #else
111
+ # if USE_RVARGC
112
+ # define RCLASS_SERIAL(c) (*RCLASS(c)->class_serial_ptr)
113
+ # else
114
+ # define RCLASS_SERIAL(c) (RCLASS_EXT(c)->class_serial)
115
+ # endif
116
+ #endif
117
+ #define RCLASS_INCLUDER(c) (RCLASS_EXT(c)->includer)
118
+ #define RCLASS_SUBCLASS_ENTRY(c) (RCLASS_EXT(c)->subclass_entry)
119
+ #define RCLASS_MODULE_SUBCLASS_ENTRY(c) (RCLASS_EXT(c)->module_subclass_entry)
120
+ #define RCLASS_ALLOCATOR(c) (RCLASS_EXT(c)->allocator)
121
+ #define RCLASS_SUBCLASSES(c) (RCLASS_EXT(c)->subclasses)
122
+ #define RCLASS_SUPERCLASS_DEPTH(c) (RCLASS_EXT(c)->superclass_depth)
123
+ #define RCLASS_SUPERCLASSES(c) (RCLASS_EXT(c)->superclasses)
124
+
125
+ #define RICLASS_IS_ORIGIN FL_USER0
126
+ #define RCLASS_CLONED FL_USER1
127
+ #define RCLASS_SUPERCLASSES_INCLUDE_SELF FL_USER2
128
+ #define RICLASS_ORIGIN_SHARED_MTBL FL_USER3
129
+
130
+ /* class.c */
131
+ void rb_class_subclass_add(VALUE super, VALUE klass);
132
+ void rb_class_remove_from_super_subclasses(VALUE);
133
+ void rb_class_update_superclasses(VALUE);
134
+ size_t rb_class_superclasses_memsize(VALUE);
135
+ void rb_class_remove_subclass_head(VALUE);
136
+ int rb_singleton_class_internal_p(VALUE sklass);
137
+ VALUE rb_class_boot(VALUE);
138
+ VALUE rb_class_s_alloc(VALUE klass);
139
+ VALUE rb_module_s_alloc(VALUE klass);
140
+ void rb_module_set_initialized(VALUE module);
141
+ void rb_module_check_initializable(VALUE module);
142
+ VALUE rb_make_metaclass(VALUE, VALUE);
143
+ VALUE rb_include_class_new(VALUE, VALUE);
144
+ void rb_class_foreach_subclass(VALUE klass, void (*f)(VALUE, VALUE), VALUE);
145
+ void rb_class_detach_subclasses(VALUE);
146
+ void rb_class_detach_module_subclasses(VALUE);
147
+ void rb_class_remove_from_module_subclasses(VALUE);
148
+ VALUE rb_obj_methods(int argc, const VALUE *argv, VALUE obj);
149
+ VALUE rb_obj_protected_methods(int argc, const VALUE *argv, VALUE obj);
150
+ VALUE rb_obj_private_methods(int argc, const VALUE *argv, VALUE obj);
151
+ VALUE rb_obj_public_methods(int argc, const VALUE *argv, VALUE obj);
152
+ VALUE rb_class_undefined_instance_methods(VALUE mod);
153
+ VALUE rb_special_singleton_class(VALUE);
154
+ VALUE rb_singleton_class_clone_and_attach(VALUE obj, VALUE attach);
155
+ VALUE rb_singleton_class_get(VALUE obj);
156
+ void rb_undef_methods_from(VALUE klass, VALUE super);
157
+
158
+ static inline void RCLASS_SET_ORIGIN(VALUE klass, VALUE origin);
159
+ static inline void RICLASS_SET_ORIGIN_SHARED_MTBL(VALUE iclass);
160
+ static inline VALUE RCLASS_SUPER(VALUE klass);
161
+ static inline VALUE RCLASS_SET_SUPER(VALUE klass, VALUE super);
162
+ static inline void RCLASS_SET_INCLUDER(VALUE iclass, VALUE klass);
163
+
164
+ MJIT_SYMBOL_EXPORT_BEGIN
165
+ VALUE rb_class_inherited(VALUE, VALUE);
166
+ VALUE rb_keyword_error_new(const char *, VALUE);
167
+ MJIT_SYMBOL_EXPORT_END
168
+
169
+ static inline void
170
+ RCLASS_SET_ORIGIN(VALUE klass, VALUE origin)
171
+ {
172
+ RB_OBJ_WRITE(klass, &RCLASS_ORIGIN(klass), origin);
173
+ if (klass != origin) FL_SET(origin, RICLASS_IS_ORIGIN);
174
+ }
175
+
176
+ static inline void
177
+ RICLASS_SET_ORIGIN_SHARED_MTBL(VALUE iclass)
178
+ {
179
+ FL_SET(iclass, RICLASS_ORIGIN_SHARED_MTBL);
180
+ }
181
+
182
+ static inline bool
183
+ RICLASS_OWNS_M_TBL_P(VALUE iclass)
184
+ {
185
+ return FL_TEST_RAW(iclass, RICLASS_IS_ORIGIN | RICLASS_ORIGIN_SHARED_MTBL) == RICLASS_IS_ORIGIN;
186
+ }
187
+
188
+ static inline void
189
+ RCLASS_SET_INCLUDER(VALUE iclass, VALUE klass)
190
+ {
191
+ RB_OBJ_WRITE(iclass, &RCLASS_INCLUDER(iclass), klass);
192
+ }
193
+
194
+ static inline VALUE
195
+ RCLASS_SUPER(VALUE klass)
196
+ {
197
+ return RCLASS(klass)->super;
198
+ }
199
+
200
+ static inline VALUE
201
+ RCLASS_SET_SUPER(VALUE klass, VALUE super)
202
+ {
203
+ if (super) {
204
+ rb_class_remove_from_super_subclasses(klass);
205
+ rb_class_subclass_add(super, klass);
206
+ }
207
+ RB_OBJ_WRITE(klass, &RCLASS(klass)->super, super);
208
+ rb_class_update_superclasses(klass);
209
+ return super;
210
+ }
211
+
212
+ #endif /* INTERNAL_CLASS_H */
@@ -0,0 +1,107 @@
1
+ #ifndef INTERNAL_COMPILERS_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_COMPILERS_H
3
+ /**
4
+ * @author Ruby developers <ruby-core@ruby-lang.org>
5
+ * @copyright This file is a part of the programming language Ruby.
6
+ * Permission is hereby granted, to either redistribute and/or
7
+ * modify this file, provided that the conditions mentioned in the
8
+ * file COPYING are met. Consult the file for details.
9
+ * @brief Internal header absorbing C compiler differences.
10
+ */
11
+ #include "ruby/internal/compiler_since.h"
12
+ #include "ruby/internal/has/attribute.h"
13
+ #include "ruby/internal/has/builtin.h"
14
+ #include "ruby/internal/has/c_attribute.h"
15
+ #include "ruby/internal/has/declspec_attribute.h"
16
+ #include "ruby/internal/has/extension.h"
17
+ #include "ruby/internal/has/feature.h"
18
+ #include "ruby/internal/has/warning.h"
19
+ #include "ruby/backward/2/gcc_version_since.h"
20
+
21
+ #define MSC_VERSION_SINCE(_) RBIMPL_COMPILER_SINCE(MSVC, (_) / 100, (_) % 100, 0)
22
+ #define MSC_VERSION_BEFORE(_) RBIMPL_COMPILER_BEFORE(MSVC, (_) / 100, (_) % 100, 0)
23
+
24
+ #ifndef __has_attribute
25
+ # define __has_attribute(...) RBIMPL_HAS_ATTRIBUTE(__VA_ARGS__)
26
+ #endif
27
+
28
+ #ifndef __has_c_attribute
29
+ # /* As of writing everything that lacks __has_c_attribute also completely
30
+ # * lacks C2x attributes as well. Might change in future? */
31
+ # define __has_c_attribute(...) 0
32
+ #endif
33
+
34
+ #ifndef __has_declspec_attribute
35
+ # define __has_declspec_attribute(...) RBIMPL_HAS_DECLSPEC_ATTRIBUTE(__VA_ARGS__)
36
+ #endif
37
+
38
+ #ifndef __has_builtin
39
+ # define __has_builtin(...) RBIMPL_HAS_BUILTIN(__VA_ARGS__)
40
+ #endif
41
+
42
+ #ifndef __has_feature
43
+ # define __has_feature(...) RBIMPL_HAS_FEATURE(__VA_ARGS__)
44
+ #endif
45
+
46
+ #ifndef __has_extension
47
+ # define __has_extension(...) RBIMPL_HAS_EXTENSION(__VA_ARGS__)
48
+ #endif
49
+
50
+ #ifndef __has_warning
51
+ # define __has_warning(...) RBIMPL_HAS_WARNING(__VA_ARGS__)
52
+ #endif
53
+
54
+ #ifndef __GNUC__
55
+ # define __extension__ /* void */
56
+ #endif
57
+
58
+ #ifndef MAYBE_UNUSED
59
+ # define MAYBE_UNUSED(x) x
60
+ #endif
61
+
62
+ #ifndef WARN_UNUSED_RESULT
63
+ # define WARN_UNUSED_RESULT(x) x
64
+ #endif
65
+
66
+ #define RB_OBJ_BUILTIN_TYPE(obj) rb_obj_builtin_type(obj)
67
+ #define OBJ_BUILTIN_TYPE(obj) RB_OBJ_BUILTIN_TYPE(obj)
68
+ #ifdef __GNUC__
69
+ #define rb_obj_builtin_type(obj) \
70
+ __extension__({ \
71
+ VALUE arg_obj = (obj); \
72
+ RB_SPECIAL_CONST_P(arg_obj) ? -1 : \
73
+ (int)RB_BUILTIN_TYPE(arg_obj); \
74
+ })
75
+ #else
76
+ # include "ruby/ruby.h"
77
+ static inline int
78
+ rb_obj_builtin_type(VALUE obj)
79
+ {
80
+ return RB_SPECIAL_CONST_P(obj) ? -1 :
81
+ (int)RB_BUILTIN_TYPE(obj);
82
+ }
83
+ #endif
84
+
85
+ /* A macro for defining a flexible array, like: VALUE ary[FLEX_ARY_LEN]; */
86
+ #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
87
+ # define FLEX_ARY_LEN /* VALUE ary[]; */
88
+ #elif defined(__GNUC__) && !defined(__STRICT_ANSI__)
89
+ # define FLEX_ARY_LEN 0 /* VALUE ary[0]; */
90
+ #else
91
+ # define FLEX_ARY_LEN 1 /* VALUE ary[1]; */
92
+ #endif
93
+
94
+ /*
95
+ * For declaring bitfields out of non-unsigned int types:
96
+ * struct date {
97
+ * BITFIELD(enum months, month, 4);
98
+ * ...
99
+ * };
100
+ */
101
+ #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
102
+ # define BITFIELD(type, name, size) type name : size
103
+ #else
104
+ # define BITFIELD(type, name, size) unsigned int name : size
105
+ #endif
106
+
107
+ #endif /* INTERNAL_COMPILERS_H */