summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-02-09 06:08:24 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-02-09 06:08:24 +0000
commit115eb4595cea72226ec8acd357e7c403e2c4b04a (patch)
treec050f1ee16f730fc7dbc89586e09b33a23196485 /lib
parent9b64dfe3b8f0343ebf97ae80d3a4ec3f4bd115b3 (diff)
990209
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_3@394 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/complex.rb18
-rw-r--r--lib/e2mmap.rb2
-rw-r--r--lib/mutex_m.rb9
-rw-r--r--lib/sync.rb14
4 files changed, 22 insertions, 21 deletions
diff --git a/lib/complex.rb b/lib/complex.rb
index 59caad6..0af8c20 100644
--- a/lib/complex.rb
+++ b/lib/complex.rb
@@ -72,6 +72,8 @@ class Complex < Numeric
end
def initialize(a, b = 0)
+ raise "non numeric 1st arg `#{a.inspect}'" if !a.kind_of? Numeric
+ raise "non numeric 2nd arg `#{b.inspect}'" if !b.kind_of? Numeric
@real = a
@image = b
end
@@ -84,7 +86,7 @@ class Complex < Numeric
elsif Complex.generic?(other)
Complex(@real + other, @image)
else
- x , y = a.coerce(self)
+ x , y = other.coerce(self)
x + y
end
end
@@ -97,7 +99,7 @@ class Complex < Numeric
elsif Complex.generic?(other)
Complex(@real - other, @image)
else
- x , y = a.coerce(self)
+ x , y = other.coerce(self)
x - y
end
end
@@ -110,7 +112,7 @@ class Complex < Numeric
elsif Complex.generic?(other)
Complex(@real * other, @image * other)
else
- x , y = a.coerce(self)
+ x , y = other.coerce(self)
x * y
end
end
@@ -121,7 +123,7 @@ class Complex < Numeric
elsif Complex.generic?(other)
Complex(@real / other, @image / other)
else
- x , y = a.coerce(self)
+ x , y = other.coerce(self)
x / y
end
end
@@ -163,7 +165,7 @@ class Complex < Numeric
r, theta = polar
Complex.polar(r.power!(other), theta * other)
else
- x , y = a.coerce(self)
+ x , y = other.coerce(self)
x / y
end
end
@@ -174,7 +176,7 @@ class Complex < Numeric
elsif Complex.generic?(other)
Complex(@real % other, @image % other)
else
- x , y = a.coerce(self)
+ x , y = other.coerce(self)
x % y
end
end
@@ -187,7 +189,7 @@ class Complex < Numeric
elsif Complex.generic?(other)
Complex(@real.divmod(other), @image.divmod(other))
else
- x , y = a.coerce(self)
+ x , y = other.coerce(self)
x.divmod(y)
end
end
@@ -222,7 +224,7 @@ class Complex < Numeric
elsif Complex.generic?(other)
@real == other and @image == 0
else
- x , y = a.coerce(self)
+ x , y = other.coerce(self)
x == y
end
end
diff --git a/lib/e2mmap.rb b/lib/e2mmap.rb
index bf860dc..3d72aaf 100644
--- a/lib/e2mmap.rb
+++ b/lib/e2mmap.rb
@@ -72,7 +72,7 @@ else
end
end
- # 過去の互換性のため
+ # backward compatibility
def self.fail(err = nil, *rest)
if form = E2MM_ErrorMSG[err]
$! = err.new(sprintf(form, *rest))
diff --git a/lib/mutex_m.rb b/lib/mutex_m.rb
index 4b8d644..dd92ff9 100644
--- a/lib/mutex_m.rb
+++ b/lib/mutex_m.rb
@@ -12,7 +12,7 @@
# obj = Object.new
# obj.extend Mutex_m
# ...
-# 後はMutexと同じ使い方
+# extended object can be handled like Mutex
#
require "finalize"
@@ -36,7 +36,7 @@ module Mutex_m
dummy = cl.new
Mutex_m.extendable_module(dummy)
rescue NameError
- # newが定義されていない時は, DATAとみなす.
+ # if new is not defined, cl must be Data.
For_primitive_object
end
end
@@ -44,8 +44,8 @@ module Mutex_m
def Mutex_m.extend_class(cl)
return super if cl.instance_of?(Module)
- # モジュールの時は何もしない. クラスの場合, 適切なモジュールの決定
- # とaliasを行う.
+ # do nothing for Modules
+ # make aliases and include the proper module.
real = includable_module(cl)
cl.module_eval %q{
include real
@@ -162,7 +162,6 @@ module Mutex_m
def For_primitive_object.mu_finalize(id)
Thread.critical = TRUE
if wait = Mu_Locked.delete(id)
- # wait == [] ときだけ GCされるので, for w in wait は意味なし.
Thread.critical = FALSE
for w in wait
w.run
diff --git a/lib/sync.rb b/lib/sync.rb
index 9f9706d..dc54626 100644
--- a/lib/sync.rb
+++ b/lib/sync.rb
@@ -1,5 +1,5 @@
#
-# sync.rb - カウント付2-フェーズロッククラス
+# sync.rb - 2 phase lock with counter
# $Release Version: 0.2$
# $Revision$
# $Date$
@@ -54,7 +54,7 @@ module Sync_m
SH = :SH
EX = :EX
- # 例外定義
+ # exceptions
class Err < StandardError
def Err.Fail(*opt)
fail self, sprintf(self::Message, *opt)
@@ -97,7 +97,7 @@ module Sync_m
dummy = cl.new
Sync_m.extendable_module(dummy)
rescue NameError
- # newが定義されていない時は, DATAとみなす.
+ # if new is not defined, cl must be Data.
For_primitive_object
end
end
@@ -105,8 +105,8 @@ module Sync_m
def Sync_m.extend_class(cl)
return super if cl.instance_of?(Module)
- # モジュールの時は何もしない. クラスの場合, 適切なモジュールの決定
- # とaliasを行う.
+ # do nothing for Modules
+ # make aliases and include the proper module.
real = includable_module(cl)
cl.module_eval %q{
include real
@@ -267,7 +267,7 @@ module Sync_m
sync_sh_locker[Thread.current] = count + 1
ret = TRUE
when EX
- # 既に, モードがEXである時は, 必ずEXロックとなる.
+ # in EX mode, lock will upgrade to EX lock
if sync_ex_locker == Thread.current
self.sync_ex_count = sync_ex_count + 1
ret = TRUE
@@ -342,7 +342,7 @@ module Sync_m
def For_primitive_object.sync_finalize(id)
wait = Sync_Locked.delete(id)
- # waiting == [] ときだけ GCされるので, 待ち行列の解放は意味がない.
+ # need not to free waiting
end
def sync_mode