object2module 0.5.0-i386-mingw32 → 0.5.1-i386-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +4 -1
- data/Rakefile +5 -2
- data/ext/object2module/object2module.c +1 -35
- data/lib/1.8/object2module.so +0 -0
- data/lib/1.9/object2module.so +0 -0
- data/lib/object2module/version.rb +1 -1
- metadata +3 -4
- data/test/test_flymake.rb +0 -166
data/README.markdown
CHANGED
@@ -51,7 +51,9 @@ example: gen_extend()
|
|
51
51
|
How it works
|
52
52
|
--------------
|
53
53
|
|
54
|
-
Object2module
|
54
|
+
Object2module removes the check for `T_MODULE` from
|
55
|
+
`rb_include_module()` and prevents inclusion of classes above Object
|
56
|
+
(or meta^n(Object) for singleton classes).
|
55
57
|
|
56
58
|
Companion Libraries
|
57
59
|
--------------------
|
@@ -65,6 +67,7 @@ the language, see also:
|
|
65
67
|
module singleton classes during an include. No more ugly ClassMethods and included() hook hacks.
|
66
68
|
* [Prepend](http://github.com/banister/prepend) - Prepends modules in front of a class; so method lookup starts with the module
|
67
69
|
* [GenEval](http://github.com/banister/gen_eval) - A strange new breed of instance_eval
|
70
|
+
* [LocalEval](http://github.com/banister/local_eval) - instance_eval without changing self
|
68
71
|
|
69
72
|
Contact
|
70
73
|
-------
|
data/Rakefile
CHANGED
@@ -60,8 +60,11 @@ namespace :ruby do
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
+
directories = ["#{direc}/lib/1.8", "#{direc}/lib/1.9"]
|
64
|
+
directories.each { |d| directory d }
|
65
|
+
|
63
66
|
desc "build the 1.8 and 1.9 binaries from source and copy to lib/"
|
64
|
-
task :compile do
|
67
|
+
task :compile => [:clean, *directories] do
|
65
68
|
build_for = proc do |pik_ver, ver|
|
66
69
|
sh %{ \
|
67
70
|
c:\\devkit\\devkitvars.bat && \
|
@@ -80,7 +83,7 @@ task :compile do
|
|
80
83
|
end
|
81
84
|
|
82
85
|
desc "build all platform gems at once"
|
83
|
-
task :gems => [:rmgems, "mingw32:gem", "mswin32:gem", "ruby:gem"]
|
86
|
+
task :gems => [:clean, :rmgems, "mingw32:gem", "mswin32:gem", "ruby:gem"]
|
84
87
|
|
85
88
|
desc "remove all platform gems"
|
86
89
|
task :rmgems => ["ruby:clobber_package"]
|
@@ -6,37 +6,6 @@
|
|
6
6
|
#include <ruby.h>
|
7
7
|
#include "compat.h"
|
8
8
|
|
9
|
-
static VALUE
|
10
|
-
class_to_s(VALUE self)
|
11
|
-
{
|
12
|
-
if (!rb_obj_is_kind_of(self, rb_cModule) || self == Qnil)
|
13
|
-
return rb_str_new2("Anon");
|
14
|
-
|
15
|
-
VALUE attached = rb_iv_get(self, "__attached__");
|
16
|
-
VALUE name;
|
17
|
-
|
18
|
-
if (attached) {
|
19
|
-
VALUE val = rb_iv_get(attached, "__module__");
|
20
|
-
/* if (NIL_P(val)) */
|
21
|
-
/* return rb_str_new2("Anon"); */
|
22
|
-
|
23
|
-
name = rb_mod_name(val);
|
24
|
-
}
|
25
|
-
else {
|
26
|
-
VALUE val = rb_iv_get(attached, "__module__");
|
27
|
-
/* if (NIL_P(val)) */
|
28
|
-
/* return rb_str_new2("Anon"); */
|
29
|
-
|
30
|
-
name = rb_mod_name(val);
|
31
|
-
}
|
32
|
-
|
33
|
-
/* if module does not have a name, return "Anon" */
|
34
|
-
if (NIL_P(name) || RSTRING_LEN(name) == 0)
|
35
|
-
return rb_str_new2("Anon");
|
36
|
-
else
|
37
|
-
return name;
|
38
|
-
}
|
39
|
-
|
40
9
|
// also returns true for receiver
|
41
10
|
static VALUE
|
42
11
|
is_meta_singleton_of(VALUE self, VALUE obj)
|
@@ -65,9 +34,6 @@ include_class_new(VALUE module, VALUE super)
|
|
65
34
|
module = RBASIC(module)->klass;
|
66
35
|
}
|
67
36
|
|
68
|
-
// rb_define_singleton_method(module, "to_s", class_to_s, 0);
|
69
|
-
// rb_define_method(module, "to_s", class_to_s, 0);
|
70
|
-
|
71
37
|
if (!RCLASS_IV_TBL(module)) {
|
72
38
|
RCLASS_IV_TBL(module) = st_init_numtable();
|
73
39
|
}
|
@@ -106,7 +72,7 @@ rb_gen_include_one(VALUE klass, VALUE module)
|
|
106
72
|
c = klass;
|
107
73
|
|
108
74
|
// loop until superclass is 0 (for modules) or superclass is a meta^n singleton of Object (for classes)
|
109
|
-
while (module && !
|
75
|
+
while (module && !is_meta_singleton_of(module, rb_cObject)) {
|
110
76
|
int superclass_seen = FALSE;
|
111
77
|
|
112
78
|
if (RCLASS_M_TBL(klass) == RCLASS_M_TBL(module))
|
data/lib/1.8/object2module.so
CHANGED
Binary file
|
data/lib/1.9/object2module.so
CHANGED
Binary file
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 5
|
8
|
-
-
|
9
|
-
version: 0.5.
|
8
|
+
- 1
|
9
|
+
version: 0.5.1
|
10
10
|
platform: i386-mingw32
|
11
11
|
authors:
|
12
12
|
- John Mair (banisterfiend)
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-11-
|
17
|
+
date: 2010-11-18 00:00:00 +13:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
@@ -33,7 +33,6 @@ files:
|
|
33
33
|
- lib/object2module/version.rb
|
34
34
|
- lib/object2module.rb
|
35
35
|
- test/test.rb
|
36
|
-
- test/test_flymake.rb
|
37
36
|
- test/test_simple.rb
|
38
37
|
- test/test_stress.rb
|
39
38
|
- test/test_with_remix.rb
|
data/test/test_flymake.rb
DELETED
@@ -1,166 +0,0 @@
|
|
1
|
-
direc = File.dirname(__FILE__)
|
2
|
-
require 'rubygems'
|
3
|
-
require 'bacon'
|
4
|
-
require "#{direc}/../lib/object2module"
|
5
|
-
|
6
|
-
class Module
|
7
|
-
public :include, :remove_const
|
8
|
-
end
|
9
|
-
|
10
|
-
puts "testing Object2module version #{Object2module::VERSION}..."
|
11
|
-
|
12
|
-
describe Object2module do
|
13
|
-
before do
|
14
|
-
class A
|
15
|
-
def a
|
16
|
-
:a
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
class B
|
21
|
-
def b
|
22
|
-
:b
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
module M
|
27
|
-
def m
|
28
|
-
:m
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
O = Object.new
|
33
|
-
class << O
|
34
|
-
def o
|
35
|
-
:o
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
C = Class.new
|
40
|
-
end
|
41
|
-
|
42
|
-
after do
|
43
|
-
Object.remove_const(:A)
|
44
|
-
Object.remove_const(:B)
|
45
|
-
Object.remove_const(:C)
|
46
|
-
Object.remove_const(:M)
|
47
|
-
Object.remove_const(:O)
|
48
|
-
end
|
49
|
-
|
50
|
-
describe 'gen_include' do
|
51
|
-
it 'includes a module' do
|
52
|
-
C.gen_include M
|
53
|
-
C.new.m.should == :m
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'includes a class' do
|
57
|
-
C.gen_include A
|
58
|
-
C.new.a.should == :a
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'includes an object' do
|
62
|
-
C.gen_include O
|
63
|
-
C.new.o.should == :o
|
64
|
-
end
|
65
|
-
|
66
|
-
it 'includes a class that includes a class' do
|
67
|
-
A.gen_include B
|
68
|
-
C.gen_include A
|
69
|
-
C.new.b.should == :b
|
70
|
-
C.new.a.should == :a
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'includes an object that includes a class that includes a class' do
|
74
|
-
A.gen_include B
|
75
|
-
O.gen_extend A
|
76
|
-
C.gen_include O
|
77
|
-
C.new.o.should == :o
|
78
|
-
C.new.a.should == :a
|
79
|
-
C.new.b.should == :b
|
80
|
-
end
|
81
|
-
|
82
|
-
it 'includes an object that includes an object' do
|
83
|
-
n = Object.new
|
84
|
-
class << n
|
85
|
-
def n
|
86
|
-
:n
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
l = Object.new
|
91
|
-
class << l
|
92
|
-
def l
|
93
|
-
:l
|
94
|
-
end
|
95
|
-
self
|
96
|
-
end.gen_include n
|
97
|
-
|
98
|
-
C.gen_include l
|
99
|
-
C.new.l.should == :l
|
100
|
-
C.new.n.should == :n
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
describe 'gen_extend' do
|
105
|
-
it 'extends a module' do
|
106
|
-
O.gen_extend M
|
107
|
-
O.m.should == :m
|
108
|
-
end
|
109
|
-
|
110
|
-
it 'extends a class' do
|
111
|
-
O.gen_extend A
|
112
|
-
O.a.should == :a
|
113
|
-
end
|
114
|
-
|
115
|
-
it 'extends an object' do
|
116
|
-
n = Object.new
|
117
|
-
class << n
|
118
|
-
def n
|
119
|
-
:n
|
120
|
-
end
|
121
|
-
end
|
122
|
-
O.gen_extend n
|
123
|
-
O.n.should == :n
|
124
|
-
end
|
125
|
-
|
126
|
-
it 'extends a class that includes a class' do
|
127
|
-
A.gen_include B
|
128
|
-
O.gen_extend A
|
129
|
-
O.b.should == :b
|
130
|
-
O.a.should == :a
|
131
|
-
end
|
132
|
-
|
133
|
-
it 'extends an object that includes a class that includes a class' do
|
134
|
-
A.gen_include B
|
135
|
-
C.gen_include A
|
136
|
-
O.gen_extend C
|
137
|
-
O.o.should == :o
|
138
|
-
O.a.should == :a
|
139
|
-
O.b.should == :b
|
140
|
-
end
|
141
|
-
|
142
|
-
it 'extends an object that extends an object' do
|
143
|
-
n = Object.new
|
144
|
-
class << n
|
145
|
-
def n
|
146
|
-
:n
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
l = Object.new
|
151
|
-
class << l
|
152
|
-
def l
|
153
|
-
:l
|
154
|
-
end
|
155
|
-
self
|
156
|
-
end
|
157
|
-
|
158
|
-
l.gen_extend n
|
159
|
-
|
160
|
-
O.gen_extend l
|
161
|
-
O.l.should == :l
|
162
|
-
O.n.should == :n
|
163
|
-
end
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|