looksee 4.2.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 +4 -4
- data/CHANGELOG +15 -0
- data/Rakefile +27 -0
- data/ext/extconf.rb +6 -7
- data/ext/mri/3.0.0/id_table.h +36 -0
- data/ext/mri/3.0.0/internal/array.h +119 -0
- data/ext/mri/3.0.0/internal/class.h +174 -0
- data/ext/mri/3.0.0/internal/compilers.h +108 -0
- data/ext/mri/3.0.0/internal/gc.h +161 -0
- data/ext/mri/3.0.0/internal/imemo.h +243 -0
- data/ext/mri/3.0.0/internal/serial.h +24 -0
- data/ext/mri/3.0.0/internal/static_assert.h +17 -0
- data/ext/mri/3.0.0/internal/warnings.h +17 -0
- data/ext/mri/3.0.0/internal.h +107 -0
- data/ext/mri/3.0.0/method.h +246 -0
- data/ext/mri/3.2.0/id_table.h +36 -0
- data/ext/mri/3.2.0/internal/array.h +162 -0
- data/ext/mri/3.2.0/internal/class.h +212 -0
- data/ext/mri/3.2.0/internal/compilers.h +107 -0
- data/ext/mri/3.2.0/internal/gc.h +188 -0
- data/ext/mri/3.2.0/internal/imemo.h +242 -0
- data/ext/mri/3.2.0/internal/serial.h +23 -0
- data/ext/mri/3.2.0/internal/static_assert.h +16 -0
- data/ext/mri/3.2.0/internal/warnings.h +16 -0
- data/ext/mri/3.2.0/internal.h +113 -0
- data/ext/mri/{2.3.0 → 3.2.0}/method.h +95 -55
- data/ext/mri/mri.c +7 -37
- data/lib/looksee/adapter/base.rb +17 -3
- data/lib/looksee/adapter.rb +0 -1
- data/lib/looksee/clean.rb +1 -3
- data/lib/looksee/core_ext.rb +21 -9
- data/lib/looksee/help.rb +2 -2
- data/lib/looksee/inspector.rb +11 -0
- data/lib/looksee/lookup_path.rb +1 -1
- data/lib/looksee/version.rb +1 -1
- data/spec/looksee/adapter_spec.rb +53 -47
- data/spec/looksee/core_ext_spec.rb +2 -2
- data/spec/looksee/inspector_spec.rb +42 -0
- data/spec/looksee/lookup_path_spec.rb +1 -1
- metadata +34 -20
- data/ext/mri/2.1.0/internal.h +0 -889
- data/ext/mri/2.1.0/method.h +0 -142
- data/ext/mri/2.2.0/internal.h +0 -1182
- data/ext/mri/2.2.0/method.h +0 -141
- data/ext/mri/2.3.0/internal.h +0 -1404
- data/ext/rbx/rbx.c +0 -4
- data/lib/looksee/adapter/rubinius.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48ef0a2047045795c76025fd0544aaa9c2c2545903cad6c944fffcfcb2ee75d0
|
4
|
+
data.tar.gz: 23493fa986e3b3eb584db4d50d921aa036ee260dc69a6a87f03fe194aed4c26a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e286370942fed7ed9b420e5448639a1a7a3903afcb092d6777f974632ba78c347fc146f95b0dd0b9bb215743d94a498a7402ee17a84d95bcfb4638da14efb6f
|
7
|
+
data.tar.gz: e96734ae3281967a23a13c287c39e1ea2469782348886936ba63827de8cdbeb2e0fa0a0698658351078f31accb6efeabcc3152eab71917b5412602056c9f0055
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,18 @@
|
|
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
|
+
|
12
|
+
== 4.4.0 2021-01-17
|
13
|
+
|
14
|
+
* Support for MRI 3.0. [Mathieu Jobin]
|
15
|
+
|
1
16
|
== 4.2.0 2019-12-26
|
2
17
|
|
3
18
|
* Support for MRI 2.7.
|
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,14 +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 >= '2.
|
7
|
+
if RUBY_VERSION >= '3.2.0'
|
8
|
+
$CPPFLAGS << " -Imri/3.2.0"
|
9
|
+
elsif RUBY_VERSION >= '3.0.0'
|
10
|
+
$CPPFLAGS << " -Imri/3.0.0"
|
11
|
+
else
|
8
12
|
$CPPFLAGS << " -Imri/2.7.0"
|
9
|
-
elsif RUBY_VERSION >= '2.3.0'
|
10
|
-
$CPPFLAGS << " -Imri/2.3.0"
|
11
|
-
elsif RUBY_VERSION >= '2.2.0'
|
12
|
-
$CPPFLAGS << " -Imri/2.2.0"
|
13
|
-
elsif RUBY_VERSION >= '2.1.0'
|
14
|
-
$CPPFLAGS << " -Imri/2.1.0"
|
15
13
|
end
|
16
14
|
end
|
15
|
+
|
17
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_callback_func_t(ID *id, 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_with_replace(struct rb_id_table *tbl, rb_id_table_foreach_func_t *func, rb_id_table_update_callback_func_t *replace, void *data);
|
34
|
+
void rb_id_table_foreach_values(struct rb_id_table *tbl, rb_id_table_foreach_values_func_t *func, void *data);
|
35
|
+
|
36
|
+
#endif /* RUBY_ID_TABLE_H */
|
@@ -0,0 +1,119 @@
|
|
1
|
+
#ifndef INTERNAL_ARRAY_H /*-*-C-*-vi:se ft=c:*/
|
2
|
+
#define INTERNAL_ARRAY_H
|
3
|
+
/**
|
4
|
+
* @file
|
5
|
+
* @author Ruby developers <ruby-core@ruby-lang.org>
|
6
|
+
* @copyright This file is a part of the programming language Ruby.
|
7
|
+
* Permission is hereby granted, to either redistribute and/or
|
8
|
+
* modify this file, provided that the conditions mentioned in the
|
9
|
+
* file COPYING are met. Consult the file for details.
|
10
|
+
* @brief Internal header for Array.
|
11
|
+
*/
|
12
|
+
#include "ruby/internal/config.h"
|
13
|
+
#include <stddef.h> /* for size_t */
|
14
|
+
#include "internal/static_assert.h" /* for STATIC_ASSERT */
|
15
|
+
#include "ruby/internal/stdbool.h" /* for bool */
|
16
|
+
#include "ruby/ruby.h" /* for RARRAY_LEN */
|
17
|
+
|
18
|
+
#ifndef ARRAY_DEBUG
|
19
|
+
# define ARRAY_DEBUG (0+RUBY_DEBUG)
|
20
|
+
#endif
|
21
|
+
|
22
|
+
#define RARRAY_PTR_IN_USE_FLAG FL_USER14
|
23
|
+
|
24
|
+
/* array.c */
|
25
|
+
VALUE rb_ary_last(int, const VALUE *, VALUE);
|
26
|
+
void rb_ary_set_len(VALUE, long);
|
27
|
+
void rb_ary_delete_same(VALUE, VALUE);
|
28
|
+
VALUE rb_ary_tmp_new_fill(long capa);
|
29
|
+
VALUE rb_ary_at(VALUE, VALUE);
|
30
|
+
size_t rb_ary_memsize(VALUE);
|
31
|
+
VALUE rb_to_array_type(VALUE obj);
|
32
|
+
void rb_ary_cancel_sharing(VALUE ary);
|
33
|
+
|
34
|
+
static inline VALUE rb_ary_entry_internal(VALUE ary, long offset);
|
35
|
+
static inline bool ARY_PTR_USING_P(VALUE ary);
|
36
|
+
static inline void RARY_TRANSIENT_SET(VALUE ary);
|
37
|
+
static inline void RARY_TRANSIENT_UNSET(VALUE ary);
|
38
|
+
|
39
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
40
|
+
/* array.c (export) */
|
41
|
+
void rb_ary_detransient(VALUE a);
|
42
|
+
VALUE *rb_ary_ptr_use_start(VALUE ary);
|
43
|
+
void rb_ary_ptr_use_end(VALUE ary);
|
44
|
+
RUBY_SYMBOL_EXPORT_END
|
45
|
+
|
46
|
+
MJIT_SYMBOL_EXPORT_BEGIN
|
47
|
+
VALUE rb_ary_tmp_new_from_values(VALUE, long, const VALUE *);
|
48
|
+
VALUE rb_check_to_array(VALUE ary);
|
49
|
+
VALUE rb_ary_behead(VALUE, long);
|
50
|
+
VALUE rb_ary_aref1(VALUE ary, VALUE i);
|
51
|
+
|
52
|
+
struct rb_execution_context_struct;
|
53
|
+
VALUE rb_ec_ary_new_from_values(struct rb_execution_context_struct *ec, long n, const VALUE *elts);
|
54
|
+
MJIT_SYMBOL_EXPORT_END
|
55
|
+
|
56
|
+
static inline VALUE
|
57
|
+
rb_ary_entry_internal(VALUE ary, long offset)
|
58
|
+
{
|
59
|
+
long len = RARRAY_LEN(ary);
|
60
|
+
const VALUE *ptr = RARRAY_CONST_PTR_TRANSIENT(ary);
|
61
|
+
if (len == 0) return Qnil;
|
62
|
+
if (offset < 0) {
|
63
|
+
offset += len;
|
64
|
+
if (offset < 0) return Qnil;
|
65
|
+
}
|
66
|
+
else if (len <= offset) {
|
67
|
+
return Qnil;
|
68
|
+
}
|
69
|
+
return ptr[offset];
|
70
|
+
}
|
71
|
+
|
72
|
+
static inline bool
|
73
|
+
ARY_PTR_USING_P(VALUE ary)
|
74
|
+
{
|
75
|
+
return FL_TEST_RAW(ary, RARRAY_PTR_IN_USE_FLAG);
|
76
|
+
}
|
77
|
+
|
78
|
+
static inline void
|
79
|
+
RARY_TRANSIENT_SET(VALUE ary)
|
80
|
+
{
|
81
|
+
#if USE_TRANSIENT_HEAP
|
82
|
+
FL_SET_RAW(ary, RARRAY_TRANSIENT_FLAG);
|
83
|
+
#endif
|
84
|
+
}
|
85
|
+
|
86
|
+
static inline void
|
87
|
+
RARY_TRANSIENT_UNSET(VALUE ary)
|
88
|
+
{
|
89
|
+
#if USE_TRANSIENT_HEAP
|
90
|
+
FL_UNSET_RAW(ary, RARRAY_TRANSIENT_FLAG);
|
91
|
+
#endif
|
92
|
+
}
|
93
|
+
|
94
|
+
#undef rb_ary_new_from_args
|
95
|
+
#if RBIMPL_HAS_WARNING("-Wgnu-zero-variadic-macro-arguments")
|
96
|
+
# /* Skip it; clang -pedantic doesn't like the following */
|
97
|
+
#elif defined(__GNUC__) && defined(HAVE_VA_ARGS_MACRO)
|
98
|
+
#define rb_ary_new_from_args(n, ...) \
|
99
|
+
__extension__ ({ \
|
100
|
+
const VALUE args_to_new_ary[] = {__VA_ARGS__}; \
|
101
|
+
if (__builtin_constant_p(n)) { \
|
102
|
+
STATIC_ASSERT(rb_ary_new_from_args, numberof(args_to_new_ary) == (n)); \
|
103
|
+
} \
|
104
|
+
rb_ary_new_from_values(numberof(args_to_new_ary), args_to_new_ary); \
|
105
|
+
})
|
106
|
+
#endif
|
107
|
+
|
108
|
+
#undef RARRAY_AREF
|
109
|
+
RBIMPL_ATTR_PURE_UNLESS_DEBUG()
|
110
|
+
RBIMPL_ATTR_ARTIFICIAL()
|
111
|
+
static inline VALUE
|
112
|
+
RARRAY_AREF(VALUE ary, long i)
|
113
|
+
{
|
114
|
+
RBIMPL_ASSERT_TYPE(ary, RUBY_T_ARRAY);
|
115
|
+
|
116
|
+
return RARRAY_CONST_PTR_TRANSIENT(ary)[i];
|
117
|
+
}
|
118
|
+
|
119
|
+
#endif /* INTERNAL_ARRAY_H */
|
@@ -0,0 +1,174 @@
|
|
1
|
+
#ifndef INTERNAL_CLASS_H /*-*-C-*-vi:se ft=c:*/
|
2
|
+
#define INTERNAL_CLASS_H
|
3
|
+
/**
|
4
|
+
* @file
|
5
|
+
* @author Ruby developers <ruby-core@ruby-lang.org>
|
6
|
+
* @copyright This file is a part of the programming language Ruby.
|
7
|
+
* Permission is hereby granted, to either redistribute and/or
|
8
|
+
* modify this file, provided that the conditions mentioned in the
|
9
|
+
* file COPYING are met. Consult the file for details.
|
10
|
+
* @brief Internal header for Class.
|
11
|
+
*/
|
12
|
+
#include "id_table.h" /* for struct rb_id_table */
|
13
|
+
#include "internal/gc.h" /* for RB_OBJ_WRITE */
|
14
|
+
#include "internal/serial.h" /* for rb_serial_t */
|
15
|
+
#include "ruby/internal/stdbool.h" /* for bool */
|
16
|
+
#include "ruby/intern.h" /* for rb_alloc_func_t */
|
17
|
+
#include "ruby/ruby.h" /* for struct RBasic */
|
18
|
+
|
19
|
+
#ifdef RCLASS_SUPER
|
20
|
+
# undef RCLASS_SUPER
|
21
|
+
#endif
|
22
|
+
|
23
|
+
struct rb_subclass_entry {
|
24
|
+
VALUE klass;
|
25
|
+
struct rb_subclass_entry *next;
|
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_classext_struct {
|
35
|
+
struct st_table *iv_index_tbl; // ID -> struct rb_iv_index_tbl_entry
|
36
|
+
struct st_table *iv_tbl;
|
37
|
+
#if SIZEOF_SERIAL_T == SIZEOF_VALUE /* otherwise m_tbl is in struct RClass */
|
38
|
+
struct rb_id_table *m_tbl;
|
39
|
+
#endif
|
40
|
+
struct rb_id_table *const_tbl;
|
41
|
+
struct rb_id_table *callable_m_tbl;
|
42
|
+
struct rb_id_table *cc_tbl; /* ID -> [[ci, cc1], cc2, ...] */
|
43
|
+
struct rb_subclass_entry *subclasses;
|
44
|
+
struct rb_subclass_entry **parent_subclasses;
|
45
|
+
/**
|
46
|
+
* In the case that this is an `ICLASS`, `module_subclasses` points to the link
|
47
|
+
* in the module's `subclasses` list that indicates that the klass has been
|
48
|
+
* included. Hopefully that makes sense.
|
49
|
+
*/
|
50
|
+
struct rb_subclass_entry **module_subclasses;
|
51
|
+
#if SIZEOF_SERIAL_T != SIZEOF_VALUE /* otherwise class_serial is in struct RClass */
|
52
|
+
rb_serial_t class_serial;
|
53
|
+
#endif
|
54
|
+
const VALUE origin_;
|
55
|
+
const VALUE refined_class;
|
56
|
+
rb_alloc_func_t allocator;
|
57
|
+
const VALUE includer;
|
58
|
+
};
|
59
|
+
|
60
|
+
struct RClass {
|
61
|
+
struct RBasic basic;
|
62
|
+
VALUE super;
|
63
|
+
struct rb_classext_struct *ptr;
|
64
|
+
#if SIZEOF_SERIAL_T == SIZEOF_VALUE
|
65
|
+
/* Class serial is as wide as VALUE. Place it here. */
|
66
|
+
rb_serial_t class_serial;
|
67
|
+
#else
|
68
|
+
/* Class serial does not fit into struct RClass. Place m_tbl instead. */
|
69
|
+
struct rb_id_table *m_tbl;
|
70
|
+
#endif
|
71
|
+
};
|
72
|
+
|
73
|
+
typedef struct rb_subclass_entry rb_subclass_entry_t;
|
74
|
+
typedef struct rb_classext_struct rb_classext_t;
|
75
|
+
|
76
|
+
#define RCLASS_EXT(c) (RCLASS(c)->ptr)
|
77
|
+
#define RCLASS_IV_TBL(c) (RCLASS_EXT(c)->iv_tbl)
|
78
|
+
#define RCLASS_CONST_TBL(c) (RCLASS_EXT(c)->const_tbl)
|
79
|
+
#if SIZEOF_SERIAL_T == SIZEOF_VALUE
|
80
|
+
# define RCLASS_M_TBL(c) (RCLASS_EXT(c)->m_tbl)
|
81
|
+
#else
|
82
|
+
# define RCLASS_M_TBL(c) (RCLASS(c)->m_tbl)
|
83
|
+
#endif
|
84
|
+
#define RCLASS_CALLABLE_M_TBL(c) (RCLASS_EXT(c)->callable_m_tbl)
|
85
|
+
#define RCLASS_CC_TBL(c) (RCLASS_EXT(c)->cc_tbl)
|
86
|
+
#define RCLASS_IV_INDEX_TBL(c) (RCLASS_EXT(c)->iv_index_tbl)
|
87
|
+
#define RCLASS_ORIGIN(c) (RCLASS_EXT(c)->origin_)
|
88
|
+
#define RCLASS_REFINED_CLASS(c) (RCLASS_EXT(c)->refined_class)
|
89
|
+
#if SIZEOF_SERIAL_T == SIZEOF_VALUE
|
90
|
+
# define RCLASS_SERIAL(c) (RCLASS(c)->class_serial)
|
91
|
+
#else
|
92
|
+
# define RCLASS_SERIAL(c) (RCLASS_EXT(c)->class_serial)
|
93
|
+
#endif
|
94
|
+
#define RCLASS_INCLUDER(c) (RCLASS_EXT(c)->includer)
|
95
|
+
|
96
|
+
#define RICLASS_IS_ORIGIN FL_USER5
|
97
|
+
#define RCLASS_CLONED FL_USER6
|
98
|
+
#define RICLASS_ORIGIN_SHARED_MTBL FL_USER8
|
99
|
+
|
100
|
+
/* class.c */
|
101
|
+
void rb_class_subclass_add(VALUE super, VALUE klass);
|
102
|
+
void rb_class_remove_from_super_subclasses(VALUE);
|
103
|
+
int rb_singleton_class_internal_p(VALUE sklass);
|
104
|
+
VALUE rb_class_boot(VALUE);
|
105
|
+
VALUE rb_make_metaclass(VALUE, VALUE);
|
106
|
+
VALUE rb_include_class_new(VALUE, VALUE);
|
107
|
+
void rb_class_foreach_subclass(VALUE klass, void (*f)(VALUE, VALUE), VALUE);
|
108
|
+
void rb_class_detach_subclasses(VALUE);
|
109
|
+
void rb_class_detach_module_subclasses(VALUE);
|
110
|
+
void rb_class_remove_from_module_subclasses(VALUE);
|
111
|
+
VALUE rb_obj_methods(int argc, const VALUE *argv, VALUE obj);
|
112
|
+
VALUE rb_obj_protected_methods(int argc, const VALUE *argv, VALUE obj);
|
113
|
+
VALUE rb_obj_private_methods(int argc, const VALUE *argv, VALUE obj);
|
114
|
+
VALUE rb_obj_public_methods(int argc, const VALUE *argv, VALUE obj);
|
115
|
+
VALUE rb_special_singleton_class(VALUE);
|
116
|
+
VALUE rb_singleton_class_clone_and_attach(VALUE obj, VALUE attach);
|
117
|
+
VALUE rb_singleton_class_get(VALUE obj);
|
118
|
+
int rb_class_has_methods(VALUE c);
|
119
|
+
void rb_undef_methods_from(VALUE klass, VALUE super);
|
120
|
+
|
121
|
+
static inline void RCLASS_SET_ORIGIN(VALUE klass, VALUE origin);
|
122
|
+
static inline void RICLASS_SET_ORIGIN_SHARED_MTBL(VALUE iclass);
|
123
|
+
static inline VALUE RCLASS_SUPER(VALUE klass);
|
124
|
+
static inline VALUE RCLASS_SET_SUPER(VALUE klass, VALUE super);
|
125
|
+
static inline void RCLASS_SET_INCLUDER(VALUE iclass, VALUE klass);
|
126
|
+
|
127
|
+
MJIT_SYMBOL_EXPORT_BEGIN
|
128
|
+
VALUE rb_class_inherited(VALUE, VALUE);
|
129
|
+
VALUE rb_keyword_error_new(const char *, VALUE);
|
130
|
+
MJIT_SYMBOL_EXPORT_END
|
131
|
+
|
132
|
+
static inline void
|
133
|
+
RCLASS_SET_ORIGIN(VALUE klass, VALUE origin)
|
134
|
+
{
|
135
|
+
RB_OBJ_WRITE(klass, &RCLASS_ORIGIN(klass), origin);
|
136
|
+
if (klass != origin) FL_SET(origin, RICLASS_IS_ORIGIN);
|
137
|
+
}
|
138
|
+
|
139
|
+
static inline void
|
140
|
+
RICLASS_SET_ORIGIN_SHARED_MTBL(VALUE iclass)
|
141
|
+
{
|
142
|
+
FL_SET(iclass, RICLASS_ORIGIN_SHARED_MTBL);
|
143
|
+
}
|
144
|
+
|
145
|
+
static inline bool
|
146
|
+
RICLASS_OWNS_M_TBL_P(VALUE iclass)
|
147
|
+
{
|
148
|
+
return FL_TEST_RAW(iclass, RICLASS_IS_ORIGIN | RICLASS_ORIGIN_SHARED_MTBL) == RICLASS_IS_ORIGIN;
|
149
|
+
}
|
150
|
+
|
151
|
+
static inline void
|
152
|
+
RCLASS_SET_INCLUDER(VALUE iclass, VALUE klass)
|
153
|
+
{
|
154
|
+
RB_OBJ_WRITE(iclass, &RCLASS_INCLUDER(iclass), klass);
|
155
|
+
}
|
156
|
+
|
157
|
+
static inline VALUE
|
158
|
+
RCLASS_SUPER(VALUE klass)
|
159
|
+
{
|
160
|
+
return RCLASS(klass)->super;
|
161
|
+
}
|
162
|
+
|
163
|
+
static inline VALUE
|
164
|
+
RCLASS_SET_SUPER(VALUE klass, VALUE super)
|
165
|
+
{
|
166
|
+
if (super) {
|
167
|
+
rb_class_remove_from_super_subclasses(klass);
|
168
|
+
rb_class_subclass_add(super, klass);
|
169
|
+
}
|
170
|
+
RB_OBJ_WRITE(klass, &RCLASS(klass)->super, super);
|
171
|
+
return super;
|
172
|
+
}
|
173
|
+
|
174
|
+
#endif /* INTERNAL_CLASS_H */
|
@@ -0,0 +1,108 @@
|
|
1
|
+
#ifndef INTERNAL_COMPILERS_H /*-*-C-*-vi:se ft=c:*/
|
2
|
+
#define INTERNAL_COMPILERS_H
|
3
|
+
/**
|
4
|
+
* @file
|
5
|
+
* @author Ruby developers <ruby-core@ruby-lang.org>
|
6
|
+
* @copyright This file is a part of the programming language Ruby.
|
7
|
+
* Permission is hereby granted, to either redistribute and/or
|
8
|
+
* modify this file, provided that the conditions mentioned in the
|
9
|
+
* file COPYING are met. Consult the file for details.
|
10
|
+
* @brief Internal header absorbing C compipler differences.
|
11
|
+
*/
|
12
|
+
#include "ruby/internal/compiler_since.h"
|
13
|
+
#include "ruby/internal/has/attribute.h"
|
14
|
+
#include "ruby/internal/has/builtin.h"
|
15
|
+
#include "ruby/internal/has/c_attribute.h"
|
16
|
+
#include "ruby/internal/has/declspec_attribute.h"
|
17
|
+
#include "ruby/internal/has/extension.h"
|
18
|
+
#include "ruby/internal/has/feature.h"
|
19
|
+
#include "ruby/internal/has/warning.h"
|
20
|
+
#include "ruby/backward/2/gcc_version_since.h"
|
21
|
+
|
22
|
+
#define MSC_VERSION_SINCE(_) RBIMPL_COMPILER_SINCE(MSVC, (_) / 100, (_) % 100, 0)
|
23
|
+
#define MSC_VERSION_BEFORE(_) RBIMPL_COMPILER_BEFORE(MSVC, (_) / 100, (_) % 100, 0)
|
24
|
+
|
25
|
+
#ifndef __has_attribute
|
26
|
+
# define __has_attribute(...) RBIMPL_HAS_ATTRIBUTE(__VA_ARGS__)
|
27
|
+
#endif
|
28
|
+
|
29
|
+
#ifndef __has_c_attribute
|
30
|
+
# /* As of writing everything that lacks __has_c_attribute also completely
|
31
|
+
# * lacks C2x attributes as well. Might change in future? */
|
32
|
+
# define __has_c_attribute(...) 0
|
33
|
+
#endif
|
34
|
+
|
35
|
+
#ifndef __has_declspec_attribute
|
36
|
+
# define __has_declspec_attribute(...) RBIMPL_HAS_DECLSPEC_ATTRIBUTE(__VA_ARGS__)
|
37
|
+
#endif
|
38
|
+
|
39
|
+
#ifndef __has_builtin
|
40
|
+
# define __has_builtin(...) RBIMPL_HAS_BUILTIN(__VA_ARGS__)
|
41
|
+
#endif
|
42
|
+
|
43
|
+
#ifndef __has_feature
|
44
|
+
# define __has_feature(...) RBIMPL_HAS_FEATURE(__VA_ARGS__)
|
45
|
+
#endif
|
46
|
+
|
47
|
+
#ifndef __has_extension
|
48
|
+
# define __has_extension(...) RBIMPL_HAS_EXTENSION(__VA_ARGS__)
|
49
|
+
#endif
|
50
|
+
|
51
|
+
#ifndef __has_warning
|
52
|
+
# define __has_warning(...) RBIMPL_HAS_WARNING(__VA_ARGS__)
|
53
|
+
#endif
|
54
|
+
|
55
|
+
#ifndef __GNUC__
|
56
|
+
# define __extension__ /* void */
|
57
|
+
#endif
|
58
|
+
|
59
|
+
#ifndef MAYBE_UNUSED
|
60
|
+
# define MAYBE_UNUSED(x) x
|
61
|
+
#endif
|
62
|
+
|
63
|
+
#ifndef WARN_UNUSED_RESULT
|
64
|
+
# define WARN_UNUSED_RESULT(x) x
|
65
|
+
#endif
|
66
|
+
|
67
|
+
#define RB_OBJ_BUILTIN_TYPE(obj) rb_obj_builtin_type(obj)
|
68
|
+
#define OBJ_BUILTIN_TYPE(obj) RB_OBJ_BUILTIN_TYPE(obj)
|
69
|
+
#ifdef __GNUC__
|
70
|
+
#define rb_obj_builtin_type(obj) \
|
71
|
+
__extension__({ \
|
72
|
+
VALUE arg_obj = (obj); \
|
73
|
+
RB_SPECIAL_CONST_P(arg_obj) ? -1 : \
|
74
|
+
(int)RB_BUILTIN_TYPE(arg_obj); \
|
75
|
+
})
|
76
|
+
#else
|
77
|
+
# include "ruby/ruby.h"
|
78
|
+
static inline int
|
79
|
+
rb_obj_builtin_type(VALUE obj)
|
80
|
+
{
|
81
|
+
return RB_SPECIAL_CONST_P(obj) ? -1 :
|
82
|
+
(int)RB_BUILTIN_TYPE(obj);
|
83
|
+
}
|
84
|
+
#endif
|
85
|
+
|
86
|
+
/* A macro for defining a flexible array, like: VALUE ary[FLEX_ARY_LEN]; */
|
87
|
+
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
|
88
|
+
# define FLEX_ARY_LEN /* VALUE ary[]; */
|
89
|
+
#elif defined(__GNUC__) && !defined(__STRICT_ANSI__)
|
90
|
+
# define FLEX_ARY_LEN 0 /* VALUE ary[0]; */
|
91
|
+
#else
|
92
|
+
# define FLEX_ARY_LEN 1 /* VALUE ary[1]; */
|
93
|
+
#endif
|
94
|
+
|
95
|
+
/*
|
96
|
+
* For declaring bitfields out of non-unsigned int types:
|
97
|
+
* struct date {
|
98
|
+
* BITFIELD(enum months, month, 4);
|
99
|
+
* ...
|
100
|
+
* };
|
101
|
+
*/
|
102
|
+
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
|
103
|
+
# define BITFIELD(type, name, size) type name : size
|
104
|
+
#else
|
105
|
+
# define BITFIELD(type, name, size) unsigned int name : size
|
106
|
+
#endif
|
107
|
+
|
108
|
+
#endif /* INTERNAL_COMPILERS_H */
|
@@ -0,0 +1,161 @@
|
|
1
|
+
#ifndef INTERNAL_GC_H /*-*-C-*-vi:se ft=c:*/
|
2
|
+
#define INTERNAL_GC_H
|
3
|
+
/**
|
4
|
+
* @file
|
5
|
+
* @author Ruby developers <ruby-core@ruby-lang.org>
|
6
|
+
* @copyright This file is a part of the programming language Ruby.
|
7
|
+
* Permission is hereby granted, to either redistribute and/or
|
8
|
+
* modify this file, provided that the conditions mentioned in the
|
9
|
+
* file COPYING are met. Consult the file for details.
|
10
|
+
* @brief Internal header for GC.
|
11
|
+
*/
|
12
|
+
#include "ruby/internal/config.h"
|
13
|
+
|
14
|
+
#include <stddef.h> /* for size_t */
|
15
|
+
|
16
|
+
#include "internal/compilers.h" /* for __has_attribute */
|
17
|
+
#include "ruby/ruby.h" /* for rb_event_flag_t */
|
18
|
+
|
19
|
+
struct rb_execution_context_struct; /* in vm_core.h */
|
20
|
+
struct rb_objspace; /* in vm_core.h */
|
21
|
+
|
22
|
+
#ifdef NEWOBJ_OF
|
23
|
+
# undef NEWOBJ_OF
|
24
|
+
# undef RB_NEWOBJ_OF
|
25
|
+
# undef RB_OBJ_WRITE
|
26
|
+
#endif
|
27
|
+
|
28
|
+
/* optimized version of NEWOBJ() */
|
29
|
+
#define RB_NEWOBJ_OF(var, T, c, f) \
|
30
|
+
T *(var) = (T *)(((f) & FL_WB_PROTECTED) ? \
|
31
|
+
rb_wb_protected_newobj_of((c), (f) & ~FL_WB_PROTECTED) : \
|
32
|
+
rb_wb_unprotected_newobj_of((c), (f)))
|
33
|
+
|
34
|
+
#define RB_EC_NEWOBJ_OF(ec, var, T, c, f) \
|
35
|
+
T *(var) = (T *)(((f) & FL_WB_PROTECTED) ? \
|
36
|
+
rb_ec_wb_protected_newobj_of((ec), (c), (f) & ~FL_WB_PROTECTED) : \
|
37
|
+
rb_wb_unprotected_newobj_of((c), (f)))
|
38
|
+
|
39
|
+
#define NEWOBJ_OF(var, T, c, f) RB_NEWOBJ_OF((var), T, (c), (f))
|
40
|
+
#define RB_OBJ_GC_FLAGS_MAX 6 /* used in ext/objspace */
|
41
|
+
|
42
|
+
#ifndef USE_UNALIGNED_MEMBER_ACCESS
|
43
|
+
# define UNALIGNED_MEMBER_ACCESS(expr) (expr)
|
44
|
+
#elif ! USE_UNALIGNED_MEMBER_ACCESS
|
45
|
+
# define UNALIGNED_MEMBER_ACCESS(expr) (expr)
|
46
|
+
#elif ! (__has_warning("-Waddress-of-packed-member") || GCC_VERSION_SINCE(9, 0, 0))
|
47
|
+
# define UNALIGNED_MEMBER_ACCESS(expr) (expr)
|
48
|
+
#else
|
49
|
+
# include "internal/warnings.h"
|
50
|
+
# define UNALIGNED_MEMBER_ACCESS(expr) __extension__({ \
|
51
|
+
COMPILER_WARNING_PUSH; \
|
52
|
+
COMPILER_WARNING_IGNORED(-Waddress-of-packed-member); \
|
53
|
+
__typeof__(expr) unaligned_member_access_result = (expr); \
|
54
|
+
COMPILER_WARNING_POP; \
|
55
|
+
unaligned_member_access_result; \
|
56
|
+
})
|
57
|
+
#endif
|
58
|
+
|
59
|
+
#define UNALIGNED_MEMBER_PTR(ptr, mem) UNALIGNED_MEMBER_ACCESS(&(ptr)->mem)
|
60
|
+
#define RB_OBJ_WRITE(a, slot, b) \
|
61
|
+
rb_obj_write((VALUE)(a), UNALIGNED_MEMBER_ACCESS((VALUE *)(slot)), \
|
62
|
+
(VALUE)(b), __FILE__, __LINE__)
|
63
|
+
|
64
|
+
/* gc.c */
|
65
|
+
extern VALUE *ruby_initial_gc_stress_ptr;
|
66
|
+
extern int ruby_disable_gc;
|
67
|
+
RUBY_ATTR_MALLOC void *ruby_mimmalloc(size_t size);
|
68
|
+
void ruby_mimfree(void *ptr);
|
69
|
+
void rb_objspace_set_event_hook(const rb_event_flag_t event);
|
70
|
+
VALUE rb_objspace_gc_enable(struct rb_objspace *);
|
71
|
+
VALUE rb_objspace_gc_disable(struct rb_objspace *);
|
72
|
+
void ruby_gc_set_params(void);
|
73
|
+
void rb_copy_wb_protected_attribute(VALUE dest, VALUE obj);
|
74
|
+
#if __has_attribute(alloc_align)
|
75
|
+
__attribute__((__alloc_align__(1)))
|
76
|
+
#endif
|
77
|
+
RUBY_ATTR_MALLOC void *rb_aligned_malloc(size_t, size_t) RUBY_ATTR_ALLOC_SIZE((2));
|
78
|
+
size_t rb_size_mul_or_raise(size_t, size_t, VALUE); /* used in compile.c */
|
79
|
+
size_t rb_size_mul_add_or_raise(size_t, size_t, size_t, VALUE); /* used in iseq.h */
|
80
|
+
RUBY_ATTR_MALLOC void *rb_xmalloc_mul_add(size_t, size_t, size_t);
|
81
|
+
void *rb_xrealloc_mul_add(const void *, size_t, size_t, size_t);
|
82
|
+
RUBY_ATTR_MALLOC void *rb_xmalloc_mul_add_mul(size_t, size_t, size_t, size_t);
|
83
|
+
RUBY_ATTR_MALLOC void *rb_xcalloc_mul_add_mul(size_t, size_t, size_t, size_t);
|
84
|
+
static inline void *ruby_sized_xrealloc_inlined(void *ptr, size_t new_size, size_t old_size) RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((2));
|
85
|
+
static inline void *ruby_sized_xrealloc2_inlined(void *ptr, size_t new_count, size_t elemsiz, size_t old_count) RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((2, 3));
|
86
|
+
static inline void ruby_sized_xfree_inlined(void *ptr, size_t size);
|
87
|
+
VALUE rb_class_allocate_instance(VALUE klass);
|
88
|
+
|
89
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
90
|
+
/* gc.c (export) */
|
91
|
+
const char *rb_objspace_data_type_name(VALUE obj);
|
92
|
+
VALUE rb_wb_protected_newobj_of(VALUE, VALUE);
|
93
|
+
VALUE rb_wb_unprotected_newobj_of(VALUE, VALUE);
|
94
|
+
VALUE rb_ec_wb_protected_newobj_of(struct rb_execution_context_struct *ec, VALUE klass, VALUE flags);
|
95
|
+
size_t rb_obj_memsize_of(VALUE);
|
96
|
+
void rb_gc_verify_internal_consistency(void);
|
97
|
+
size_t rb_obj_gc_flags(VALUE, ID[], size_t);
|
98
|
+
void rb_gc_mark_values(long n, const VALUE *values);
|
99
|
+
void rb_gc_mark_vm_stack_values(long n, const VALUE *values);
|
100
|
+
void *ruby_sized_xrealloc(void *ptr, size_t new_size, size_t old_size) RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((2));
|
101
|
+
void *ruby_sized_xrealloc2(void *ptr, size_t new_count, size_t element_size, size_t old_count) RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((2, 3));
|
102
|
+
void ruby_sized_xfree(void *x, size_t size);
|
103
|
+
RUBY_SYMBOL_EXPORT_END
|
104
|
+
|
105
|
+
MJIT_SYMBOL_EXPORT_BEGIN
|
106
|
+
int rb_ec_stack_check(struct rb_execution_context_struct *ec);
|
107
|
+
void rb_gc_writebarrier_remember(VALUE obj);
|
108
|
+
const char *rb_obj_info(VALUE obj);
|
109
|
+
MJIT_SYMBOL_EXPORT_END
|
110
|
+
|
111
|
+
#if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE) || defined(_WIN32)
|
112
|
+
|
113
|
+
static inline void *
|
114
|
+
ruby_sized_xrealloc_inlined(void *ptr, size_t new_size, size_t old_size)
|
115
|
+
{
|
116
|
+
return ruby_xrealloc(ptr, new_size);
|
117
|
+
}
|
118
|
+
|
119
|
+
static inline void *
|
120
|
+
ruby_sized_xrealloc2_inlined(void *ptr, size_t new_count, size_t elemsiz, size_t old_count)
|
121
|
+
{
|
122
|
+
return ruby_xrealloc2(ptr, new_count, elemsiz);
|
123
|
+
}
|
124
|
+
|
125
|
+
static inline void
|
126
|
+
ruby_sized_xfree_inlined(void *ptr, size_t size)
|
127
|
+
{
|
128
|
+
ruby_xfree(ptr);
|
129
|
+
}
|
130
|
+
|
131
|
+
# define SIZED_REALLOC_N(x, y, z, w) REALLOC_N(x, y, z)
|
132
|
+
|
133
|
+
#else
|
134
|
+
|
135
|
+
static inline void *
|
136
|
+
ruby_sized_xrealloc_inlined(void *ptr, size_t new_size, size_t old_size)
|
137
|
+
{
|
138
|
+
return ruby_sized_xrealloc(ptr, new_size, old_size);
|
139
|
+
}
|
140
|
+
|
141
|
+
static inline void *
|
142
|
+
ruby_sized_xrealloc2_inlined(void *ptr, size_t new_count, size_t elemsiz, size_t old_count)
|
143
|
+
{
|
144
|
+
return ruby_sized_xrealloc2(ptr, new_count, elemsiz, old_count);
|
145
|
+
}
|
146
|
+
|
147
|
+
static inline void
|
148
|
+
ruby_sized_xfree_inlined(void *ptr, size_t size)
|
149
|
+
{
|
150
|
+
ruby_sized_xfree(ptr, size);
|
151
|
+
}
|
152
|
+
|
153
|
+
# define SIZED_REALLOC_N(v, T, m, n) \
|
154
|
+
((v) = (T *)ruby_sized_xrealloc2((void *)(v), (m), sizeof(T), (n)))
|
155
|
+
|
156
|
+
#endif /* HAVE_MALLOC_USABLE_SIZE */
|
157
|
+
|
158
|
+
#define ruby_sized_xrealloc ruby_sized_xrealloc_inlined
|
159
|
+
#define ruby_sized_xrealloc2 ruby_sized_xrealloc2_inlined
|
160
|
+
#define ruby_sized_xfree ruby_sized_xfree_inlined
|
161
|
+
#endif /* INTERNAL_GC_H */
|