looksee 3.1.0-universal-java-1.8 → 4.0.0-universal-java-1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +13 -0
  3. data/README.markdown +61 -81
  4. data/ext/extconf.rb +3 -7
  5. data/ext/mri/2.3.0/internal.h +1404 -0
  6. data/ext/mri/2.3.0/method.h +213 -0
  7. data/ext/mri/mri.c +21 -264
  8. data/ext/rbx/rbx.c +0 -9
  9. data/lib/looksee/JRuby.jar +0 -0
  10. data/lib/looksee/adapter/base.rb +19 -54
  11. data/lib/looksee/adapter/rubinius.rb +3 -62
  12. data/lib/looksee/clean.rb +5 -1
  13. data/lib/looksee/editor.rb +1 -1
  14. data/lib/looksee/help.rb +3 -2
  15. data/lib/looksee/lookup_path.rb +7 -3
  16. data/lib/looksee/version.rb +1 -1
  17. data/spec/looksee/adapter_spec.rb +72 -365
  18. data/spec/looksee/editor_spec.rb +1 -1
  19. data/spec/looksee/inspector_spec.rb +21 -21
  20. data/spec/looksee/lookup_path_spec.rb +34 -21
  21. data/spec/spec_helper.rb +2 -0
  22. data/spec/support/temporary_classes.rb +10 -14
  23. data/spec/support/test_adapter.rb +2 -53
  24. metadata +8 -29
  25. data/ext/mri/1.9.2/debug.h +0 -36
  26. data/ext/mri/1.9.2/id.h +0 -170
  27. data/ext/mri/1.9.2/method.h +0 -103
  28. data/ext/mri/1.9.2/node.h +0 -483
  29. data/ext/mri/1.9.2/thread_pthread.h +0 -27
  30. data/ext/mri/1.9.2/vm_core.h +0 -707
  31. data/ext/mri/1.9.2/vm_opts.h +0 -51
  32. data/ext/mri/1.9.3/atomic.h +0 -56
  33. data/ext/mri/1.9.3/debug.h +0 -41
  34. data/ext/mri/1.9.3/id.h +0 -175
  35. data/ext/mri/1.9.3/internal.h +0 -227
  36. data/ext/mri/1.9.3/internal_falcon.h +0 -248
  37. data/ext/mri/1.9.3/method.h +0 -105
  38. data/ext/mri/1.9.3/node.h +0 -503
  39. data/ext/mri/1.9.3/thread_pthread.h +0 -51
  40. data/ext/mri/1.9.3/vm_core.h +0 -755
  41. data/ext/mri/1.9.3/vm_opts.h +0 -51
  42. data/ext/mri/2.0.0/internal.h +0 -378
  43. data/ext/mri/2.0.0/method.h +0 -138
  44. data/ext/mri/env-1.8.h +0 -27
  45. data/ext/mri/eval_c-1.8.h +0 -27
  46. data/ext/mri/node-1.9.h +0 -35
  47. data/lib/looksee/rbx.bundle +0 -0
@@ -11,8 +11,20 @@ describe Looksee::LookupPath do
11
11
  temporary_class(:C) { include M }
12
12
  @object = Object.new
13
13
  Looksee.adapter.ancestors[@object] = [C, M]
14
- Looksee.adapter.set_methods(M, [:public1, :public2], [:protected1, :protected2], [:private1, :private2], [:undefined1, :undefined2])
15
- Looksee.adapter.set_methods(C, [:public1, :public2], [:protected1, :protected2], [:private1, :private2], [:undefined1, :undefined2])
14
+ add_methods(
15
+ M,
16
+ public: [:pub1, :pub2],
17
+ protected: [:pro1, :pro2],
18
+ private: [:pri1, :pri2],
19
+ undefined: [:und1, :und2],
20
+ )
21
+ add_methods(
22
+ C,
23
+ public: [:pub1, :pub2],
24
+ protected: [:pro1, :pro2],
25
+ private: [:pri1, :pri2],
26
+ undefined: [:und1, :und2],
27
+ )
16
28
  @lookup_path = Looksee::LookupPath.new(@object)
17
29
  end
18
30
 
