utilrb 2.1.0.rc3 → 3.0.0.rc1
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.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/Rakefile +1 -9
- data/lib/utilrb/common.rb +0 -45
- data/lib/utilrb/enumerable/uniq.rb +13 -15
- data/lib/utilrb/version.rb +1 -1
- data/manifest.xml +0 -2
- data/package.xml +1 -3
- data/utilrb.gemspec +1 -3
- metadata +2 -26
- data/Manifest.txt +0 -117
- data/ext/utilrb/extconf.rb +0 -22
- data/ext/utilrb/ruby_allocator.hh +0 -76
- data/ext/utilrb/utilrb.cc +0 -56
- data/ext/utilrb/value_set.cc +0 -431
- data/lib/utilrb/value_set.rb +0 -49
- data/patches/gc_live_objects.patch +0 -71
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 1177a0481f28609c9b83fce1ab8c6d59de177135
         | 
| 4 | 
            +
              data.tar.gz: 0cdd4d813b69adb757e7e802ebb5ad60f605cee0
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: f8ef0d60064a2b747bf83f861be83140dc6541c3e993368c4483c807212df4c5e68cbed356d52bcb56449d2ae0e63326334512a87b94fcd438cd7cae0c95ffda
         | 
| 7 | 
            +
              data.tar.gz: c9d4ec56d77051ffda15c56120ca7accdfbaca2bd2c969e14cdd13e645b1b24b7ee274379ec76059ac2709f4e0690b8f4e1a7686908983887394e3523a87285a
         | 
    
        data/.gitignore
    CHANGED
    
    
    
        data/Rakefile
    CHANGED
    
    | @@ -1,15 +1,7 @@ | |
| 1 1 | 
             
            require "bundler/gem_tasks"
         | 
| 2 2 | 
             
            require "rake/testtask"
         | 
| 3 3 |  | 
| 4 | 
            -
             | 
| 5 | 
            -
            Rake::ExtensionTask.new('utilrb') do |ext|
         | 
| 6 | 
            -
                ext.name = 'utilrb'
         | 
| 7 | 
            -
                ext.ext_dir = 'ext/utilrb'
         | 
| 8 | 
            -
                ext.lib_dir = 'lib/utilrb'
         | 
| 9 | 
            -
                ext.source_pattern ="*.{c,cc,cpp}"
         | 
| 10 | 
            -
            end
         | 
| 11 | 
            -
             | 
| 12 | 
            -
            task :default => :compile
         | 
| 4 | 
            +
            task :default
         | 
| 13 5 |  | 
| 14 6 | 
             
            Rake::TestTask.new(:test) do |t|
         | 
| 15 7 | 
             
              t.libs << "test"
         | 
    
        data/lib/utilrb/common.rb
    CHANGED
    
    | @@ -4,50 +4,5 @@ require 'utilrb/version' | |
| 4 4 | 
             
            # the standard class extensions used by www.rock-robotics.org projects.
         | 
| 5 5 | 
             
            module Utilrb
         | 
| 6 6 | 
             
                LIB_DIR = File.expand_path(File.dirname(__FILE__))
         | 
| 7 | 
            -
             | 
| 8 | 
            -
                unless defined? UTILRB_EXT_MODE
         | 
| 9 | 
            -
            	if ENV['UTILRB_EXT_MODE'] == 'no'
         | 
| 10 | 
            -
            	    UTILRB_EXT_MODE = nil
         | 
| 11 | 
            -
            	    STDERR.puts "Utilrb: not loading the C extension"
         | 
| 12 | 
            -
            	else
         | 
| 13 | 
            -
            	    begin
         | 
| 14 | 
            -
            		require 'utilrb/utilrb'
         | 
| 15 | 
            -
            		UTILRB_EXT_MODE = true
         | 
| 16 | 
            -
            		STDERR.puts "Utilrb: loaded C extension" if ENV['UTILRB_EXT_MODE']
         | 
| 17 | 
            -
            	    rescue LoadError => e
         | 
| 18 | 
            -
            		if ENV['UTILRB_EXT_MODE'] == 'yes'
         | 
| 19 | 
            -
            		    raise LoadError, "unable to load Util.rb C extension: #{e.message}"
         | 
| 20 | 
            -
            		else
         | 
| 21 | 
            -
            		    UTILRB_EXT_MODE = nil
         | 
| 22 | 
            -
            		end
         | 
| 23 | 
            -
            	    end
         | 
| 24 | 
            -
            	end
         | 
| 25 | 
            -
                end
         | 
| 26 | 
            -
             | 
| 27 | 
            -
                # Yields if the extension is not present
         | 
| 28 | 
            -
                # This is used by Utilrb libraries to provide a 
         | 
| 29 | 
            -
                # Ruby version if the C extension is not loaded
         | 
| 30 | 
            -
                def self.unless_ext # :yield:
         | 
| 31 | 
            -
            	unless UTILRB_EXT_MODE
         | 
| 32 | 
            -
            	    return yield if block_given?
         | 
| 33 | 
            -
            	end
         | 
| 34 | 
            -
                end
         | 
| 35 | 
            -
             | 
| 36 | 
            -
                # Yields if the extension is present. This is used for Ruby code
         | 
| 37 | 
            -
                # which depends on methods in the C extension
         | 
| 38 | 
            -
                def self.if_ext(&block)
         | 
| 39 | 
            -
            	require_ext(nil, &block)
         | 
| 40 | 
            -
                end
         | 
| 41 | 
            -
             | 
| 42 | 
            -
                # Yields if the extension is present, and 
         | 
| 43 | 
            -
                # issue a warning otherwise. This is used for Ruby
         | 
| 44 | 
            -
                # code which depends on methods in the C extension
         | 
| 45 | 
            -
                def self.require_ext(name)
         | 
| 46 | 
            -
            	if UTILRB_EXT_MODE
         | 
| 47 | 
            -
            	    yield if block_given?
         | 
| 48 | 
            -
            	elsif name
         | 
| 49 | 
            -
            	    STDERR.puts "Utilrb: not loading #{name} since the C extension is not available"
         | 
| 50 | 
            -
            	end
         | 
| 51 | 
            -
                end
         | 
| 52 7 | 
             
            end
         | 
| 53 8 |  | 
| @@ -48,21 +48,19 @@ class Object | |
| 48 48 | 
             
                end
         | 
| 49 49 | 
             
            end
         | 
| 50 50 |  | 
| 51 | 
            -
             | 
| 52 | 
            -
                 | 
| 53 | 
            -
             | 
| 54 | 
            -
             | 
| 55 | 
            -
             | 
| 56 | 
            -
             | 
| 57 | 
            -
             | 
| 58 | 
            -
             | 
| 59 | 
            -
             | 
| 60 | 
            -
             | 
| 61 | 
            -
             | 
| 62 | 
            -
             | 
| 63 | 
            -
             | 
| 64 | 
            -
            	    end
         | 
| 65 | 
            -
            	end
         | 
| 51 | 
            +
            module Enumerable
         | 
| 52 | 
            +
                # call-seq:
         | 
| 53 | 
            +
                #  each_uniq { |obj| ... }
         | 
| 54 | 
            +
                # 
         | 
| 55 | 
            +
                # Yields all unique values found in +enum+
         | 
| 56 | 
            +
                def each_uniq
         | 
| 57 | 
            +
                    seen = Set.new
         | 
| 58 | 
            +
                    each do |obj|
         | 
| 59 | 
            +
                        if !seen.include?(obj)
         | 
| 60 | 
            +
                            seen << obj
         | 
| 61 | 
            +
                            yield(obj)
         | 
| 62 | 
            +
                        end
         | 
| 63 | 
            +
                    end
         | 
| 66 64 | 
             
                end
         | 
| 67 65 | 
             
            end
         | 
| 68 66 |  | 
    
        data/lib/utilrb/version.rb
    CHANGED
    
    
    
        data/manifest.xml
    CHANGED
    
    
    
        data/package.xml
    CHANGED
    
    | @@ -12,13 +12,11 @@ | |
| 12 12 | 
             
              <run_depend>catkin</run_depend>
         | 
| 13 13 |  | 
| 14 14 | 
             
              <build_depend>ruby</build_depend>
         | 
| 15 | 
            +
              <build_depend>bundler</build_depend>
         | 
| 15 16 | 
             
              <build_depend>facets</build_depend>
         | 
| 16 | 
            -
              <build_depend>hoe</build_depend>
         | 
| 17 | 
            -
              <build_depend>rake-compiler</build_depend>
         | 
| 18 17 |  | 
| 19 18 | 
             
              <run_depend>ruby</run_depend>
         | 
| 20 19 | 
             
              <run_depend>facets</run_depend>
         | 
| 21 | 
            -
              <run_depend>hoe</run_depend>
         | 
| 22 20 |  | 
| 23 21 | 
             
              <export>
         | 
| 24 22 | 
             
                <build_type>
         | 
    
        data/utilrb.gemspec
    CHANGED
    
    | @@ -14,13 +14,11 @@ Gem::Specification.new do |s| | |
