rice 1.4.0 → 1.4.2
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/Doxyfile +1 -1
- data/Rakefile +1 -3
- data/extconf.rb +4 -7
- data/rice/Address_Registration_Guard.cpp +22 -0
- data/rice/Address_Registration_Guard.ipp +4 -1
- data/rice/Address_Registration_Guard_defn.hpp +10 -0
- data/rice/Makefile.am +1 -0
- data/rice/Makefile.in +5 -2
- data/rice/String.cpp +2 -2
- data/rice/to_from_ruby.ipp +4 -7
- data/ruby/lib/version.rb +1 -1
- data/sample/enum/test.rb +0 -1
- data/test/test_To_From_Ruby.cpp +14 -0
- metadata +6 -17
    
        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. | 
| 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 | 
            -
               | 
| 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 | 
            -
             | 
| 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 | 
            -
               | 
| 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 | 
            -
               | 
| 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
    
    
    
        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)  | 
| 65 | 
            -
            	 | 
| 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. | 
| 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/to_from_ruby.ipp
    CHANGED
    
    | @@ -261,10 +261,7 @@ template<> | |
| 261 261 | 
             
            inline
         | 
| 262 262 | 
             
            char const * from_ruby<char const *>(Rice::Object x)
         | 
| 263 263 | 
             
            {
         | 
| 264 | 
            -
               | 
| 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  | 
| 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  | 
| 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( | 
| 293 | 
            +
              return new std::string(Rice::String(x).str());
         | 
| 297 294 | 
             
            }
         | 
    
        data/ruby/lib/version.rb
    CHANGED
    
    
    
        data/sample/enum/test.rb
    CHANGED
    
    
    
        data/test/test_To_From_Ruby.cpp
    CHANGED
    
    | @@ -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 | 
            -
              -  | 
| 9 | 
            -
              version: 1.4. | 
| 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- | 
| 18 | 
            +
            date: 2010-12-27 00:00:00 -05:00
         | 
| 19 19 | 
             
            default_executable: 
         | 
| 20 | 
            -
            dependencies: 
         | 
| 21 | 
            -
             | 
| 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
         |