looksee 4.1.0 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,229 @@
1
+ /**********************************************************************
2
+
3
+ method.h -
4
+
5
+ $Author$
6
+ created at: Wed Jul 15 20:02:33 2009
7
+
8
+ Copyright (C) 2009 Koichi Sasada
9
+
10
+ **********************************************************************/
11
+ #ifndef RUBY_METHOD_H
12
+ #define RUBY_METHOD_H 1
13
+
14
+ #include "internal.h"
15
+
16
+ #ifndef END_OF_ENUMERATION
17
+ # if defined(__GNUC__) &&! defined(__STRICT_ANSI__)
18
+ # define END_OF_ENUMERATION(key)
19
+ # else
20
+ # define END_OF_ENUMERATION(key) END_OF_##key##_PLACEHOLDER = 0
21
+ # endif
22
+ #endif
23
+
24
+ /* cref */
25
+
26
+ typedef enum {
27
+ METHOD_VISI_UNDEF = 0x00,
28
+ METHOD_VISI_PUBLIC = 0x01,
29
+ METHOD_VISI_PRIVATE = 0x02,
30
+ METHOD_VISI_PROTECTED = 0x03,
31
+
32
+ METHOD_VISI_MASK = 0x03
33
+ } rb_method_visibility_t;
34
+
35
+ typedef struct rb_scope_visi_struct {
36
+ BITFIELD(rb_method_visibility_t, method_visi, 3);
37
+ unsigned int module_func : 1;
38
+ } rb_scope_visibility_t;
39
+
40
+ /*! CREF (Class REFerence) */
41
+ typedef struct rb_cref_struct {
42
+ VALUE flags;
43
+ VALUE refinements;
44
+ VALUE klass;
45
+ struct rb_cref_struct * next;
46
+ const rb_scope_visibility_t scope_visi;
47
+ } rb_cref_t;
48
+
49
+ /* method data type */
50
+
51
+ typedef struct rb_method_entry_struct {
52
+ VALUE flags;
53
+ VALUE defined_class;
54
+ struct rb_method_definition_struct * const def;
55
+ ID called_id;
56
+ VALUE owner;
57
+ } rb_method_entry_t;
58
+
59
+ typedef struct rb_callable_method_entry_struct { /* same fields with rb_method_entry_t */
60
+ VALUE flags;
61
+ const VALUE defined_class;
62
+ struct rb_method_definition_struct * const def;
63
+ ID called_id;
64
+ const VALUE owner;
65
+ } rb_callable_method_entry_t;
66
+
67
+ #define METHOD_ENTRY_VISI(me) (rb_method_visibility_t)(((me)->flags & (IMEMO_FL_USER0 | IMEMO_FL_USER1)) >> (IMEMO_FL_USHIFT+0))
68
+ #define METHOD_ENTRY_BASIC(me) (int) (((me)->flags & (IMEMO_FL_USER2 )) >> (IMEMO_FL_USHIFT+2))
69
+ #define METHOD_ENTRY_COMPLEMENTED(me) ((me)->flags & IMEMO_FL_USER3)
70
+ #define METHOD_ENTRY_COMPLEMENTED_SET(me) ((me)->flags = (me)->flags | IMEMO_FL_USER3)
71
+
72
+ static inline void
73
+ METHOD_ENTRY_VISI_SET(rb_method_entry_t *me, rb_method_visibility_t visi)
74
+ {
75
+ VM_ASSERT((int)visi >= 0 && visi <= 3);
76
+ me->flags = (me->flags & ~(IMEMO_FL_USER0 | IMEMO_FL_USER1)) | (visi << (IMEMO_FL_USHIFT+0));
77
+ }
78
+ static inline void
79
+ METHOD_ENTRY_BASIC_SET(rb_method_entry_t *me, unsigned int basic)
80
+ {
81
+ VM_ASSERT(basic <= 1);
82
+ me->flags = (me->flags & ~(IMEMO_FL_USER2 )) | (basic << (IMEMO_FL_USHIFT+2));
83
+ }
84
+ static inline void
85
+ METHOD_ENTRY_FLAGS_SET(rb_method_entry_t *me, rb_method_visibility_t visi, unsigned int basic)
86
+ {
87
+ VM_ASSERT((int)visi >= 0 && visi <= 3);
88
+ VM_ASSERT(basic <= 1);
89
+ me->flags =
90
+ (me->flags & ~(IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2)) |
91
+ ((visi << (IMEMO_FL_USHIFT+0)) | (basic << (IMEMO_FL_USHIFT+2)));
92
+ }
93
+ static inline void
94
+ METHOD_ENTRY_FLAGS_COPY(rb_method_entry_t *dst, const rb_method_entry_t *src)
95
+ {
96
+ dst->flags =
97
+ (dst->flags & ~(IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2)) |
98
+ (src->flags & (IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2));
99
+ }
100
+
101
+ typedef enum {
102
+ VM_METHOD_TYPE_ISEQ, /*!< Ruby method */
103
+ VM_METHOD_TYPE_CFUNC, /*!< C method */
104
+ VM_METHOD_TYPE_ATTRSET, /*!< attr_writer or attr_accessor */
105
+ VM_METHOD_TYPE_IVAR, /*!< attr_reader or attr_accessor */
106
+ VM_METHOD_TYPE_BMETHOD,
107
+ VM_METHOD_TYPE_ZSUPER,
108
+ VM_METHOD_TYPE_ALIAS,
109
+ VM_METHOD_TYPE_UNDEF,
110
+ VM_METHOD_TYPE_NOTIMPLEMENTED,
111
+ VM_METHOD_TYPE_OPTIMIZED, /*!< Kernel#send, Proc#call, etc */
112
+ VM_METHOD_TYPE_MISSING, /*!< wrapper for method_missing(id) */
113
+ VM_METHOD_TYPE_REFINED, /*!< refinement */
114
+
115
+ END_OF_ENUMERATION(VM_METHOD_TYPE)
116
+ } rb_method_type_t;
117
+ #define VM_METHOD_TYPE_MINIMUM_BITS 4
118
+ STATIC_ASSERT(VM_METHOD_TYPE_MINIMUM_BITS,
119
+ VM_METHOD_TYPE_REFINED <= (1<<VM_METHOD_TYPE_MINIMUM_BITS));
120
+
121
+ #ifndef rb_iseq_t
122
+ typedef struct rb_iseq_struct rb_iseq_t;
123
+ #define rb_iseq_t rb_iseq_t
124
+ #endif
125
+
126
+ typedef struct rb_method_iseq_struct {
127
+ rb_iseq_t * iseqptr; /*!< iseq pointer, should be separated from iseqval */
128
+ rb_cref_t * cref; /*!< class reference, should be marked */
129
+ } rb_method_iseq_t; /* check rb_add_method_iseq() when modify the fields */
130
+
131
+ typedef struct rb_method_cfunc_struct {
132
+ VALUE (*func)(ANYARGS);
133
+ VALUE (*invoker)(VALUE recv, int argc, const VALUE *argv, VALUE (*func)(ANYARGS));
134
+ int argc;
135
+ } rb_method_cfunc_t;
136
+
137
+ typedef struct rb_method_attr_struct {
138
+ ID id;
139
+ VALUE location; /* should be marked */
140
+ } rb_method_attr_t;
141
+
142
+ typedef struct rb_method_alias_struct {
143
+ struct rb_method_entry_struct * original_me; /* original_me->klass is original owner */
144
+ } rb_method_alias_t;
145
+
146
+ typedef struct rb_method_refined_struct {
147
+ struct rb_method_entry_struct * orig_me;
148
+ VALUE owner;
149
+ } rb_method_refined_t;
150
+
151
+ typedef struct rb_method_bmethod_struct {
152
+ VALUE proc; /* should be marked */
153
+ struct rb_hook_list_struct *hooks;
154
+ } rb_method_bmethod_t;
155
+
156
+ enum method_optimized_type {
157
+ OPTIMIZED_METHOD_TYPE_SEND,
158
+ OPTIMIZED_METHOD_TYPE_CALL,
159
+ OPTIMIZED_METHOD_TYPE_BLOCK_CALL,
160
+ OPTIMIZED_METHOD_TYPE__MAX
161
+ };
162
+
163
+ struct rb_method_definition_struct {
164
+ BITFIELD(rb_method_type_t, type, VM_METHOD_TYPE_MINIMUM_BITS);
165
+ int alias_count : 28;
166
+ int complemented_count : 28;
167
+
168
+ union {
169
+ rb_method_iseq_t iseq;
170
+ rb_method_cfunc_t cfunc;
171
+ rb_method_attr_t attr;
172
+ rb_method_alias_t alias;
173
+ rb_method_refined_t refined;
174
+ rb_method_bmethod_t bmethod;
175
+
176
+ enum method_optimized_type optimize_type;
177
+ } body;
178
+
179
+ ID original_id;
180
+ uintptr_t method_serial;
181
+ };
182
+
183
+ typedef struct rb_method_definition_struct rb_method_definition_t;
184
+ STATIC_ASSERT(sizeof_method_def, offsetof(rb_method_definition_t, body)==8);
185
+
186
+ #define UNDEFINED_METHOD_ENTRY_P(me) (!(me) || !(me)->def || (me)->def->type == VM_METHOD_TYPE_UNDEF)
187
+ #define UNDEFINED_REFINED_METHOD_P(def) \
188
+ ((def)->type == VM_METHOD_TYPE_REFINED && \
189
+ UNDEFINED_METHOD_ENTRY_P((def)->body.refined.orig_me))
190
+
191
+ void rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_method_visibility_t visi);
192
+ void rb_add_method_iseq(VALUE klass, ID mid, const rb_iseq_t *iseq, rb_cref_t *cref, rb_method_visibility_t visi);
193
+ void rb_add_refined_method_entry(VALUE refined_class, ID mid);
194
+ void rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *option, rb_method_visibility_t visi);
195
+
196
+ rb_method_entry_t *rb_method_entry_set(VALUE klass, ID mid, const rb_method_entry_t *, rb_method_visibility_t noex);
197
+ rb_method_entry_t *rb_method_entry_create(ID called_id, VALUE klass, rb_method_visibility_t visi, const rb_method_definition_t *def);
198
+
199
+ const rb_method_entry_t *rb_method_entry_at(VALUE obj, ID id);
200
+
201
+ const rb_method_entry_t *rb_method_entry(VALUE klass, ID id);
202
+ const rb_method_entry_t *rb_method_entry_with_refinements(VALUE klass, ID id, VALUE *defined_class);
203
+ const rb_method_entry_t *rb_method_entry_without_refinements(VALUE klass, ID id, VALUE *defined_class);
204
+ const rb_method_entry_t *rb_resolve_refined_method(VALUE refinements, const rb_method_entry_t *me);
205
+ RUBY_SYMBOL_EXPORT_BEGIN
206
+ const rb_method_entry_t *rb_resolve_me_location(const rb_method_entry_t *, VALUE[5]);
207
+ RUBY_SYMBOL_EXPORT_END
208
+
209
+ const rb_callable_method_entry_t *rb_callable_method_entry(VALUE klass, ID id);
210
+ const rb_callable_method_entry_t *rb_callable_method_entry_with_refinements(VALUE klass, ID id, VALUE *defined_class);
211
+ const rb_callable_method_entry_t *rb_callable_method_entry_without_refinements(VALUE klass, ID id, VALUE *defined_class);
212
+
213
+ int rb_method_entry_arity(const rb_method_entry_t *me);
214
+ int rb_method_entry_eq(const rb_method_entry_t *m1, const rb_method_entry_t *m2);
215
+ st_index_t rb_hash_method_entry(st_index_t hash, const rb_method_entry_t *me);
216
+
217
+ VALUE rb_method_entry_location(const rb_method_entry_t *me);
218
+
219
+ void rb_free_method_entry(const rb_method_entry_t *me);
220
+
221
+ const rb_method_entry_t *rb_method_entry_clone(const rb_method_entry_t *me);
222
+ const rb_callable_method_entry_t *rb_method_entry_complement_defined_class(const rb_method_entry_t *src_me, ID called_id, VALUE defined_class);
223
+ void rb_method_entry_copy(rb_method_entry_t *dst, const rb_method_entry_t *src);
224
+
225
+ void rb_scope_visibility_set(rb_method_visibility_t);
226
+
227
+ VALUE rb_unnamed_parameters(int arity);
228
+
229
+ #endif /* RUBY_METHOD_H */
@@ -12,17 +12,19 @@
12
12
  # define Looksee_method_table_lookup st_lookup
