diff options
author | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-09-13 07:25:02 +0000 |
---|---|---|
committer | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-09-13 07:25:02 +0000 |
commit | 32f41748f3bb9fc0e7e9a682d67725ac2a565250 (patch) | |
tree | 41fe381eb1fb509e40dc3c9b49716fc38ecdac0c /ext/tk/lib/multi-tk.rb | |
parent | 898eabf550d0afef7f1de6829e62088e7f49f282 (diff) | |
download | ruby-32f41748f3bb9fc0e7e9a682d67725ac2a565250.tar.gz ruby-32f41748f3bb9fc0e7e9a682d67725ac2a565250.tar.xz ruby-32f41748f3bb9fc0e7e9a682d67725ac2a565250.zip |
* ext/tk/lib/multi-tk.rb: MultiTkIp.new_master and new_slave accept
safe-level value argument
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@6899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/lib/multi-tk.rb')
-rw-r--r-- | ext/tk/lib/multi-tk.rb | 64 |
1 files changed, 56 insertions, 8 deletions
diff --git a/ext/tk/lib/multi-tk.rb b/ext/tk/lib/multi-tk.rb index dea1661c6..0d82ce74b 100644 --- a/ext/tk/lib/multi-tk.rb +++ b/ext/tk/lib/multi-tk.rb @@ -934,7 +934,20 @@ class << MultiTkIp private :__new - def new_master(keys={}) + def new_master(safe=nil, keys={}) + if safe.kind_of?(Hash) + keys = safe + elsif safe.kind_of?(Integer) + raise ArgumentError, "unexpected argument(s)" unless keys.kind_of?(Hash) + if !keys.key?(:safe) && !keys.key?('safe') + keys[:safe] = safe + end + elsif safe == nil + # do nothing + else + raise ArgumentError, "unexpected argument(s)" + end + ip = __new(__getip, nil, keys) ip.eval_proc(proc{$SAFE=ip.safe_level; Proc.new}.call) if block_given? ip @@ -942,7 +955,20 @@ class << MultiTkIp alias new new_master - def new_slave(keys={}) + def new_slave(safe=nil, keys={}) + if safe.kind_of?(Hash) + keys = safe + elsif safe.kind_of?(Integer) + raise ArgumentError, "unexpected argument(s)" unless keys.kind_of?(Hash) + if !keys.key?(:safe) && !keys.key?('safe') + keys[:safe] = safe + end + elsif safe == nil + # do nothing + else + raise ArgumentError, "unexpected argument(s)" + end + ip = __new(__getip, false, keys) ip.eval_proc(proc{$SAFE=ip.safe_level; Proc.new}.call) if block_given? ip @@ -1242,21 +1268,43 @@ class MultiTkIp end private :eval_proc_core - def eval_callback(cmd = proc{$SAFE=@safe_level[0]; Proc.new}.call, *args) - eval_proc_core(false, cmd, *args) + #def eval_callback(cmd = proc{$SAFE=@safe_level[0]; Proc.new}.call, *args) + # eval_proc_core(false, cmd, *args) + #end + def eval_callback(*args) + if block_given? + eval_proc_core(false, proc{$SAFE=@safe_level[0]; Proc.new}.call, *args) + else + eval_proc_core(false, *args) + end end - def eval_proc(cmd = proc{$SAFE=@safe_level[0]; Proc.new}.call, *args) - eval_proc_core(true, cmd, *args) + #def eval_proc(cmd = proc{$SAFE=@safe_level[0]; Proc.new}.call, *args) + # eval_proc_core(true, cmd, *args) + #end + def eval_proc(*args) + if block_given? + eval_proc_core(true, proc{$SAFE=@safe_level[0]; Proc.new}.call, *args) + else + eval_proc_core(true, *args) + end end alias call eval_proc alias eval_string eval_proc end class << MultiTkIp # class method - def eval_proc(cmd = proc{$SAFE=__getip.safe_level; Proc.new}.call, *args) + # def eval_proc(cmd = proc{$SAFE=__getip.safe_level; Proc.new}.call, *args) + # # class ==> interp object + # __getip.eval_proc(cmd, *args) + # end + def eval_proc(*args) # class ==> interp object - __getip.eval_proc(cmd, *args) + if block_given? + __getip.eval_proc(proc{$SAFE=__getip.safe_level; Proc.new}.call, *args) + else + __getip.eval_proc(*args) + end end alias call eval_proc alias eval_string eval_proc |