rice-jdguyot 1.4.0 → 1.4.3p1

Sign up to get free protection for your applications and to get access to all the features.
data/Doxyfile CHANGED
@@ -23,7 +23,7 @@ PROJECT_NAME = Rice
23
23
  # This could be handy for archiving the generated documentation or
24
24
  # if some version control system is used.
25
25
 
26
- PROJECT_NUMBER = 1.4.0
26
+ PROJECT_NUMBER = 1.4.3
27
27
 
28
28
  # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
29
29
  # base path where the generated documentation will be put.
data/extconf.rb CHANGED
@@ -14,25 +14,26 @@
14
14
  $:.unshift File.expand_path(File.dirname(__FILE__))
15
15
 
16
16
  require 'rbconfig'
17
- require 'rubygems'
18
17
  require 'ruby/lib/version.rb'
19
18
 
20
- gem_name = "rice-#{Rice::VERSION}"
21
-
22
- gem_base_dir = File.writable?(Gem.default_dir) ? Gem.default_dir : Gem.user_dir
23
- prefix_dir = File.join(gem_base_dir, "gems", gem_name, "ruby", "lib")
19
+ prefix_dir = File.join(File.dirname(File.expand_path(__FILE__)), "ruby", "lib")
24
20
  with_ruby = File.join(Config::CONFIG["bindir"], Config::CONFIG["RUBY_INSTALL_NAME"])
25
21
 
26
22
  other_opts = ""
27
23
  env = ""
28
24
 
29
- arch = 'x86_64'
25
+ if RUBY_PLATFORM =~ /darwin10/ || RUBY_PLATFORM =~ /darwin11/
26
+ arch = Config::CONFIG["arch"].split("-")[0]
27
+
28
+ if arch == "universal"
29
+ arch = `uname -m`.strip
30
+ end
30
31
 
31
- if RUBY_PLATFORM =~ /darwin10/
32
32
  other_opts = "--disable-dependency-tracking"
33
- env = "ARCHFLAGS='-arch #{arch}'"
33
+ env = "ARCHFLAGS='-arch #{arch}' CPPFLAGS='-arch #{arch}'"
34
34
  elsif RUBY_PLATFORM =~ /darwin9/
35
- env = "ARCHFLAGS='-arch #{`uname -p`.chomp}'"
35
+ arch = `uname -p`.chomp
36
+ env = "ARCHFLAGS='-arch #{arch}' CPPFLAGS='-arch #{arch}'"
36
37
  end
37
38
 
38
39
  system "#{env} sh configure --with-ruby=#{with_ruby} --prefix=#{prefix_dir} #{other_opts}"
@@ -0,0 +1,22 @@
1
+ #include "Address_Registration_Guard.hpp"
2
+
3
+ bool Rice::Address_Registration_Guard::enabled = true;
4
+ bool Rice::Address_Registration_Guard::exit_handler_registered = false;
5
+
6
+ static void disable_all_guards(VALUE)
7
+ {
8
+ Rice::Address_Registration_Guard::disable();
9
+ }
10
+
11
+ void Rice::Address_Registration_Guard::registerExitHandler()
12
+ {
13
+ if (exit_handler_registered) return;
14
+ rb_set_end_proc(&disable_all_guards, Qnil);
15
+ exit_handler_registered = true;
16
+ }
17
+
18
+ void Rice::Address_Registration_Guard::disable()
19
+ {
20
+ enabled = false;
21
+ }
22
+
@@ -5,6 +5,7 @@ inline Rice::Address_Registration_Guard::
5
5
  Address_Registration_Guard(VALUE * address)
6
6
  : address_(address)
7
7
  {
8
+ registerExitHandler();
8
9
  rb_gc_register_address(address);
9
10
  }
10
11
 
@@ -12,13 +13,15 @@ inline Rice::Address_Registration_Guard::
12
13
  Address_Registration_Guard(Object * object)
13
14
  : address_(const_cast<VALUE *>(&object->value()))
14
15
  {
16
+ registerExitHandler();
15
17
  rb_gc_register_address(address_);
16
18
  }
17
19
 
18
20
  inline Rice::Address_Registration_Guard::
19
21
  ~Address_Registration_Guard()
20
22
  {
21
- rb_gc_unregister_address(address_);
23
+ if (enabled)
24
+ rb_gc_unregister_address(address_);
22
25
  }
23
26
 
24
27
  inline VALUE * Rice::Address_Registration_Guard::