@@ -22,22 +34,22 @@ describe Looksee::LookupPath do
22
34
 
23
35
  it "should include methods of all visibilities, including overridden ones" do
24
36
  @lookup_path.entries[0].methods.should == {
25
- 'public1' => :public , 'public2' => :public,
26
- 'protected1' => :protected, 'protected2' => :protected,
27
- 'private1' => :private , 'private2' => :private,
28
- 'undefined1' => :undefined, 'undefined2' => :undefined,
37
+ 'pub1' => :public, 'pub2' => :public,
38
+ 'pro1' => :protected, 'pro2' => :protected,
39
+ 'pri1' => :private, 'pri2' => :private,
40
+ 'und1' => :undefined, 'und2' => :undefined,
29
41
  }
30
42
  @lookup_path.entries[1].methods.should == {
31
- 'public1' => :public , 'public2' => :public,
32
- 'protected1' => :protected, 'protected2' => :protected,
33
- 'private1' => :private , 'private2' => :private,
34
- 'undefined1' => :undefined, 'undefined2' => :undefined,
43
+ 'pub1' => :public, 'pub2' => :public,
44
+ 'pro1' => :protected, 'pro2' => :protected,
45
+ 'pri1' => :private, 'pri2' => :private,
46
+ 'und1' => :undefined, 'und2' => :undefined,
35
47
  }
36
48
  end
37
49
 
38
50
  it "should know which methods have been overridden" do
39
- @lookup_path.entries[0].overridden?('public1').should == false
40
- @lookup_path.entries[1].overridden?('public1').should == true
51
+ @lookup_path.entries[0].overridden?('pub1').should == false
52
+ @lookup_path.entries[1].overridden?('pub1').should == true
41
53
  end
42
54
  end
43
55
 
@@ -52,7 +64,7 @@ describe Looksee::LookupPath do
52
64
  lookup_path = Looksee::LookupPath.new(@object)
53
65
  method = lookup_path.find('f')
54
66
  method.owner.should == C
55
- method.name.should == (RUBY_VERSION < "1.9.0" ? 'f' : :f)
67
+ method.name.should == :f
56
68
  end
57
69
 
58
70
  it "should find methods in included modules" do
@@ -60,7 +72,7 @@ describe Looksee::LookupPath do
60
72
  lookup_path = Looksee::LookupPath.new(@object)
61
73
  method = lookup_path.find('g')
62
74
  method.owner.should == M
63
- method.name.should == (RUBY_VERSION < "1.9.0" ? 'g' : :g)
75
+ method.name.should == :g
64
76
  end
65
77
 
66
78
  it "should return nil if the method does not exist" do
@@ -68,19 +80,20 @@ describe Looksee::LookupPath do
68
80
  lookup_path.find('g').should be_nil
69
81
  end
70
82
 
71
- it "should return nil if the method has been undefined" do
72
- C.send(:undef_method, :f)
73
- lookup_path = Looksee::LookupPath.new(@object)
74
- lookup_path.find('f').should be_nil
83
+ unless RUBY_VERSION >= '2.3.0'
84
+ it "should return nil if the method has been undefined" do
85
+ add_methods(C, undefined: [:f])
86
+ lookup_path = Looksee::LookupPath.new(@object)
87
+ lookup_path.find('f').should be_nil
88
+ end
75
89
  end
76
90
  end
77
91
 
78
92
  describe Looksee::LookupPath::Entry do
79
93
  it "should iterate over methods in alphabetical order" do
80
94
  temporary_class(:C)
81
- @object = C.new
82
- Looksee.adapter.stub(internal_public_instance_methods: [:a, :c, :b])
83
- @lookup_path = Looksee::LookupPath.new(@object)
95
+ add_methods(C, public: [:a, :c, :b])
96
+ @lookup_path = Looksee::LookupPath.new(C.new)
84
97
  @lookup_path.entries.first.map{|name, visibility| name}.should == ['a', 'b', 'c']
85
98
  end
86
99
  end
data/spec/spec_helper.rb CHANGED
@@ -2,6 +2,8 @@ $:.unshift File.expand_path('..', File.dirname(__FILE__))
2
2
  ENV['LOOKSEE_METHOD'] = nil
