rbplusplus 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 64998377ef64e53b53ac16ef3e58f12b774ef4eb
4
- data.tar.gz: a81d11259a71875f068793bc6596c27f8c9e0f6d
3
+ metadata.gz: 02f6abce82d5c75c2de491a4a4e3c8f62d4ef907
4
+ data.tar.gz: ba76ec48f81e2f02f89dd70ddde10b11590b8872
5
5
  SHA512:
6
- metadata.gz: 04983a3329b555383e52e5736276804fdd288559a5553234566e1d72b46a95e89d47b650d1f17e64b09e6b24a86e15c2e0369d06218b21b9cefd97ec94b47307
7
- data.tar.gz: fd928903087c72d024a72df13ec8253549655a218f144155a2ca120b33b0455214c9c343d3c1e4634e5a0613ebb04232ad0ebebef53602d4c7bfaa438e432239
6
+ metadata.gz: f076adf0e236a54dfb592a0444ae9c8e1c4552916f6770c09c6d07b86e0e1f2190b18bcb9f9174f7f29bc78444030e70eed6726f2990c8b507d6e95ca491096c
7
+ data.tar.gz: d48214b92b458638c93f67387cc233d5a61ca06ab751ec5fb2c58d4ddc4da22c49841d70267fc0911f635c271a59e17fb392e1342233b5d4771a2a30ac48c581
data/Rakefile CHANGED
@@ -1,5 +1,4 @@
1
1
  require 'rdoc/task'
2
- require 'rake/contrib/sshpublisher'
3
2
 
4
3
  task :default => :test
5
4
 
@@ -18,7 +17,7 @@ task :test do
18
17
  # the exact ruby binary that's linked to the ruby running the Rakefile. Just saying
19
18
  # "ruby" will find the system's installed ruby and be worthless
20
19
  ruby = File.join(RbConfig::CONFIG["bindir"], RbConfig::CONFIG["RUBY_INSTALL_NAME"])
21
- sh "#{ruby} -S rspec -Itest #{file}"
20
+ sh "#{ruby} -Itest -S rspec #{file}"
22
21
  end
23
22
  end
24
23
 
@@ -29,28 +28,3 @@ Rake::RDocTask.new do |rd|
29
28
  rd.template = File.expand_path(File.dirname(__FILE__) + "/lib/jamis.rb")
30
29
  rd.options << '--line-numbers' << '--inline-source'
31
30
  end
32
-
33
- RUBYFORGE_USERNAME = "jameskilton"
34
- PROJECT_WEB_PATH = "/var/www/gforge-projects/rbplusplus"
35
-
36
- namespace :web do
37
- desc "Build website"
38
- task :build => :rdoc do |t|
39
- unless File.directory?("publish")
40
- mkdir "publish"
41
- end
42
-
43
- sh "jekyll --pygment website publish/"
44
- sh "cp -r html/* publish/rbplusplus/"
45
- end
46
-
47
- desc "Update the website"
48
- task :upload => "web:build" do |t|
49
- Rake::SshDirPublisher.new("#{RUBYFORGE_USERNAME}@rubyforge.org", PROJECT_WEB_PATH, "publish").upload
50
- end
51
-
52
- desc "Clean up generated website files"
53
- task :clean do
54
- rm_rf "publish"
55
- end
56
- end
@@ -95,7 +95,7 @@ module RbPlusPlus
95
95
  # to allocate the class directly. If this code tries to use a non-public
96
96
  # constructor, we hit a compiler error.
97
97
  def check_allocation_strategies
98
- # Due to the nature of GCC-XML's handling of templated classes, there are some
98
+ # Due to the nature of CastXML's handling of templated classes, there are some
99
99
  # classes that might not have any gcc-generated constructors or destructors.
100
100
  # We check here if we're one of those classes and completely skip this step
101
101
  return if [self.code.constructors].flatten.empty?
@@ -32,7 +32,7 @@ module RbPlusPlus
32
32
  includes << "#include \"#{self.code.file}\""
33
33
 
34
34
  declarations << "template<>"
35
- declarations << "Rice::Object to_ruby<#{full_name} >(#{full_name} const & a);"
35
+ declarations << "Rice::Object to_ruby< #{full_name} >(#{full_name} const & a);"
36
36
 
37
37
  build_as = if self.parent.is_a?(EnumerationNode)
38
38
  "new #{full_name}(a)"
@@ -41,8 +41,8 @@ module RbPlusPlus
41
41
  end
42
42
 
43
43
  registrations << "template<>"
44
- registrations << "Rice::Object to_ruby<#{full_name} >(#{full_name} const & a) {"
45
- registrations << "\treturn Rice::Data_Object<#{full_name} >(#{build_as}, Rice::Data_Type<#{full_name} >::klass(), 0, 0);"
44
+ registrations << "Rice::Object to_ruby< #{full_name} >(#{full_name} const & a) {"
45
+ registrations << "\treturn Rice::Data_Object< #{full_name} >(#{build_as}, Rice::Data_Type< #{full_name} >::klass(), 0, 0);"
46
46
  registrations << "}"
47
47
  end
48
48
 
@@ -11,7 +11,7 @@ module RbPlusPlus
11
11
  # See ClassNode
12
12
  add_global_child ConstConverterNode.new(self.code, self)
13
13
 
