Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'master' of git://github.com/rubinius/rubinius

Conflicts:
	vm/vmmethod.cpp
  • Loading branch information...
commit 780eb7f4739f53ace60f757f8609e536f209c43b 2 parents 3e7e61f + e38aaa8
Ryo Onodera authored
12  kernel/bootstrap/weakref.rb
@@ -19,6 +19,18 @@ def __object__
19 19
     ::Kernel.raise PrimitiveFailure, "WeakRef#__object__ failed"
20 20
   end
21 21
 
  22
+  def class
  23
+    WeakRef
  24
+  end
  25
+
  26
+  def marshal_dump
  27
+    __object__
  28
+  end
  29
+
  30
+  def marshal_load(data)
  31
+    __setobj__(data)
  32
+  end
  33
+
22 34
   def __getobj__
23 35
     obj = __object__()
24 36
     unless weakref_alive?
8  kernel/bootstrap/weakref19.rb
... ...
@@ -1,6 +1,14 @@
1 1
 # -*- encoding: us-ascii -*-
2 2
 
3 3
 class WeakRef < BasicObject
  4
+  def respond_to?(method)
  5
+    if method == :marshal_dump || method == :marshal_load
  6
+      true
  7
+    else
  8
+      super
  9
+    end
  10
+  end
  11
+
4 12
   def respond_to_missing?(method, include_private)
5 13
     target = __getobj__
6 14
     target.respond_to?(method, include_private) and
2  kernel/common/marshal.rb
@@ -993,7 +993,7 @@ def self.load(obj, prc = nil)
993 993
     end
994 994
 
995 995
     if major != MAJOR_VERSION or minor > MINOR_VERSION
996  
-      raise TypeError, "incompatible marshal file format (can't be read)\n\tformat version #{MAJOR_VERSION}.#{MINOR_VERSION} required; #{major}.#{minor} given"
  996
+      raise TypeError, "incompatible marshal file format (can't be read)\n\tformat version #{MAJOR_VERSION}.#{MINOR_VERSION} required; #{major.inspect}.#{minor.inspect} given"
997 997
     end
998 998
 
999 999
     ms.construct
5  kernel/common/module.rb
@@ -321,6 +321,11 @@ def define_method(name, meth = undefined, &prc)
321 321
       if exec.kind_of? Rubinius::DelegatedMethod
322 322
         cm = exec
323 323
       else
  324
+        if Rubinius::Type.object_kind_of?(meth.defined_in, Class) and
  325
+           Rubinius::Type.singleton_class_object(meth.defined_in) and
  326
+           not Rubinius::Type.object_kind_of?(Rubinius::Type.singleton_class_object(self), Class) and
  327
+          raise TypeError, "illegal attempt to rebind a singleton method to another object"
  328
+        end
324 329
         cm = Rubinius::DelegatedMethod.new(name, :call_on_instance, meth, true)
325 330
       end
326 331
     else