| 14 14 | 
             
                s.licenses = ["BSD"]
         | 
| 15 15 |  | 
| 16 16 | 
             
                s.require_paths = ["lib"]
         | 
| 17 | 
            -
                s. | 
| 18 | 
            -
                s.extra_rdoc_files = ["History.txt", "License.txt", "Manifest.txt", "History.txt"]
         | 
| 17 | 
            +
                s.extra_rdoc_files = ["License.txt"]
         | 
| 19 18 | 
             
                s.files         = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
         | 
| 20 19 |  | 
| 21 20 | 
             
                s.add_runtime_dependency "facets", ">= 2.4.0"
         | 
| 22 21 | 
             
                s.add_runtime_dependency "rake", ">= 0.9"
         | 
| 23 | 
            -
                s.add_runtime_dependency "rake-compiler", "~> 0.8.0"
         | 
| 24 22 | 
             
                s.add_development_dependency "flexmock", ">= 2.0.0"
         | 
| 25 23 | 
             
                s.add_development_dependency "minitest", ">= 5.0", "~> 5.0"
         | 
| 26 24 | 
             
                s.add_development_dependency "coveralls"
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: utilrb
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version:  | 
| 4 | 
            +
              version: 3.0.0.rc1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Sylvain Joyeux
         | 
| @@ -38,20 +38,6 @@ dependencies: | |
| 38 38 | 
             
                - - ">="
         | 
| 39 39 | 
             
                  - !ruby/object:Gem::Version
         | 
| 40 40 | 
             
                    version: '0.9'
         | 
| 41 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            -
              name: rake-compiler
         | 
| 43 | 
            -
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 | 
            -
                requirements:
         | 
| 45 | 
            -
                - - "~>"
         | 
| 46 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            -
                    version: 0.8.0
         | 
| 48 | 
            -
              type: :runtime
         | 
| 49 | 
            -
              prerelease: false
         | 
| 50 | 
            -
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 | 
            -
                requirements:
         | 
| 52 | 
            -
                - - "~>"
         | 
| 53 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            -
                    version: 0.8.0
         | 
| 55 41 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 56 42 | 
             
              name: flexmock
         | 
| 57 43 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -105,12 +91,9 @@ description: |- | |
| 105 91 | 
             
              the standard class extensions I use in other projects.
         | 
| 106 92 | 
             
            email: sylvain.joyeux@m4x.org
         | 
| 107 93 | 
             
            executables: []
         | 
| 108 | 
            -
            extensions:
         | 
| 109 | 
            -
            - ext/utilrb/extconf.rb
         | 
| 94 | 
            +
            extensions: []
         | 
| 110 95 | 
             
            extra_rdoc_files:
         | 
| 111 | 
            -
            - History.txt
         | 
| 112 96 | 
             
            - License.txt
         | 
| 113 | 
            -
            - Manifest.txt
         | 
| 114 97 | 
             
            files:
         | 
| 115 98 | 
             
            - ".boring"
         | 
| 116 99 | 
             
            - ".gemtest"
         | 
| @@ -121,16 +104,11 @@ files: | |
| 121 104 | 
             
            - History.txt
         | 
| 122 105 | 
             
            - License.txt
         | 
| 123 106 | 
             
            - Makefile
         | 
| 124 | 
            -
            - Manifest.txt
         | 
| 125 107 | 
             
            - README.md
         | 
| 126 108 | 
             
            - Rakefile
         | 
| 127 109 | 
             
            - benchmarks/validate_options.rb
         | 
| 128 110 | 
             
            - bm/allocation.rb
         | 
| 129 111 | 
             
            - bm/speed.rb
         | 
| 130 | 
            -
            - ext/utilrb/extconf.rb
         | 
| 131 | 
            -
            - ext/utilrb/ruby_allocator.hh
         | 
| 132 | 
            -
            - ext/utilrb/utilrb.cc
         | 
| 133 | 
            -
            - ext/utilrb/value_set.cc
         | 
| 134 112 | 
             
            - lib/utilrb.rb
         | 
| 135 113 | 
             
            - lib/utilrb/array.rb
         | 
| 136 114 | 
             
            - lib/utilrb/array/to_s.rb
         | 
| @@ -211,14 +189,12 @@ files: | |
| 211 189 | 
             
            - lib/utilrb/timepoints.rb
         | 
| 212 190 | 
             
            - lib/utilrb/unbound_method.rb
         | 
| 213 191 | 
             
            - lib/utilrb/unbound_method/call.rb
         | 
| 214 | 
            -
            - lib/utilrb/value_set.rb
         | 
| 215 192 | 
             
            - lib/utilrb/version.rb
         | 
| 216 193 | 
             
            - lib/utilrb/weakref.rb
         | 
| 217 194 | 
             
            - lib/utilrb/yard.rb
         | 
| 218 195 | 
             
            - lib/yard-utilrb.rb
         | 
| 219 196 | 
             
            - manifest.xml
         | 
| 220 197 | 
             
            - package.xml
         | 
| 221 | 
            -
            - patches/gc_live_objects.patch
         | 
| 222 198 | 
             
            - utilrb.gemspec
         | 
| 223 199 | 
             
            homepage: http://rock-robotics.org
         | 
| 224 200 | 
             
            licenses:
         | 
    
        data/Manifest.txt
    DELETED
    
    | @@ -1,117 +0,0 @@ | |
| 1 | 
            -
            .gemtest
         | 
| 2 | 
            -
            History.txt
         | 
| 3 | 
            -
            License.txt
         | 
| 4 | 
            -
            Manifest.txt
         | 
| 5 | 
            -
            README.rd
         | 
| 6 | 
            -
            Rakefile
         | 
| 7 | 
            -
            bm/allocation.rb
         | 
| 8 | 
            -
            bm/speed.rb
         | 
| 9 | 
            -
            ext/utilrb/extconf.rb
         | 
| 10 | 
            -
            ext/utilrb/proc.c
         | 
| 11 | 
            -
            ext/utilrb/ruby_allocator.hh
         | 
| 12 | 
            -
            ext/utilrb/utilrb.cc
         | 
| 13 | 
            -
            ext/utilrb/value_set.cc
         | 
| 14 | 
            -
            ext/utilrb/weakref.cc
         | 
| 15 | 
            -
            lib/utilrb.rb
         | 
| 16 | 
            -
            lib/utilrb/array.rb
         | 
| 17 | 
            -
            lib/utilrb/array/to_s.rb
         | 
| 18 | 
            -
            lib/utilrb/column_formatter.rb
         | 
| 19 | 
            -
            lib/utilrb/common.rb
         | 
| 20 | 
            -
            lib/utilrb/configsearch.rb
         | 
| 21 | 
            -
            lib/utilrb/configsearch/configuration_finder.rb
         | 
| 22 | 
            -
            lib/utilrb/dir.rb
         | 
| 23 | 
            -
            lib/utilrb/dir/empty.rb
         | 
| 24 | 
            -
            lib/utilrb/doc/rake.rb
         | 
| 25 | 
            -
            lib/utilrb/enumerable.rb
         | 
| 26 | 
            -
            lib/utilrb/enumerable/null.rb
         | 
| 27 | 
            -
            lib/utilrb/enumerable/random_element.rb
         | 
| 28 | 
            -
            lib/utilrb/enumerable/sequence.rb
         | 
| 29 | 
            -
            lib/utilrb/enumerable/to_s_helper.rb
         | 
| 30 | 
            -
            lib/utilrb/enumerable/uniq.rb
         | 
| 31 | 
            -
            lib/utilrb/event_loop.rb
         | 
| 32 | 
            -
            lib/utilrb/exception.rb
         | 
| 33 | 
            -
            lib/utilrb/exception/full_message.rb
         | 
| 34 | 
            -
            lib/utilrb/gc.rb
         | 
| 35 | 
            -
            lib/utilrb/gc/force.rb
         | 
| 36 | 
            -
            lib/utilrb/hash.rb
         | 
| 37 | 
            -
            lib/utilrb/hash/map_key.rb
         | 
| 38 | 
            -
            lib/utilrb/hash/map_value.rb
         | 
| 39 | 
            -
            lib/utilrb/hash/recursive_merge.rb
         | 
| 40 | 
            -
            lib/utilrb/hash/slice.rb
         | 
| 41 | 
            -
            lib/utilrb/hash/to_s.rb
         | 
| 42 | 
            -
            lib/utilrb/hash/to_sym_keys.rb
         | 
| 43 | 
            -
            lib/utilrb/kernel.rb
         | 
| 44 | 
            -
            lib/utilrb/kernel/arity.rb
         | 
| 45 | 
            -
            lib/utilrb/kernel/load_dsl_file.rb
         | 
| 46 | 
            -
            lib/utilrb/kernel/options.rb
         | 
| 47 | 
            -
            lib/utilrb/kernel/poll.rb
         | 
| 48 | 
            -
            lib/utilrb/kernel/require.rb
         | 
| 49 | 
            -
            lib/utilrb/kernel/with_module.rb
         | 