13
13
  #endif
14
14
 
15
+ #if RUBY_VERSION < 230
15
16
  static int add_method_if_undefined(ID method_name, rb_method_entry_t *me, VALUE *names) {
16
- #ifdef ID_ALLOCATOR
17
+ # ifdef ID_ALLOCATOR
17
18
  /* The allocator can be undefined with rb_undef_alloc_func, e.g. Struct. */
18
19
  if (method_name == ID_ALLOCATOR)
19
20
  return ST_CONTINUE;
20
- #endif
21
+ # endif
21
22
 
22
23
  if (UNDEFINED_METHOD_ENTRY_P(me))
23
24
  rb_ary_push(*names, ID2SYM(method_name));
24
25
  return ST_CONTINUE;
25
26
  }
27
+ #endif
26
28
 
27
29
  /*
28
30
  * Return the list of undefined instance methods (as Symbols) of the
@@ -1,5 +1,5 @@
1
1
  module Looksee
2
- VERSION = [4, 1, 0]
2
+ VERSION = [4, 2, 0]
3
3
 
4
4
  class << VERSION
5
5
  include Comparable
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: looksee
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - George Ogata
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-25 00:00:00.000000000 Z
11
+ date: 2019-12-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -32,10 +32,11 @@ files:
32
32
  - ext/mri/2.2.0/method.h
33
33
  - ext/mri/2.3.0/internal.h
34
34
  - ext/mri/2.3.0/method.h
35
+ - ext/mri/2.7.0/internal.h
36
+ - ext/mri/2.7.0/method.h
35
37
  - ext/mri/mri.c
36
38
  - ext/rbx/rbx.c
37
39
  - lib/looksee.rb
38
- - lib/looksee/JRuby.jar
39
40
  - lib/looksee/adapter.rb
40
41
  - lib/looksee/adapter/base.rb
41
42
  - lib/looksee/adapter/rubinius.rb
@@ -46,7 +47,6 @@ files:
46
47
  - lib/looksee/help.rb
47
48
  - lib/looksee/inspector.rb
48
49
  - lib/looksee/lookup_path.rb
49
- - lib/looksee/mri.bundle
50
50
  - lib/looksee/version.rb
51
51
  - spec/looksee/adapter_spec.rb
52
52
  - spec/looksee/clean_spec.rb
@@ -78,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
78
  - !ruby/object:Gem::Version
79
79
  version: '0'
80
80
  requirements: []
81
- rubygems_version: 3.0.3
81
+ rubygems_version: 3.1.2
82
82
  signing_key:
83
83
  specification_version: 3
84
84
  summary: Supercharged method introspection in IRB.
Binary file
Binary file