rice 1.4.3 → 1.5.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.
Files changed (54) hide show
  1. data/COPYING +2 -2
  2. data/Doxyfile +1 -1
  3. data/Makefile.in +296 -166
  4. data/README +18 -13
  5. data/Rakefile +3 -2
  6. data/aclocal.m4 +375 -248
  7. data/config.guess +296 -261
  8. data/config.sub +268 -94
  9. data/configure +2789 -3054
  10. data/configure.ac +1 -1
  11. data/depcomp +403 -197
  12. data/extconf.rb +14 -3
  13. data/install-sh +139 -119
  14. data/missing +154 -306
  15. data/rice/Builtin_Object_defn.hpp +0 -1
  16. data/rice/Constructor.hpp +31 -30
  17. data/rice/Data_Object_defn.hpp +8 -2
  18. data/rice/Hash.hpp +26 -9
  19. data/rice/Hash.ipp +52 -60
  20. data/rice/Makefile.am +0 -1
  21. data/rice/Makefile.in +278 -152
  22. data/rice/Module_impl.ipp +1 -1
  23. data/rice/VM.cpp +1 -11
  24. data/rice/config.hpp +3 -0
  25. data/rice/config.hpp.in +3 -0
  26. data/rice/detail/Auto_Function_Wrapper.hpp +69 -0
  27. data/rice/detail/Auto_Function_Wrapper.ipp +815 -512
  28. data/rice/detail/Auto_Member_Function_Wrapper.hpp +69 -0
  29. data/rice/detail/Auto_Member_Function_Wrapper.ipp +543 -272
  30. data/rice/detail/object_call.hpp +1 -0
  31. data/rice/detail/ruby.hpp +0 -9
  32. data/rice/detail/ruby_version_code.hpp +1 -1
  33. data/rice/detail/st.hpp +0 -38
  34. data/rice/protect.hpp +1 -0
  35. data/rice/protect.ipp +1 -0
  36. data/rice/to_from_ruby.ipp +1 -1
  37. data/ruby.ac +2 -2
  38. data/ruby/Makefile.in +221 -134
  39. data/ruby/lib/Makefile.in +133 -44
  40. data/ruby/lib/mkmf-rice.rb.in +1 -4
  41. data/ruby/lib/version.rb +1 -1
  42. data/sample/Makefile.in +96 -31
  43. data/test/Makefile.am +0 -1
  44. data/test/Makefile.in +617 -219
  45. data/test/ext/Makefile.in +96 -31
  46. data/test/test_Class.cpp +2 -2
  47. data/test/test_Data_Object.cpp +11 -11
  48. data/test/test_Hash.cpp +7 -4
  49. data/test/test_Module.cpp +17 -1
  50. data/test/test_To_From_Ruby.cpp +44 -0
  51. data/test/test_rice.rb +2 -2
  52. metadata +29 -43
  53. data/rice/Allocation_Strategies.hpp +0 -37
  54. data/test/test_Allocation_Strategies.cpp +0 -77
@@ -1,6 +1,8 @@
1
1
  #include "unittest.hpp"
2
2
  #include "rice/to_from_ruby.hpp"
3
3
  #include "rice/String.hpp"
4
+ #include "rice/Array.hpp"
5
+ #include "rice/Hash.hpp"
4
6
  #include <limits>
5
7
  #include <cmath>
6
8
 
@@ -249,6 +251,24 @@ TESTCASE(char_const_ptr_from_ruby)
249
251
  ASSERT_EQUAL("foo", from_ruby<char const *>(rb_str_new2("foo")));
250
252
  }
251
253
 
254
+ TESTCASE(char_from_ruby_single_character_string)
255
+ {
256
+ ASSERT_EQUAL('x', from_ruby<char>(rb_str_new2("x")));
257
+ }
258
+
259
+ TESTCASE(char_from_ruby_longer_string)
260
+ {
261
+ ASSERT_EXCEPTION(
262
+ std::invalid_argument,
263
+ from_ruby<char>(rb_str_new2("xy"))
264
+ );
265
+ }
266
+
267
+ TESTCASE(char_from_ruby_fixnum)
268
+ {
269
+ ASSERT_EQUAL('1', from_ruby<char>(INT2NUM(49)));
270
+ }
271
+
252
272
  TESTCASE(std_string_to_ruby)
253
273
  {
254
274
  ASSERT_EQUAL(String(""), to_ruby(std::string("")));
@@ -275,3 +295,27 @@ TESTCASE(std_string_from_ruby_with_binary)
275
295
  ASSERT_EQUAL(5, got.length());
276
296
  ASSERT_EQUAL(std::string("\000test", 5), got);
277
297
  }