10  kernel/common/time18.rb
@@ -44,7 +44,15 @@ def self.from_array(sec, min, hour, mday, month, year, nsec, is_dst, from_gmt, u
44 44
 
45 45
     sec = sec.kind_of?(String) ? sec.to_i : Rubinius::Type.coerce_to(sec || 0, Integer, :to_int)
46 46
 
47  
-    from_array(sec, min, hour, mday, month, year, nsec || 0, is_dst, from_gmt, utc_offset)
  47
+    if utc_offset
  48
+      utc_offset_sec = utc_offset.to_i
  49
+      utc_offset_nsec = ((utc_offset % 1.0) * 1_000_000_000 + 0.5).to_i
  50
+    else
  51
+      utc_offset_sec = 0
  52
+      utc_offset_nsec = 0
  53
+    end
  54
+
  55
+    from_array(sec, min, hour, mday, month, year, nsec || 0, is_dst, from_gmt, utc_offset, utc_offset_sec, utc_offset_nsec)
48 56
   end
49 57
 
50 58
   def inspect
10  kernel/common/time19.rb
@@ -51,7 +51,15 @@ def self.from_array(sec, min, hour, mday, month, year, nsec, is_dst, from_gmt, u
51 51
     sec += nsec / 1_000_000_000
52 52
     nsec %= 1_000_000_000
53 53
 
54  
-    from_array(sec, min, hour, mday, month, year, nsec, is_dst, from_gmt, utc_offset)
  54
+    if utc_offset
  55
+      utc_offset_sec = utc_offset.to_i
  56
+      utc_offset_nsec = ((utc_offset % 1.0) * 1_000_000_000 + 0.5).to_i
  57
+    else
  58
+      utc_offset_sec = 0
  59
+      utc_offset_nsec = 0
  60
+    end
  61
+
  62
+    from_array(sec, min, hour, mday, month, year, nsec, is_dst, from_gmt, utc_offset, utc_offset_sec, utc_offset_nsec)
55 63
   end
56 64
 
57 65
   def self.new(year=undefined, month=nil, day=nil, hour=nil, minute=nil, second=nil, utc_offset=nil)
8  lib/zlib.rb.ffi
@@ -392,6 +392,12 @@ module Zlib
392 392
 
393 393
     alias :close :end
394 394
 
  395
+    def ended?
  396
+      !ready?
  397
+    end
  398
+
  399
+    alias :closed? :ended?
  400
+
395 401
     def expand_output
396 402
       if @output.nil? then
397 403
         @output = ''
@@ -459,8 +465,6 @@ module Zlib
459 465
     def ready?
460 466
       @flags & READY == READY
461 467
     end
462  
-    alias :closed? :ready?
463  
-    alias :ended? :ready?
464 468
 
465 469
     ##
466 470
     # Resets and initializes the stream. All data in both input and output
1  rakelib/vm.rake
@@ -101,7 +101,6 @@ field_extract_headers = %w[
101 101
   vm/builtin/proc.hpp
102 102
   vm/builtin/variable_scope.hpp
103 103
   vm/builtin/location.hpp
104  
-  vm/builtin/capi_handle.hpp
105 104
   vm/builtin/global_cache_entry.hpp
106 105
   vm/builtin/weakref.hpp
107 106
   vm/builtin/fiber.hpp
5  spec/core/marshal/dump_spec.rb
@@ -5,4 +5,9 @@
5 5
     atomic_reference = Rubinius::AtomicReference.new(0)
6 6
     Marshal.dump(atomic_reference).should == "\x04\bU:\x1ERubinius::AtomicReferencei\x00"
7 7
   end
  8
+
  9
+  it "dumps a WeakRef" do
  10
+    atomic_reference = WeakRef.new(0)
  11
+    Marshal.dump(atomic_reference).should == "\x04\bU:\fWeakRefi\x00"
  12
+  end
8 13
 end
7  spec/core/marshal/shared/load.rb
@@ -5,4 +5,11 @@
5 5
     atomic_reference.class.should == Rubinius::AtomicReference
6 6
     atomic_reference.value.should == 0
7 7
   end
  8
+
  9
+  it "loads a WeakRef" do
  10
+    data = "\x04\bU:\fWeakRefi\x00"
  11
+    atomic_reference = Marshal.send(@method, data)
  12
+    atomic_reference.class.should == WeakRef
  13
+    atomic_reference.__object__.should == 0
  14
+  end
8 15
 end
7  spec/ruby/core/time/shared/gmt_offset.rb
@@ -25,4 +25,11 @@
25 25
       Time.local(2010,4,4,3,0,0).send(@method).should == 12*60*60
26 26
     end
27 27
   end
  28
+
  29
+  ruby_version_is "1.9" do
  30
+    it "returns offset as Rational" do
  31
+      Time.new(2010,4,4,1,59,59,7245).send(@method).should == 7245
  32
+      Time.new(2010,4,4,1,59,59,7245.5).send(@method).should == Rational(14491,2)
  33
+    end
  34
+  end
28 35
 end
4  spec/ruby/language/splat_spec.rb
@@ -52,6 +52,10 @@
52 52
         a = *1; a.should == [1]
53 53
       end
54 54
 
  55
+      it "assigns the splatted object contained into an array when the splatted object is a result of 'obj || []'" do
  56
+        a = *(1 || []); a.should == [1]
  57
+      end
  58
+
55 59
       it "assigns the returned value of to_a when the splatted object responds to to_a" do
56 60
         o = mock(Object)
57 61
         o.should_receive(:to_a).once.and_return(["foo"])
1  spec/tags/19/ruby/core/kernel/define_singleton_method_tags.txt
... ...
@@ -1 +0,0 @@
1  
-fails:Kernel#define_singleton_method when given an UnboundMethod will raise when attempting to define an object's singleton method from another object's singleton method
2  spec/tags/19/ruby/core/time/getlocal_tags.txt
... ...
@@ -1,2 +0,0 @@
1  
-fails:Time#getlocal returns a Time with a UTC offset of the specified number of Rational seconds
2  
-fails:Time#getlocal with an argument that responds to #to_r coerces using #to_r
2  spec/tags/19/ruby/core/time/localtime_tags.txt
... ...
@@ -1,2 +0,0 @@
1  
-fails:Time#localtime returns a Time with a UTC offset of the specified number of Rational seconds
2  
-fails:Time#localtime with an argument that responds to #to_r coerces using #to_r
2  spec/tags/19/ruby/core/time/new_tags.txt
... ...
@@ -1,3 +1 @@
1  
-fails:Time.new with a utc_offset argument returns a Time with a UTC offset of the specified number of Rational seconds
2  
-fails:Time.new with a utc_offset argument with an argument that responds to #to_r coerces using #to_r
3 1
 unstable(fails on 32-bit linux):Time.new accepts various year ranges
1  spec/tags/19/ruby/language/splat_tags.txt
... ...
@@ -0,0 +1 @@
  1
+fails:Splat operator used to assign a splatted object to an object assigns the splatted object contained into an array when the splatted object is a result of 'obj || []'
9  vm/builtin/capi_handle.cpp
... ...
@@ -1,9 +0,0 @@
1  
-#include "builtin/capi_handle.hpp"
2  
-
3  
-namespace rubinius {
4  
-  CApiHandle* CApiHandle::create(STATE, capi::Handle* handle) {
5  
-    CApiHandle* wrapper = state->new_object<CApiHandle>(G(object));
6  
-    wrapper->handle = handle;
7  
-    return wrapper;
8  
-  }
9  
-}
22  vm/builtin/capi_handle.hpp
... ...
@@ -1,22 +0,0 @@
1  
-#ifndef RBX_BUILTIN_CAPI_HANDLE_HPP
2  
-#define RBX_BUILTIN_CAPI_HANDLE_HPP
3  
-
4  
-#include "vm.hpp"
5  
-#include "builtin/object.hpp"
6  
-
7  
-namespace rubinius {
8  
-  namespace capi {
9  
-    class Handle;
10  
-  }
11  
-
12  
-  class CApiHandle : public Object {
13  
-  public:
14  
-    const static object_type type = CApiHandleType;
15  
-
16  
-    capi::Handle* handle;
17  
-
18  
-    static CApiHandle* create(STATE, capi::Handle* handle);
19  
-  };
20  
-}
21  
-
22  
-#endif
1  vm/builtin/nativemethod.cpp
@@ -18,7 +18,6 @@
18 18
 #include "builtin/string.hpp"
19 19
 #include "builtin/system.hpp"
20 20
 #include "builtin/tuple.hpp"
21  
-#include "builtin/capi_handle.hpp"
22 21
 #include "builtin/location.hpp"
23 22
 #include "builtin/ffi_pointer.hpp"
24 23
 
17  vm/builtin/time.cpp
@@ -93,10 +93,11 @@ namespace rubinius {
93 93
     return tm;
94 94
   }
95 95
 
96  
-  Time* Time::from_array(STATE, Object* self, 
  96
+  Time* Time::from_array(STATE, Object* self,
97 97
                          Fixnum* sec, Fixnum* min, Fixnum* hour,
98 98
                          Fixnum* mday, Fixnum* mon, Fixnum* year, Fixnum* nsec,
99  
-                         Fixnum* isdst, Object* from_gmt, Object* offset) {
  99
+                         Fixnum* isdst, Object* from_gmt, Object* offset,
  100
+                         Fixnum* offset_sec, Fixnum* offset_nsec) {
100 101
     struct tm tm;
101 102
 
102 103
     tm.tm_sec = sec->to_native();
@@ -158,8 +159,16 @@ namespace rubinius {
158 159
     obj->nanoseconds_ = nsec->to_native();
159 160
     obj->is_gmt(state, CBOOL(from_gmt) ? cTrue : cFalse);
160 161
 
161  
-    if(Fixnum* off = try_as<Fixnum>(offset)) {
162  
-      obj->seconds_ -= off->to_native();
  162
+    if(!offset->nil_p()) {
  163
+      obj->seconds_ -= offset_sec->to_native();
  164
+      obj->nanoseconds_ -= offset_nsec->to_native();
  165
+
  166
+      // Deal with underflow wrapping
  167
+      if(obj->nanoseconds_ < 0) {
  168
+        obj->seconds_ += NDIV(obj->nanoseconds_, 1000000000);
  169
+        obj->nanoseconds_ = NMOD(obj->nanoseconds_, 1000000000);
  170
+      }
  171
+
163 172
       obj->offset(state, offset);
164 173
     }
165 174
 
2  vm/builtin/time.hpp
@@ -42,7 +42,7 @@ namespace rubinius {
42 42
     static Time* now(STATE, Object* self);
43 43
 
44 44
     // Rubinius.primitive :time_s_from_array
45  
-    static Time* from_array(STATE, Object* self, Fixnum* sec, Fixnum* min, Fixnum* hour, Fixnum* mday, Fixnum* mon, Fixnum* year, Fixnum* nsec, Fixnum* isdst, Object* from_gmt, Object* offset);
  45
+    static Time* from_array(STATE, Object* self, Fixnum* sec, Fixnum* min, Fixnum* hour, Fixnum* mday, Fixnum* mon, Fixnum* year, Fixnum* nsec, Fixnum* isdst, Object* from_gmt, Object* offset, Fixnum* offset_sec, Fixnum* offset_nsec);
46 46
 
47 47
     // Rubinius.primitive :time_s_dup
48 48
     static Time* dup(STATE, Object* self, Time* other);
4  vm/instructions.def
@@ -216,9 +216,7 @@ end
216 216
 #   ...
217 217
 
218 218
 instruction pop_many(count) [ +count -- ]
219  
-  for(intptr_t i = 0; i < count; i++) {
220  
-    (void)stack_pop();
221  
-  }
  219
+  stack_clear(count);
222 220
 end
223 221
 
224 222
 # [Description]

0 notes on commit 780eb7f

Please sign in to comment.
Something went wrong with that request. Please try again.