rice 1.4.0 → 1.4.2

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.2
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/Rakefile CHANGED
@@ -23,9 +23,7 @@ end
23
23
 
24
24
  desc "Upload documentation to the website. Requires rubyforge gem"
25
25
  task :upload_web => [:doc] do
26
- config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
27
- host = "#{config["username"]}@rubyforge.org"
28
-
26
+ host = "jameskilton@rubyforge.org"
29
27
  Rake::SshDirPublisher.new(host, PROJECT_WEB_PATH, "doc/html").upload
30
28
  end
31
29
 
data/extconf.rb CHANGED
@@ -14,13 +14,9 @@
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 = ""
@@ -30,9 +26,10 @@ arch = Config::CONFIG["arch"].split("-")[0]
30
26
 
31
27
  if RUBY_PLATFORM =~ /darwin10/
32
28
  other_opts = "--disable-dependency-tracking"
33
- env = "ARCHFLAGS='-arch #{arch}'"
29
+ env = "ARCHFLAGS='-arch #{arch}' CPPFLAGS='-arch #{arch}'"
34
30
  elsif RUBY_PLATFORM =~ /darwin9/
35
- env = "ARCHFLAGS='-arch #{`uname -p`.chomp}'"
31
+ arch = `uname -p`.chomp
32
+ env = "ARCHFLAGS='-arch #{arch}' CPPFLAGS='-arch #{arch}'"
36
33
  end
37
34
 
38
35
  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/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@
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::
@@ -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.2"
3
3
  end
data/sample/enum/test.rb CHANGED
@@ -1,4 +1,3 @@
1
- $: << "."
2
1
  require 'sample_enum'
3
2
 
4
3
  Sample_Enum.each { |x| p x }
@@ -261,3 +261,17 @@ TESTCASE(std_string_from_ruby)
261
261
  ASSERT_EQUAL(std::string("foo"), from_ruby<std::string>(rb_str_new2("foo")));
262
262
  }
263
263
 
264
+ TESTCASE(std_string_to_ruby_with_binary)
265
+ {
266
+ Rice::String got = to_ruby(std::string("\000test", 5));
267
+
268
+ ASSERT_EQUAL(String(std::string("\000test", 5)), got);
269
+ ASSERT_EQUAL(5, got.length());
270
+ }
271
+
272
+ TESTCASE(std_string_from_ruby_with_binary)
273
+ {
274
+ std::string got = from_ruby<std::string>(rb_str_new("\000test", 5));
275
+ ASSERT_EQUAL(5, got.length());
276
+ ASSERT_EQUAL(std::string("\000test", 5), got);
277
+ }
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 4
8
- - 0
9
- version: 1.4.0
8
+ - 2
9
+ version: 1.4.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Paul Brannan
@@ -15,22 +15,10 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-25 00:00:00 -04:00
18
+ date: 2010-12-27 00:00:00 -05:00
19
19
  default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- name: rubyforge
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- segments:
30
- - 0
31
- version: "0"
32
- type: :development
33
- version_requirements: *id001
20
+ dependencies: []
21
+
34
22
  description: |
35
23
  Rice is a C++ interface to Ruby's C API. It provides a type-safe and
36
24
  exception-safe interface in order to make embedding Ruby and writing
@@ -80,6 +68,7 @@ files:
80
68
  - sample/Makefile.in
81
69
  - test/Makefile.am
82
70
  - test/Makefile.in
71
+ - rice/Address_Registration_Guard.cpp
83
72
  - rice/Address_Registration_Guard.hpp
84
73
  - rice/Address_Registration_Guard.ipp
85
74
  - rice/Address_Registration_Guard_defn.hpp