14
- self.rice_variable_type = "Rice::Enum<#{code.qualified_name}>"
14
+ self.rice_variable_type = "Rice::Enum< #{code.qualified_name} >"
15
15
  self.rice_variable = "rb_e#{code.name}"
16
16
 
17
17
  Logger.info "Wrapping enumeration #{code.qualified_name}"
@@ -21,7 +21,7 @@ module RbPlusPlus
21
21
  second = parent.rice_variable ? ", #{parent.rice_variable}" : ""
22
22
 
23
23
  registrations << "\t#{rice_variable_type} #{rice_variable} = " \
24
- "Rice::define_enum<#{code.qualified_name}>(\"#{code.name}\"#{second});"
24
+ "Rice::define_enum< #{code.qualified_name} >(\"#{code.name}\"#{second});"
25
25
 
26
26
  code.values.each do |v|
27
27
  registrations << "\t#{rice_variable}.define_value(\"#{v.name}\", #{v.qualified_name});"
@@ -150,7 +150,7 @@ module RbPlusPlus
150
150
 
151
151
  # See http://www.gccxml.org/Bug/view.php?id=9234
152
152
  #
153
- # Basically due to inconsistencies within gcc, GCC-XML parses default arguments
153
+ # Basically due to inconsistencies within gcc, CastXML parses default arguments
154
154
  # with having enumeration values exactly as they are in the code. This means
155
155
  # that if the C++ doesn't fully namespace the enumeration, extension compilation
156
156
  # will fail because g++ can't find the enumeration.
@@ -163,9 +163,10 @@ module RbPlusPlus
163
163
  # for an example.
164
164
  def fix_enumeration_value(enum, default_value)
165
165
  enum_values = [enum.values].flatten
166
+ just_base_name = default_value.split("::").last
166
167
  found =
167
168
  enum_values.select do |enum_value|
168
- enum_value.name == default_value
169
+ enum_value.name == default_value || enum_value.name == just_base_name
169
170
  end.first
170
171
 
171
172
  found ? found.qualified_name : default_value
@@ -3,7 +3,7 @@ require 'optparse'
3
3
  module RbPlusPlus
4
4
 
5
5
  # This is the starting class for Rb++ wrapping. All Rb++ projects start as such:
6
- #
6
+ #
7
7
  # Extension.new "extension_name" do |e|
8
8
  # ...
9
9
  # end
@@ -18,8 +18,8 @@ module RbPlusPlus
18
18
  #
19
19
  # The following calls are required in both formats:
20
20
  #
21
- # e.sources - The directory / array / name of C++ header files to parse.
22
- #
21
+ # e.sources - The directory / array / name of C++ header files to parse.
22
+ #
23
23
  # In the non-block format, the following calls are required:
24
24
  #
25
25
  # e.working_dir - Specify the directory where the code will be generated. This needs
@@ -32,8 +32,8 @@ module RbPlusPlus
32
32
  #
33
33
  # e.write - Writes out the generated code into files
34
34
  #
35
- # e.compile - Compiles the generated code into a Ruby extension.
36
- #
35
+ # e.compile - Compiles the generated code into a Ruby extension.
36
+ #
37
37
  class Extension
38
38
 
39
39
  # Where will the generated code be put
@@ -45,14 +45,14 @@ module RbPlusPlus
45
45
  # Various options given by the user to help with
46
46
  # parsing, linking, compiling, etc.
47
47
  #
48
- # See #sources for a list of the possible options
48
+ # See #sources for a list of the possible options
49
49
  attr_accessor :options
50
50
 
51
51
  # Create a new Ruby extension with a given name. This name will be
52
52
  # the actual name of the extension, e.g. you'll have name.so and you will
53
53
  # call require 'name' when using your new extension.
54
54
  #
55
- # This constructor can be standalone or take a block.
55
+ # This constructor can be standalone or take a block.
56
56
  def initialize(name, &block)
57
57
  @name = name
58
58
  @modules = []
@@ -99,14 +99,22 @@ module RbPlusPlus
99
99
  # * <tt>:ldflags</tt> - Flag(s) to be added to command line for linking
100
100
  # * <tt>:includes</tt> - Header file(s) to include at the beginning of each .rb.cpp file generated.
101
101
  # * <tt>:include_source_files</tt> - C++ source files that need to be compiled into the extension but not wrapped.
102
- # * <tt>:include_source_dir</tt> - A combination option for reducing duplication, this option will
103
- # query the given directory for source files, adding all to <tt>:include_source_files</tt> and
104
- # adding all h/hpp files to <tt>:includes</tt>
102
+ # * <tt>:include_source_dir</tt> - A combination option for reducing duplication, this option will
103
+ # query the given directory for source files, adding all to <tt>:include_source_files</tt> and
104
+ # adding all h/hpp files to <tt>:includes</tt>
105
105
  #
106
106
  def sources(dirs, options = {})
107
- parser_options = {}
107
+ parser_options = {
108
+ :includes => [],
109
+ :cxxflags => [
110
+ # Force castxml into C++ mode
111
+ "-x c++",
112
+ # Allow things like `<::`
113
+ "-fpermissive"
114
+ ]
115
+ }
108
116
 
109
- if (code_dir = options.delete(:include_source_dir))
117
+ if (code_dir = options.delete(:include_source_dir))
110
118
  options[:include_source_files] ||= []
111
119
  options[:includes] ||= []
