Skip to content
Browse files

Implement initialize_clone / initialize_dup behavior

Fixes #1889, #1910
  • Loading branch information...
1 parent 35acfab commit 663e6cfa5413d040574d080f24f5acd864f3cc8e @dbussink dbussink committed
Showing with 34 additions and 6 deletions.
  1. +2 −6 kernel/alpha.rb
  2. +8 −0 kernel/common/kernel19.rb
  3. +12 −0 kernel/common/type18.rb
  4. +12 −0 kernel/common/type19.rb
View
8 kernel/alpha.rb
@@ -206,9 +206,7 @@ def dup
Rubinius.invoke_primitive :object_copy_object, copy, self
- Rubinius.privately do
- copy.initialize_copy self
- end
+ Rubinius::Type.object_initialize_dup self, copy
copy
end
@@ -236,9 +234,7 @@ def clone
Rubinius.invoke_primitive :object_copy_object, copy, self
Rubinius.invoke_primitive :object_copy_singleton_class, copy, self
- Rubinius.privately do
- copy.initialize_copy self
- end
+ Rubinius::Type.object_initialize_clone self, copy
copy.freeze if frozen?
copy
View
8 kernel/common/kernel19.rb
@@ -247,4 +247,12 @@ def Rational(a, b = 1)
def <=>(other)
self == other ? 0 : nil
end
+
+ def initialize_dup(other)
+ initialize_copy(other)
+ end
+
+ def initialize_clone(other)
+ initialize_copy(other)
+ end
end
View
12 kernel/common/type18.rb
@@ -55,5 +55,17 @@ def self.coerce_to_pid(obj)
obj
end
+
+ def self.object_initialize_dup(obj, copy)
+ Rubinius.privately do
+ copy.initialize_copy obj
+ end
+ end
+
+ def self.object_initialize_clone(obj, copy)
+ Rubinius.privately do
+ copy.initialize_copy obj
+ end
+ end
end
end
View
12 kernel/common/type19.rb
@@ -135,5 +135,17 @@ def self.coerce_to_utc_offset(offset)
def self.coerce_to_pid(obj)
Rubinius::Type.coerce_to obj, Integer, :to_int
end
+
+ def self.object_initialize_dup(obj, copy)
+ Rubinius.privately do
+ copy.initialize_dup obj
+ end
+ end
+
+ def self.object_initialize_clone(obj, copy)
+ Rubinius.privately do
+ copy.initialize_clone obj
+ end
+ end
end
end

0 comments on commit 663e6cf

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