3
3
 
4
4
  require 'rspec'
5
+ require 'pry' unless ENV['CI']
6
+
5
7
  require 'looksee'
6
8
 
7
9
  require 'rbconfig'
@@ -47,10 +47,6 @@ module TemporaryClasses
47
47
  #
48
48
  # +methods+ is a hash of visibilities to names.
49
49
  #
50
- # As Ruby's reflection on singleton classes of classes isn't quite
51
- # adequate, you need to provide a :class_singleton option when such
52
- # a class is given.
53
- #
54
50
  # e.g.:
55
51
  #
56
52
  # replace_methods MyClass, :public => [:a, :b]
@@ -63,16 +59,16 @@ module TemporaryClasses
63
59
  send visibility, name
64
60
  end
65
61
  end
66
- end
67
- end
68
-
69
- private # ---------------------------------------------------------
70
62
 
71
- def all_instance_methods(mod)
72
- names =
73
- mod.public_instance_methods(false) +
74
- mod.protected_instance_methods(false) +
75
- mod.private_instance_methods(false)
76
- names.map{|name| name.to_sym} # they're strings in ruby <1.9
63
+ if (methods = options[:undefined])
64
+ Array(methods).each do |name|
65
+ define_method(name){} unless method_defined?(name)
66
+ undef_method(name)
67
+ end
68
+ if Looksee.adapter.is_a?(TestAdapter)
69
+ Looksee.adapter.set_undefined_methods(mod, methods)
70
+ end
71
+ end
72
+ end
77
73
  end
78
74
  end
@@ -10,74 +10,23 @@ class TestAdapter < Looksee::Adapter::Base
10
10
  ancestors[object]
11
11
  end
12
12
 
13
- def internal_public_instance_methods(mod)
14
- public_methods[mod]
15
- end
16
-
17
- def internal_protected_instance_methods(mod)
18
- protected_methods[mod]
19
- end
20
-
21
- def internal_private_instance_methods(mod)
22
- private_methods[mod]
23
- end
24
-
25
13
  def internal_undefined_instance_methods(mod)
26
14
  undefined_methods[mod]
27
15
  end
28
16
 
29
- def included_class?(object)
30
- NATIVE_ADAPTER.included_class?(object)
31
- end
32
-
33
- def singleton_class?(object)
34
- NATIVE_ADAPTER.singleton_class?(object)
35
- end
36
-
37
17
  def singleton_instance(object)
38
18
  NATIVE_ADAPTER.singleton_instance(object)
39
19
  end
40
20
 
41
- def module_name(object)
42
- NATIVE_ADAPTER.module_name(object)
43
- end
44
-
45
- def set_methods(mod, public, protected, private, undefined)
46
- self.public_methods[mod] = public
47
- self.protected_methods[mod] = protected
48
- self.private_methods[mod] = private
49
- self.undefined_methods[mod] = undefined
50
- end
51
-
52
- def source_location(method)
53
- source_locations[[method.owner.name.to_s, method.name.to_s]]
54
- end
55
-
56
- def set_source_location(mod, method, location)
57
- source_locations[[mod.name.to_s, method.to_s]] = location
21
+ def set_undefined_methods(mod, names)
22
+ self.undefined_methods[mod] = names
58
23
  end
59
24
 
60
25
  def ancestors
61
26
  @ancestors ||= Hash.new { |h, k| h[k] = [] }
62
27
  end
63
28
 
64
- def public_methods
65
- @public_methods ||= Hash.new { |h, k| h[k] = [] }
66
- end
67
-
68
- def protected_methods
69
- @protected_methods ||= Hash.new { |h, k| h[k] = [] }
70
- end
71
-
72
- def private_methods
73
- @private_methods ||= Hash.new { |h, k| h[k] = [] }
74
- end
75
-
76
29
  def undefined_methods
77
30
  @undefined_methods ||= Hash.new { |h, k| h[k] = [] }
78
31
  end
79
-
80
- def source_locations
81
- @source_locations ||= {}
82
- end
83
32
  end
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: 3.1.0
4
+ version: 4.0.0
5
5
  platform: universal-java-1.8