| 50 | 
            -
            lib/utilrb/logger.rb
         | 
| 51 | 
            -
            lib/utilrb/logger/forward.rb
         | 
| 52 | 
            -
            lib/utilrb/logger/hierarchy.rb
         | 
| 53 | 
            -
            lib/utilrb/logger/indent.rb
         | 
| 54 | 
            -
            lib/utilrb/logger/io.rb
         | 
| 55 | 
            -
            lib/utilrb/logger/log_pp.rb
         | 
| 56 | 
            -
            lib/utilrb/logger/root.rb
         | 
| 57 | 
            -
            lib/utilrb/logger/silent.rb
         | 
| 58 | 
            -
            lib/utilrb/marshal/load_with_missing_constants.rb
         | 
| 59 | 
            -
            lib/utilrb/module.rb
         | 
| 60 | 
            -
            lib/utilrb/module/ancestor_p.rb
         | 
| 61 | 
            -
            lib/utilrb/module/attr_enumerable.rb
         | 
| 62 | 
            -
            lib/utilrb/module/attr_predicate.rb
         | 
| 63 | 
            -
            lib/utilrb/module/cached_enum.rb
         | 
| 64 | 
            -
            lib/utilrb/module/const_defined_here_p.rb
         | 
| 65 | 
            -
            lib/utilrb/module/define_method.rb
         | 
| 66 | 
            -
            lib/utilrb/module/define_or_reuse.rb
         | 
| 67 | 
            -
            lib/utilrb/module/dsl_attribute.rb
         | 
| 68 | 
            -
            lib/utilrb/module/include.rb
         | 
| 69 | 
            -
            lib/utilrb/module/inherited_enumerable.rb
         | 
| 70 | 
            -
            lib/utilrb/object.rb
         | 
| 71 | 
            -
            lib/utilrb/object/address.rb
         | 
| 72 | 
            -
            lib/utilrb/object/attribute.rb
         | 
| 73 | 
            -
            lib/utilrb/object/scoped_eval.rb
         | 
| 74 | 
            -
            lib/utilrb/object/singleton_class.rb
         | 
| 75 | 
            -
            lib/utilrb/pathname.rb
         | 
| 76 | 
            -
            lib/utilrb/pathname/find_matching_parent.rb
         | 
| 77 | 
            -
            lib/utilrb/pkgconfig.rb
         | 
| 78 | 
            -
            lib/utilrb/qt/mime_data/mime_data.rb
         | 
| 79 | 
            -
            lib/utilrb/qt/variant/from_ruby.rb
         | 
| 80 | 
            -
            lib/utilrb/rake_common.rb
         | 
| 81 | 
            -
            lib/utilrb/set.rb
         | 
| 82 | 
            -
            lib/utilrb/set/to_s.rb
         | 
| 83 | 
            -
            lib/utilrb/socket/tcp_server.rb
         | 
| 84 | 
            -
            lib/utilrb/socket/tcp_socket.rb
         | 
| 85 | 
            -
            lib/utilrb/spawn.rb
         | 
| 86 | 
            -
            lib/utilrb/symbol/to_str.rb
         | 
| 87 | 
            -
            lib/utilrb/thread_pool.rb
         | 
| 88 | 
            -
            lib/utilrb/time.rb
         | 
| 89 | 
            -
            lib/utilrb/time/to_hms.rb
         | 
| 90 | 
            -
            lib/utilrb/timepoints.rb
         | 
| 91 | 
            -
            lib/utilrb/unbound_method.rb
         | 
| 92 | 
            -
            lib/utilrb/unbound_method/call.rb
         | 
| 93 | 
            -
            lib/utilrb/value_set.rb
         | 
| 94 | 
            -
            lib/utilrb/weakref.rb
         | 
| 95 | 
            -
            lib/utilrb/yard.rb
         | 
| 96 | 
            -
            patches/gc_live_objects.patch
         | 
| 97 | 
            -
            test/data/test_pkgconfig.pc
         | 
| 98 | 
            -
            test/data/test_pkgconfig_empty.pc
         | 
| 99 | 
            -
            test/test_array.rb
         | 
| 100 | 
            -
            test/test_dir.rb
         | 
| 101 | 
            -
            test/test_enumerable.rb
         | 
| 102 | 
            -
            test/test_event_loop.rb
         | 
| 103 | 
            -
            test/test_exception.rb
         | 
| 104 | 
            -
            test/test_gc.rb
         | 
| 105 | 
            -
            test/test_hash.rb
         | 
| 106 | 
            -
            test/test_kernel.rb
         | 
| 107 | 
            -
            test/test_logger.rb
         | 
| 108 | 
            -
            test/test_misc.rb
         | 
| 109 | 
            -
            test/test_module.rb
         | 
| 110 | 
            -
            test/test_object.rb
         | 
| 111 | 
            -
            test/test_pkgconfig.rb
         | 
| 112 | 
            -
            test/test_proc.rb
         | 
| 113 | 
            -
            test/test_set.rb
         | 
| 114 | 
            -
            test/test_thread_pool.rb
         | 
| 115 | 
            -
            test/test_time.rb
         | 
| 116 | 
            -
            test/test_unbound_method.rb
         | 
| 117 | 
            -
            test/test_weakref.rb
         | 
    
        data/ext/utilrb/extconf.rb
    DELETED
    
    | @@ -1,22 +0,0 @@ | |
| 1 | 
            -
            require 'mkmf'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            CONFIG['LDSHARED'].gsub! '$(CC)', "$(CXX)"
         | 
| 4 | 
            -
            if try_link("int main() { }", "-module")
         | 
| 5 | 
            -
                $LDFLAGS += " -module"
         | 
| 6 | 
            -
            end
         | 
| 7 | 
            -
             | 
| 8 | 
            -
            create_makefile("utilrb/utilrb")
         | 
| 9 | 
            -
             | 
| 10 | 
            -
            ## WORKAROUND a problem with mkmf.rb
         | 
| 11 | 
            -
            # It seems that the newest version do define an 'install' target. However, that
         | 
| 12 | 
            -
            # install target tries to install in the system directories
         | 
| 13 | 
            -
            #
         | 
| 14 | 
            -
            # The issue is that RubyGems *does* call make install. Ergo, gem install utilrb
         | 
| 15 | 
            -
            # is broken right now
         | 
| 16 | 
            -
            #lines = File.readlines("Makefile")
         | 
| 17 | 
            -
            #lines.delete_if { |l| l =~ /^install:/ }
         | 
| 18 | 
            -
            #lines << "install:"
         | 
| 19 | 
            -
            #File.open("Makefile", 'w') do |io|
         | 
| 20 | 
            -
            #      io.write lines.join("\n")
         | 
| 21 | 
            -
            #end
         | 
| 22 | 
            -
             | 
| @@ -1,76 +0,0 @@ | |
| 1 | 
            -
            #ifndef RUBY_ALLOCATOR_HH
         | 
| 2 | 
            -
            #define RUBY_ALLOCATOR_HH
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            #include <ruby.h>
         | 
| 5 | 
            -
             | 
| 6 | 
            -
            template <class T> class ruby_allocator
         | 
| 7 | 
            -
            {
         | 
| 8 | 
            -
            public:
         | 
| 9 | 
            -
              typedef T                 value_type;
         | 
| 10 | 
            -
              typedef value_type*       pointer;
         | 
| 11 | 
            -
              typedef const value_type* const_pointer;
         | 
| 12 | 
            -
              typedef value_type&       reference;
         | 
| 13 | 
            -
              typedef const value_type& const_reference;
         | 
| 14 | 
            -
              typedef std::size_t       size_type;
         | 
| 15 | 
            -
              typedef std::ptrdiff_t    difference_type;
         | 
| 16 | 
            -
              
         | 
| 17 | 
            -
              template <class U> 
         | 
| 18 | 
            -
              struct rebind { typedef ruby_allocator<U> other; };
         | 
| 19 | 
            -
             | 
| 20 | 
            -
              ruby_allocator() {}
         | 
| 21 | 
            -
              ruby_allocator(const ruby_allocator&) {}
         | 
| 22 | 
            -
              template <class U> 
         | 
| 23 | 
            -
              ruby_allocator(const ruby_allocator<U>&) {}
         | 
| 24 | 
            -
              ~ruby_allocator() {}
         | 
| 25 | 
            -
             | 
| 26 | 
            -
              pointer address(reference x) const { return &x; }
         | 
| 27 | 
            -
              const_pointer address(const_reference x) const { 
         | 
| 28 | 
            -
                return x;
         | 
| 29 | 
            -
              }
         | 
| 30 | 
            -
             | 
| 31 | 
            -
              pointer allocate(size_type n, const_pointer = 0) {
         | 
| 32 | 
            -
                void* p = ruby_xmalloc(n * sizeof(T));
         | 
| 33 | 
            -
                if (!p)
         | 
| 34 | 
            -
                  throw std::bad_alloc();
         | 
| 35 | 
            -
                return static_cast<pointer>(p);
         | 
| 36 | 
            -
              }
         | 
| 37 | 
            -
             | 
| 38 | 
            -
              void deallocate(pointer p, size_type) { ruby_xfree(p); }
         | 
| 39 | 
            -
             | 
| 40 | 
            -
              size_type max_size() const { 
         | 
| 41 | 
            -
                return static_cast<size_type>(-1) / sizeof(T);
         | 
| 42 | 
            -
              }
         | 
| 43 | 
            -
             | 
| 44 | 
            -
              void construct(pointer p, const value_type& x) { 
         | 
| 45 | 
            -
                new(p) value_type(x); 
         | 
| 46 | 
            -
              }
         | 
| 47 | 
            -
              void destroy(pointer p) { p->~value_type(); }
         | 
| 48 | 
            -
             | 
| 49 | 
            -
            private:
         | 
| 50 | 
            -
              void operator=(const ruby_allocator&);
         | 
| 51 | 
            -
            };
         | 
