looksee 2.1.1 → 3.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 +6 -0
- data/README.markdown +10 -3
- data/ext/extconf.rb +3 -1
- data/ext/mri/2.2.0/internal.h +1182 -0
- data/ext/mri/2.2.0/method.h +141 -0
- data/lib/looksee.rb +0 -3
- data/lib/looksee/JRuby.jar +0 -0
- data/lib/looksee/core_ext.rb +14 -3
- data/lib/looksee/version.rb +1 -1
- data/spec/looksee/adapter_spec.rb +1 -1
- metadata +5 -6
- data/lib/looksee/wirble_compatibility.rb +0 -86
- data/spec/looksee/wirble_compatibility_spec.rb +0 -116
@@ -0,0 +1,141 @@
|
|
1
|
+
/**********************************************************************
|
2
|
+
|
3
|
+
method.h -
|
4
|
+
|
5
|
+
$Author: normal $
|
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
|
+
#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
|
+
typedef enum {
|
25
|
+
NOEX_PUBLIC = 0x00,
|
26
|
+
NOEX_NOSUPER = 0x01,
|
27
|
+
NOEX_PRIVATE = 0x02,
|
28
|
+
NOEX_PROTECTED = 0x04,
|
29
|
+
NOEX_MASK = 0x06,
|
30
|
+
NOEX_BASIC = 0x08,
|
31
|
+
NOEX_UNDEF = NOEX_NOSUPER,
|
32
|
+
NOEX_MODFUNC = 0x12,
|
33
|
+
NOEX_SUPER = 0x20,
|
34
|
+
NOEX_VCALL = 0x40,
|
35
|
+
NOEX_RESPONDS = 0x80,
|
36
|
+
|
37
|
+
NOEX_BIT_WIDTH = 8,
|
38
|
+
NOEX_SAFE_SHIFT_OFFSET = ((NOEX_BIT_WIDTH+3)/4)*4 /* round up to nibble */
|
39
|
+
} rb_method_flag_t;
|
40
|
+
|
41
|
+
#define NOEX_SAFE(n) ((int)((n) >> NOEX_SAFE_SHIFT_OFFSET) & 0x0F)
|
42
|
+
#define NOEX_WITH(n, s) (((s) << NOEX_SAFE_SHIFT_OFFSET) | (n) | (ruby_running ? 0 : NOEX_BASIC))
|
43
|
+
#define NOEX_WITH_SAFE(n) NOEX_WITH((n), rb_safe_level())
|
44
|
+
|
45
|
+
/* method data type */
|
46
|
+
|
47
|
+
typedef enum {
|
48
|
+
VM_METHOD_TYPE_ISEQ,
|
49
|
+
VM_METHOD_TYPE_CFUNC,
|
50
|
+
VM_METHOD_TYPE_ATTRSET,
|
51
|
+
VM_METHOD_TYPE_IVAR,
|
52
|
+
VM_METHOD_TYPE_BMETHOD,
|
53
|
+
VM_METHOD_TYPE_ZSUPER,
|
54
|
+
VM_METHOD_TYPE_UNDEF,
|
55
|
+
VM_METHOD_TYPE_NOTIMPLEMENTED,
|
56
|
+
VM_METHOD_TYPE_OPTIMIZED, /* Kernel#send, Proc#call, etc */
|
57
|
+
VM_METHOD_TYPE_MISSING, /* wrapper for method_missing(id) */
|
58
|
+
VM_METHOD_TYPE_REFINED,
|
59
|
+
|
60
|
+
END_OF_ENUMERATION(VM_METHOD_TYPE)
|
61
|
+
} rb_method_type_t;
|
62
|
+
|
63
|
+
struct rb_call_info_struct;
|
64
|
+
|
65
|
+
typedef struct rb_method_cfunc_struct {
|
66
|
+
VALUE (*func)(ANYARGS);
|
67
|
+
VALUE (*invoker)(VALUE (*func)(ANYARGS), VALUE recv, int argc, const VALUE *argv);
|
68
|
+
int argc;
|
69
|
+
} rb_method_cfunc_t;
|
70
|
+
|
71
|
+
typedef struct rb_method_attr_struct {
|
72
|
+
ID id;
|
73
|
+
const VALUE location;
|
74
|
+
} rb_method_attr_t;
|
75
|
+
|
76
|
+
typedef struct rb_iseq_struct rb_iseq_t;
|
77
|
+
|
78
|
+
typedef struct rb_method_definition_struct {
|
79
|
+
rb_method_type_t type; /* method type */
|
80
|
+
int alias_count;
|
81
|
+
ID original_id;
|
82
|
+
union {
|
83
|
+
rb_iseq_t * const iseq; /* should be mark */
|
84
|
+
rb_method_cfunc_t cfunc;
|
85
|
+
rb_method_attr_t attr;
|
86
|
+
const VALUE proc; /* should be mark */
|
87
|
+
enum method_optimized_type {
|
88
|
+
OPTIMIZED_METHOD_TYPE_SEND,
|
89
|
+
OPTIMIZED_METHOD_TYPE_CALL,
|
90
|
+
|
91
|
+
OPTIMIZED_METHOD_TYPE__MAX
|
92
|
+
} optimize_type;
|
93
|
+
struct rb_method_entry_struct *orig_me;
|
94
|
+
} body;
|
95
|
+
} rb_method_definition_t;
|
96
|
+
|
97
|
+
typedef struct rb_method_entry_struct {
|
98
|
+
rb_method_flag_t flag;
|
99
|
+
char mark;
|
100
|
+
rb_method_definition_t *def;
|
101
|
+
ID called_id;
|
102
|
+
VALUE klass; /* should be mark */
|
103
|
+
} rb_method_entry_t;
|
104
|
+
|
105
|
+
struct unlinked_method_entry_list_entry {
|
106
|
+
struct unlinked_method_entry_list_entry *next;
|
107
|
+
rb_method_entry_t *me;
|
108
|
+
};
|
109
|
+
|
110
|
+
#define UNDEFINED_METHOD_ENTRY_P(me) (!(me) || !(me)->def || (me)->def->type == VM_METHOD_TYPE_UNDEF)
|
111
|
+
|
112
|
+
void rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_method_flag_t noex);
|
113
|
+
rb_method_entry_t *rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *option, rb_method_flag_t noex);
|
114
|
+
rb_method_entry_t *rb_method_entry(VALUE klass, ID id, VALUE *define_class_ptr);
|
115
|
+
rb_method_entry_t *rb_method_entry_at(VALUE obj, ID id);
|
116
|
+
void rb_add_refined_method_entry(VALUE refined_class, ID mid);
|
117
|
+
rb_method_entry_t *rb_resolve_refined_method(VALUE refinements,
|
118
|
+
const rb_method_entry_t *me,
|
119
|
+
VALUE *defined_class_ptr);
|
120
|
+
rb_method_entry_t *rb_method_entry_with_refinements(VALUE klass, ID id,
|
121
|
+
VALUE *defined_class_ptr);
|
122
|
+
rb_method_entry_t *rb_method_entry_without_refinements(VALUE klass, ID id,
|
123
|
+
VALUE *defined_class_ptr);
|
124
|
+
|
125
|
+
rb_method_entry_t *rb_method_entry_get_without_cache(VALUE klass, ID id, VALUE *define_class_ptr);
|
126
|
+
rb_method_entry_t *rb_method_entry_set(VALUE klass, ID mid, const rb_method_entry_t *, rb_method_flag_t noex);
|
127
|
+
|
128
|
+
int rb_method_entry_arity(const rb_method_entry_t *me);
|
129
|
+
int rb_method_entry_eq(const rb_method_entry_t *m1, const rb_method_entry_t *m2);
|
130
|
+
st_index_t rb_hash_method_entry(st_index_t hash, const rb_method_entry_t *me);
|
131
|
+
|
132
|
+
VALUE rb_method_entry_location(rb_method_entry_t *me);
|
133
|
+
VALUE rb_mod_method_location(VALUE mod, ID id);
|
134
|
+
VALUE rb_obj_method_location(VALUE obj, ID id);
|
135
|
+
|
136
|
+
void rb_mark_method_entry(const rb_method_entry_t *me);
|
137
|
+
void rb_free_method_entry(rb_method_entry_t *me);
|
138
|
+
void rb_sweep_method_entry(void *vm);
|
139
|
+
void rb_free_m_tbl_wrapper(struct method_table_wrapper *wrapper);
|
140
|
+
|
141
|
+
#endif /* METHOD_H */
|
data/lib/looksee.rb
CHANGED
data/lib/looksee/JRuby.jar
CHANGED
Binary file
|
data/lib/looksee/core_ext.rb
CHANGED
@@ -1,10 +1,21 @@
|
|
1
1
|
module Looksee
|
2
2
|
module ObjectMixin
|
3
3
|
#
|
4
|
-
#
|
4
|
+
# Define #ls as a shortcut for Looksee[self, *args].
|
5
5
|
#
|
6
|
-
|
7
|
-
|
6
|
+
# This is defined via method_missing to be less intrusive. pry 0.10, e.g.,
|
7
|
+
# relies on Object#ls not existing.
|
8
|
+
#
|
9
|
+
def method_missing(name, *args)
|
10
|
+
if name == :ls
|
11
|
+
Looksee[self, *args]
|
12
|
+
else
|
13
|
+
super
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def respond_to?(name, include_private=false)
|
18
|
+
super || name == :ls
|
8
19
|
end
|
9
20
|
|
10
21
|
def self.rename(name) # :nodoc:
|
data/lib/looksee/version.rb
CHANGED
@@ -569,7 +569,7 @@ describe "Looksee.adapter" do
|
|
569
569
|
end
|
570
570
|
|
571
571
|
it "should return nil for primitive methods (MRI CBODY)" do
|
572
|
-
method =
|
572
|
+
method = String.instance_method(:bytesize)
|
573
573
|
@adapter.source_location(method).should == nil
|
574
574
|
end
|
575
575
|
|
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
|
+
version: 3.0.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:
|
11
|
+
date: 2015-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -47,6 +47,8 @@ files:
|
|
47
47
|
- ext/mri/2.0.0/method.h
|
48
48
|
- ext/mri/2.1.0/internal.h
|
49
49
|
- ext/mri/2.1.0/method.h
|
50
|
+
- ext/mri/2.2.0/internal.h
|
51
|
+
- ext/mri/2.2.0/method.h
|
50
52
|
- ext/mri/env-1.8.h
|
51
53
|
- ext/mri/eval_c-1.8.h
|
52
54
|
- ext/mri/mri.c
|
@@ -66,7 +68,6 @@ files:
|
|
66
68
|
- lib/looksee/lookup_path.rb
|
67
69
|
- lib/looksee/rbx.bundle
|
68
70
|
- lib/looksee/version.rb
|
69
|
-
- lib/looksee/wirble_compatibility.rb
|
70
71
|
- spec/looksee/adapter_spec.rb
|
71
72
|
- spec/looksee/clean_spec.rb
|
72
73
|
- spec/looksee/columnizer_spec.rb
|
@@ -74,7 +75,6 @@ files:
|
|
74
75
|
- spec/looksee/editor_spec.rb
|
75
76
|
- spec/looksee/inspector_spec.rb
|
76
77
|
- spec/looksee/lookup_path_spec.rb
|
77
|
-
- spec/looksee/wirble_compatibility_spec.rb
|
78
78
|
- spec/spec_helper.rb
|
79
79
|
- spec/support/core_ext.rb
|
80
80
|
- spec/support/temporary_classes.rb
|
@@ -99,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
99
|
version: '0'
|
100
100
|
requirements: []
|
101
101
|
rubyforge_project:
|
102
|
-
rubygems_version: 2.
|
102
|
+
rubygems_version: 2.4.3
|
103
103
|
signing_key:
|
104
104
|
specification_version: 3
|
105
105
|
summary: Supercharged method introspection in IRB.
|
@@ -111,7 +111,6 @@ test_files:
|
|
111
111
|
- spec/looksee/editor_spec.rb
|
112
112
|
- spec/looksee/inspector_spec.rb
|
113
113
|
- spec/looksee/lookup_path_spec.rb
|
114
|
-
- spec/looksee/wirble_compatibility_spec.rb
|
115
114
|
- spec/spec_helper.rb
|
116
115
|
- spec/support/core_ext.rb
|
117
116
|
- spec/support/temporary_classes.rb
|
@@ -1,86 +0,0 @@
|
|
1
|
-
module Looksee
|
2
|
-
module WirbleCompatibility
|
3
|
-
class << self
|
4
|
-
def wirble_loaded?
|
5
|
-
Object.const_defined?(:Wirble) &&
|
6
|
-
Wirble.is_a?(Module) &&
|
7
|
-
Wirble.respond_to?(:colorize)
|
8
|
-
end
|
9
|
-
|
10
|
-
def wirble_colorizing?
|
11
|
-
require 'irb'
|
12
|
-
IRB::Irb.method_defined?(:non_color_output_value)
|
13
|
-
end
|
14
|
-
|
15
|
-
def hook_into_wirble_load
|
16
|
-
unless Object.const_defined?(:Wirble)
|
17
|
-
Object.const_set :Wirble, Module.new
|
18
|
-
end
|
19
|
-
Wirble.send :extend, WirbleLoadHook
|
20
|
-
end
|
21
|
-
|
22
|
-
def hook_into_wirble_colorize
|
23
|
-
class << Wirble
|
24
|
-
def colorize_with_looksee(*args)
|
25
|
-
# If this gets called twice, Wirble will fuck up the
|
26
|
-
# aliases. Disable colorizing first to reset them.
|
27
|
-
if WirbleCompatibility.hooked_into_irb_output_value?
|
28
|
-
Wirble::Colorize.disable
|
29
|
-
end
|
30
|
-
colorize_without_looksee(*args)
|
31
|
-
WirbleCompatibility.hook_into_irb_output_value
|
32
|
-
end
|
33
|
-
|
34
|
-
alias colorize_without_looksee colorize
|
35
|
-
alias colorize colorize_with_looksee
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def hook_into_irb_output_value
|
40
|
-
IRB::Irb.class_eval do
|
41
|
-
def output_value_with_looksee
|
42
|
-
case @context.last_value
|
43
|
-
when Looksee::Inspector, Looksee::Help
|
44
|
-
non_color_output_value
|
45
|
-
else
|
46
|
-
output_value_without_looksee
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
alias output_value_without_looksee output_value
|
51
|
-
alias output_value output_value_with_looksee
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def hooked_into_irb_output_value?
|
56
|
-
IRB::Irb.method_defined?(:output_value_with_looksee)
|
57
|
-
end
|
58
|
-
|
59
|
-
def init
|
60
|
-
#
|
61
|
-
# How wirble is used:
|
62
|
-
#
|
63
|
-
# * Wirble is required/loaded. Defines Wirble module, with methods like Wirble.colorize.
|
64
|
-
# * Wirble.init is called. Nothing interesting.
|
65
|
-
# * Wirble.colorize is called. Hooks into IRB::Irb.output_value via an alias.
|
66
|
-
#
|
67
|
-
if !wirble_loaded?
|
68
|
-
hook_into_wirble_load
|
69
|
-
elsif !wirble_colorizing?
|
70
|
-
hook_into_wirble_colorize
|
71
|
-
else
|
72
|
-
hook_into_irb_output_value
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
module WirbleLoadHook
|
78
|
-
def singleton_method_added(name)
|
79
|
-
if name == :colorize && !respond_to?(:colorize_with_looksee)
|
80
|
-
WirbleCompatibility.hook_into_wirble_colorize
|
81
|
-
end
|
82
|
-
super
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
@@ -1,116 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Looksee::WirbleCompatibility do
|
4
|
-
describe "when looksee is loaded" do
|
5
|
-
#
|
6
|
-
# Run the given ruby string, and return the standard output.
|
7
|
-
#
|
8
|
-
def init_irb_with(code)
|
9
|
-
code = <<-EOS.demargin
|
10
|
-
|#{code}
|
11
|
-
|#{setup_code}
|
12
|
-
|c.ls
|
13
|
-
EOS
|
14
|
-
code = code.chomp.gsub(/\n/, ';') # only print value of last line
|
15
|
-
lib = File.expand_path('lib')
|
16
|
-
# irb hangs when using readline without a tty
|
17
|
-
output = IO.popen("bundle exec irb -f --noreadline --noprompt --noverbose -I#{lib}", 'r+') do |io|
|
18
|
-
io.puts code
|
19
|
-
io.flush
|
20
|
-
io.close_write
|
21
|
-
io.read
|
22
|
-
end
|
23
|
-
# Ruby 1.9.3 prints gc parameters if configured
|
24
|
-
nil while output.gsub!(/^(?:malloc_limit|heap_min_slots|free_min)=.*\n/, '')
|
25
|
-
# Ruby 1.9.2 prints an extra newline on exit.
|
26
|
-
output.chomp! if RUBY_VERSION >= '1.9.2'
|
27
|
-
output
|
28
|
-
end
|
29
|
-
|
30
|
-
def setup_code
|
31
|
-
<<-EOS.demargin
|
32
|
-
|C = Class.new
|
33
|
-
|c = C.new
|
34
|
-
|#{File.read('spec/support/test_adapter.rb')}
|
35
|
-
|
|
36
|
-
|Looksee.styles = Hash.new{'%s'}
|
37
|
-
|Looksee.styles[:public] = "\\e[1;32m%s\\e[0m"
|
38
|
-
|NATIVE_ADAPTER = Looksee.adapter
|
39
|
-
|Looksee.adapter = TestAdapter.new
|
40
|
-
|Looksee.adapter.ancestors[c] = [C]
|
41
|
-
|Looksee.adapter.public_methods[C] = [:a]
|
42
|
-
EOS
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should work if wirble is not loaded" do
|
46
|
-
output = init_irb_with(<<-EOS.demargin)
|
47
|
-
|require 'irb'
|
48
|
-
|require 'looksee'
|
49
|
-
|require 'wirble'
|
50
|
-
|Wirble.init
|
51
|
-
|Wirble.colorize
|
52
|
-
EOS
|
53
|
-
output.should == <<-EOS.demargin
|
54
|
-
|C
|
55
|
-
| \e[1;32ma\e[0m
|
56
|
-
EOS
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should work if wirble is loaded, but not initialized" do
|
60
|
-
output = init_irb_with(<<-EOS.demargin)
|
61
|
-
|require 'irb'
|
62
|
-
|require 'wirble'
|
63
|
-
|require 'looksee'
|
64
|
-
|Wirble.init
|
65
|
-
|Wirble.colorize
|
66
|
-
EOS
|
67
|
-
output.should == <<-EOS.demargin
|
68
|
-
|C
|
69
|
-
| \e[1;32ma\e[0m
|
70
|
-
EOS
|
71
|
-
end
|
72
|
-
|
73
|
-
it "should work if wirble is loaded and initialized, but colorizing is off" do
|
74
|
-
output = init_irb_with(<<-EOS.demargin)
|
75
|
-
|require 'irb'
|
76
|
-
|require 'wirble'
|
77
|
-
|Wirble.init
|
78
|
-
|require 'looksee'
|
79
|
-
|Wirble.colorize
|
80
|
-
EOS
|
81
|
-
output.should == <<-EOS.demargin
|
82
|
-
|C
|
83
|
-
| \e[1;32ma\e[0m
|
84
|
-
EOS
|
85
|
-
end
|
86
|
-
|
87
|
-
it "should work if wirble is loaded, initialized, and colorizing is on" do
|
88
|
-
output = init_irb_with(<<-EOS.demargin)
|
89
|
-
|require 'irb'
|
90
|
-
|require 'wirble'
|
91
|
-
|Wirble.init
|
92
|
-
|Wirble.colorize
|
93
|
-
|require 'looksee'
|
94
|
-
EOS
|
95
|
-
output.should == <<-EOS.demargin
|
96
|
-
|C
|
97
|
-
| \e[1;32ma\e[0m
|
98
|
-
EOS
|
99
|
-
end
|
100
|
-
|
101
|
-
it "should work if wirble colorizing is enabled twice" do
|
102
|
-
output = init_irb_with(<<-EOS.demargin)
|
103
|
-
|require 'irb'
|
104
|
-
|require 'looksee'
|
105
|
-
|require 'wirble'
|
106
|
-
|Wirble.init
|
107
|
-
|Wirble.colorize
|
108
|
-
|Wirble.colorize
|
109
|
-
EOS
|
110
|
-
output.should == <<-EOS.demargin
|
111
|
-
|C
|
112
|
-
| \e[1;32ma\e[0m
|
113
|
-
EOS
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|