6
6
  authors:
7
7
  - George Ogata
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-06 00:00:00.000000000 Z
11
+ date: 2016-08-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -25,33 +25,13 @@ files:
25
25
  - README.markdown
26
26
  - Rakefile
27
27
  - ext/extconf.rb
28
- - ext/mri/1.9.2/debug.h
29
- - ext/mri/1.9.2/id.h
30
- - ext/mri/1.9.2/method.h
31
- - ext/mri/1.9.2/node.h
32
- - ext/mri/1.9.2/thread_pthread.h
33
- - ext/mri/1.9.2/vm_core.h
34
- - ext/mri/1.9.2/vm_opts.h
35
- - ext/mri/1.9.3/atomic.h
36
- - ext/mri/1.9.3/debug.h
37
- - ext/mri/1.9.3/id.h
38
- - ext/mri/1.9.3/internal.h
39
- - ext/mri/1.9.3/internal_falcon.h
40
- - ext/mri/1.9.3/method.h
41
- - ext/mri/1.9.3/node.h
42
- - ext/mri/1.9.3/thread_pthread.h
43
- - ext/mri/1.9.3/vm_core.h
44
- - ext/mri/1.9.3/vm_opts.h
45
- - ext/mri/2.0.0/internal.h
46
- - ext/mri/2.0.0/method.h
47
28
  - ext/mri/2.1.0/internal.h
48
29
  - ext/mri/2.1.0/method.h
49
30
  - ext/mri/2.2.0/internal.h
50
31
  - ext/mri/2.2.0/method.h
51
- - ext/mri/env-1.8.h
52
- - ext/mri/eval_c-1.8.h
32
+ - ext/mri/2.3.0/internal.h
33
+ - ext/mri/2.3.0/method.h
53
34
  - ext/mri/mri.c
54
- - ext/mri/node-1.9.h
55
35
  - ext/rbx/rbx.c
56
36
  - lib/looksee.rb
57
37
  - lib/looksee/JRuby.jar
@@ -65,7 +45,6 @@ files:
65
45
  - lib/looksee/help.rb
66
46
  - lib/looksee/inspector.rb
67
47
  - lib/looksee/lookup_path.rb
68
- - lib/looksee/rbx.bundle
69
48
  - lib/looksee/version.rb
70
49
  - spec/looksee/adapter_spec.rb
71
50
  - spec/looksee/clean_spec.rb
@@ -88,17 +67,17 @@ require_paths:
88
67
  - lib
89
68
  required_ruby_version: !ruby/object:Gem::Requirement
90
69
  requirements:
91
- - - '>='
70
+ - - ">="
92
71
  - !ruby/object:Gem::Version
93
- version: '0'
72
+ version: '2.1'
94
73
  required_rubygems_version: !ruby/object:Gem::Requirement
95
74
  requirements:
96
- - - '>='
75
+ - - ">="
97
76
  - !ruby/object:Gem::Version
98
77
  version: '0'
99
78
  requirements: []
100
79
  rubyforge_project:
101
- rubygems_version: 2.4.5
80
+ rubygems_version: 2.6.4
102
81
  signing_key:
103
82
  specification_version: 3
104
83
  summary: Supercharged method introspection in IRB.
