binding_of_caller 0.4.0 → 0.4.1
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.
- data/ext/binding_of_caller/binding_of_caller.c +3 -13
- data/lib/binding_of_caller/version.rb +1 -1
- metadata +31 -35
@@ -1,16 +1,11 @@
|
|
1
1
|
/* (c) 2011 John Mair (banisterfiend), MIT license */
|
2
2
|
|
3
3
|
#include <ruby.h>
|
4
|
-
|
5
|
-
#include <ruby/io.h>
|
6
|
-
#include <ruby/re.h>
|
7
4
|
#include "vm_core.h"
|
8
5
|
#include "gc.h"
|
9
6
|
|
10
7
|
typedef enum { false, true } bool;
|
11
8
|
|
12
|
-
const int max_frame_errors = 4;
|
13
|
-
|
14
9
|
static size_t
|
15
10
|
binding_memsize(const void *ptr)
|
16
11
|
{
|
@@ -59,22 +54,18 @@ binding_alloc(VALUE klass)
|
|
59
54
|
}
|
60
55
|
|
61
56
|
static bool valid_frame_p(rb_control_frame_t * cfp, rb_control_frame_t * limit_cfp) {
|
62
|
-
if (cfp
|
57
|
+
if (cfp >= limit_cfp)
|
63
58
|
rb_raise(rb_eRuntimeError, "Invalid frame, gone beyond end of stack!");
|
64
59
|
|
65
60
|
return cfp->iseq && !NIL_P(cfp->self);
|
66
61
|
}
|
67
62
|
|
68
63
|
static rb_control_frame_t * find_valid_frame(rb_control_frame_t * cfp, rb_control_frame_t * limit_cfp) {
|
69
|
-
|
70
|
-
|
71
|
-
while (error_count <= max_frame_errors) {
|
64
|
+
while (true) {
|
72
65
|
cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
|
73
66
|
|
74
67
|
if (valid_frame_p(cfp, limit_cfp))
|
75
68
|
return cfp;
|
76
|
-
else
|
77
|
-
error_count += 1;
|
78
69
|
}
|
79
70
|
|
80
71
|
// never reached
|
@@ -100,9 +91,8 @@ static VALUE binding_of_caller(VALUE self, VALUE rb_level)
|
|
100
91
|
VALUE bindval = binding_alloc(rb_cBinding);
|
101
92
|
rb_binding_t *bind;
|
102
93
|
|
103
|
-
if (cfp == 0)
|
94
|
+
if (cfp == 0)
|
104
95
|
rb_raise(rb_eRuntimeError, "Can't create Binding Object on top of Fiber.");
|
105
|
-
}
|
106
96
|
|
107
97
|
GetBindingPtr(bindval, bind);
|
108
98
|
bind->env = rb_vm_make_env_object(th, cfp);
|
metadata
CHANGED
@@ -1,37 +1,35 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: binding_of_caller
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.1
|
4
5
|
prerelease:
|
5
|
-
version: 0.4.0
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- John Mair (banisterfiend)
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-10-22 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
16
15
|
name: bacon
|
17
|
-
|
18
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70343943988340 !ruby/object:Gem::Requirement
|
19
17
|
none: false
|
20
|
-
requirements:
|
18
|
+
requirements:
|
21
19
|
- - ~>
|
22
|
-
- !ruby/object:Gem::Version
|
20
|
+
- !ruby/object:Gem::Version
|
23
21
|
version: 1.1.0
|
24
22
|
type: :development
|
25
|
-
|
26
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70343943988340
|
25
|
+
description: Retrieve the binding of a method's caller. Can also retrieve bindings
|
26
|
+
even further up the stack. Currently only works for MRI 1.9.2.
|
27
27
|
email: jrmair@gmail.com
|
28
28
|
executables: []
|
29
|
-
|
30
|
-
extensions:
|
29
|
+
extensions:
|
31
30
|
- ext/binding_of_caller/extconf.rb
|
32
31
|
extra_rdoc_files: []
|
33
|
-
|
34
|
-
files:
|
32
|
+
files:
|
35
33
|
- .gemtest
|
36
34
|
- .gitignore
|
37
35
|
- .yardopts
|
@@ -94,30 +92,28 @@ files:
|
|
94
92
|
- test/test.rb
|
95
93
|
homepage: http://github.com/banister/binding_of_caller
|
96
94
|
licenses: []
|
97
|
-
|
98
95
|
post_install_message:
|
99
96
|
rdoc_options: []
|
100
|
-
|
101
|
-
require_paths:
|
97
|
+
require_paths:
|
102
98
|
- lib
|
103
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
104
100
|
none: false
|
105
|
-
requirements:
|
106
|
-
- -
|
107
|
-
- !ruby/object:Gem::Version
|
108
|
-
version:
|
109
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ! '>='
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
106
|
none: false
|
111
|
-
requirements:
|
112
|
-
- -
|
113
|
-
- !ruby/object:Gem::Version
|
114
|
-
version:
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
115
111
|
requirements: []
|
116
|
-
|
117
112
|
rubyforge_project:
|
118
|
-
rubygems_version: 1.8.
|
113
|
+
rubygems_version: 1.8.6
|
119
114
|
signing_key:
|
120
115
|
specification_version: 3
|
121
|
-
summary: Retrieve the binding of a method's caller. Can also retrieve bindings even
|
122
|
-
|
116
|
+
summary: Retrieve the binding of a method's caller. Can also retrieve bindings even
|
117
|
+
further up the stack. Currently only works for MRI 1.9.2.
|
118
|
+
test_files:
|
123
119
|
- test/test.rb
|