rbplusplus 0.9.1 → 1.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.
- data/Rakefile +4 -9
- data/lib/rbplusplus/builders/allocation_strategy.rb +0 -7
- data/lib/rbplusplus/builders/base.rb +11 -5
- data/lib/rbplusplus/builders/class.rb +5 -14
- data/lib/rbplusplus/builders/const.rb +1 -1
- data/lib/rbplusplus/builders/constructor.rb +1 -1
- data/lib/rbplusplus/builders/director.rb +13 -13
- data/lib/rbplusplus/builders/enumeration.rb +2 -2
- data/lib/rbplusplus/builders/helpers/class.rb +17 -2
- data/lib/rbplusplus/builders/helpers/implicit_caster.rb +0 -0
- data/lib/rbplusplus/builders/implicit_caster.rb +24 -0
- data/lib/rbplusplus/builders/instance_variable.rb +4 -4
- data/lib/rbplusplus/builders/method_base.rb +8 -7
- data/lib/rbplusplus/builders/module.rb +1 -1
- data/lib/rbplusplus/logger.rb +13 -4
- data/lib/rbplusplus/transformers/class.rb +43 -34
- data/lib/rbplusplus/transformers/constructor.rb +30 -0
- data/lib/rbplusplus/transformers/function.rb +3 -3
- data/lib/rbplusplus/transformers/method.rb +2 -2
- data/lib/rbplusplus/transformers/node.rb +10 -17
- data/lib/rbplusplus/writers/multiple_files_writer.rb +8 -6
- data/lib/rbplusplus.rb +2 -1
- data/test/allocation_strategies_test.rb +21 -14
- data/test/class_methods_encapsulate_test.rb +25 -25
- data/test/class_methods_test.rb +7 -12
- data/test/classes_test.rb +36 -40
- data/test/compiling_test.rb +23 -19
- data/test/constructors_test.rb +5 -5
- data/test/custom_code_test.rb +25 -32
- data/test/default_arguments_test.rb +38 -42
- data/test/director_test.rb +51 -53
- data/test/enumerations_test.rb +37 -41
- data/test/extension_test.rb +10 -10
- data/test/file_writers_test.rb +17 -21
- data/test/function_pointer_test.rb +9 -13
- data/test/function_pointers_classes_test.rb +7 -11
- data/test/functions_test.rb +4 -10
- data/test/generated/extconf.rb +2 -2
- data/test/headers/alloc_strats.h +3 -1
- data/test/headers/implicit_cast.h +107 -0
- data/test/headers/to_from_ruby.h +13 -6
- data/test/headers/to_from_ruby_source.cpp +2 -2
- data/test/implicit_cast_test.rb +67 -0
- data/test/modules_test.rb +39 -40
- data/test/nested_test.rb +14 -16
- data/test/overloading_test.rb +17 -20
- data/test/struct_test.rb +4 -6
- data/test/subclass_test.rb +10 -12
- data/test/test_helper.rb +21 -12
- data/test/to_from_ruby_test.rb +7 -1
- data/test/wrap_as_test.rb +32 -29
- metadata +170 -108
- data/lib/rbplusplus/transformers/node_cache.rb +0 -15
@@ -1,54 +1,50 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
node
|
13
|
-
|
14
|
-
e.module "Inner" do |m|
|
15
|
-
m.includes node.functions("module_do")
|
16
|
-
end
|
17
|
-
|
18
|
-
node.classes("Directed").director
|
3
|
+
describe "Default arguments properly exposed" do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
Extension.new "defargs" do |e|
|
7
|
+
e.sources full_dir("headers/default_arguments.h")
|
8
|
+
e.writer_mode :single
|
9
|
+
node = e.namespace "default_args"
|
10
|
+
|
11
|
+
e.module "Inner" do |m|
|
12
|
+
m.includes node.functions("module_do")
|
19
13
|
end
|
20
14
|
|
21
|
-
|
15
|
+
node.classes("Directed").director
|
22
16
|
end
|
17
|
+
|
18
|
+
require 'defargs'
|
23
19
|
end
|
24
20
|
|
25
21
|
specify "global functions" do
|
26
|
-
global_do(1, 4, 5).should
|
27
|
-
global_do(1, 4).should
|
28
|
-
global_do(1).should
|
22
|
+
global_do(1, 4, 5).should == 20
|
23
|
+
global_do(1, 4).should == 40
|
24
|
+
global_do(1).should == 30
|
29
25
|
end
|
30
26
|
|
31
27
|
specify "module functions" do
|
32
|
-
Inner.module_do(5).should
|
33
|
-
Inner.module_do(5, 5).should
|
34
|
-
Inner.module_do(5, 5, 5).should
|
28
|
+
Inner.module_do(5).should == 18
|
29
|
+
Inner.module_do(5, 5).should == 20
|
30
|
+
Inner.module_do(5, 5, 5).should == 15
|
35
31
|
end
|
36
32
|
|
37
33
|
specify "class instance methods" do
|
38
34
|
tester = Tester.new
|
39
|
-
tester.concat("this", "that").should
|
40
|
-
tester.concat("this", "that", ";").should
|
35
|
+
tester.concat("this", "that").should == "this-that"
|
36
|
+
tester.concat("this", "that", ";").should == "this;that"
|
41
37
|
end
|
42
38
|
|
43
39
|
specify "class static methods" do
|
44
|
-
Tester.build("base").should
|
45
|
-
Tester.build("woot", 5).should
|
40
|
+
Tester.build("base").should == "basebasebase"
|
41
|
+
Tester.build("woot", 5).should == "wootwootwootwootwoot"
|
46
42
|
end
|
47
43
|
|
48
44
|
specify "director methods" do
|
49
45
|
d = Directed.new
|
50
|
-
d.virtual_do(3).should
|
51
|
-
d.virtual_do(3, 9).should
|
46
|
+
d.virtual_do(3).should == 30
|
47
|
+
d.virtual_do(3, 9).should == 27
|
52
48
|
|
53
49
|
class MyD < Directed
|
54
50
|
def virtual_do(x, y = 10)
|
@@ -57,31 +53,31 @@ context "Default arguments properly exposed" do
|
|
57
53
|
end
|
58
54
|
|
59
55
|
myd = MyD.new
|
60
|
-
myd.virtual_do(10).should
|
56
|
+
myd.virtual_do(10).should == 300
|
61
57
|
end
|
62
58
|
|
63
59
|
specify "throw argument error on bad types" do
|
64
|
-
|
60
|
+
lambda do
|
65
61
|
global_do(1, "three")
|
66
|
-
end
|
62
|
+
end.should raise_error(TypeError)
|
67
63
|
end
|
68
64
|
|
69
65
|
# See MethodBase#fix_enumeration_value
|
70
66
|
specify "properly handle incomplete enums in default values" do
|
71
|
-
modify(1).should
|
72
|
-
modify(1, Ops::ADD).should
|
73
|
-
modify(1, Ops::REMOVE).should
|
67
|
+
modify(1).should == 11
|
68
|
+
modify(1, Ops::ADD).should == 11
|
69
|
+
modify(1, Ops::REMOVE).should == -9
|
74
70
|
end
|
75
71
|
|
76
72
|
# Ogre does this to handle some weird pass-back-enum-that-signals-error (Ogre::Frustum::isVisible)
|
77
73
|
specify "properly handle incomplete enums arguments with straight integer default values" do
|
78
|
-
modify2(1).should
|
79
|
-
modify2(1, Ops::ADD).should
|
80
|
-
modify2(1, Ops::REMOVE).should
|
74
|
+
modify2(1).should == 1
|
75
|
+
modify2(1, Ops::ADD).should == 1
|
76
|
+
modify2(1, Ops::REMOVE).should == 1
|
81
77
|
end
|
82
78
|
|
83
|
-
|
84
|
-
build_strings("I'd ").should
|
85
|
-
build_strings("You won't", " do it").should
|
86
|
-
end
|
79
|
+
specify "should properly handle argument type qualifiers like refs and consts" # do
|
80
|
+
# build_strings("I'd ").should == "I'd kick-it"
|
81
|
+
# build_strings("You won't", " do it").should == "You won't do it"
|
82
|
+
# end
|
87
83
|
end
|
data/test/director_test.rb
CHANGED
@@ -2,32 +2,28 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
context "Director proxy generation" do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
# classes to have directors set on.
|
17
|
-
%w(Worker MultiplyWorker BadNameClass VirtualWithArgs NoConstructor VBase VOne VTwo).each do |k|
|
18
|
-
node.classes(k).director
|
19
|
-
end
|
20
|
-
|
21
|
-
node.classes("Worker").methods("doProcessImpl").default_return_value(0)
|
22
|
-
|
23
|
-
klass = node.classes("BadNameClass")
|
24
|
-
klass.wrap_as("BetterNamedClass")
|
25
|
-
klass.methods("_is_x_ok_to_run").wrap_as("x_ok?")
|
26
|
-
klass.methods("__do_someProcessing").wrap_as("do_processing")
|
5
|
+
before(:all) do
|
6
|
+
Extension.new "director" do |e|
|
7
|
+
e.sources full_dir("headers/director.h")
|
8
|
+
|
9
|
+
node = e.namespace "director"
|
10
|
+
|
11
|
+
# As director is pretty complicated to get right
|
12
|
+
# automatically for now, we force-specify which
|
13
|
+
# classes to have directors set on.
|
14
|
+
%w(Worker MultiplyWorker BadNameClass VirtualWithArgs NoConstructor VBase VOne VTwo).each do |k|
|
15
|
+
node.classes(k).director
|
27
16
|
end
|
28
17
|
|
29
|
-
|
18
|
+
node.classes("Worker").methods("doProcessImpl").default_return_value(0)
|
19
|
+
|
20
|
+
klass = node.classes("BadNameClass")
|
21
|
+
klass.wrap_as("BetterNamedClass")
|
22
|
+
klass.methods("_is_x_ok_to_run").wrap_as("x_ok?")
|
23
|
+
klass.methods("__do_someProcessing").wrap_as("do_processing")
|
30
24
|
end
|
25
|
+
|
26
|
+
require 'director'
|
31
27
|
end
|
32
28
|
|
33
29
|
specify "polymorphic calls extend into Ruby" do
|
@@ -40,7 +36,7 @@ context "Director proxy generation" do
|
|
40
36
|
h = Handler.new
|
41
37
|
h.add_worker(MyWorker.new)
|
42
38
|
|
43
|
-
h.process_workers(5).should
|
39
|
+
h.process_workers(5).should == 15
|
44
40
|
end
|
45
41
|
|
46
42
|
specify "super calls on pure virtual raise exception" do
|
@@ -50,9 +46,9 @@ context "Director proxy generation" do
|
|
50
46
|
end
|
51
47
|
end
|
52
48
|
|
53
|
-
|
49
|
+
lambda do
|
54
50
|
SuperBadWorker.new.process(10)
|
55
|
-
end
|
51
|
+
end.should raise_error(NotImplementedError)
|
56
52
|
end
|
57
53
|
|
58
54
|
specify "allows super calls to continue back into C++ classes" do
|
@@ -62,9 +58,9 @@ context "Director proxy generation" do
|
|
62
58
|
end
|
63
59
|
end
|
64
60
|
|
65
|
-
|
66
|
-
SuperGoodWorker.new.do_something(10).should
|
67
|
-
end
|
61
|
+
lambda do
|
62
|
+
SuperGoodWorker.new.do_something(10).should == 50
|
63
|
+
end.should_not raise_error(NotImplementedError)
|
68
64
|
end
|
69
65
|
|
70
66
|
specify "can specify a default return value in the wrapper" do
|
@@ -79,25 +75,25 @@ context "Director proxy generation" do
|
|
79
75
|
end
|
80
76
|
|
81
77
|
w = MyAwesomeWorker.new
|
82
|
-
w.do_process(3).should
|
78
|
+
w.do_process(3).should == 10
|
83
79
|
|
84
80
|
h = Handler.new
|
85
81
|
h.add_worker(w)
|
86
82
|
|
87
|
-
h.process_workers(10).should
|
83
|
+
h.process_workers(10).should == 18
|
88
84
|
end
|
89
85
|
|
90
86
|
specify "properly adds all constructor arguments" do
|
91
87
|
v = VirtualWithArgs.new 14, true
|
92
|
-
v.process_a("hi").should
|
93
|
-
v.process_b.should
|
88
|
+
v.process_a("hi").should == 16
|
89
|
+
v.process_b.should be_true
|
94
90
|
end
|
95
91
|
|
96
92
|
specify "takes into account renamed methods / classes" do
|
97
93
|
c = BetterNamedClass.new
|
98
|
-
|
94
|
+
c.x_ok?.should_not be_true
|
99
95
|
|
100
|
-
c.do_processing.should
|
96
|
+
c.do_processing.should == 14
|
101
97
|
end
|
102
98
|
|
103
99
|
specify "handles no constructors" do
|
@@ -105,7 +101,7 @@ context "Director proxy generation" do
|
|
105
101
|
end
|
106
102
|
|
107
103
|
n = MyThing.new
|
108
|
-
n.do_something.should
|
104
|
+
n.do_something.should == 4
|
109
105
|
end
|
110
106
|
|
111
107
|
specify "only builds method wrappers for virtual methods" do
|
@@ -117,13 +113,13 @@ context "Director proxy generation" do
|
|
117
113
|
|
118
114
|
# Super calls still work
|
119
115
|
w = NumberWorker.new
|
120
|
-
w.get_number.should
|
116
|
+
w.get_number.should == 27
|
121
117
|
|
122
118
|
# But polymorphism stops in the C++
|
123
119
|
h = Handler.new
|
124
120
|
h.add_worker(w)
|
125
121
|
|
126
|
-
h.add_worker_numbers.should
|
122
|
+
h.add_worker_numbers.should == 12
|
127
123
|
end
|
128
124
|
|
129
125
|
specify "Directors implement all pure virtual methods up the inheritance tree" do
|
@@ -131,21 +127,22 @@ context "Director proxy generation" do
|
|
131
127
|
v1 = VOne.new
|
132
128
|
v2 = VTwo.new
|
133
129
|
|
134
|
-
v1.method_one.should
|
130
|
+
v1.method_one.should == "methodOne"
|
135
131
|
|
136
|
-
|
132
|
+
lambda do
|
137
133
|
v1.method_two
|
138
|
-
end
|
139
|
-
|
134
|
+
end.should raise_error(NotImplementedError)
|
135
|
+
|
136
|
+
lambda do
|
140
137
|
v1.method_three
|
141
|
-
end
|
138
|
+
end.should raise_error(NotImplementedError)
|
142
139
|
|
143
|
-
v2.method_one.should
|
144
|
-
v2.method_two.should
|
140
|
+
v2.method_one.should == "methodOne"
|
141
|
+
v2.method_two.should == "methodTwo"
|
145
142
|
|
146
|
-
|
143
|
+
lambda do
|
147
144
|
v2.method_three
|
148
|
-
end
|
145
|
+
end.should raise_error(NotImplementedError)
|
149
146
|
end
|
150
147
|
|
151
148
|
specify "handles superclasses of the class with virtual methods" do
|
@@ -158,21 +155,22 @@ context "Director proxy generation" do
|
|
158
155
|
h = Handler.new
|
159
156
|
|
160
157
|
h.add_worker(MultiplyWorker.new)
|
161
|
-
h.process_workers(5).should
|
158
|
+
h.process_workers(5).should == 10
|
162
159
|
|
163
160
|
h.add_worker(QuadWorker.new)
|
164
|
-
h.process_workers(5).should
|
161
|
+
h.process_workers(5).should == 40
|
165
162
|
end
|
166
163
|
|
167
164
|
specify "multiple files writer properly handles directors and nested nodes" do
|
168
|
-
|
169
|
-
|
170
|
-
|
165
|
+
lambda { Worker::ZeeEnum }.should_not raise_error(NameError)
|
166
|
+
lambda { Worker::ZeeEnum::VALUE }.should_not raise_error(NameError)
|
167
|
+
|
168
|
+
Worker::ZeeEnum::VALUE.to_i.should == 4
|
171
169
|
end
|
172
170
|
|
173
171
|
specify "inheritance types are registered properly" do
|
174
172
|
two = VTwo.new
|
175
|
-
VBase::process(two).should
|
173
|
+
VBase::process(two).should == "methodTwo"
|
176
174
|
end
|
177
175
|
|
178
176
|
end
|
data/test/enumerations_test.rb
CHANGED
@@ -1,27 +1,23 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
e.sources full_dir("headers/enums.h")
|
11
|
-
e.namespace "enums"
|
12
|
-
e.writer_mode :single
|
13
|
-
|
14
|
-
e.module "Mod" do |m|
|
15
|
-
m.namespace "inner"
|
16
|
-
end
|
17
|
-
end
|
3
|
+
describe "Wrapping enumerations" do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
Extension.new "enums" do |e|
|
7
|
+
e.sources full_dir("headers/enums.h")
|
8
|
+
e.namespace "enums"
|
9
|
+
e.writer_mode :single
|
18
10
|
|
19
|
-
|
11
|
+
e.module "Mod" do |m|
|
12
|
+
m.namespace "inner"
|
13
|
+
end
|
20
14
|
end
|
15
|
+
|
16
|
+
require 'enums'
|
21
17
|
end
|
22
18
|
|
23
19
|
specify "should wrap up enums properly" do
|
24
|
-
|
20
|
+
lambda { TestEnum }.should_not raise_error(NameError)
|
25
21
|
|
26
22
|
TestEnum::VALUE1.to_i.should == 0
|
27
23
|
TestEnum::VALUE2.to_i.should == 1
|
@@ -29,12 +25,12 @@ context "Wrapping enumerations" do
|
|
29
25
|
end
|
30
26
|
|
31
27
|
specify "should only wrap public enums" do
|
32
|
-
|
33
|
-
|
28
|
+
lambda { Tester::NotWrapped }.should raise_error(NameError)
|
29
|
+
lambda { Tester::AlsoNotWrapped }.should raise_error(NameError)
|
34
30
|
end
|
35
31
|
|
36
32
|
specify "should wrap up enumerations at proper nesting" do
|
37
|
-
|
33
|
+
lambda { Tester::TestEnum }.should_not raise_error(NameError)
|
38
34
|
|
39
35
|
Tester::MyEnum::I_LIKE_MONEY.to_i.should == 3
|
40
36
|
Tester::MyEnum::YOU_LIKE_MONEY_TOO.to_i.should == 4
|
@@ -42,7 +38,7 @@ context "Wrapping enumerations" do
|
|
42
38
|
end
|
43
39
|
|
44
40
|
specify "should work in user-defined modules" do
|
45
|
-
|
41
|
+
lambda { Mod::InnerEnum }.should_not raise_error(NameError)
|
46
42
|
|
47
43
|
Mod::InnerEnum::INNER_1.to_i.should == 0
|
48
44
|
Mod::InnerEnum::INNER_2.to_i.should == 1
|
@@ -52,9 +48,9 @@ context "Wrapping enumerations" do
|
|
52
48
|
what_test_enum(TestEnum::VALUE1).should == "We gots enum 0";
|
53
49
|
|
54
50
|
# Types should be adhered to
|
55
|
-
|
51
|
+
lambda do
|
56
52
|
what_test_enum(Mod::InnerEnum::INNER_1)
|
57
|
-
end
|
53
|
+
end.should raise_error(RuntimeError)
|
58
54
|
|
59
55
|
t = Tester.new
|
60
56
|
t.get_enum_description(Tester::MyEnum::YOU_LIKE_MONEY_TOO).should == "You like money!"
|
@@ -67,26 +63,26 @@ context "Wrapping enumerations" do
|
|
67
63
|
end
|
68
64
|
|
69
65
|
specify "anonymous enumerations' values are added as constants to the parent class" do
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
Tester::ANON_ENUM_VAL1.should
|
76
|
-
Tester::ANON_ENUM_VAL2.should
|
77
|
-
Tester::ANON_ENUM_VAL3.should
|
78
|
-
Tester::ANON_ENUM_VAL4.should
|
66
|
+
lambda { Tester::ANON_ENUM_VAL1 }.should_not raise_error(NameError)
|
67
|
+
lambda { Tester::ANON_ENUM_VAL2 }.should_not raise_error(NameError)
|
68
|
+
lambda { Tester::ANON_ENUM_VAL3 }.should_not raise_error(NameError)
|
69
|
+
lambda { Tester::ANON_ENUM_VAL4 }.should_not raise_error(NameError)
|
70
|
+
|
71
|
+
Tester::ANON_ENUM_VAL1.should == 1
|
72
|
+
Tester::ANON_ENUM_VAL2.should == 2
|
73
|
+
Tester::ANON_ENUM_VAL3.should == 5
|
74
|
+
Tester::ANON_ENUM_VAL4.should == 3
|
79
75
|
end
|
80
76
|
|
81
77
|
specify "top-level anonymous enumerations' values are added to the global scope" do
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
OUTER_ANON_1.should
|
88
|
-
OUTER_ANON_2.should
|
89
|
-
FOURTY_TWO.should
|
90
|
-
SEPERATE_OUTER_VALUE.should
|
78
|
+
lambda { OUTER_ANON_1 }.should_not raise_error(NameError)
|
79
|
+
lambda { OUTER_ANON_2 }.should_not raise_error(NameError)
|
80
|
+
lambda { FOURTY_TWO }.should_not raise_error(NameError)
|
81
|
+
lambda { SEPERATE_OUTER_VALUE }.should_not raise_error(NameError)
|
82
|
+
|
83
|
+
OUTER_ANON_1.should == 0
|
84
|
+
OUTER_ANON_2.should == 1
|
85
|
+
FOURTY_TWO.should == 42
|
86
|
+
SEPERATE_OUTER_VALUE.should == 14
|
91
87
|
end
|
92
88
|
end
|
data/test/extension_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
|
3
|
+
describe "Ruby Extension creation" do
|
4
4
|
|
5
5
|
specify "should create a valid Ruby extension" do
|
6
6
|
Extension.new "ext_test" do |e|
|
@@ -8,9 +8,9 @@ context "Ruby Extension creation" do
|
|
8
8
|
e.writer_mode :single
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
require
|
13
|
-
end
|
11
|
+
lambda do
|
12
|
+
require "ext_test"
|
13
|
+
end.should_not raise_error(LoadError)
|
14
14
|
end
|
15
15
|
|
16
16
|
specify "should create a valid Ruby extension without a block" do
|
@@ -22,13 +22,13 @@ context "Ruby Extension creation" do
|
|
22
22
|
e.write
|
23
23
|
e.compile
|
24
24
|
|
25
|
-
|
26
|
-
require
|
27
|
-
end
|
25
|
+
lambda do
|
26
|
+
require "ext_test"
|
27
|
+
end.should_not raise_error(LoadError)
|
28
28
|
end
|
29
29
|
|
30
30
|
specify "should properly build working dir as deep as needed" do
|
31
|
-
|
31
|
+
lambda do
|
32
32
|
path = File.join(File.expand_path(File.dirname(__FILE__)), "generated", "path1", "path2")
|
33
33
|
Extension.new "extension" do |e|
|
34
34
|
e.sources full_dir("headers/empty.h")
|
@@ -36,8 +36,8 @@ context "Ruby Extension creation" do
|
|
36
36
|
e.writer_mode :single
|
37
37
|
end
|
38
38
|
|
39
|
-
|
40
|
-
end
|
39
|
+
File.exists?(File.join(path, "extconf.rb")).should be_true
|
40
|
+
end.should_not raise_error(Errno::ENOENT)
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
data/test/file_writers_test.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
|
3
|
+
describe "Multiple file writer (default)" do
|
4
4
|
|
5
|
-
|
5
|
+
before(:each) do
|
6
6
|
@working_dir = File.expand_path(File.dirname(__FILE__) + "/generated")
|
7
7
|
|
8
8
|
e = Extension.new "adder"
|
@@ -20,7 +20,7 @@ context "Multiple file writer (default)" do
|
|
20
20
|
|
21
21
|
specify "should properly split up code into multiple files" do
|
22
22
|
files = Dir["#{@working_dir}/*"]
|
23
|
-
files.size.should ==
|
23
|
+
files.size.should == 10
|
24
24
|
|
25
25
|
%w(
|
26
26
|
extconf.rb
|
@@ -32,28 +32,24 @@ context "Multiple file writer (default)" do
|
|
32
32
|
_classes_IntAdder.rb.hpp
|
33
33
|
_classes_ShouldFindMe.rb.hpp
|
34
34
|
_classes_ShouldFindMe.rb.cpp
|
35
|
-
_rbpp_custom.rb.hpp
|
36
|
-
_rbpp_custom.rb.cpp
|
37
35
|
adder.rb.cpp
|
38
36
|
).each do |wants|
|
39
|
-
|
37
|
+
files.find {|got| File.basename(got) == wants }.should_not be_nil
|
40
38
|
end
|
41
39
|
end
|
42
40
|
|
43
41
|
end
|
44
42
|
|
45
|
-
|
43
|
+
describe "Multiple file writer works with global _rbpp_custom" do
|
46
44
|
|
47
|
-
|
45
|
+
before(:each) do
|
48
46
|
@working_dir = File.expand_path(File.dirname(__FILE__) + "/generated")
|
49
47
|
|
50
|
-
e = Extension.new "
|
48
|
+
e = Extension.new "enums"
|
51
49
|
e.working_dir = @working_dir
|
52
|
-
e.sources full_dir("headers/
|
53
|
-
:include_paths => full_dir("headers"),
|
54
|
-
:include_source_files => full_dir("headers/to_from_ruby_source.cpp")
|
50
|
+
e.sources full_dir("headers/enums.h")
|
55
51
|
|
56
|
-
e.namespace "
|
52
|
+
e.namespace "enums"
|
57
53
|
|
58
54
|
e.build
|
59
55
|
e.write
|
@@ -67,15 +63,15 @@ context "Multiple file writer with to_from_ruby" do
|
|
67
63
|
_rbpp_custom.rb.hpp
|
68
64
|
_rbpp_custom.rb.cpp
|
69
65
|
).each do |wants|
|
70
|
-
|
66
|
+
files.find {|got| File.basename(got) == wants }.should_not be_nil
|
71
67
|
end
|
72
68
|
end
|
73
69
|
|
74
70
|
end
|
75
71
|
|
76
|
-
|
72
|
+
describe "Single file writer" do
|
77
73
|
|
78
|
-
|
74
|
+
before(:each) do
|
79
75
|
@working_dir = File.expand_path(File.dirname(__FILE__) + "/generated")
|
80
76
|
|
81
77
|
e = Extension.new "adder"
|
@@ -99,15 +95,15 @@ context "Single file writer" do
|
|
99
95
|
extconf.rb
|
100
96
|
adder.rb.cpp
|
101
97
|
).each do |wants|
|
102
|
-
|
98
|
+
files.find {|got| File.basename(got) == wants }.should_not be_nil
|
103
99
|
end
|
104
100
|
end
|
105
101
|
|
106
102
|
end
|
107
103
|
|
108
|
-
|
104
|
+
describe "Single file writer with to_from_ruby" do
|
109
105
|
|
110
|
-
|
106
|
+
before(:each) do
|
111
107
|
Extension.new "to_from_ruby" do |e|
|
112
108
|
e.sources full_dir("headers/to_from_ruby.h"),
|
113
109
|
:include_paths => full_dir("headers"),
|
@@ -120,8 +116,8 @@ context "Single file writer with to_from_ruby" do
|
|
120
116
|
end
|
121
117
|
|
122
118
|
specify "should have compiled properly" do
|
123
|
-
|
119
|
+
lambda do
|
124
120
|
require 'to_from_ruby'
|
125
|
-
end
|
121
|
+
end.should_not raise_error(LoadError)
|
126
122
|
end
|
127
123
|
end
|
@@ -1,18 +1,14 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
Extension.new "function_pointers" do |e|
|
10
|
-
e.sources full_dir("headers/function_pointers.h")
|
11
|
-
node = e.namespace "function_pointers"
|
12
|
-
end
|
13
|
-
|
14
|
-
require 'function_pointers'
|
3
|
+
describe "properly handles and wraps function pointer arguments" do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
Extension.new "function_pointers" do |e|
|
7
|
+
e.sources full_dir("headers/function_pointers.h")
|
8
|
+
node = e.namespace "function_pointers"
|
15
9
|
end
|
10
|
+
|
11
|
+
require 'function_pointers'
|
16
12
|
end
|
17
13
|
|
18
14
|
specify "no arguments, no return" do
|
@@ -24,7 +20,7 @@ context "properly handles and wraps function pointer arguments" do
|
|
24
20
|
|
25
21
|
call_callback
|
26
22
|
|
27
|
-
|
23
|
+
proc_called.should be_true
|
28
24
|
end
|
29
25
|
|
30
26
|
specify "arguments, no return" do
|
@@ -1,18 +1,14 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
|
3
|
+
describe "Function pointers into class methods" do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
Extension.new "function_pointers_class" do |e|
|
10
|
-
e.sources full_dir("headers/function_pointers_class.h")
|
11
|
-
node = e.namespace "function_pointers_class"
|
12
|
-
end
|
13
|
-
|
14
|
-
require 'function_pointers_class'
|
5
|
+
before(:all) do
|
6
|
+
Extension.new "function_pointers_class" do |e|
|
7
|
+
e.sources full_dir("headers/function_pointers_class.h")
|
8
|
+
node = e.namespace "function_pointers_class"
|
15
9
|
end
|
10
|
+
|
11
|
+
require 'function_pointers_class'
|
16
12
|
end
|
17
13
|
|
18
14
|
|