@@ -1,36 +0,0 @@
1
- /**********************************************************************
2
-
3
- debug.h - YARV Debug function interface
4
-
5
- $Author: akr $
6
- created at: 04/08/25 02:33:49 JST
7
-
8
- Copyright (C) 2004-2007 Koichi Sasada
9
-
10
- **********************************************************************/
11
-
12
- #ifndef RUBY_DEBUG_H
13
- #define RUBY_DEBUG_H
14
-
15
- #include "ruby/ruby.h"
16
- #include "node.h"
17
-
18
- #define dpv(h,v) ruby_debug_print_value(-1, 0, h, v)
19
- #define dp(v) ruby_debug_print_value(-1, 0, "", v)
20
- #define dpi(i) ruby_debug_print_id(-1, 0, "", i)
21
- #define dpn(n) ruby_debug_print_node(-1, 0, "", n)
22
-
23
- #define bp() ruby_debug_breakpoint()
24
-
25
- VALUE ruby_debug_print_value(int level, int debug_level, const char *header, VALUE v);
26
- ID ruby_debug_print_id(int level, int debug_level, const char *header, ID id);
27
- NODE *ruby_debug_print_node(int level, int debug_level, const char *header, const NODE *node);
28
- int ruby_debug_print_indent(int level, int debug_level, int indent_level);
29
- void ruby_debug_breakpoint(void);
30
- void ruby_debug_gc_check_func(void);
31
-
32
- #ifdef RUBY_DEBUG_ENV
33
- void ruby_set_debug_option(const char *str);
34
- #endif
35
-
36
- #endif /* RUBY_DEBUG_H */
data/ext/mri/1.9.2/id.h DELETED
@@ -1,170 +0,0 @@
1
- /* DO NOT EDIT THIS FILE DIRECTLY */
2
- /**********************************************************************
3
-
4
- id.h -
5
-
6
- $Author: akr $
7
- created at: Sun Oct 19 21:12:51 2008
8
-
9
- Copyright (C) 2007 Koichi Sasada
10
-
11
- **********************************************************************/
12
-
13
- #ifndef RUBY_ID_H
14
- #define RUBY_ID_H
15
-
16
- #define ID_SCOPE_SHIFT 3
17
- #define ID_SCOPE_MASK 0x07
18
- #define ID_LOCAL 0x00
19
- #define ID_INSTANCE 0x01
20
- #define ID_GLOBAL 0x03
21
- #define ID_ATTRSET 0x04
22
- #define ID_CONST 0x05
23
- #define ID_CLASS 0x06
24
- #define ID_JUNK 0x07
25
- #define ID_INTERNAL ID_JUNK
26
-
27
- #ifdef USE_PARSE_H
28
- #include "parse.h"
29
- #endif
30
-
31
- #define symIFUNC ID2SYM(idIFUNC)
32
- #define symCFUNC ID2SYM(idCFUNC)
33
-
34
- #if !defined tLAST_TOKEN && defined YYTOKENTYPE
35
- #define tLAST_TOKEN tLAST_TOKEN
36
- #endif
37
-
38
- enum ruby_method_ids {
39
- #ifndef tLAST_TOKEN
40
- tUPLUS = 321,
41
- tUMINUS = 322,
42
- tPOW = 323,
43
- tCMP = 324,
44
- tEQ = 325,
45
- tEQQ = 326,
46
- tNEQ = 327,
47
- tGEQ = 328,
48
- tLEQ = 329,
49
- tANDOP = 330,
50
- tOROP = 331,
51
- tMATCH = 332,
52
- tNMATCH = 333,
53
- tDOT2 = 334,
54
- tDOT3 = 335,
55
- tAREF = 336,
56
- tASET = 337,
57
- tLSHFT = 338,
58
- tRSHFT = 339,
59
- tLAMBDA = 352,
60
- idNULL = 365,
61
- idRespond_to = 366,
62
- idIFUNC = 367,
63
- idCFUNC = 368,
64
- id_core_set_method_alias = 369,
65
- id_core_set_variable_alias = 370,
66
- id_core_undef_method = 371,
67
- id_core_define_method = 372,
68
- id_core_define_singleton_method = 373,
69
- id_core_set_postexe = 374,
70
- tLAST_TOKEN = 375,
71
- #endif
72
- idDot2 = tDOT2,
73
- idDot3 = tDOT3,
74
- idUPlus = tUPLUS,
75
- idUMinus = tUMINUS,
76
- idPow = tPOW,
77
- idCmp = tCMP,
78
- idPLUS = '+',
79
- idMINUS = '-',
80
- idMULT = '*',
81
- idDIV = '/',
82
- idMOD = '%',
83
- idLT = '<',
84
- idLTLT = tLSHFT,
85
- idLE = tLEQ,
86
- idGT = '>',
87
- idGE = tGEQ,
88
- idEq = tEQ,
89
- idEqq = tEQQ,
90
- idNeq = tNEQ,
91
- idNot = '!',
92
- idBackquote = '`',
93
- idEqTilde = tMATCH,
94
- idNeqTilde = tNMATCH,
95
- idAREF = tAREF,
96
- idASET = tASET,
97
- idLAST_TOKEN = tLAST_TOKEN >> ID_SCOPE_SHIFT,
98
- tIntern,
99
- tMethodMissing,
100
- tLength,
101
- tSize,
102
- tGets,
103
- tSucc,
104
- tEach,
105
- tLambda,
106
- tSend,
107
- t__send__,
108
- tInitialize,
109
- #if SUPPORT_JOKE
110
- tBitblt,
111
- tAnswer,
112
- #endif
113
- tLAST_ID,
114
- #define TOKEN2ID(n) id##n = ((t##n<<ID_SCOPE_SHIFT)|ID_LOCAL)
115
- #if SUPPORT_JOKE
116
- TOKEN2ID(Bitblt),
117
- TOKEN2ID(Answer),
118
- #endif
119
- TOKEN2ID(Intern),
120
- TOKEN2ID(MethodMissing),
121
- TOKEN2ID(Length),
122
- TOKEN2ID(Size),
123
- TOKEN2ID(Gets),
124
- TOKEN2ID(Succ),
125
- TOKEN2ID(Each),
126
- TOKEN2ID(Lambda),
127
- TOKEN2ID(Send),
128
- TOKEN2ID(__send__),
129
- TOKEN2ID(Initialize)
130
- };
131
-
132
- #ifdef tLAST_TOKEN
133
- struct ruby_method_ids_check {
134
- #define ruby_method_id_check_for(name, value) \
135
- int checking_for_##name[name == value ? 1 : -1]
136
- ruby_method_id_check_for(tUPLUS, 321);
137
- ruby_method_id_check_for(tUMINUS, 322);
138
- ruby_method_id_check_for(tPOW, 323);
139
- ruby_method_id_check_for(tCMP, 324);
140
- ruby_method_id_check_for(tEQ, 325);
141
- ruby_method_id_check_for(tEQQ, 326);
142
- ruby_method_id_check_for(tNEQ, 327);
143
- ruby_method_id_check_for(tGEQ, 328);
144
- ruby_method_id_check_for(tLEQ, 329);
145
- ruby_method_id_check_for(tANDOP, 330);
146
- ruby_method_id_check_for(tOROP, 331);
147
- ruby_method_id_check_for(tMATCH, 332);
148
- ruby_method_id_check_for(tNMATCH, 333);
149
- ruby_method_id_check_for(tDOT2, 334);
150
- ruby_method_id_check_for(tDOT3, 335);
151
- ruby_method_id_check_for(tAREF, 336);
152
- ruby_method_id_check_for(tASET, 337);
153
- ruby_method_id_check_for(tLSHFT, 338);
154
- ruby_method_id_check_for(tRSHFT, 339);
155
- ruby_method_id_check_for(tLAMBDA, 352);
156
- ruby_method_id_check_for(idNULL, 365);
157
- ruby_method_id_check_for(idRespond_to, 366);
158
- ruby_method_id_check_for(idIFUNC, 367);
159
- ruby_method_id_check_for(idCFUNC, 368);
160
- ruby_method_id_check_for(id_core_set_method_alias, 369);
161
- ruby_method_id_check_for(id_core_set_variable_alias, 370);
162
- ruby_method_id_check_for(id_core_undef_method, 371);
163
- ruby_method_id_check_for(id_core_define_method, 372);
164
- ruby_method_id_check_for(id_core_define_singleton_method, 373);
165
- ruby_method_id_check_for(id_core_set_postexe, 374);
166
- ruby_method_id_check_for(tLAST_TOKEN, 375);
167
- };
168
- #endif
169
-
170
- #endif /* RUBY_ID_H */
@@ -1,103 +0,0 @@
1
- /**********************************************************************
2
-
3
- method.h -
4
-
5
- $Author: ko1 $
6
- created at: Wed Jul 15 20:02:33 2009
7
-
8
- Copyright (C) 2009 Koichi Sasada
9
-
10
- **********************************************************************/
11
- #ifndef METHOD_H
12
- #define METHOD_H
13
-
14
- typedef enum {
15
- NOEX_PUBLIC = 0x00,
16
- NOEX_NOSUPER = 0x01,
17
- NOEX_PRIVATE = 0x02,
18
- NOEX_PROTECTED = 0x04,
19
- NOEX_MASK = 0x06,
20
- NOEX_BASIC = 0x08,
21
- NOEX_UNDEF = NOEX_NOSUPER,
22
- NOEX_MODFUNC = 0x12,
23
- NOEX_SUPER = 0x20,
24
- NOEX_VCALL = 0x40,
25
- NOEX_RESPONDS = 0x80
26
- } rb_method_flag_t;
27
-
28
- #define NOEX_SAFE(n) ((int)((n) >> 8) & 0x0F)
29
- #define NOEX_WITH(n, s) ((s << 8) | (n) | (ruby_running ? 0 : NOEX_BASIC))
30
- #define NOEX_WITH_SAFE(n) NOEX_WITH(n, rb_safe_level())
31
-
32
- /* method data type */
33
-
34
- typedef enum {
35
- VM_METHOD_TYPE_ISEQ,
36
- VM_METHOD_TYPE_CFUNC,
37
- VM_METHOD_TYPE_ATTRSET,
38
- VM_METHOD_TYPE_IVAR,
39
- VM_METHOD_TYPE_BMETHOD,
40
- VM_METHOD_TYPE_ZSUPER,
41
- VM_METHOD_TYPE_UNDEF,
42
- VM_METHOD_TYPE_NOTIMPLEMENTED,
43
- VM_METHOD_TYPE_OPTIMIZED, /* Kernel#send, Proc#call, etc */
44
- VM_METHOD_TYPE_MISSING /* wrapper for method_missing(id) */
45
- } rb_method_type_t;
46
-
47
- typedef struct rb_method_cfunc_struct {
48
- VALUE (*func)(ANYARGS);
49
- int argc;
50
- } rb_method_cfunc_t;
51
-
52
- typedef struct rb_method_attr_struct {
53
- ID id;
54
- VALUE location;
55
- } rb_method_attr_t;
56
-
57
- typedef struct rb_iseq_struct rb_iseq_t;
58
-
59
- typedef struct rb_method_definition_struct {
60
- rb_method_type_t type; /* method type */
61
- ID original_id;
62
- union {
63
- rb_iseq_t *iseq; /* should be mark */
64
- rb_method_cfunc_t cfunc;
65
- rb_method_attr_t attr;
66
- VALUE proc; /* should be mark */
67
- enum method_optimized_type {
68
- OPTIMIZED_METHOD_TYPE_SEND,
69
- OPTIMIZED_METHOD_TYPE_CALL
70
- } optimize_type;
71
- } body;
72
- int alias_count;
73
- } rb_method_definition_t;
74
-
75
- typedef struct rb_method_entry_struct {
76
- rb_method_flag_t flag;
77
- char mark;
78
- rb_method_definition_t *def;
79
- ID called_id;
80
- VALUE klass; /* should be mark */
81
- } rb_method_entry_t;
82
-
83
- struct unlinked_method_entry_list_entry {
84
- struct unlinked_method_entry_list_entry *next;
85
- rb_method_entry_t *me;
86
- };
87
-
88
- #define UNDEFINED_METHOD_ENTRY_P(me) (!(me) || !(me)->def || (me)->def->type == VM_METHOD_TYPE_UNDEF)
89
-
90
- void rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_method_flag_t noex);
91
- rb_method_entry_t *rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *option, rb_method_flag_t noex);
92
- rb_method_entry_t *rb_method_entry(VALUE klass, ID id);
93
-
94
- rb_method_entry_t *rb_method_entry_get_without_cache(VALUE klass, ID id);
95
- rb_method_entry_t *rb_method_entry_set(VALUE klass, ID mid, const rb_method_entry_t *, rb_method_flag_t noex);
96
-
97
- int rb_method_entry_arity(const rb_method_entry_t *me);
98
-
99
- void rb_mark_method_entry(const rb_method_entry_t *me);
100
- void rb_free_method_entry(rb_method_entry_t *me);
101
- void rb_sweep_method_entry(void *vm);
102
-
103
- #endif /* METHOD_H */