From 97dedf4f8cf522a607d281a5ba31e955ba9b0830 Mon Sep 17 00:00:00 2001 From: Evan Weaver Date: Tue, 22 Feb 2011 16:24:26 -0800 Subject: [PATCH] Work with SWIG 2.0.2. --- Manifest | 3 +-- ext/extconf.rb | 11 ++++------ ext/rlibmemcached_wrap.c | 25 +++++++++------------ lib/memcached/memcached.rb | 28 ++++++++++++------------ test/setup.rb | 12 +++++----- test/test_helper.rb | 7 ++++-- test/unit/memcached_experimental_test.rb | 3 --- test/unit/memcached_test.rb | 3 --- 8 files changed, 40 insertions(+), 52 deletions(-) diff --git a/Manifest b/Manifest index 7b2676f..369ef8f 100644 --- a/Manifest +++ b/Manifest @@ -5,6 +5,7 @@ Manifest README Rakefile TODO +ext/extconf-make.rb ext/extconf.rb ext/libmemcached-0.32.tar.gz ext/libmemcached-2.patch @@ -21,10 +22,8 @@ lib/memcached/auth.rb lib/memcached/behaviors.rb lib/memcached/exceptions.rb lib/memcached/experimental.rb -lib/memcached/integer.rb lib/memcached/memcached.rb lib/memcached/rails.rb -memcached.gemspec test/profile/benchmark.rb test/profile/profile.rb test/profile/valgrind.rb diff --git a/ext/extconf.rb b/ext/extconf.rb index bed5eb4..efa363b 100644 --- a/ext/extconf.rb +++ b/ext/extconf.rb @@ -90,13 +90,10 @@ end check_libmemcached if ENV['SWIG'] - if (`swig -version`=~ /2.0.1/) - run("swig #{$defines} #{$includes} -ruby -autorename rlibmemcached.i", "Running SWIG.") - run("sed -i '' 's/STR2CSTR/StringValuePtr/' rlibmemcached_wrap.c", "Patching SWIG output for Ruby 1.9.") - run("sed -i '' 's/\"swig_runtime_data\"/\"SwigRuntimeData\"/' rlibmemcached_wrap.c", "Patching SWIG output for Ruby 1.9.") - else - raise "Swig 2.0.1 not found. Newer versions may not work." - end + puts "WARNING: Swig 2.0.2 not found. Other versions may not work." if (`swig -version`!~ /2.0.2/) + run("swig #{$defines} #{$includes} -ruby -autorename rlibmemcached.i", "Running SWIG.") + run("sed -i '' 's/STR2CSTR/StringValuePtr/' rlibmemcached_wrap.c", "Patching SWIG output for Ruby 1.9.") + run("sed -i '' 's/\"swig_runtime_data\"/\"SwigRuntimeData\"/' rlibmemcached_wrap.c", "Patching SWIG output for Ruby 1.9.") end $CFLAGS << " -Os" diff --git a/ext/rlibmemcached_wrap.c b/ext/rlibmemcached_wrap.c index 8e7e744..21b63f4 100644 --- a/ext/rlibmemcached_wrap.c +++ b/ext/rlibmemcached_wrap.c @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.1 + * Version 2.0.2 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -1819,11 +1819,10 @@ int SWIG_Ruby_arity( VALUE proc, int minimal ) #define SWIGTYPE_p_p_char swig_types[27] #define SWIGTYPE_p_sasl_callback_t swig_types[28] #define SWIGTYPE_p_size_t swig_types[29] -#define SWIGTYPE_p_time_t swig_types[30] -#define SWIGTYPE_p_uint32_t swig_types[31] -#define SWIGTYPE_p_uint64_t swig_types[32] -static swig_type_info *swig_types[34]; -static swig_module_info swig_module = {swig_types, 33, 0, 0, 0, 0}; +#define SWIGTYPE_p_uint32_t swig_types[30] +#define SWIGTYPE_p_uint64_t swig_types[31] +static swig_type_info *swig_types[33]; +static swig_module_info swig_module = {swig_types, 32, 0, 0, 0, 0}; #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) @@ -1838,7 +1837,7 @@ static VALUE mRlibmemcached; #define SWIG_RUBY_THREAD_END_BLOCK -#define SWIGVERSION 0x020001 +#define SWIGVERSION 0x020002 #define SWIG_VERSION SWIGVERSION @@ -1942,7 +1941,7 @@ SWIG_ruby_failed(void) } -/*@SWIG:/opt/local/share/swig/2.0.1/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ +/*@SWIG:/opt/local/share/swig/2.0.2/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ SWIGINTERN VALUE SWIG_AUX_NUM2DBL(VALUE *args) { VALUE obj = args[0]; @@ -2036,7 +2035,7 @@ SWIG_AsCharArray(VALUE obj, char *val, size_t size) } -/*@SWIG:/opt/local/share/swig/2.0.1/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ +/*@SWIG:/opt/local/share/swig/2.0.2/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ SWIGINTERN VALUE SWIG_AUX_NUM2ULONG(VALUE *args) { VALUE obj = args[0]; @@ -2095,7 +2094,7 @@ SWIG_From_unsigned_SS_short (unsigned short value) } -/*@SWIG:/opt/local/share/swig/2.0.1/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ +/*@SWIG:/opt/local/share/swig/2.0.2/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE *args) { VALUE obj = args[0]; @@ -2217,7 +2216,7 @@ SWIG_AsVal_unsigned_SS_int (VALUE obj, unsigned int *val) } -/*@SWIG:/opt/local/share/swig/2.0.1/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ +/*@SWIG:/opt/local/share/swig/2.0.2/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ SWIGINTERN VALUE SWIG_AUX_NUM2ULL(VALUE *args) { VALUE obj = args[0]; @@ -12866,7 +12865,6 @@ static swig_type_info _swigt__p_memcached_trigger_key = {"_p_memcached_trigger_k static swig_type_info _swigt__p_p_char = {"_p_p_char", "char **", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_sasl_callback_t = {"_p_sasl_callback_t", "sasl_callback_t *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_size_t = {"_p_size_t", "size_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_time_t = {"_p_time_t", "time_t *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_uint32_t = {"_p_uint32_t", "uint32_t *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_uint64_t = {"_p_uint64_t", "uint64_t *", 0, 0, (void*)0, 0}; @@ -12901,7 +12899,6 @@ static swig_type_info *swig_type_initial[] = { &_swigt__p_p_char, &_swigt__p_sasl_callback_t, &_swigt__p_size_t, - &_swigt__p_time_t, &_swigt__p_uint32_t, &_swigt__p_uint64_t, }; @@ -12936,7 +12933,6 @@ static swig_cast_info _swigc__p_memcached_trigger_key[] = { {&_swigt__p_memcach static swig_cast_info _swigc__p_p_char[] = { {&_swigt__p_p_char, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_sasl_callback_t[] = { {&_swigt__p_sasl_callback_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_size_t[] = { {&_swigt__p_size_t, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_time_t[] = { {&_swigt__p_time_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_uint32_t[] = { {&_swigt__p_uint32_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_uint64_t[] = { {&_swigt__p_uint64_t, 0, 0, 0},{0, 0, 0, 0}}; @@ -12971,7 +12967,6 @@ static swig_cast_info *swig_cast_initial[] = { _swigc__p_p_char, _swigc__p_sasl_callback_t, _swigc__p_size_t, - _swigc__p_time_t, _swigc__p_uint32_t, _swigc__p_uint64_t, }; diff --git a/lib/memcached/memcached.rb b/lib/memcached/memcached.rb index ec739b4..e614017 100644 --- a/lib/memcached/memcached.rb +++ b/lib/memcached/memcached.rb @@ -120,7 +120,7 @@ Please note that when :no_block => true, update methods do not raise on end instance_eval { send(:extend, Experimental) } if options[:experimental_features] - + options[:binary_protocol] = true if options[:credentials] != nil # Force :buffer_requests to use :no_block @@ -303,7 +303,7 @@ Please note that when :no_block => true, update methods do not raise on # Set a key/value pair. Accepts a String key and an arbitrary Ruby object. Overwrites any existing value on the server. # - # Accepts an optional ttl value to specify the maximum lifetime of the key on the server. ttl can be either an integer number of seconds, or a Time elapsed time object. 0 means no ttl. Note that there is no guarantee that the key will persist as long as the ttl, but it will not persist longer. + # Accepts an optional ttl value to specify the maximum lifetime of the key on the server, in seconds. ttl must be a FixNum. 0 means no ttl. Note that there is no guarantee that the key will persist as long as the ttl, but it will not persist longer. # # Also accepts a marshal value, which defaults to true. Set marshal to false if you want the value to be set directly. # @@ -319,7 +319,7 @@ Please note that when :no_block => true, update methods do not raise on retry if e.instance_of?(ClientError) && !tries raise unless tries < options[:exception_retry_limit] && should_retry(e) tries += 1 - retry + retry end end @@ -335,7 +335,7 @@ Please note that when :no_block => true, update methods do not raise on tries ||= 0 raise unless tries < options[:exception_retry_limit] && should_retry(e) tries += 1 - retry + retry end end @@ -352,7 +352,7 @@ Please note that when :no_block => true, update methods do not raise on tries ||= 0 raise unless tries < options[:exception_retry_limit] && should_retry(e) tries += 1 - retry + retry end # Decrement a key's value. The parameters and exception behavior are the same as increment. @@ -364,7 +364,7 @@ Please note that when :no_block => true, update methods do not raise on tries ||= 0 raise unless tries < options[:exception_retry_limit] && should_retry(e) tries += 1 - retry + retry end #:stopdoc: @@ -384,7 +384,7 @@ Please note that when :no_block => true, update methods do not raise on tries ||= 0 raise unless tries < options[:exception_retry_limit] && should_retry(e) tries += 1 - retry + retry end end @@ -401,7 +401,7 @@ Please note that when :no_block => true, update methods do not raise on tries ||= 0 raise unless tries < options[:exception_retry_limit] && should_retry(e) tries += 1 - retry + retry end # Prepends a string to a key's value. The parameters and exception behavior are the same as append. @@ -415,7 +415,7 @@ Please note that when :no_block => true, update methods do not raise on tries ||= 0 raise unless tries < options[:exception_retry_limit] && should_retry(e) tries += 1 - retry + retry end # Reads a key's value from the server and yields it to a block. Replaces the key's value with the result of the block as long as the key hasn't been updated in the meantime, otherwise raises Memcached::NotStored. Accepts a String key and a block. @@ -434,9 +434,9 @@ Please note that when :no_block => true, update methods do not raise on tries_for_get ||= 0 raise unless tries_for_get < options[:exception_retry_limit] && should_retry(e) tries_for_get += 1 - retry + retry end - + cas = @struct.result.cas value = Marshal.load(value) if marshal @@ -452,7 +452,7 @@ Please note that when :no_block => true, update methods do not raise on tries_for_cas ||= 0 raise unless tries_for_cas < options[:exception_retry_limit] && should_retry(e) tries_for_cas += 1 - retry + retry end end @@ -470,7 +470,7 @@ Please note that when :no_block => true, update methods do not raise on tries ||= 0 raise unless tries < options[:exception_retry_limit] && should_retry(e) tries += 1 - retry + retry end # Flushes all key/value pairs from all the servers. @@ -482,7 +482,7 @@ Please note that when :no_block => true, update methods do not raise on tries ||= 0 raise unless tries < options[:exception_retry_limit] && should_retry(e) tries += 1 - retry + retry end ### Getters diff --git a/test/setup.rb b/test/setup.rb index 01205d3..8777659 100644 --- a/test/setup.rb +++ b/test/setup.rb @@ -1,26 +1,26 @@ - + unless defined? UNIX_SOCKET_NAME HERE = File.dirname(__FILE__) UNIX_SOCKET_NAME = File.join(ENV['TMPDIR']||'/tmp','memcached') - + # Kill memcached system("killall -9 memcached") - + # Start memcached verbosity = (ENV['DEBUG'] ? "-vv" : "") log = "/tmp/memcached.log" system ">#{log}" - + # TCP memcached (43042..43046).each do |port| cmd = "memcached #{verbosity} -U 0 -p #{port} >> #{log} 2>&1 &" raise "'#{cmd}' failed to start" unless system(cmd) - end + end # UDP memcached (43052..43053).each do |port| cmd = "memcached #{verbosity} -U #{port} -p 0 >> #{log} 2>&1 &" raise "'#{cmd}' failed to start" unless system(cmd) - end + end # Domain socket memcached (0..1).each do |i| cmd = "memcached -M -s #{UNIX_SOCKET_NAME}#{i} #{verbosity} >> #{log} 2>&1 &" diff --git a/test/test_helper.rb b/test/test_helper.rb index 523b803..b174c16 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -3,11 +3,13 @@ $LOAD_PATH << "#{File.dirname(__FILE__)}/../lib" require 'rubygems' require 'mocha' +require 'socket' +require 'benchmark' if ENV['DEBUG'] - require 'ruby-debug' + require 'ruby-debug' end - + require 'memcached' require 'test/unit' require 'ostruct' @@ -16,3 +18,4 @@ UNIX_SOCKET_NAME = File.join(ENV['TMPDIR']||'/tmp','memcached') unless defined? class GenericClass end + diff --git a/test/unit/memcached_experimental_test.rb b/test/unit/memcached_experimental_test.rb index 6bd7216..578dc58 100644 --- a/test/unit/memcached_experimental_test.rb +++ b/test/unit/memcached_experimental_test.rb @@ -1,8 +1,5 @@ require File.expand_path("#{File.dirname(__FILE__)}/../test_helper") -require 'socket' -require 'mocha' -require 'benchmark' class MemcachedExperimentalTest < Test::Unit::TestCase diff --git a/test/unit/memcached_test.rb b/test/unit/memcached_test.rb index a63ee59..fe01a1c 100644 --- a/test/unit/memcached_test.rb +++ b/test/unit/memcached_test.rb @@ -1,8 +1,5 @@ require File.expand_path("#{File.dirname(__FILE__)}/../test_helper") -require 'socket' -require 'mocha' -require 'benchmark' class MemcachedTest < Test::Unit::TestCase