1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/delegate.rb: catch up with class local variable (@_v) spec.

* lib/singleton.rb: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11742 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2007-02-14 16:50:16 +00:00
parent fdf4aa982f
commit 970df0d138
4 changed files with 29 additions and 23 deletions

View file

@ -1,3 +1,9 @@
Thu Feb 15 01:43:45 2007 Koichi Sasada <ko1@atdot.net>
* lib/delegate.rb: catch up with class local variable (@_v) spec.
* lib/singleton.rb: ditto.
Wed Feb 14 22:52:43 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c (ole_variant2val): VC++6 does not

View file

@ -95,15 +95,15 @@
# class SimpleDelegator < Delegator
# def initialize(obj)
# super # pass obj to Delegator constructor, required
# @_sd_obj = obj # store obj for future use
# @delegate_sd_obj = obj # store obj for future use
# end
#
# def __getobj__
# @_sd_obj # return object we are delegating to, required
# @delegate_sd_obj # return object we are delegating to, required
# end
#
# def __setobj__(obj)
# @_sd_obj = obj # change delegation object, a feature we're providing
# @delegate_sd_obj = obj # change delegation object, a feature we're providing
# end
#
# # ...
@ -219,7 +219,7 @@ end
class SimpleDelegator<Delegator
# Returns the current object method calls are being delegated to.
def __getobj__
@_sd_obj
@delegate_sd_obj
end
#
@ -238,7 +238,7 @@ class SimpleDelegator<Delegator
#
def __setobj__(obj)
raise ArgumentError, "cannot delegate to self" if self.equal?(obj)
@_sd_obj = obj
@delegate_sd_obj = obj
end
end
@ -269,11 +269,11 @@ def DelegateClass(superclass)
klass.module_eval {
include Delegator::MethodDelegation
def __getobj__ # :nodoc:
@_dc_obj
@delegate_dc_obj
end
def __setobj__(obj) # :nodoc:
raise ArgumentError, "cannot delegate to self" if self.equal?(obj)
@_dc_obj = obj
@delegate_dc_obj = obj
end
}
for method in methods
@ -281,7 +281,7 @@ def DelegateClass(superclass)
klass.module_eval <<-EOS, __FILE__, __LINE__+1
def #{method}(*args, &block)
begin
@_dc_obj.__send(:#{method}, *args, &block)
@delegate_dc_obj.__send(:#{method}, *args, &block)
rescue
$@[0,2] = nil
raise

View file

@ -39,7 +39,7 @@
# method body is a simple:
#
# def Klass.instance()
# return @__instance__
# return @singleton__instance__
# end
#
# * Klass._load(str) - calling Klass.instance()
@ -101,16 +101,16 @@ module Singleton
class << Singleton
def __init__(klass)
klass.instance_eval {
@__instance__ = nil
@__mutex__ = Mutex.new
@singleton__instance__ = nil
@singleton__mutex__ = Mutex.new
}
def klass.instance
return @__instance__ if @__instance__
@__mutex__.synchronize {
return @__instance__ if @__instance__
@__instance__ = new()
return @singleton__instance__ if @singleton__instance__
@singleton__mutex__.synchronize {
return @singleton__instance__ if @singleton__instance__
@singleton__instance__ = new()
}
@__instance__
@singleton__instance__
end
klass
end
@ -177,13 +177,13 @@ end
class << Ups
def _instantiate?
@enter.push Thread.current[:i]
while false.equal?(@__instance__)
@__mutex__.unlock
while false.equal?(@singleton__instance__)
@singleton__mutex__.unlock
sleep 0.08
@__mutex__.lock
@singleton__mutex__.lock
end
@leave.push Thread.current[:i]
@__instance__
@singleton__instance__
end
def __sleep

View file

@ -1,7 +1,7 @@
#define RUBY_VERSION "1.9.0"
#define RUBY_RELEASE_DATE "2007-02-14"
#define RUBY_RELEASE_DATE "2007-02-15"
#define RUBY_VERSION_CODE 190
#define RUBY_RELEASE_CODE 20070214
#define RUBY_RELEASE_CODE 20070215
#define RUBY_PATCHLEVEL 0
#define RUBY_VERSION_MAJOR 1
@ -9,7 +9,7 @@
#define RUBY_VERSION_TEENY 0
#define RUBY_RELEASE_YEAR 2007
#define RUBY_RELEASE_MONTH 2
#define RUBY_RELEASE_DAY 14
#define RUBY_RELEASE_DAY 15
RUBY_EXTERN const char ruby_version[];
RUBY_EXTERN const char ruby_release_date[];