From 32f41748f3bb9fc0e7e9a682d67725ac2a565250 Mon Sep 17 00:00:00 2001 From: nagai Date: Mon, 13 Sep 2004 07:25:02 +0000 Subject: * 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 --- ext/tk/sample/tkoptdb-safeTk.rb | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'ext/tk/sample') diff --git a/ext/tk/sample/tkoptdb-safeTk.rb b/ext/tk/sample/tkoptdb-safeTk.rb index ebbc7b486..b41c856d5 100644 --- a/ext/tk/sample/tkoptdb-safeTk.rb +++ b/ext/tk/sample/tkoptdb-safeTk.rb @@ -4,15 +4,16 @@ require 'multi-tk' TkMessage.new(:text => < ", ip.eval_proc{$SAFE}, "\n" + +ret = ip.eval_proc{ # When a block is given to 'eval_proc' method, # the block is evaluated on the IP's current safe level. - # So, the followings raises exceptions. + # So, the followings raises an exception. + # An Exception object of the exception is returned as a + # return value of this method. + load file } -=end +print "ip.eval_proc{}, which includes insecure operiation in the given block, returns an exception object: ", ret.inspect, "\n" + +print "If a proc object is given, the proc is evaluated on the safe-level which is kept on the proc :: ip.eval_proc( proc{$SAFE} ) ==> ", ip.eval_proc(proc{$SAFE}), "\n" -ip.eval_proc(proc{ - # When a Procedure object is given to 'eval_proc' method as an argument, - # the proc is evaluated on the proc's binding. - # So, the followings are evaluated on $SAFE==0 +safe0_cmd = Proc.new{ + # This proc object keeps current safe-level ($SAFE==0). load file -}) +} +ip.eval_proc(safe0_cmd) + # Tk.mainloop is ignored on the slave-IP -- cgit