boc 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.rdoc ADDED
@@ -0,0 +1,16 @@
1
+
2
+ = boc Changes
3
+
4
+ == Version 0.3.2
5
+
6
+ * "rake test" now works without rake-compiler on Windows
7
+ * additions to readme
8
+
9
+ == Version 0.3.1
10
+
11
+ * add prototype for rb_funcall_passing block
12
+ (http://redmine.ruby-lang.org/issues/4504)
13
+
14
+ == Version 0.3.0
15
+
16
+ * birthday
data/MANIFEST ADDED
@@ -0,0 +1,14 @@
1
+ CHANGES.rdoc
2
+ MANIFEST
3
+ README.rdoc
4
+ Rakefile
5
+ devel/levitate.rb
6
+ ext/boc/boc.c
7
+ ext/boc/extconf.rb
8
+ lib/boc.rb
9
+ lib/boc/binding_of_caller.rb
10
+ lib/boc/version.rb
11
+ test/basic_test.rb
12
+ test/main.rb
13
+ test/readme_test.rb
14
+ test/shim_test.rb
data/README.rdoc ADDED
@@ -0,0 +1,119 @@
1
+
2
+ = boc
3
+
4
+ == Summary
5
+
6
+ Binding of caller.
7
+
8
+ == Synopsis
9
+
10
+ require 'boc'
11
+
12
+ class A
13
+ def f
14
+ p eval("x", Boc.value)
15
+ end
16
+ end
17
+
18
+ Boc.enable A, :f
19
+ x = 33
20
+ A.new.f # => 33
21
+
22
+ == Install
23
+
24
+ % gem install boc
25
+
26
+ Or from inside an unpacked .tgz download, <code>rake install</code> /
27
+ <code>rake uninstall</code>.
28
+
29
+ == Description
30
+
31
+ Binding of caller: obtain a caller's binding.
32
+
33
+ MRI 1.9.2 is required. Support for other Ruby platforms is a goal.
34
+
35
+ == <code>Binding.of_caller</code>
36
+
37
+ <code>require 'boc/binding_of_caller'</code> will define
38
+ <code>Binding.of_caller</code> (not present by default).
39
+
40
+ require 'boc/binding_of_caller'
41
+
42
+ class A
43
+ def f
44
+ Binding.of_caller do |bind|
45
+ p eval("x", bind)
46
+ end
47
+ end
48
+ end
49
+
50
+ Boc.enable A, :f
51
+ x = 33
52
+ A.new.f # => 33
53
+
54
+ This is not an actual compatibility layer since the call to +enable+
55
+ is still necessary. <code>Binding.of_caller</code> is merely a
56
+ convenience method for existing 1.8 code.
57
+
58
+ == Links
59
+
60
+ * Home: http://quix.github.com/boc
61
+ * Feature Requests, Bug Reports: http://github.com/quix/boc/issues
62
+ * Manual Download: http://github.com/quix/boc/archives/master
63
+ * Repository: http://github.com/quix/boc
64
+
65
+ == Implementation
66
+
67
+ <code>Boc.enable(A, :f)</code> is essentially
68
+
69
+ class A
70
+ alias_method :f__impl, :f
71
+ end
72
+
73
+ followed by a redefinition of +f+. The new +f+ is a native method
74
+ which sets <code>Boc.value</code> and then forwards the incoming
75
+ arguments to +f__impl+.
76
+
77
+ == Background
78
+
79
+ After adapting the old continuation-based
80
+ <code>Binding.of_caller</code> to 1.9.2
81
+ (http://quix.github.com/binding_of_caller), I found the result
82
+ unsatisfying. There were syntax restrictions surrounding the use of
83
+ it, and though workaroundable they raised practical problems.
84
+
85
+ While a caller's binding might be obtained by accessesing VM innards,
86
+ this approach would be subject to future breakage. The implementation
87
+ presented herein is a compromise. In exchange for restricting
88
+ functionality (the additional requirement of +enable+),
89
+ binding-of-caller may be implemented straightforwardly with only the
90
+ public C API, meaning that it should work in future MRI releases.
91
+
92
+ == Author
93
+
94
+ * James M. Lawrence < quixoticsycophant@gmail.com >
95
+
96
+ == License
97
+
98
+ Copyright (c) 2011 James M. Lawrence. All rights reserved.
99
+
100
+ Permission is hereby granted, free of charge, to any person
101
+ obtaining a copy of this software and associated documentation files
102
+ (the "Software"), to deal in the Software without restriction,
103
+ including without limitation the rights to use, copy, modify, merge,
104
+ publish, distribute, sublicense, and/or sell copies of the Software,
105
+ and to permit persons to whom the Software is furnished to do so,
106
+ subject to the following conditions:
107
+
108
+ The above copyright notice and this permission notice shall be
109
+ included in all copies or substantial portions of the Software.
110
+
111
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
112
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
113
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
114
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
115
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
116
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
117
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
118
+ SOFTWARE.
119
+
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require_relative 'devel/levitate'
2
+
3
+ Levitate.new "boc" do |s|
4
+ s.developers << ["James M. Lawrence", "quixoticsycophant@gmail.com"]
5
+ s.username = "quix"
6
+ s.required_ruby_version = ">= 1.9.2"
7
+ s.development_dependencies << ["rake-compiler", "~> 0.7.6"]
8
+
9
+ s.rdoc_files = %w[
10
+ lib/boc.rb
11
+ lib/boc/version.rb
12
+ ]
13
+ end