| 52 | 
            -
             | 
| 53 | 
            -
            template<> class ruby_allocator<void>
         | 
| 54 | 
            -
            {
         | 
| 55 | 
            -
              typedef void        value_type;
         | 
| 56 | 
            -
              typedef void*       pointer;
         | 
| 57 | 
            -
              typedef const void* const_pointer;
         | 
| 58 | 
            -
             | 
| 59 | 
            -
              template <class U> 
         | 
| 60 | 
            -
              struct rebind { typedef ruby_allocator<U> other; };
         | 
| 61 | 
            -
            };
         | 
| 62 | 
            -
             | 
| 63 | 
            -
             | 
| 64 | 
            -
            template <class T>
         | 
| 65 | 
            -
            inline bool operator==(const ruby_allocator<T>&, 
         | 
| 66 | 
            -
                                   const ruby_allocator<T>&) {
         | 
| 67 | 
            -
              return true;
         | 
| 68 | 
            -
            }
         | 
| 69 | 
            -
             | 
| 70 | 
            -
            template <class T>
         | 
| 71 | 
            -
            inline bool operator!=(const ruby_allocator<T>&, 
         | 
| 72 | 
            -
                                   const ruby_allocator<T>&) {
         | 
| 73 | 
            -
              return false;
         | 
| 74 | 
            -
            }
         | 
| 75 | 
            -
             | 
| 76 | 
            -
            #endif
         | 
    
        data/ext/utilrb/utilrb.cc
    DELETED
    
    | @@ -1,56 +0,0 @@ | |
| 1 | 
            -
            #include <ruby.h>
         | 
| 2 | 
            -
            #include <set>
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            static VALUE mUtilrb;
         | 
| 5 | 
            -
             | 
| 6 | 
            -
            using namespace std;
         | 
| 7 | 
            -
             | 
| 8 | 
            -
            #ifndef RUBINIUS
         | 
| 9 | 
            -
            static VALUE enumerable_each_uniq_i(VALUE i, VALUE* memo)
         | 
| 10 | 
            -
            { 
         | 
| 11 | 
            -
                set<VALUE>& seen = *reinterpret_cast< set<VALUE>* >(memo); 
         | 
| 12 | 
            -
                if (seen.find(i) == seen.end())
         | 
| 13 | 
            -
                {
         | 
| 14 | 
            -
            	seen.insert(i);
         | 
| 15 | 
            -
            	return rb_yield(i);
         | 
| 16 | 
            -
                }
         | 
| 17 | 
            -
                else
         | 
| 18 | 
            -
            	return Qnil;
         | 
| 19 | 
            -
             | 
| 20 | 
            -
            }
         | 
| 21 | 
            -
             | 
| 22 | 
            -
            /* :nodoc: */
         | 
| 23 | 
            -
            static VALUE enumerable_each_uniq(VALUE self)
         | 
| 24 | 
            -
            {
         | 
| 25 | 
            -
                set<VALUE> seen;
         | 
| 26 | 
            -
                rb_iterate(rb_each, self, 
         | 
| 27 | 
            -
            	    RUBY_METHOD_FUNC(enumerable_each_uniq_i), (VALUE)&seen);
         | 
| 28 | 
            -
                return self;
         | 
| 29 | 
            -
            }
         | 
| 30 | 
            -
             | 
| 31 | 
            -
            static VALUE kernel_is_immediate(VALUE klass, VALUE object)
         | 
| 32 | 
            -
            { return IMMEDIATE_P(object) ? Qtrue : Qfalse; }
         | 
| 33 | 
            -
            #endif
         | 
| 34 | 
            -
             | 
| 35 | 
            -
            static VALUE kernel_crash(VALUE klass)
         | 
| 36 | 
            -
            {
         | 
| 37 | 
            -
                *((int*)0) = 10;
         | 
| 38 | 
            -
                // Return something to shut gcc up
         | 
| 39 | 
            -
                return Qfalse;
         | 
| 40 | 
            -
            }
         | 
| 41 | 
            -
             | 
| 42 | 
            -
            extern "C" void Init_value_set();
         | 
| 43 | 
            -
             | 
| 44 | 
            -
            extern "C" void Init_utilrb()
         | 
| 45 | 
            -
            {
         | 
| 46 | 
            -
                mUtilrb = rb_define_module("Utilrb");
         | 
| 47 | 
            -
             | 
| 48 | 
            -
            #ifndef RUBINIUS
         | 
| 49 | 
            -
                rb_define_method(rb_mEnumerable, "each_uniq", RUBY_METHOD_FUNC(enumerable_each_uniq), 0);
         | 
| 50 | 
            -
                rb_define_singleton_method(rb_mKernel, "crash!", RUBY_METHOD_FUNC(kernel_crash), 0);
         | 
| 51 | 
            -
                rb_define_singleton_method(rb_mKernel, "immediate?", RUBY_METHOD_FUNC(kernel_is_immediate), 1);
         | 
| 52 | 
            -
            #endif
         | 
| 53 | 
            -
             | 
| 54 | 
            -
                Init_value_set();
         | 
| 55 | 
            -
            }
         | 
| 56 | 
            -
             | 
    
        data/ext/utilrb/value_set.cc
    DELETED
    
    | @@ -1,431 +0,0 @@ | |
| 1 | 
            -
            #include <ruby.h>
         | 
| 2 | 
            -
            #include <set>
         | 
| 3 | 
            -
            #include <algorithm>
         | 
| 4 | 
            -
            #include "ruby_allocator.hh"
         | 
| 5 | 
            -
             | 
| 6 | 
            -
            using namespace std;
         | 
| 7 | 
            -
             | 
| 8 | 
            -
            static VALUE cValueSet;
         | 
| 9 | 
            -
            static ID id_new;
         | 
| 10 | 
            -
             | 
| 11 | 
            -
            typedef std::set<VALUE, std::less<VALUE>, ruby_allocator<VALUE> > ValueSet;
         | 
| 12 | 
            -
            static ValueSet& get_wrapped_set(VALUE self)
         | 
| 13 | 
            -
            {
         | 
| 14 | 
            -
                ValueSet* object = 0;
         | 
| 15 | 
            -
                Data_Get_Struct(self, ValueSet, object);
         | 
| 16 | 
            -
                return *object;
         | 
| 17 | 
            -
            }
         | 
| 18 | 
            -
             | 
| 19 | 
            -
            static void value_set_mark(ValueSet const* set) { std::for_each(set->begin(), set->end(), rb_gc_mark); }
         | 
| 20 | 
            -
            static void value_set_free(ValueSet const* set) { delete set; }
         | 
| 21 | 
            -
            static VALUE value_set_alloc(VALUE klass)
         | 
| 22 | 
            -
            {
         | 
| 23 | 
            -
                ValueSet* cxx_set = new ValueSet;
         | 
| 24 | 
            -
                return Data_Wrap_Struct(klass, value_set_mark, value_set_free, cxx_set);
         | 
| 25 | 
            -
            }
         | 
| 26 | 
            -
            /* call-seq:
         | 
| 27 | 
            -
             *  set.empty?			    => true or false
         | 
| 28 | 
            -
             *
         | 
| 29 | 
            -
             * Checks if this set is empty
         | 
| 30 | 
            -
             */
         | 
| 31 | 
            -
            static VALUE value_set_empty_p(VALUE self)
         | 
| 32 | 
            -
            { 
         | 
| 33 | 
            -
                ValueSet& set = get_wrapped_set(self);
         | 
| 34 | 
            -
                return set.empty() ? Qtrue : Qfalse;
         | 
| 35 | 
            -
            }
         | 
| 36 | 
            -
             | 
| 37 | 
            -
            /* call-seq:
         | 
| 38 | 
            -
             *  set.size			    => size
         | 
| 39 | 
            -
             *
         | 
| 40 | 
            -
             * Returns this set size
         | 
| 41 | 
            -
             */
         | 
| 42 | 
            -
            static VALUE value_set_size(VALUE self)
         | 
| 43 | 
            -
            { 
         | 
| 44 | 
            -
                ValueSet& set = get_wrapped_set(self);
         | 
| 45 | 
            -
                return INT2NUM(set.size());
         | 
| 46 | 
            -
            }
         | 