112
120
  Dir["#{code_dir}/*"].each do |f|
@@ -118,11 +126,11 @@ module RbPlusPlus
118
126
 
119
127
  if (paths = options.delete(:include_paths))
120
128
  @options[:include_paths] << paths
121
- parser_options[:includes] = paths
129
+ parser_options[:includes] << paths
122
130
  end
123
131
 
124
132
  if (lib_paths = options.delete(:library_paths))
125
- @options[:library_paths] << lib_paths
133
+ @options[:library_paths] << lib_paths
126
134
  end
127
135
 
128
136
  if (libs = options.delete(:libraries))
@@ -131,7 +139,7 @@ module RbPlusPlus
131
139
 
132
140
  if (flags = options.delete(:cxxflags))
133
141
  @options[:cxxflags] << flags
134
- parser_options[:cxxflags] = flags
142
+ parser_options[:cxxflags] << flags
135
143
  end
136
144
 
137
145
  if (flags = options.delete(:ldflags))
@@ -146,7 +154,7 @@ module RbPlusPlus
146
154
  options[:includes] << f if File.extname(f) =~ /hpp/i || File.extname(f) =~ /h/i
147
155
  end
148
156
  end
149
-
157
+
150
158
  if (flags = options.delete(:includes))
151
159
  includes = Dir.glob(flags)
152
160
  if(includes.length == 0)
@@ -195,8 +203,8 @@ module RbPlusPlus
195
203
  raise "Unknown writer mode #{mode}" unless [:multiple, :single].include?(mode)
196
204
  @writer_mode = mode
197
205
  end
198
-
199
- # Start the code generation process.
206
+
207
+ # Start the code generation process.
200
208
  def build
201
209
  raise ConfigurationError.new("Must specify working directory") unless @working_dir
202
210
  raise ConfigurationError.new("Must specify which sources to wrap") unless @parser
@@ -217,7 +225,7 @@ module RbPlusPlus
217
225
  Logger.info "Writing code to files"
218
226
  prepare_working_dir
219
227
  process_other_source_files
220
-
228
+
221
229
  # Create the code
222
230
  writer_class = @writer_mode == :multiple ? Writers::MultipleFilesWriter : Writers::SingleFileWriter
223
231
  writer_class.new(@builder, @working_dir).write
@@ -257,7 +265,7 @@ module RbPlusPlus
257
265
  exit
258
266
  end
259
267
 
260
- opts.on("-v", "--verbose", "Show all progress messages (INFO, DEBUG, WARNING, ERROR)") do
268
+ opts.on("-v", "--verbose", "Show all progress messages (INFO, DEBUG, WARNING, ERROR)") do
261
269
  Logger.verbose = true
262
270
  end
263
271
 
@@ -307,7 +315,7 @@ module RbPlusPlus
307
315
 
308
316
  # Cool little eval / binding hack, from need.rb
309
317
  def build_working_dir(&block)
310
- file_name =
318
+ file_name =
311
319
  if block.respond_to?(:source_location)
312
320
  block.source_location[0]
313
321
  else
@@ -331,7 +339,7 @@ module IRB # :nodoc:
331
339
  ARGV.replace(args)
332
340
  @__initialized = true
333
341
  end
334
-
342
+
335
343
  workspace = WorkSpace.new(binding)
336
344
 
337
345
  irb = Irb.new(workspace)
@@ -15,19 +15,13 @@ describe "Allocation Strategies" do
15
15
  # instantiate an object with a non-public constructor
16
16
  # and it all dies.
17
17
  specify "properly figures out what allocation to do" do
18
- lambda do
19
- require 'alloc_strats'
20
- end.should_not raise_error(LoadError)
18
+ require 'alloc_strats'
21
19
 
22
20
  # Private constructor, public destructor
23
- lambda do
24
- NoConstructor
25
- end.should_not raise_error(NameError)
21
+ NoConstructor
26
22
 
27
23
  # Private constructor and destructor
28
- lambda do
29
- Neither
30
- end.should_not raise_error(NameError)
24
+ Neither
31
25
  end
32
26
 
33
27
  specify "can get access to Neither object" do
@@ -22,7 +22,7 @@ describe "Correct handling of encapsulated methods" do
22
22
  ext.protected_method
23
23
  end.should raise_error(NoMethodError)
24
24
  end
25
-
25
+
26
26
  specify "should handle virtual methods" do
27
27
  ext_factory = ExtendedFactory.new
28
28
  ext = ext_factory.new_instance
@@ -42,18 +42,14 @@ describe "Correct handling of encapsulated methods" do
42
42
  arg.wrap_me_protected
43
43
  end.should raise_error(NoMethodError)
44
44
 
45
- lambda do
46
- arg.wrap_me_public ArgumentAccess::PublicStruct.new
47
- end.should_not raise_error(NoMethodError)
48
-
45
+ arg.wrap_me_public ArgumentAccess::PublicStruct.new
46
+
49
47
  # Multiple argument methods
50
48
  lambda do
51
49
  arg.wrap_me_many_no
52
50
  end.should raise_error(NoMethodError)
53
51
 
54
- lambda do
55
- arg.wrap_me_many_yes(1, 2.0, ArgumentAccess::PublicStruct.new)
56
- end.should_not raise_error(NoMethodError)
52
+ arg.wrap_me_many_yes(1, 2.0, ArgumentAccess::PublicStruct.new)
57
53
  end