298
+
299
+ TESTCASE(array_to_ruby)
300
+ {
301
+ Array a(rb_ary_new());
302
+ ASSERT_EQUAL(a.value(), to_ruby(a).value());
303
+ }
304
+
305
+ TESTCASE(array_from_ruby)
306
+ {
307
+ Array a(rb_ary_new());
308
+ ASSERT_EQUAL(a.value(), from_ruby<Array>(a).value());
309
+ }
310
+
311
+ TESTCASE(hash_to_ruby)
312
+ {
313
+ Hash h(rb_hash_new());
314
+ ASSERT_EQUAL(h.value(), to_ruby(h).value());
315
+ }
316
+
317
+ TESTCASE(hash_from_ruby)
318
+ {
319
+ Hash h(rb_hash_new());
320
+ ASSERT_EQUAL(h.value(), from_ruby<Hash>(h).value());
321
+ }
data/test/test_rice.rb CHANGED
@@ -5,8 +5,8 @@ class RiceTest < Test::Unit::TestCase
5
5
  # TODO: probably a better way to find this out...
6
6
  VERBOSE = ARGV.include?('-v')
7
7
 
8
- EXEEXT = Config::CONFIG['EXEEXT']
9
- RUBY = Config::CONFIG['RUBY_INSTALL_NAME']
8
+ EXEEXT = RbConfig::CONFIG['EXEEXT']
9
+ RUBY = RbConfig::CONFIG['RUBY_INSTALL_NAME']
10
10
 
11
11
  def test_unittest
12
12
  run_external_test("./unittest#{EXEEXT}")
metadata CHANGED
@@ -1,41 +1,38 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rice
3
- version: !ruby/object:Gem::Version
4
- hash: 1
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.5.0
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 4
9
- - 3
10
- version: 1.4.3
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Paul Brannan
14
9
  - Jason Roelofs
15
10
  autorequire:
16
11
  bindir: bin
17
12
  cert_chain: []
18
-
19
- date: 2011-10-09 00:00:00 Z
13
+ date: 2013-05-01 00:00:00.000000000 Z
20
14
  dependencies: []
15
+ description: ! 'Rice is a C++ interface to Ruby''s C API. It provides a type-safe
16
+ and
21
17
 
22
- description: |
23
- Rice is a C++ interface to Ruby's C API. It provides a type-safe and
24
18
  exception-safe interface in order to make embedding Ruby and writing
19
+
25
20
  Ruby extensions with C++ easier. It is similar to Boost.Python in many
21
+
26
22
  ways, but also attempts to provide an object-oriented interface to all
23
+
27
24
  of the Ruby C API.
28
25
 
29
- email:
26
+ '
27
+ email:
30
28
  - curlypaul924@gmail.com
31
- - jameskilton@gmail.com
29
+ - jasonroelofs@gmail.com
32
30
  executables: []
33
-
34
- extensions:
31
+ extensions:
35
32
  - extconf.rb
36
- extra_rdoc_files:
33
+ extra_rdoc_files:
37
34
  - README
38
- files:
35
+ files:
39
36
  - COPYING
40
37
  - README
41
38
  - README.mingw
@@ -72,7 +69,6 @@ files:
72
69
  - rice/Address_Registration_Guard.hpp
73
70
  - rice/Address_Registration_Guard.ipp
74
71
  - rice/Address_Registration_Guard_defn.hpp
75
- - rice/Allocation_Strategies.hpp
76
72
  - rice/Arg.hpp
77
73
  - rice/Arg_impl.hpp
78
74
  - rice/Arg_operators.cpp
@@ -205,7 +201,6 @@ files:
205
201
  - sample/inheritance/animals.cpp
206
202
  - sample/inheritance/test.rb
207
203
  - test/test_Address_Registration_Guard.cpp
208
- - test/test_Allocation_Strategies.cpp
209
204
  - test/test_Array.cpp
210
205
  - test/test_Builtin_Object.cpp
211
206
  - test/test_Class.cpp
@@ -240,36 +235,27 @@ files:
240
235
  - test/test_rice.rb
241
236
  homepage: http://rice.rubyforge.org/
242
237
  licenses: []
243
-
244
238
  post_install_message:
245
239
  rdoc_options: []
246
-
247
- require_paths:
240
+ require_paths:
248
241
  - ruby/lib
249
- required_ruby_version: !ruby/object:Gem::Requirement
242
+ required_ruby_version: !ruby/object:Gem::Requirement
250
243
  none: false