| 47 | 
            -
             | 
| 48 | 
            -
             | 
| 49 | 
            -
            /* call-seq:
         | 
| 50 | 
            -
             *  set.each { |obj| ... }	    => set
         | 
| 51 | 
            -
             *
         | 
| 52 | 
            -
             */
         | 
| 53 | 
            -
            static VALUE value_set_each(VALUE self)
         | 
| 54 | 
            -
            {
         | 
| 55 | 
            -
                ValueSet& set = get_wrapped_set(self);
         | 
| 56 | 
            -
                for (ValueSet::iterator it = set.begin(); it != set.end();)
         | 
| 57 | 
            -
                {
         | 
| 58 | 
            -
            	// Increment before calling yield() so that 
         | 
| 59 | 
            -
            	// the current element can be deleted safely
         | 
| 60 | 
            -
            	ValueSet::iterator this_it = it++;
         | 
| 61 | 
            -
            	rb_yield(*this_it);
         | 
| 62 | 
            -
                }
         | 
| 63 | 
            -
                return self;
         | 
| 64 | 
            -
            }
         | 
| 65 | 
            -
             | 
| 66 | 
            -
            /* call-seq:
         | 
| 67 | 
            -
             *  set.delete_if { |obj| ... }		=> set
         | 
| 68 | 
            -
             *
         | 
| 69 | 
            -
             * Deletes all objects for which the block returns true
         | 
| 70 | 
            -
             */
         | 
| 71 | 
            -
            static VALUE value_set_delete_if(VALUE self)
         | 
| 72 | 
            -
            {
         | 
| 73 | 
            -
                ValueSet& set = get_wrapped_set(self);
         | 
| 74 | 
            -
                for (ValueSet::iterator it = set.begin(); it != set.end();)
         | 
| 75 | 
            -
                {
         | 
| 76 | 
            -
            	// Increment before calling yield() so that 
         | 
| 77 | 
            -
            	// the current element can be deleted safely
         | 
| 78 | 
            -
            	ValueSet::iterator this_it = it++;
         | 
| 79 | 
            -
            	bool do_delete = RTEST(rb_yield(*this_it));
         | 
| 80 | 
            -
            	if (do_delete)
         | 
| 81 | 
            -
            	    set.erase(this_it);
         | 
| 82 | 
            -
                }
         | 
| 83 | 
            -
                return self;
         | 
| 84 | 
            -
            }
         | 
| 85 | 
            -
             | 
| 86 | 
            -
            /* call-seq:
         | 
| 87 | 
            -
             *  set.include?(value)	    => true or false
         | 
| 88 | 
            -
             *
         | 
| 89 | 
            -
             * Checks if +value+ is in +set+
         | 
| 90 | 
            -
             */
         | 
| 91 | 
            -
            static VALUE value_set_include_p(VALUE vself, VALUE vother)
         | 
| 92 | 
            -
            {
         | 
| 93 | 
            -
                ValueSet const& self  = get_wrapped_set(vself);
         | 
| 94 | 
            -
                return self.find(vother) == self.end() ? Qfalse : Qtrue;
         | 
| 95 | 
            -
            }
         | 
| 96 | 
            -
             | 
| 97 | 
            -
            /* call-seq:
         | 
| 98 | 
            -
             *  set.to_value_set		    => set
         | 
| 99 | 
            -
             */
         | 
| 100 | 
            -
            static VALUE value_set_to_value_set(VALUE self) { return self; }
         | 
| 101 | 
            -
             | 
| 102 | 
            -
            /* call-seq:
         | 
| 103 | 
            -
             *  set.dup => other_set
         | 
| 104 | 
            -
             *
         | 
| 105 | 
            -
             * Duplicates this set, without duplicating the pointed-to objects
         | 
| 106 | 
            -
             */
         | 
| 107 | 
            -
            static VALUE value_set_dup(VALUE vself, VALUE vother)
         | 
| 108 | 
            -
            {
         | 
| 109 | 
            -
                ValueSet const& self  = get_wrapped_set(vself);
         | 
| 110 | 
            -
                VALUE vresult = rb_funcall2(cValueSet, id_new, 0, NULL);
         | 
| 111 | 
            -
                ValueSet& result = get_wrapped_set(vresult);
         | 
| 112 | 
            -
                for (ValueSet::const_iterator it = self.begin(); it != self.end(); ++it)
         | 
| 113 | 
            -
            	result.insert(result.end(), *it);
         | 
| 114 | 
            -
             | 
| 115 | 
            -
                return vresult;
         | 
| 116 | 
            -
            }
         | 
| 117 | 
            -
             | 
| 118 | 
            -
            /* call-seq:
         | 
| 119 | 
            -
             *  set.include_all?(other)		=> true or false
         | 
| 120 | 
            -
             *
         | 
| 121 | 
            -
             * Checks if all elements of +other+ are in +set+
         | 
| 122 | 
            -
             */
         | 
| 123 | 
            -
            static VALUE value_set_include_all_p(VALUE vself, VALUE vother)
         | 
| 124 | 
            -
            {
         | 
| 125 | 
            -
                ValueSet const& self  = get_wrapped_set(vself);
         | 
| 126 | 
            -
                if (!RTEST(rb_obj_is_kind_of(vother, cValueSet)))
         | 
| 127 | 
            -
            	rb_raise(rb_eArgError, "expected a ValueSet");
         | 
| 128 | 
            -
                ValueSet const& other = get_wrapped_set(vother);
         | 
| 129 | 
            -
                return std::includes(self.begin(), self.end(), other.begin(), other.end()) ? Qtrue : Qfalse;
         | 
| 130 | 
            -
            }
         | 
| 131 | 
            -
             | 
| 132 | 
            -
            /* call-seq:
         | 
| 133 | 
            -
             *  set.union(other)		=> union_set
         | 
| 134 | 
            -
             *  set | other			=> union_set
         | 
| 135 | 
            -
             *
         | 
| 136 | 
            -
             * Computes the union of +set+ and +other+. This operation is O(N + M)
         | 
| 137 | 
            -
             * is +other+ is a ValueSet
         | 
| 138 | 
            -
             */
         | 
| 139 | 
            -
            static VALUE value_set_union(VALUE vself, VALUE vother)
         | 
| 140 | 
            -
            {
         | 
| 141 | 
            -
                ValueSet const& self  = get_wrapped_set(vself);
         | 
| 142 | 
            -
                if (!RTEST(rb_obj_is_kind_of(vother, cValueSet)))
         | 
| 143 | 
            -
            	rb_raise(rb_eArgError, "expected a ValueSet");
         | 
| 144 | 
            -
                ValueSet const& other = get_wrapped_set(vother);
         | 
| 145 | 
            -
                
         | 
| 146 | 
            -
                VALUE vresult = rb_funcall2(cValueSet, id_new, 0, NULL);
         | 
| 147 | 
            -
                ValueSet& result = get_wrapped_set(vresult);
         | 
| 148 | 
            -
                std::set_union(self.begin(), self.end(), other.begin(), other.end(), 
         | 
| 149 | 
            -
            	    std::inserter(result, result.end()));
         | 
| 150 | 
            -
                return vresult;
         | 
| 151 | 
            -
            }
         | 
| 152 | 
            -
             | 
| 153 | 
            -
            /* call-seq:
         | 
| 154 | 
            -
             *  set.merge(other)		=> set
         | 
| 155 | 
            -
             *
         | 
| 156 | 
            -
             * Merges the elements of +other+ into +self+. If +other+ is a ValueSet, the operation is O(N + M)
         | 
| 157 | 
            -
             */
         | 
| 158 | 
            -
            static VALUE value_set_merge(VALUE vself, VALUE vother)
         | 
| 159 | 
            -
            {
         | 
| 160 | 
            -
                ValueSet& self  = get_wrapped_set(vself);
         | 
| 161 | 
            -
                if (!RTEST(rb_obj_is_kind_of(vother, cValueSet)))
         | 
| 162 | 
            -
            	rb_raise(rb_eArgError, "expected a ValueSet");
         | 
| 163 | 
            -
                ValueSet const& other = get_wrapped_set(vother);
         | 
| 164 | 
            -
                
         | 
| 165 | 
            -
                self.insert(other.begin(), other.end());
         | 
| 166 | 
            -
                return vself;
         | 
| 167 | 
            -
            }
         | 
| 168 | 
            -
             | 
| 169 | 
            -
            /* call-seq:
         | 
| 170 | 
            -
             *   set.intersection!(other)	=> set
         | 
| 171 | 
            -
             *
         | 
| 172 | 
            -
             * Computes the intersection of +set+ and +other+, and modifies +self+ to be
         | 
| 173 | 
            -
             * that interesection. This operation is O(N + M) if +other+ is a ValueSet
         | 
| 174 | 
            -
             */
         | 
| 175 | 
            -
            static VALUE value_set_intersection_bang(VALUE vself, VALUE vother)
         | 