@@ -56,7 +56,17 @@ public:
56
56
  //! Swap with another Address_Registration_Guard.
57
57
  void swap(Address_Registration_Guard & other);
58
58
 
59
+ /** Called during Ruby's exit process since we should not call
60
+ * rb_gc unregister_address there
61
+ */
62
+ static void disable();
63
+
59
64
  private:
65
+ static bool enabled;
66
+ static bool exit_handler_registered;
67
+
68
+ static void registerExitHandler();
69
+
60
70
  VALUE * address_;
61
71
  };
62
72
 
data/rice/Data_Type.ipp CHANGED
@@ -130,8 +130,8 @@ define_constructor(
130
130
  rb_define_alloc_func(
131
131
  static_cast<VALUE>(*this),
132
132
  detail::default_allocation_func<T>);
133
- define_method(
134
- "initialize",
133
+ this->define_method(
134
+ "initialize",
135
135
  &Constructor_T::construct,
136
136
  arguments
137
137
  );
data/rice/Hash.hpp CHANGED
@@ -204,6 +204,20 @@ private:
204
204
 
205
205
  } // namespace Rice
206
206
 
207
+ template<>
208
+ inline
209
+ Rice::Hash from_ruby<Rice::Hash>(Rice::Object x)
210
+ {
211
+ return Rice::Hash(x);
212
+ }
213
+
214
+ template<>
215
+ inline
216
+ Rice::Object to_ruby<Rice::Hash>(Rice::Hash const & x)
217
+ {
218
+ return x;
219
+ }
220
+
207
221
  #include "Hash.ipp"
208
222
 
209
223
  #endif // Rice__Hash__hpp_
data/rice/Makefile.am CHANGED
@@ -13,6 +13,7 @@ Struct.cpp \
13
13
  Symbol.cpp \
14
14
  VM.cpp \
15
15
  Arg_operators.cpp \
16
+ Address_Registration_Guard.cpp \
16
17
  detail/check_ruby_type.cpp \
17
18
  detail/demangle.cpp \
18
19
  detail/method_data.cpp \
data/rice/Makefile.in CHANGED
@@ -61,8 +61,9 @@ am_librice_a_OBJECTS = Class.$(OBJEXT) Data_Type.$(OBJEXT) \
61
61
  Director.$(OBJEXT) Exception.$(OBJEXT) Identifier.$(OBJEXT) \
62
62
  Module.$(OBJEXT) Object.$(OBJEXT) String.$(OBJEXT) \
63
63
  Struct.$(OBJEXT) Symbol.$(OBJEXT) VM.$(OBJEXT) \
64
- Arg_operators.$(OBJEXT) check_ruby_type.$(OBJEXT) \
65
- demangle.$(OBJEXT) method_data.$(OBJEXT) protect.$(OBJEXT)
64
+ Arg_operators.$(OBJEXT) Address_Registration_Guard.$(OBJEXT) \
65
+ check_ruby_type.$(OBJEXT) demangle.$(OBJEXT) \
66
+ method_data.$(OBJEXT) protect.$(OBJEXT)
66
67
  librice_a_OBJECTS = $(am_librice_a_OBJECTS)
67
68
  DEFAULT_INCLUDES = -I.@am__isrc@
68
69
  depcomp = $(SHELL) $(top_srcdir)/depcomp
@@ -222,6 +223,7 @@ Struct.cpp \
222
223
  Symbol.cpp \
223
224
  VM.cpp \
224
225
  Arg_operators.cpp \
226
+ Address_Registration_Guard.cpp \
225
227
  detail/check_ruby_type.cpp \
226
228
  detail/demangle.cpp \
227
229
  detail/method_data.cpp \
@@ -423,6 +425,7 @@ mostlyclean-compile:
423
425
  distclean-compile:
424
426
  -rm -f *.tab.c
425
427
 
428
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Address_Registration_Guard.Po@am__quote@
426
429
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Arg_operators.Po@am__quote@
427
430
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Class.Po@am__quote@
428
431
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Data_Type.Po@am__quote@
@@ -585,8 +588,8 @@ distdir: $(DISTFILES)
585
588
  sed -e "s|^$$srcdirstrip/||;t" \
586
589
  -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
587
590
  case $$dist_files in \
588
- */*) eval $(MKDIR_P) `echo "$$dist_files" | \
589
- sed '/\//!d;s|^|"$(distdir)"/|;s,/[^/]*$$,,' | \
591
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
592
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
590
593
  sort -u` ;; \
591
594
  esac; \
592
595
  for file in $$dist_files; do \
@@ -594,12 +597,12 @@ distdir: $(DISTFILES)
594
597
  if test -d $$d/$$file; then \
595
598
  dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
596
599
  if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
597
- cp -pR $(srcdir)/$$file "$(distdir)"$$dir || exit 1; \
600
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
598
601
  fi; \
599
- cp -pR $$d/$$file "$(distdir)"$$dir || exit 1; \
602
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
600
603
  else \
601
- test -f "$(distdir)"/$$file \
602
- || cp -p $$d/$$file "$(distdir)"/$$file \
604
+ test -f $(distdir)/$$file \
605
+ || cp -p $$d/$$file $(distdir)/$$file \
603
606
  || exit 1; \
604
607
  fi; \
605
608
  done
data/rice/Module_impl.ipp CHANGED
@@ -298,7 +298,7 @@ void
298
298
  Rice::Module_impl<Base_T, Derived_T>::
299
299
  remove_const(Identifier name)
300
300
  {
301
- protect(rb_mod_remove_const, *this, Symbol(name));
301
+ protect(rb_mod_remove_const, *this, name.to_sym());
302
302
  }
303
303
 
304
304
  template<typename Base_T, typename Derived_T>
data/rice/String.cpp CHANGED
@@ -37,7 +37,7 @@ String(char const * s)
37
37
 
38
38
  Rice::String::
39
39
  String(std::string const & s)
40
- : Builtin_Object<RString, T_STRING>(protect(rb_str_new, s.c_str(), s.length()))
40
+ : Builtin_Object<RString, T_STRING>(protect(rb_str_new, s.data(), s.length()))
41
41
  {
42
42
  }
43
43
 
@@ -83,7 +83,7 @@ c_str() const
83
83
  std::string Rice::String::
84
84
  str() const
85
85
  {
86
- return RSTRING_PTR(value());
86
+ return std::string(RSTRING_PTR(value()), length());
87
87
  }
88
88
 
89
89
  Rice::Identifier Rice::String::
data/rice/config.hpp ADDED
@@ -0,0 +1,41 @@
1
+ /* rice/config.hpp. Generated from config.hpp.in by configure. */
2
+ /* rice/config.hpp.in. Generated from configure.ac by autoheader. */
3
+
4
+ /* Define to 1 if you have the <env.h> header file. */
5
+ /* #undef HAVE_ENV_H */
6
+
7
+ /* Define to 1 if you have the <node.h> header file. */
8
+ /* #undef HAVE_NODE_H */
9
+
10
+ /* Define to 1 if you have the <ruby.h> header file. */
11
+ #define HAVE_RUBY_H 1
12
+
13
+ /* Define to 1 if you have the <ruby/node.h> header file. */
14
+ /* #undef HAVE_RUBY_NODE_H */
15
+
16
+ /* Define to 1 if you have the <version.h> header file. */
17
+ /* #undef HAVE_VERSION_H */
18
+
19
+ /* Name of package */
20
+ #define PACKAGE "rice"
21
+
22
+ /* Define to the address where bug reports for this package should be sent. */
23
+ #define PACKAGE_BUGREPORT ""
24
+
25
+ /* Define to the full name of this package. */
26
+ #define PACKAGE_NAME "rice"
27
+
28
+ /* Define to the full name and version of this package. */
29
+ #define PACKAGE_STRING "rice 1.1"
30
+
31
+ /* Define to the one symbol short name of this package. */
32
+ #define PACKAGE_TARNAME "rice"
33
+
34
+ /* Define to the version of this package. */
35
+ #define PACKAGE_VERSION "1.1"
36
+
37
+ /* Define this macro to use ruby/node.h */
38
+ /* #undef REALLY_HAVE_RUBY_NODE_H */
39
+
40
+ /* Version number of package */
41
+ #define VERSION "1.1"
@@ -0,0 +1,6 @@
1
+ #ifndef Rice__detail__ruby_version_code__hpp
2
+ #define Rice__detail__ruby_version_code__hpp
3
+
4
+ #define RICE__RUBY_VERSION_CODE 192
5
+
6
+ #endif // Rice__detail__ruby_version_code__hpp
@@ -261,10 +261,7 @@ template<>
261
261
  inline
262
262
  char const * from_ruby<char const *>(Rice::Object x)
263
263
  {
264
- // TODO: Maybe not the right way to do this conversion (what happens
265
- // if the object gets GC'd?)
266
- VALUE v(x.value());
267
- return (char const *)Rice::protect<char const *>(rb_string_value_cstr, &v);
264
+ return Rice::String(x).str().data();
268
265
  }
269
266
 
270
267
  template<>
@@ -279,19 +276,19 @@ template<>
279
276
  inline
280
277
  std::string from_ruby<std::string>(Rice::Object x)
281
278
  {
282
- return std::string(from_ruby<char const *>(x));
279
+ return Rice::String(x).str();
283
280
  }
284
281
 
285
282
  template<>
286
283
  inline
287
284
  Rice::Object to_ruby<std::string>(std::string const & x)
288
285
  {
289
- return to_ruby(x.c_str());
286
+ return Rice::protect(rb_str_new, x.data(), x.size());
290
287
  }
291
288
 
292
289
  template<>
293
290
  inline
294
291
  std::string* from_ruby<std::string* >(Rice::Object x)
295
292
  {
296
- return new std::string(from_ruby<char const *>(x));
293
+ return new std::string(Rice::String(x).str());
297
294
  }
data/ruby/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rice
2
- VERSION = "1.4.0"
2
+ VERSION = "1.4.3p1"
3
3
  end
@@ -71,6 +71,7 @@ namespace {
71
71
 
72
72
  int default_process(int num) {
73
73
  raisePureVirtual();
74
+ return 0;
74
75
  }
75
76
 
76
77
  virtual int doSomething(int num) {
@@ -201,6 +202,7 @@ namespace {
201
202
 
202
203
  int default_doItImpl(int in) {
203
204
  raisePureVirtual();
205
+ return 0;
204
206
  }
205
207
  };
206
208
 
@@ -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
 
@@ -261,3 +263,41 @@ TESTCASE(std_string_from_ruby)
261
263
  ASSERT_EQUAL(std::string("foo"), from_ruby<std::string>(rb_str_new2("foo")));
262
264
  }
263
265
 
266
+ TESTCASE(std_string_to_ruby_with_binary)
267
+ {
268
+ Rice::String got = to_ruby(std::string("\000test", 5));
269
+
270
+ ASSERT_EQUAL(String(std::string("\000test", 5)), got);
271
+ ASSERT_EQUAL(5, got.length());
272
+ }
273
+
274
+ TESTCASE(std_string_from_ruby_with_binary)
275
+ {
276
+ std::string got = from_ruby<std::string>(rb_str_new("\000test", 5));
277
+ ASSERT_EQUAL(5, got.length());
278
+ ASSERT_EQUAL(std::string("\000test", 5), got);
279
+ }
280
+
281
+ TESTCASE(array_to_ruby)
282
+ {
283
+ Array a(rb_ary_new());
284
+ ASSERT_EQUAL(a.value(), to_ruby(a).value());
285
+ }
286
+
287
+ TESTCASE(array_from_ruby)
288
+ {
289
+ Array a(rb_ary_new());
290
+ ASSERT_EQUAL(a.value(), from_ruby<Array>(a).value());
291
+ }
292
+
293
+ TESTCASE(hash_to_ruby)
294
+ {
295
+ Hash h(rb_hash_new());
296
+ ASSERT_EQUAL(h.value(), to_ruby(h).value());
297
+ }
298
+
299
+ TESTCASE(hash_from_ruby)
300
+ {
301
+ Hash h(rb_hash_new());
302
+ ASSERT_EQUAL(h.value(), from_ruby<Hash>(h).value());
303
+ }
data/test/unittest.hpp CHANGED
@@ -7,8 +7,6 @@
7
7
 
8
8
  #if defined(_MSC_VER)
9
9
  #define NOMINMAX
10
- #else
11
- using namespace std;
12
10
  #endif
13
11
 
14
12
  #include <vector>
@@ -17,6 +15,10 @@ using namespace std;
17
15
  #include <sstream>
18
16
  #include <iostream>
19
17
 
18
+ #if !defined(_MSC_VER)
19
+ using namespace std;
20
+ #endif
21
+
20
22
  class Failure
21
23
  {
22
24
  public:
metadata CHANGED
@@ -1,55 +1,38 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rice-jdguyot
3
- version: !ruby/object:Gem::Version
4
- hash: 7
5
- prerelease: false
6
- segments:
7
- - 1
8
- - 4
9
- - 0
10
- version: 1.4.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.4.3p1
5
+ prerelease: 5
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: []
13
+ date: 2012-04-27 00:00:00.000000000 Z
14
+ dependencies: []
15
+ description: ! 'Rice is a C++ interface to Ruby''s C API. It provides a type-safe
16
+ and
18
17
 
19
- date: 2010-09-16 00:00:00 +02:00
20
- default_executable:
21
- dependencies:
22
- - !ruby/object:Gem::Dependency
23
- name: rubyforge
24
- prerelease: false
25
- requirement: &id001 !ruby/object:Gem::Requirement
26
- none: false
27
- requirements:
28
- - - ">="
29
- - !ruby/object:Gem::Version
30
- hash: 3
31
- segments:
32
- - 0
33
- version: "0"
34
- type: :development
35
- version_requirements: *id001
36
- description: |
37
- Rice is a C++ interface to Ruby's C API. It provides a type-safe and
38
18
  exception-safe interface in order to make embedding Ruby and writing
19
+
39
20
  Ruby extensions with C++ easier. It is similar to Boost.Python in many
21
+
40
22
  ways, but also attempts to provide an object-oriented interface to all
23
+
41
24
  of the Ruby C API.
42
25
 
43
- email:
26
+ '
27
+ email:
44
28
  - curlypaul924@gmail.com
45
29
  - jameskilton@gmail.com
46
30
  executables: []
47
-
48
- extensions:
31
+ extensions:
49
32
  - extconf.rb
50
- extra_rdoc_files:
33
+ extra_rdoc_files:
51
34
  - README
52
- files:
35
+ files:
53
36
  - COPYING
54
37
  - README
55
38
  - README.mingw
@@ -82,6 +65,7 @@ files:
82
65
  - sample/Makefile.in
83
66
  - test/Makefile.am
84
67
  - test/Makefile.in
68
+ - rice/Address_Registration_Guard.cpp
85
69
  - rice/Address_Registration_Guard.hpp
86
70
  - rice/Address_Registration_Guard.ipp
87
71
  - rice/Address_Registration_Guard_defn.hpp
@@ -99,6 +83,7 @@ files:
99
83
  - rice/Class.hpp
100
84
  - rice/Class.ipp
101
85
  - rice/Class_defn.hpp
86
+ - rice/config.hpp
102
87
  - rice/Constructor.hpp
103
88
  - rice/Critical_Guard.hpp
104
89
  - rice/Critical_Guard.ipp
@@ -194,6 +179,7 @@ files:
194
179
  - rice/detail/protect.cpp
195
180
  - rice/detail/protect.hpp
196
181
  - rice/detail/ruby.hpp
182
+ - rice/detail/ruby_version_code.hpp
197
183
  - rice/detail/rubysig.hpp
198
184
  - rice/detail/st.hpp
199
185
  - rice/detail/to_ruby.hpp
@@ -249,39 +235,29 @@ files:
249
235
  - test/ext/t2/extconf.rb
250
236
  - test/ext/t2/t2.cpp
251
237
  - test/test_rice.rb
252
- has_rdoc: true
253
238
  homepage: http://rice.rubyforge.org/
254
239
  licenses: []
255
-
256
240
  post_install_message:
257
241
  rdoc_options: []
258
-
259
- require_paths:
242
+ require_paths:
260
243
  - ruby/lib
261
- required_ruby_version: !ruby/object:Gem::Requirement
244
+ required_ruby_version: !ruby/object:Gem::Requirement
262
245
  none: false
263
- requirements:
264
- - - ">="
265
- - !ruby/object:Gem::Version
266
- hash: 3
267
- segments:
268
- - 0
269
- version: "0"
270
- required_rubygems_version: !ruby/object:Gem::Requirement
246
+ requirements:
247
+ - - ! '>='
248
+ - !ruby/object:Gem::Version
249
+ version: '0'
250
+ required_rubygems_version: !ruby/object:Gem::Requirement
271
251
  none: false
272
- requirements:
273
- - - ">="
274
- - !ruby/object:Gem::Version
275
- hash: 3
276
- segments:
277
- - 0
278
- version: "0"
252
+ requirements:
253
+ - - ! '>'
254
+ - !ruby/object:Gem::Version
255
+ version: 1.3.1
279
256
  requirements: []
280
-
281
257
  rubyforge_project: rice
282
- rubygems_version: 1.3.7
258
+ rubygems_version: 1.8.23
283
259
  signing_key:
284
260
  specification_version: 3
285
261
  summary: Ruby Interface for C++ Extensions
286
- test_files:
262
+ test_files:
287
263
  - test/test_rice.rb