58
54
  end
59
55
 
@@ -22,10 +22,6 @@ describe "Extension with wrapped classes" do
22
22
  require 'adder'
23
23
  end
24
24
 
25
- specify "should make classes available as Ruby runtime constants" do
26
- lambda { Adder }.should_not raise_error
27
- end
28
-
29
25
  specify "should make wrapped classes constructable" do
30
26
  a = Adder.new
31
27
  a.should_not be_nil
@@ -46,15 +42,15 @@ describe "Extension with wrapped classes" do
46
42
  end
47
43
 
48
44
  specify "should use typedefs when findable" do
49
- lambda { IntAdder }.should_not raise_error
45
+ IntAdder
50
46
  end
51
47
 
52
48
  specify "finds and uses multi-nested typedefs" do
53
- lambda { ShouldFindMe }.should_not raise_error
49
+ ShouldFindMe
54
50
  end
55
51
 
56
52
  specify "can turn off typedef lookup for certain classes" do
57
- lambda { DontFindMeBro }.should raise_error
53
+ lambda { DontFindMeBro }.should raise_error(NameError)
58
54
  end
59
55
 
60
56
  specify "makes class constants available" do
@@ -62,7 +58,7 @@ describe "Extension with wrapped classes" do
62
58
  end
63
59
 
64
60
  specify "can ignore constants" do
65
- lambda { Adder::HideMe }.should raise_error
61
+ lambda { Adder::HideMe }.should raise_error(NameError)
66
62
  end
67
63
 
68
64
  specify "makes public instance variables accessible" do
@@ -84,7 +80,7 @@ describe "Extension with wrapped classes" do
84
80
 
85
81
  lambda do
86
82
  a.const_var = "This is a value!"
87
- end.should raise_error
83
+ end.should raise_error(NoMethodError)
88
84
 
89
85
  a.const_var.should == 14
90
86
  end
@@ -104,9 +100,5 @@ describe "Extension with wrapped classes" do
104
100
  a.add_integers(3, 7).should == 21
105
101
  a.add_strings("piz", "owned").should == "pizownedwoot"
106
102
  end
107
-
108
- specify "should not wrap incomplete types" do
109
- lambda { Forwarder }.should raise_error
110
- end
111
103
  end
112
104
 
@@ -121,29 +121,25 @@ describe "Compiler settings" do
121
121
  end
122
122
 
123
123
  specify "should pass cxxflags to rbgccxml" do
124
- lambda do
125
- e = Extension.new "parsing_test"
126
- e.working_dir = full_dir("generated")
127
- e.sources full_dir("headers/requires_define.h"),
128
- :cxxflags => "-DMUST_BE_DEFINED"
129
- e.build
130
- e.write
131
- end.should_not raise_error
124
+ e = Extension.new "parsing_test"
125
+ e.working_dir = full_dir("generated")
126
+ e.sources full_dir("headers/requires_define.h"),
127
+ :cxxflags => "-DMUST_BE_DEFINED"
128
+ e.build
129
+ e.write
132
130
  end
133
131
 
134
132
  specify "should be able to add additional headers as needed" do
135
- lambda do
136
- e = Extension.new "external"
137
- e.working_dir = full_dir("generated")
138
- e.sources full_dir("headers/external_mapping.h"),
139
- :includes => full_dir("headers/*rice.h")
140
- e.build
141
- e.write
142
-
143
- file = full_dir("generated/external.rb.cpp")
144
- contents = File.read(file)
145
- contents.should =~ %r(headers/external_mapping_rice.h)
146
- end.should_not raise_error
133
+ e = Extension.new "external"
134
+ e.working_dir = full_dir("generated")
135
+ e.sources full_dir("headers/external_mapping.h"),
136
+ :includes => full_dir("headers/*rice.h")
137
+ e.build
138
+ e.write
139
+
140
+ file = full_dir("generated/external.rb.cpp")
141
+ contents = File.read(file)
142
+ contents.should =~ %r(headers/external_mapping_rice.h)
147
143
  end
148
144
 
149
145
  specify "can specify other source files to be compiled into the extension" do
@@ -15,14 +15,12 @@ describe "Extension with constructors out the whazoo" do
15
15
 
16
16
  require 'constructors'
17
17
 
18
- lambda do
19
- # Test complex constructors
20
- d = DoubleStringHolder.new("one", "two")
21
- one = d.get_one
22
- d.get_one.should == "one"
23
- d.get_two.should == "two"
24
- end.should_not raise_error(NameError)
25
-
18
+ # Test complex constructors
19
+ d = DoubleStringHolder.new("one", "two")
20
+ one = d.get_one
21
+ d.get_one.should == "one"
22
+ d.get_two.should == "two"
23
+
26
24
  lambda do
27
25
  PrivateConstructor.new
28
26
  end.should raise_error(TypeError)
@@ -58,9 +58,7 @@ describe "Director proxy generation" do
58
58
  end
59
59
  end
60
60
 
61
- lambda do
62
- SuperGoodWorker.new.do_something(10).should == 50
63
- end.should_not raise_error(NotImplementedError)
61
+ SuperGoodWorker.new.do_something(10).should == 50
64
62
  end
65
63
 
66
64
  specify "can specify a default return value in the wrapper" do