| 176 | 
            -
            {
         | 
| 177 | 
            -
                ValueSet& self  = get_wrapped_set(vself);
         | 
| 178 | 
            -
                if (!RTEST(rb_obj_is_kind_of(vother, cValueSet)))
         | 
| 179 | 
            -
            	rb_raise(rb_eArgError, "expected a ValueSet");
         | 
| 180 | 
            -
                ValueSet const& other = get_wrapped_set(vother);
         | 
| 181 | 
            -
                
         | 
| 182 | 
            -
                ValueSet result;
         | 
| 183 | 
            -
                std::set_intersection(self.begin(), self.end(), other.begin(), other.end(), 
         | 
| 184 | 
            -
            	    std::inserter(result, result.end()));
         | 
| 185 | 
            -
                self.swap(result);
         | 
| 186 | 
            -
                return vself;
         | 
| 187 | 
            -
            }
         | 
| 188 | 
            -
             | 
| 189 | 
            -
            /* call-seq:
         | 
| 190 | 
            -
             *   set.intersection(other)	=> intersection_set
         | 
| 191 | 
            -
             *   set & other		=> intersection_set
         | 
| 192 | 
            -
             *
         | 
| 193 | 
            -
             * Computes the intersection of +set+ and +other+. This operation
         | 
| 194 | 
            -
             * is O(N + M) if +other+ is a ValueSet
         | 
| 195 | 
            -
             */
         | 
| 196 | 
            -
            static VALUE value_set_intersection(VALUE vself, VALUE vother)
         | 
| 197 | 
            -
            {
         | 
| 198 | 
            -
                ValueSet const& self  = get_wrapped_set(vself);
         | 
| 199 | 
            -
                if (!RTEST(rb_obj_is_kind_of(vother, cValueSet)))
         | 
| 200 | 
            -
            	rb_raise(rb_eArgError, "expected a ValueSet");
         | 
| 201 | 
            -
                ValueSet const& other = get_wrapped_set(vother);
         | 
| 202 | 
            -
                
         | 
| 203 | 
            -
                VALUE vresult = rb_funcall2(cValueSet, id_new, 0, NULL);
         | 
| 204 | 
            -
                ValueSet& result = get_wrapped_set(vresult);
         | 
| 205 | 
            -
                std::set_intersection(self.begin(), self.end(), other.begin(), other.end(), 
         | 
| 206 | 
            -
            	    std::inserter(result, result.end()));
         | 
| 207 | 
            -
                return vresult;
         | 
| 208 | 
            -
            }
         | 
| 209 | 
            -
             | 
| 210 | 
            -
            /* call-seq:
         | 
| 211 | 
            -
             *  set.intersects?(other)	=> true or false
         | 
| 212 | 
            -
             *
         | 
| 213 | 
            -
             * Returns true if there is elements in +set+ that are also in +other
         | 
| 214 | 
            -
             */
         | 
| 215 | 
            -
            static VALUE value_set_intersects(VALUE vself, VALUE vother)
         | 
| 216 | 
            -
            {
         | 
| 217 | 
            -
                ValueSet const& self  = get_wrapped_set(vself);
         | 
| 218 | 
            -
                if (!RTEST(rb_obj_is_kind_of(vother, cValueSet)))
         | 
| 219 | 
            -
            	rb_raise(rb_eArgError, "expected a ValueSet");
         | 
| 220 | 
            -
                ValueSet const& other = get_wrapped_set(vother);
         | 
| 221 | 
            -
             | 
| 222 | 
            -
                ValueSet::const_iterator 
         | 
| 223 | 
            -
            	self_it   = self.begin(),
         | 
| 224 | 
            -
            	self_end  = self.end(),
         | 
| 225 | 
            -
            	other_it  = other.begin(),
         | 
| 226 | 
            -
            	other_end = other.end();
         | 
| 227 | 
            -
             | 
| 228 | 
            -
                while(self_it != self_end && other_it != other_end)
         | 
| 229 | 
            -
                {
         | 
| 230 | 
            -
            	if (*self_it < *other_it)
         | 
| 231 | 
            -
            	    ++self_it;
         | 
| 232 | 
            -
            	else if (*other_it < *self_it)
         | 
| 233 | 
            -
            	    ++other_it;
         | 
| 234 | 
            -
            	else
         | 
| 235 | 
            -
            	    return Qtrue;
         | 
| 236 | 
            -
                }
         | 
| 237 | 
            -
                return Qfalse;
         | 
| 238 | 
            -
            }
         | 
| 239 | 
            -
             | 
| 240 | 
            -
            /* call-seq:
         | 
| 241 | 
            -
             *   set.difference!(other)	=> set
         | 
| 242 | 
            -
             *
         | 
| 243 | 
            -
             * Modifies +set+ so that it is the set of all elements of +set+ not in +other+.
         | 
| 244 | 
            -
             * This operation is O(N + M).
         | 
| 245 | 
            -
             */
         | 
| 246 | 
            -
            static VALUE value_set_difference_bang(VALUE vself, VALUE vother)
         | 
| 247 | 
            -
            {
         | 
| 248 | 
            -
                ValueSet& self  = get_wrapped_set(vself);
         | 
| 249 | 
            -
                if (!RTEST(rb_obj_is_kind_of(vother, cValueSet)))
         | 
| 250 | 
            -
            	rb_raise(rb_eArgError, "expected a ValueSet");
         | 
| 251 | 
            -
                ValueSet const& other = get_wrapped_set(vother);
         | 
| 252 | 
            -
                
         | 
| 253 | 
            -
                ValueSet result;
         | 
| 254 | 
            -
                std::set_difference(self.begin(), self.end(), other.begin(), other.end(), 
         | 
| 255 | 
            -
            	    std::inserter(result, result.end()));
         | 
| 256 | 
            -
                if (result.size() != self.size())
         | 
| 257 | 
            -
                    self.swap(result);
         | 
| 258 | 
            -
                return vself;
         | 
| 259 | 
            -
            }
         | 
| 260 | 
            -
             | 
| 261 | 
            -
            /* call-seq:
         | 
| 262 | 
            -
             *   set.difference(other)	=> difference_set
         | 
| 263 | 
            -
             *   set - other		=> difference_set
         | 
| 264 | 
            -
             *
         | 
| 265 | 
            -
             * Computes the set of all elements of +set+ not in +other+. This operation
         | 
| 266 | 
            -
             * is O(N + M).
         | 
| 267 | 
            -
             */
         | 
| 268 | 
            -
            static VALUE value_set_difference(VALUE vself, VALUE vother)
         | 
| 269 | 
            -
            {
         | 
| 270 | 
            -
                ValueSet const& self  = get_wrapped_set(vself);
         | 
| 271 | 
            -
                if (!RTEST(rb_obj_is_kind_of(vother, cValueSet)))
         | 
| 272 | 
            -
            	rb_raise(rb_eArgError, "expected a ValueSet");
         | 
| 273 | 
            -
                ValueSet const& other = get_wrapped_set(vother);
         | 
| 274 | 
            -
                
         | 
| 275 | 
            -
                VALUE vresult = rb_funcall2(cValueSet, id_new, 0, NULL);
         | 
| 276 | 
            -
                ValueSet& result = get_wrapped_set(vresult);
         | 
| 277 | 
            -
                std::set_difference(self.begin(), self.end(), other.begin(), other.end(), 
         | 
| 278 | 
            -
            	    std::inserter(result, result.end()));
         | 
| 279 | 
            -
                return vresult;
         | 
| 280 | 
            -
            }
         | 
| 281 | 
            -
             | 
| 282 | 
            -
            /* call-seq:
         | 
| 283 | 
            -
             *  set.insert(value)		=> true or false
         | 
| 284 | 
            -
             * 
         | 
| 285 | 
            -
             * Inserts +value+ into +set+. Returns true if the value did not exist
         | 
| 286 | 
            -
             * in the set yet (it has actually been inserted), and false otherwise.
         | 
| 287 | 
            -
             * This operation is O(log N)
         | 
| 288 | 
            -
             */
         | 
| 289 | 
            -
            static VALUE value_set_insert(VALUE vself, VALUE v)
         | 
| 290 | 
            -
            {
         | 
| 291 | 
            -
                ValueSet& self  = get_wrapped_set(vself);
         | 
| 292 | 
            -
                bool exists = self.insert(v).second;
         | 
| 293 | 
            -
                return exists ? Qtrue : Qfalse;
         | 
| 294 | 
            -
            }
         | 
| 295 | 
            -
            /* call-seq:
         | 
| 296 | 
            -
             *  set.delete(value)		=> true or false
         | 
| 297 | 
            -
             * 
         | 
| 298 | 
            -
             * Removes +value+ from +set+. Returns true if the value did exist
         | 
| 299 | 
            -
             * in the set yet (it has actually been removed), and false otherwise.
         | 
| 300 | 
            -
             */
         | 
| 301 | 
            -
            static VALUE value_set_delete(VALUE vself, VALUE v)
         | 
| 302 | 
            -
            {
         | 
| 303 | 
            -
                ValueSet& self  = get_wrapped_set(vself);
         | 
| 304 | 
            -
                size_t count = self.erase(v);
         | 
| 305 | 
            -
                return count > 0 ? Qtrue : Qfalse;
         | 
| 306 | 
            -
            }
         | 