251
- requirements:
252
- - - ">="
253
- - !ruby/object:Gem::Version
254
- hash: 3
255
- segments:
256
- - 0
257
- version: "0"
258
- required_rubygems_version: !ruby/object:Gem::Requirement
244
+ requirements:
245
+ - - ! '>='
246
+ - !ruby/object:Gem::Version
247
+ version: '0'
248
+ required_rubygems_version: !ruby/object:Gem::Requirement
259
249
  none: false
260
- requirements:
261
- - - ">="
262
- - !ruby/object:Gem::Version
263
- hash: 3
264
- segments:
265
- - 0
266
- version: "0"
250
+ requirements:
251
+ - - ! '>='
252
+ - !ruby/object:Gem::Version
253
+ version: '0'
267
254
  requirements: []
268
-
269
255
  rubyforge_project: rice
270
- rubygems_version: 1.8.6
256
+ rubygems_version: 1.8.25
271
257
  signing_key:
272
258
  specification_version: 3
273
259
  summary: Ruby Interface for C++ Extensions
274
- test_files:
260
+ test_files:
275
261
  - test/test_rice.rb
@@ -1,37 +0,0 @@
1
- #ifndef Rice__Default_Allocation_Strategy__hpp_
2
- #define Rice__Default_Allocation_Strategy__hpp_
3
-
4
- #include "detail/ruby.hpp"
5
-
6
- /*! \file
7
- * \brief Strategies for allocation/deallocation of objects.
8
- */
9
-
10
- namespace Rice
11
- {
12
-
13
- template<typename T>
14
- struct Default_Allocation_Strategy
15
- {
16
- //! Allocate an object using operator new.
17
- static T * allocate() { return new T; }
18
-
19
- //! Delete obj using the delete operator.
20
- static void free(T * obj) { delete obj; }
21
- };
22
-
23
- template<typename T>
24
- struct Xmalloc_Allocation_Strategy
25
- {
26
- //! Allocate an array of objects using operator new and xmalloc.
27
- static T * allocate() { T * obj = static_cast<T *>(::xmalloc(sizeof(T))); new(obj) T; return obj; }
28
-
29
- //! Delete obj by calling the destructor explicitly and calling xfree.
30
- static void free(T * obj) { obj->~T(); ::xfree(obj); }
31
- };
32
-
33
- // TODO: array allocation
34
-
35
- } // namespace Rice
36
-
37
- #endif // Rice__Default_Allocation_Strategy__hpp_
@@ -1,77 +0,0 @@
1
- #include "unittest.hpp"
2
- #include "rice/Allocation_Strategies.hpp"
3
-
4
- using namespace Rice;
5
-
6
- namespace
7
- {
8
-
9
- bool constructor_called = false;
10
- bool destructor_called = false;
11
-
12
- class Foo
13
- {
14
- public:
15
- Foo()
16
- {
17
- constructor_called = true;
18
- }
19
-
20
- ~Foo()
21
- {
22
- destructor_called = true;
23
- }
24
- };
25
-
26
- } // namespace
27
-
28
- TESTSUITE(Allocation_Strategies);
29
-
30
- SETUP(Allocation_Strategies)
31
- {
32
- ruby_init();
33
- constructor_called = false;
34
- destructor_called = false;
35
- }
36
-
37
- TESTCASE(default_allocation_strategy_allocate)
38
- {
39
- Foo * t = Default_Allocation_Strategy<Foo>::allocate();
40
- ASSERT(constructor_called);
41
- ASSERT(!destructor_called);
42
- delete t;
43
- ASSERT(constructor_called);
44
- ASSERT(destructor_called);
45
- }
46
-
47
- TESTCASE(default_allocation_strategy_free)
48
- {
49
- Foo * t = new Foo;
50
- ASSERT(constructor_called);
51
- ASSERT(!destructor_called);
52
- Default_Allocation_Strategy<Foo>::free(t);
53
- ASSERT(constructor_called);
54
- ASSERT(destructor_called);
55
- }
56
-
57
- TESTCASE(xmalloc_allocation_strategy_allocate)
58
- {
59
- Foo * t = Xmalloc_Allocation_Strategy<Foo>::allocate();
60
- ASSERT(constructor_called);
61
- ASSERT(!destructor_called);
62
- t->~Foo();
63
- xfree(t);
64
- ASSERT(constructor_called);
65
- ASSERT(destructor_called);
66
- }
67
-
68
- TESTCASE(xmalloc_allocation_strategy_free)
69
- {
70
- Foo * t = Xmalloc_Allocation_Strategy<Foo>::allocate();
71
- ASSERT(constructor_called);
72
- ASSERT(!destructor_called);
73
- Xmalloc_Allocation_Strategy<Foo>::free(t);
74
- ASSERT(constructor_called);
75
- ASSERT(destructor_called);
76
- }
77
-