@@ -86,12 +84,12 @@ describe "Director proxy generation" do
86
84
  specify "properly adds all constructor arguments" do
87
85
  v = VirtualWithArgs.new 14, true
88
86
  v.process_a("hi").should == 16
89
- v.process_b.should be_true
87
+ v.process_b.should eq(true)
90
88
  end
91
89
 
92
90
  specify "takes into account renamed methods / classes" do
93
91
  c = BetterNamedClass.new
94
- c.x_ok?.should_not be_true
92
+ c.x_ok?.should_not eq(true)
95
93
 
96
94
  c.do_processing.should == 14
97
95
  end
@@ -162,9 +160,6 @@ describe "Director proxy generation" do
162
160
  end
163
161
 
164
162
  specify "multiple files writer properly handles directors and nested nodes" do
165
- lambda { Worker::ZeeEnum }.should_not raise_error(NameError)
166
- lambda { Worker::ZeeEnum::VALUE }.should_not raise_error(NameError)
167
-
168
163
  Worker::ZeeEnum::VALUE.to_i.should == 4
169
164
  end
170
165
 
@@ -17,8 +17,6 @@ describe "Wrapping enumerations" do
17
17
  end
18
18
 
19
19
  specify "should wrap up enums properly" do
20
- lambda { TestEnum }.should_not raise_error(NameError)
21
-
22
20
  TestEnum::VALUE1.to_i.should == 0
23
21
  TestEnum::VALUE2.to_i.should == 1
24
22
  TestEnum::VALUE3.to_i.should == 2
@@ -30,16 +28,12 @@ describe "Wrapping enumerations" do
30
28
  end
31
29
 
32
30
  specify "should wrap up enumerations at proper nesting" do
33
- lambda { Tester::MyEnum }.should_not raise_error(NameError)
34
-
35
31
  Tester::MyEnum::I_LIKE_MONEY.to_i.should == 3
36
32
  Tester::MyEnum::YOU_LIKE_MONEY_TOO.to_i.should == 4
37
33
  Tester::MyEnum::I_LIKE_YOU.to_i.should == 7
38
34
  end
39
35
 
40
36
  specify "should work in user-defined modules" do
41
- lambda { Mod::InnerEnum }.should_not raise_error(NameError)
42
-
43
37
  Mod::InnerEnum::INNER_1.to_i.should == 0
44
38
  Mod::InnerEnum::INNER_2.to_i.should == 1
45
39
  end
@@ -63,11 +57,6 @@ describe "Wrapping enumerations" do
63
57
  end
64
58
 
65
59
  specify "anonymous enumerations' values are added as constants to the parent class" do
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
60
  Tester::ANON_ENUM_VAL1.should == 1
72
61
  Tester::ANON_ENUM_VAL2.should == 2
73
62
  Tester::ANON_ENUM_VAL3.should == 5
@@ -75,11 +64,6 @@ describe "Wrapping enumerations" do
75
64
  end
76
65
 
77
66
  specify "top-level anonymous enumerations' values are added to the global scope" do
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
67
  OUTER_ANON_1.should == 0
84
68
  OUTER_ANON_2.should == 1
85
69
  FOURTY_TWO.should == 42
@@ -8,9 +8,7 @@ describe "Ruby Extension creation" do
8
8
  e.writer_mode :single
9
9
  end
10
10
 
11
- lambda do
12
- require "ext_test"
13
- end.should_not raise_error(LoadError)
11
+ require "ext_test"
14
12
  end
15
13
 
16
14
  specify "should create a valid Ruby extension without a block" do
@@ -22,22 +20,18 @@ describe "Ruby Extension creation" do
22
20
  e.write
23
21
  e.compile
24
22
 
25
- lambda do
26
- require "ext_test"
27
- end.should_not raise_error(LoadError)
23
+ require "ext_test"
28
24
  end
29
25
 
30
26
  specify "should properly build working dir as deep as needed" do
31
- lambda do
32
- path = File.join(File.expand_path(File.dirname(__FILE__)), "generated", "path1", "path2")
33
- Extension.new "extension" do |e|
34
- e.sources full_dir("headers/empty.h")
35
- e.working_dir = path
36
- e.writer_mode :single
37
- end
38
-
39
- File.exists?(File.join(path, "extconf.rb")).should be_true
40
- end.should_not raise_error(Errno::ENOENT)
27
+ path = File.join(File.expand_path(File.dirname(__FILE__)), "generated", "path1", "path2")
28
+ Extension.new "extension" do |e|
29
+ e.sources full_dir("headers/empty.h")
30
+ e.working_dir = path
31
+ e.writer_mode :single
32
+ end
33
+
34
+ File.exists?(File.join(path, "extconf.rb")).should eq(true)
41
35
  end
42
36
  end
43
37
 
@@ -26,15 +26,15 @@ describe "Multiple file writer (default)" do
26
26
  extconf.rb
27
27
  _Mod.rb.cpp
28
28
  _Mod.rb.hpp
29
- _classes_Adder.rb.cpp
30
- _classes_Adder.rb.hpp
31
- _classes_IntAdder.rb.cpp
32
- _classes_IntAdder.rb.hpp
33
- _classes_ShouldFindMe.rb.hpp
34
- _classes_ShouldFindMe.rb.cpp
29
+ __classes_Adder.rb.cpp
30
+ __classes_Adder.rb.hpp
31
+ __classes_IntAdder.rb.cpp
32
+ __classes_IntAdder.rb.hpp
33
+ __classes_ShouldFindMe.rb.hpp
34
+ __classes_ShouldFindMe.rb.cpp
35
35
  adder.rb.cpp