| 307 | 
            -
             | 
| 308 | 
            -
            /* call-seq:
         | 
| 309 | 
            -
             *  set == other		=> true or false
         | 
| 310 | 
            -
             *
         | 
| 311 | 
            -
             * Equality
         | 
| 312 | 
            -
             */
         | 
| 313 | 
            -
            static VALUE value_set_equal(VALUE vself, VALUE vother)
         | 
| 314 | 
            -
            {
         | 
| 315 | 
            -
                ValueSet const& self  = get_wrapped_set(vself);
         | 
| 316 | 
            -
                if (!RTEST(rb_obj_is_kind_of(vother, cValueSet)))
         | 
| 317 | 
            -
            	return Qfalse;
         | 
| 318 | 
            -
                ValueSet const& other = get_wrapped_set(vother);
         | 
| 319 | 
            -
                return (self == other) ? Qtrue : Qfalse;
         | 
| 320 | 
            -
            }
         | 
| 321 | 
            -
             | 
| 322 | 
            -
            /* call-seq:
         | 
| 323 | 
            -
             *  set.clear			=> set
         | 
| 324 | 
            -
             *
         | 
| 325 | 
            -
             * Remove all elements of this set
         | 
| 326 | 
            -
             */
         | 
| 327 | 
            -
            static VALUE value_set_clear(VALUE self)
         | 
| 328 | 
            -
            {
         | 
| 329 | 
            -
                get_wrapped_set(self).clear();
         | 
| 330 | 
            -
                return self;
         | 
| 331 | 
            -
            }
         | 
| 332 | 
            -
             | 
| 333 | 
            -
            /* call-seq:
         | 
| 334 | 
            -
             *  set.initialize_copy(other)  => set
         | 
| 335 | 
            -
             *
         | 
| 336 | 
            -
             * Initializes +set+ with the values in +other+. Needed by #dup
         | 
| 337 | 
            -
             */
         | 
| 338 | 
            -
            static VALUE value_set_initialize_copy(VALUE vself, VALUE vother)
         | 
| 339 | 
            -
            {
         | 
| 340 | 
            -
                get_wrapped_set(vself) = get_wrapped_set(vother);
         | 
| 341 | 
            -
                return vself;
         | 
| 342 | 
            -
            }
         | 
| 343 | 
            -
             | 
| 344 | 
            -
             | 
| 345 | 
            -
             | 
| 346 | 
            -
             | 
| 347 | 
            -
             | 
| 348 | 
            -
             | 
| 349 | 
            -
             | 
| 350 | 
            -
            /* call-seq:
         | 
| 351 | 
            -
             *  to_value_set    => value_set
         | 
| 352 | 
            -
             *
         | 
| 353 | 
            -
             * Converts this array into a ValueSet object
         | 
| 354 | 
            -
             */
         | 
| 355 | 
            -
            static VALUE array_to_value_set(VALUE self)
         | 
| 356 | 
            -
            {
         | 
| 357 | 
            -
                VALUE vresult = rb_funcall2(cValueSet, id_new, 0, NULL);
         | 
| 358 | 
            -
                ValueSet& result = get_wrapped_set(vresult);
         | 
| 359 | 
            -
             | 
| 360 | 
            -
                long size  = RARRAY_LEN(self);
         | 
| 361 | 
            -
                for (int i = 0; i < size; ++i)
         | 
| 362 | 
            -
            	result.insert(rb_ary_entry(self, i));
         | 
| 363 | 
            -
             | 
| 364 | 
            -
                return vresult;
         | 
| 365 | 
            -
            }
         | 
| 366 | 
            -
             | 
| 367 | 
            -
            #ifndef RUBINIUS
         | 
| 368 | 
            -
            static VALUE enumerable_to_value_set_i(VALUE i, VALUE* memo)
         | 
| 369 | 
            -
            {
         | 
| 370 | 
            -
                ValueSet& result = *reinterpret_cast<ValueSet*>(memo);
         | 
| 371 | 
            -
                result.insert(i);
         | 
| 372 | 
            -
                return Qnil;
         | 
| 373 | 
            -
            }
         | 
| 374 | 
            -
             | 
| 375 | 
            -
            /* call-seq:
         | 
| 376 | 
            -
             *  enum.to_value_set		=> value_set
         | 
| 377 | 
            -
             *
         | 
| 378 | 
            -
             * Builds a ValueSet object from this enumerable
         | 
| 379 | 
            -
             */
         | 
| 380 | 
            -
            static VALUE enumerable_to_value_set(VALUE self)
         | 
| 381 | 
            -
            {
         | 
| 382 | 
            -
                VALUE vresult = rb_funcall2(cValueSet, id_new, 0, NULL);
         | 
| 383 | 
            -
                ValueSet& result = get_wrapped_set(vresult);
         | 
| 384 | 
            -
             | 
| 385 | 
            -
                rb_iterate(rb_each, self, RUBY_METHOD_FUNC(enumerable_to_value_set_i), reinterpret_cast<VALUE>(&result));
         | 
| 386 | 
            -
                return vresult;
         | 
| 387 | 
            -
            }
         | 
| 388 | 
            -
            #endif
         | 
| 389 | 
            -
             | 
| 390 | 
            -
            /*
         | 
| 391 | 
            -
             * Document-class: ValueSet
         | 
| 392 | 
            -
             *
         | 
| 393 | 
            -
             * ValueSet is a wrapper around the C++ set<> template. set<> is an ordered container,
         | 
| 394 | 
            -
             * for which union(), intersection() and difference() is done in linear time. For performance
         | 
| 395 | 
            -
             * reasons, in the case of ValueSet, the values are ordered by their VALUE, which roughly is
         | 
| 396 | 
            -
             * their object_id.
         | 
| 397 | 
            -
             */
         | 
| 398 | 
            -
             | 
| 399 | 
            -
            extern "C" void Init_value_set()
         | 
| 400 | 
            -
            {
         | 
| 401 | 
            -
            #ifndef RUBINIUS
         | 
| 402 | 
            -
                rb_define_method(rb_mEnumerable, "to_value_set", RUBY_METHOD_FUNC(enumerable_to_value_set), 0);
         | 
| 403 | 
            -
            #endif
         | 
| 404 | 
            -
                rb_define_method(rb_cArray, "to_value_set", RUBY_METHOD_FUNC(array_to_value_set), 0);
         | 
| 405 | 
            -
             | 
| 406 | 
            -
                cValueSet = rb_define_class("ValueSet", rb_cObject);
         | 
| 407 | 
            -
                id_new = rb_intern("new");
         | 
| 408 | 
            -
                rb_define_alloc_func(cValueSet, value_set_alloc);
         | 
| 409 | 
            -
                rb_define_method(cValueSet, "each", RUBY_METHOD_FUNC(value_set_each), 0);
         | 
| 410 | 
            -
                rb_define_method(cValueSet, "include?", RUBY_METHOD_FUNC(value_set_include_p), 1);
         | 
| 411 | 
            -
                rb_define_method(cValueSet, "include_all?", RUBY_METHOD_FUNC(value_set_include_all_p), 1);
         | 
| 412 | 
            -
                rb_define_method(cValueSet, "union", RUBY_METHOD_FUNC(value_set_union), 1);
         | 
| 413 | 
            -
                rb_define_method(cValueSet, "intersection", RUBY_METHOD_FUNC(value_set_intersection), 1);
         | 
| 414 | 
            -
                rb_define_method(cValueSet, "intersection!", RUBY_METHOD_FUNC(value_set_intersection_bang), 1);
         | 
| 415 | 
            -
                rb_define_method(cValueSet, "intersects?", RUBY_METHOD_FUNC(value_set_intersects), 1);
         | 
| 416 | 
            -
                rb_define_method(cValueSet, "difference", RUBY_METHOD_FUNC(value_set_difference), 1);
         | 
| 417 | 
            -
                rb_define_method(cValueSet, "difference!", RUBY_METHOD_FUNC(value_set_difference_bang), 1);
         | 
| 418 | 
            -
                rb_define_method(cValueSet, "insert", RUBY_METHOD_FUNC(value_set_insert), 1);
         | 
| 419 | 
            -
                rb_define_method(cValueSet, "merge", RUBY_METHOD_FUNC(value_set_merge), 1);
         | 
| 420 | 
            -
                rb_define_method(cValueSet, "delete", RUBY_METHOD_FUNC(value_set_delete), 1);
         | 
| 421 | 
            -
                rb_define_method(cValueSet, "==", RUBY_METHOD_FUNC(value_set_equal), 1);
         | 
| 422 | 
            -
                rb_define_method(cValueSet, "to_value_set", RUBY_METHOD_FUNC(value_set_to_value_set), 0);
         | 
| 423 | 
            -
                rb_define_method(cValueSet, "dup", RUBY_METHOD_FUNC(value_set_dup), 0);
         | 
| 424 | 
            -
                rb_define_method(cValueSet, "empty?", RUBY_METHOD_FUNC(value_set_empty_p), 0);
         | 
| 425 | 
            -
                rb_define_method(cValueSet, "size", RUBY_METHOD_FUNC(value_set_size), 0);
         | 
| 426 | 
            -
                rb_define_method(cValueSet, "clear", RUBY_METHOD_FUNC(value_set_clear), 0);
         | 
| 427 | 
            -
                rb_define_method(cValueSet, "initialize_copy", RUBY_METHOD_FUNC(value_set_initialize_copy), 1);
         | 
| 428 | 
            -
                rb_define_method(cValueSet, "delete_if", RUBY_METHOD_FUNC(value_set_delete_if), 0);
         | 
| 429 | 
            -
            }
         | 
| 430 | 
            -
             | 
| 431 | 
            -
             | 
    
        data/lib/utilrb/value_set.rb
    DELETED
    
    | @@ -1,49 +0,0 @@ | |
| 1 | 
            -
            require 'utilrb/common'
         | 
| 2 | 
            -
            require 'utilrb/enumerable/to_s_helper'
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            Utilrb.require_ext("ValueSet") do
         | 
| 5 | 
            -
                class ValueSet
         | 
| 6 | 
            -
            	def <<(obj); insert(obj) ; self end
         | 
| 7 | 
            -
            	alias :| :union
         | 
| 8 | 
            -
            	alias :& :intersection
         | 
| 9 | 
            -
            	alias :- :difference
         | 
| 10 | 
            -
            	include Enumerable
         | 
| 11 | 
            -
             | 
| 12 | 
            -
                    def substract(other_set)
         | 
| 13 | 
            -
                        difference!(other_set.to_value_set)
         | 
| 14 | 
            -
                    end
         | 
| 15 | 
            -
             | 
| 16 | 
            -
                    def add(value)
         | 
| 17 | 
            -
                        insert(value)
         | 
| 18 | 
            -
                        self
         | 
| 19 | 
            -
                    end
         | 
| 20 | 
            -
             | 
| 21 | 
            -
                    def to_s
         | 
| 22 | 
            -
            	    elements = EnumerableToString.to_s_helper(self, '{', '}') do |obj|
         | 
| 23 | 
            -
            		obj.to_s
         | 
| 24 | 
            -
            	    end
         | 
| 25 | 
            -
            	    base = super[0..-2]
         | 
| 26 | 
            -
            	    "#{base} #{elements}>"
         | 
| 27 | 
            -
            	end
         | 
| 28 | 
            -
            	alias :inspect :to_s
         | 
| 29 | 
            -
             | 
| 30 | 
            -
            	def _dump(lvl = -1)
         | 
| 31 | 
            -
            	    Marshal.dump(to_a)
         | 
| 32 | 
            -
            	end
         | 
| 33 | 
            -
            	def self._load(str)
         | 
| 34 | 
            -
            	    Marshal.load(str).to_value_set
         | 
| 35 | 
            -
            	end
         | 
| 36 | 
            -
             | 
| 37 | 
            -
                    def eql?(obj)
         | 
| 38 | 
            -
                        self == obj
         | 
| 39 | 
            -
                    end
         | 
| 40 | 
            -
             | 
| 41 | 
            -
                    def hash
         | 
| 42 | 
            -
                        result = ValueSet.hash
         | 
| 43 | 
            -
                        for obj in self
         | 
| 44 | 
            -
                            result = result ^ obj.hash
         | 
| 45 | 
            -
                        end
         | 
| 46 | 
            -
                        result
         | 
| 47 | 
            -
                    end
         | 
| 48 | 
            -
                end
         | 
| 49 | 
            -
            end
         | 
| @@ -1,71 +0,0 @@ | |
| 1 | 
            -
            --- gc.c	2006-08-25 10:12:46.000000000 +0200
         | 
| 2 | 
            -
            +++ gc.c.new	2007-01-13 12:39:38.383681000 +0100
         | 
| 3 | 
            -
            @@ -88,6 +88,8 @@ static void run_final();
         | 
| 4 | 
            -
             static VALUE nomem_error;
         | 
| 5 | 
            -
             static void garbage_collect();
         | 
| 6 | 
            -
             
         | 
| 7 | 
            -
            +static unsigned long live_objects = 0;
         | 
| 8 | 
            -
            +
         | 
| 9 | 
            -
             void
         | 
| 10 | 
            -
             rb_memerror()
         | 
| 11 | 
            -
             {
         | 
| 12 | 
            -
            @@ -401,6 +398,7 @@ rb_newobj()
         | 
| 13 | 
            -
                 RANY(obj)->file = ruby_sourcefile;
         | 
| 14 | 
            -
                 RANY(obj)->line = ruby_sourceline;
         | 
| 15 | 
            -
             #endif
         | 
| 16 | 
            -
            +    live_objects++;
         | 
| 17 | 
            -
                 return obj;
         | 
| 18 | 
            -
             }
         | 
| 19 | 
            -
             
         | 
| 20 | 
            -
            @@ -1053,8 +1051,8 @@ gc_sweep()
         | 
| 21 | 
            -
                 RVALUE *p, *pend, *final_list;
         | 
| 22 | 
            -
                 int freed = 0;
         | 
| 23 | 
            -
                 int i;
         | 
| 24 | 
            -
            -    unsigned long live = 0;
         | 
| 25 | 
            -
                 unsigned long free_min = 0;
         | 
| 26 | 
            -
            +    live_objects = 0;
         | 
| 27 | 
            -
             
         | 
| 28 | 
            -
                 for (i = 0; i < heaps_used; i++) {
         | 
| 29 | 
            -
                     free_min += heaps[i].limit;
         | 
| 30 | 
            -
            @@ -1113,7 +1111,7 @@ gc_sweep()
         | 
| 31 | 
            -
             	    }
         | 
| 32 | 
            -
             	    else {
         | 
| 33 | 
            -
             		RBASIC(p)->flags &= ~FL_MARK;
         | 
| 34 | 
            -
            -		live++;
         | 
| 35 | 
            -
            +		live_objects++;
         | 
| 36 | 
            -
             	    }
         | 
| 37 | 
            -
             	    p++;
         | 
| 38 | 
            -
             	}
         | 
| 39 | 
            -
            @@ -1131,7 +1129,7 @@ gc_sweep()
         | 
| 40 | 
            -
             	}
         | 
| 41 | 
            -
                 }
         | 
| 42 | 
            -
                 if (malloc_increase > malloc_limit) {
         | 
| 43 | 
            -
            -	malloc_limit += (malloc_increase - malloc_limit) * (double)live / (live + freed);
         | 
| 44 | 
            -
            +	malloc_limit += (malloc_increase - malloc_limit) * (double)live_objects / (live_objects + freed);
         | 
| 45 | 
            -
             	if (malloc_limit < GC_MALLOC_LIMIT) malloc_limit = GC_MALLOC_LIMIT;
         | 
| 46 | 
            -
                 }
         | 
| 47 | 
            -
                 malloc_increase = 0;
         | 
| 48 | 
            -
            @@ -2003,6 +2001,15 @@ rb_obj_id(VALUE obj)
         | 
| 49 | 
            -
                 return (VALUE)((long)obj|FIXNUM_FLAG);
         | 
| 50 | 
            -
             }
         | 
| 51 | 
            -
             
         | 
| 52 | 
            -
            +/* call-seq:
         | 
| 53 | 
            -
            + *  GC.live_objects => number
         | 
| 54 | 
            -
            + *
         | 
| 55 | 
            -
            + * Returns the count of objects currently allocated
         | 
| 56 | 
            -
            + */
         | 
| 57 | 
            -
            +static
         | 
| 58 | 
            -
            +VALUE rb_gc_live_objects(VALUE self)
         | 
| 59 | 
            -
            +{ return INT2FIX(live_objects); }
         | 
| 60 | 
            -
            +
         | 
| 61 | 
            -
             /*
         | 
| 62 | 
            -
              *  The <code>GC</code> module provides an interface to Ruby's mark and
         | 
| 63 | 
            -
              *  sweep garbage collection mechanism. Some of the underlying methods
         | 
| 64 | 
            -
            @@ -2027,6 +2034,7 @@ Init_GC()
         | 
| 65 | 
            -
                 rb_define_module_function(rb_mObSpace, "remove_finalizer", rm_final, 1);
         | 
| 66 | 
            -
                 rb_define_module_function(rb_mObSpace, "finalizers", finals, 0);
         | 
| 67 | 
            -
                 rb_define_module_function(rb_mObSpace, "call_finalizer", call_final, 1);
         | 
| 68 | 
            -
            +    rb_define_module_function(rb_mObSpace, "live_objects", rb_gc_live_objects, 0);
         | 
| 69 | 
            -
             
         | 
| 70 | 
            -
                 rb_define_module_function(rb_mObSpace, "define_finalizer", define_final, -1);
         | 
| 71 | 
            -
                 rb_define_module_function(rb_mObSpace, "undefine_finalizer", undefine_final, 1);
         |