36
36
  ).each do |wants|
37
- files.find {|got| File.basename(got) == wants }.should_not be_nil
37
+ files.find {|got| File.basename(got) == wants }.should_not be_nil, "Expected #{wants} to exist"
38
38
  end
39
39
  end
40
40
 
@@ -116,8 +116,6 @@ describe "Single file writer with to_from_ruby" do
116
116
  end
117
117
 
118
118
  specify "should have compiled properly" do
119
- lambda do
120
- require 'to_from_ruby'
121
- end.should_not raise_error(LoadError)
119
+ require 'to_from_ruby'
122
120
  end
123
121
  end
@@ -20,7 +20,7 @@ describe "properly handles and wraps function pointer arguments" do
20
20
 
21
21
  call_callback
22
22
 
23
- proc_called.should be_true
23
+ proc_called.should eq(true)
24
24
  end
25
25
 
26
26
  specify "arguments, no return" do
@@ -10,7 +10,7 @@ describe "Extension with globally available functions" do
10
10
 
11
11
  require 'functions'
12
12
 
13
- lambda { test1 }.should_not raise_error(NameError)
13
+ test1
14
14
 
15
15
  test2(2.0).should be_within(0.001).of(1.0)
16
16
 
@@ -0,0 +1,25 @@
1
+ require 'rubygems'
2
+ require 'mkmf-rice'
3
+
4
+ # Add the arguments to the linker flags.
5
+ def append_ld_flags(flags)
6
+ flags = [flags] unless flags.is_a?(Array)
7
+ with_ldflags("#{$LDFLAGS} #{flags.join(' ')}") { true }
8
+ end
9
+
10
+ $CPPFLAGS += " -I'/Users/jroelofs/Development/rbplusplus/test/generated' "
11
+ $LDFLAGS += " "
12
+
13
+ if RUBY_PLATFORM =~ /darwin/
14
+ # In order to link the shared library into our bundle with GCC 4.x on OSX, we have to work around a bug:
15
+ # GCC redefines symbols - which the -fno-common prohibits. In order to keep the -fno-common, we
16
+ # remove the flat_namespace (we now have two namespaces, which fixes the GCC clash). Also, we now lookup
17
+ # symbols in both the namespaces (dynamic_lookup).
18
+
19
+ $LDSHARED_CXX.gsub!('suppress', 'dynamic_lookup')
20
+ $LDSHARED_CXX.gsub!('-flat_namespace', '')
21
+
22
+ append_ld_flags '-all_load'
23
+ end
24
+
25
+ create_makefile("ui")
@@ -5,8 +5,6 @@
5
5
  using namespace std;
6
6
 
7
7
  namespace classes {
8
- class Forwarder;
9
-
10
8
  class Adder {
11
9
  public:
12
10
  Adder();
@@ -6,7 +6,7 @@ describe "Specify types to allow implicit casting" do
6
6
  Extension.new "implicit_cast" do |e|
7
7
  e.sources full_dir("headers/implicit_cast.h")
8
8
  e.writer_mode :single
9
-
9
+
10
10
  node = e.namespace "implicit_cast"
11
11
 
12
12
  # Can flag individual constructors
@@ -25,16 +25,16 @@ describe "Specify types to allow implicit casting" do
25
25
  end
26
26
 
27
27
  specify "can use Degree in place of Radian" do
28
- is_obtuse(Degree.new(75)).should be_false
28
+ is_obtuse(Degree.new(75)).should eq(false)
29
29
  end
30
30
 
31
31
  specify "can use Radian in place of Degree" do
32
- is_acute(Radian.new(2.0)).should be_false
32
+ is_acute(Radian.new(2.0)).should eq(false)
33
33
  end
34
34
 
35
35
  specify "pointers also work fine" do
36
- is_right(Degree.new(90)).should be_true
37
- is_right(Radian.new(2.0)).should be_false
36
+ is_right(Degree.new(90)).should eq(true)
37
+ is_right(Radian.new(2.0)).should eq(false)
38
38
  end
39
39
  end
40
40
 
@@ -42,28 +42,21 @@ describe "Extension with modules" do
42
42
  end
43
43
 
44
44
  specify "should be able to generate a module definition" do
45
- lambda { Empty }.should_not raise_error(NameError)
46
-
47
45
  Empty.class.should == Module
48
46
  end
49
47
 
50
48
  specify "should wrap up C++ classes under the namespace as requested" do
51
- lambda { Adder }.should raise_error(NameError)
52
- lambda { Wrapper::Adder }.should_not raise_error(NameError)
53
-
54
49
  a = Wrapper::Adder.new
55
50
  a.get_class_name.should == "Adder"
56
51
  end
57
52
 
58
53
  specify "should wrap up C++ functions in the module" do
59
- lambda { Functions }.should_not raise_error(NameError)
60
54
  Functions::test2(2).should be_within(0.001).of(1.0)
61
55
  Functions::test3(4, 6).should == 4
62
56
  end
63
57
 
64
58
  specify "should be able to nest modules and related definitions" do
65
59
  lambda { Subtracter }.should raise_error(NameError)
66
- lambda { Nested::Nested::Inner::Subtracter }.should_not raise_error(NameError)
67
60
 
68
61
  s = Nested::Nested::Inner::Subtracter.new
69
62
  s.get_class_name.should == "Subtracter"
@@ -11,12 +11,6 @@ describe "Wrapping Classes within classes" do
11
11
  end
12
12
 
13
13
  specify "should properly make nested classes available" do
14
- lambda do
15
- Kernel.const_get(TestClass)
16
- Kernel.const_get(TestClass::InnerClass)
17
- Kernel.const_get(TestClass::InnerClass::Inner2)
18
- end.should_not raise_error(NameError)
19
-
20
14
  TestClass.new.should_not be_nil
21
15
  TestClass::InnerClass.new.should_not be_nil
22
16
  TestClass::InnerClass::Inner2.new.should_not be_nil
@@ -19,26 +19,21 @@ describe "Extension with overloaded methods" do
19
19
  require 'overload'
20
20
 
21
21
  #Constructor overloading is broken in rice
22
- #math = Mathy.new
22
+ #math = Mathy.new
23
23
  math = Mathy.new(1)
24
-
24
+
25
25
  math.times.should == 1
26
26
  math.times_1(3).should == 3
27
27
  math.times_2(3,2).should == 6
28
28
  math.times_3(3,2,3).should == 18
29
-
30
- lambda do
31
- math.nothing_0
32
- math.nothing_1(1)
33
- end.should_not raise_error(NameError)
34
29
 
35
- # Should properly handle const overloads as well
36
- lambda do
37
- math.const_method_0(1)
38
- math.const_method_1(1)
39
- math.const_method_string("love")
40
- end.should_not raise_error(NameError)
30
+ math.nothing_0
31
+ math.nothing_1(1)
41
32
 
33
+ # Should properly handle const overloads as well
34
+ math.const_method_0(1)
35
+ math.const_method_1(1)
36
+ math.const_method_string("love")
42
37
  end
43
38
 
44
39
  end
@@ -25,14 +25,9 @@ describe "Extension with class hierachies" do
25
25
  # Template superclasses shouldn't cause problems
26
26
  TemplateSub.new.zero.should == TemplateSub.new.custom
27
27
 
28
- lambda do
29
- TemplatePtr.new.custom
30
- end.should_not raise_error(NameError)
31
-
32
- lambda do
33
- Multiple.new
34
- end.should_not raise_error(NameError)
35
-
28
+ # Shouldn't throw exceptions
29
+ TemplatePtr.new.custom
30
+ Multiple.new
36
31
  Multiple.superclass.should == Base2
37
32
  end
38
33
 
@@ -32,6 +32,10 @@ RSpec.configure do |config|
32
32
  config.include(FileDirectoryHelpers)
33
33
  config.include(TestHelpers)
34
34
 
35
+ config.expect_with(:rspec) do |c|
36
+ c.syntax = :should
37
+ end
38
+
35
39
  config.before(:all) do
36
40
  test_setup
37
41
  end
@@ -61,48 +61,36 @@ describe "Ugly interfaces cleaner" do
61
61
  ui_add(1,2)
62
62
  end.should raise_error(NoMethodError)
63
63
 
64
- lambda do
65
- UI::Math::add(1,2).should == 3
66
- end.should_not raise_error(NoMethodError)
64
+ UI::Math::add(1,2).should == 3
67
65
 
68
66
  lambda do
69
67
  ui_subtract(2,1)
70
68
  end.should raise_error(NoMethodError)
71
69
 
72
- lambda do
73
- UI::Math::subtract(2,1).should == 1
74
- end.should_not raise_error(NoMethodError)
70
+ UI::Math::subtract(2,1).should == 1
75
71
 
76
72
  lambda do
77
73
  C_UIVector.new
78
74
  end.should raise_error(NameError)
79
75
 
80
- lambda do
81
- v = UI::Vector.new
82
- v.x = 3
83
- v.x.should == 3
84
- end.should_not raise_error(NameError)
76
+ v = UI::Vector.new
77
+ v.x = 3
78
+ v.x.should == 3
85
79
 
86
80
  lambda do
87
81
  UI::DMath::divide(1.0,2.0)
88
82
  end.should raise_error(NameError)
89
83
 
90
- lambda do
91
- UI::Modulus.mod(3,2).should == 1
92
- end.should_not raise_error(NameError)
84
+ UI::Modulus.mod(3,2).should == 1
93
85
 
94
86
  UI::Modulus.new.method_mod(4, 3).should == 1
95
87
 
96
- lambda do
97
- UI::Math::divide(2,1).should == 2
98
- end.should_not raise_error(NoMethodError)
88
+ UI::Math::divide(2,1).should == 2
99
89
 
100
90
  lambda do
101
91
  UI::NoConstructor.new
102
92
  end.should raise_error(TypeError)
103
93
 
104
- lambda do
105
- UI::Outside::Inside.new
106
- end.should_not raise_error(NoMethodError)
94
+ UI::Outside::Inside.new
107
95
  end
108
96
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbplusplus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Roelofs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-16 00:00:00.000000000 Z
11
+ date: 2017-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbgccxml
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: '1.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.0'
26
+ version: '1.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rice
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -105,6 +105,7 @@ files:
105
105
  - test/function_pointer_test.rb
106
106
  - test/function_pointers_classes_test.rb
107
107
  - test/functions_test.rb
108
+ - test/generated/extconf.rb
108
109
  - test/headers/Adder.cpp
109
110
  - test/headers/Adder.h
110
111
  - test/headers/Subtracter.hpp
@@ -148,7 +149,7 @@ files:
148
149
  - test/test_helper.rb
149
150
  - test/to_from_ruby_test.rb
150
151
  - test/wrap_as_test.rb
151
- homepage: http://rbplusplus.rubyforge.org
152
+ homepage: https://github.com/jasonroelofs/rbplusplus
152
153
  licenses:
153
154
  - MIT
154
155
  metadata: {}
@@ -168,66 +169,67 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
169
  version: '0'
169
170
  requirements: []
170
171
  rubyforge_project: rbplusplus
171
- rubygems_version: 2.4.8
172
+ rubygems_version: 2.6.13
172
173
  signing_key:
173
174
  specification_version: 4
174
175
  summary: Ruby library to generate Rice wrapper code
175
176
  test_files:
176
- - test/allocation_strategies_test.rb
177
+ - test/generated/extconf.rb
177
178
  - test/class_methods_encapsulate_test.rb
178
- - test/class_methods_test.rb
179
- - test/classes_test.rb
180
- - test/compiling_test.rb
179
+ - test/wrap_as_test.rb
180
+ - test/director_test.rb
181
+ - test/overloading_test.rb
182
+ - test/default_arguments_test.rb
183
+ - test/to_from_ruby_test.rb
184
+ - test/include_source_files_test.rb
181
185
  - test/constructors_test.rb
186
+ - test/allocation_strategies_test.rb
187
+ - test/modules_test.rb
188
+ - test/functions_test.rb
189
+ - test/classes_test.rb
182
190
  - test/custom_code_test.rb
183
- - test/default_arguments_test.rb
184
- - test/director_test.rb
185
- - test/enumerations_test.rb
191
+ - test/function_pointers_classes_test.rb
186
192
  - test/extension_test.rb
187
- - test/file_writers_test.rb
193
+ - test/class_methods_test.rb
188
194
  - test/function_pointer_test.rb
189
- - test/function_pointers_classes_test.rb
190
- - test/functions_test.rb
191
- - test/implicit_cast_test.rb
192
- - test/include_source_dir_test.rb
193
- - test/include_source_files_test.rb
194
- - test/modules_test.rb
195
195
  - test/nested_test.rb
196
- - test/overloading_test.rb
196
+ - test/test_helper.rb
197
+ - test/file_writers_test.rb
197
198
  - test/struct_test.rb
198
199
  - test/subclass_test.rb
199
- - test/test_helper.rb
200
- - test/to_from_ruby_test.rb
201
- - test/wrap_as_test.rb
202
- - test/headers/Adder.cpp
203
- - test/headers/Adder.h
204
- - test/headers/alloc_strats.h
200
+ - test/enumerations_test.rb
201
+ - test/implicit_cast_test.rb
202
+ - test/compiling_test.rb
203
+ - test/include_source_dir_test.rb
204
+ - test/headers/function_pointers.h
205
+ - test/headers/with_includes.h
206
+ - test/headers/requires_define.h
207
+ - test/headers/director.h
205
208
  - test/headers/class_methods.h
209
+ - test/headers/external_mapping_rice.h
210
+ - test/headers/needs_code.h
211
+ - test/headers/ugly_interface_ns.h
212
+ - test/headers/to_from_ruby_source.cpp
213
+ - test/headers/overload.h
214
+ - test/headers/include/helper.h
215
+ - test/headers/Adder.cpp
216
+ - test/headers/complex_static_methods.h
217
+ - test/headers/code/my_type.hpp
206
218
  - test/headers/code/custom_to_from_ruby.cpp
207
219
  - test/headers/code/custom_to_from_ruby.hpp
208
- - test/headers/code/my_type.hpp
209
- - test/headers/complex_static_methods.h
220
+ - test/headers/Subtracter.hpp
221
+ - test/headers/external_mapping.h
210
222
  - test/headers/constructors.h
211
223
  - test/headers/default_arguments.h
212
- - test/headers/director.h
224
+ - test/headers/alloc_strats.h
213
225
  - test/headers/empty.h
226
+ - test/headers/implicit_cast.h
214
227
  - test/headers/enums.h
215
- - test/headers/external_mapping.h
216
- - test/headers/external_mapping_rice.h
217
- - test/headers/function_pointers.h
228
+ - test/headers/Adder.h
229
+ - test/headers/ugly_interface.h
230
+ - test/headers/nested_struct.h
218
231
  - test/headers/function_pointers_class.h
219
232
  - test/headers/functions.h
220
- - test/headers/implicit_cast.h
221
- - test/headers/include/helper.h
222
- - test/headers/needs_code.h
223
- - test/headers/nested_classes.h
224
- - test/headers/nested_struct.h
225
- - test/headers/overload.h
226
- - test/headers/requires_define.h
227
233
  - test/headers/subclass.h
228
- - test/headers/Subtracter.hpp
234
+ - test/headers/nested_classes.h
229
235
  - test/headers/to_from_ruby.h
230
- - test/headers/to_from_ruby_source.cpp
231
- - test/headers/ugly_interface.h
232
- - test/headers/ugly_interface_ns.h
233
- - test/headers/with_includes.h