From 20790d5cefe97b9099cdabdc83cab1eab1d409be Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Tue, 29 Dec 2015 00:13:26 +0900 Subject: [PATCH] $SAFE=2 to 4 are obsolete (ArgumentError) * lib/tk/optiondb.rb: change the safe_level from 4 to 1 * sample/cmd_res_test.rb: change the safe_level from 3 to 1 * sample/tkoptdb.rb: change the safe_level from 3 to 1 --- ext/tk/lib/tk/optiondb.rb | 8 ++++---- ext/tk/sample/cmd_res_test.rb | 8 ++++---- ext/tk/sample/tkoptdb.rb | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ext/tk/lib/tk/optiondb.rb b/ext/tk/lib/tk/optiondb.rb index ced8a11..606e63a 100644 --- a/ext/tk/lib/tk/optiondb.rb +++ b/ext/tk/lib/tk/optiondb.rb @@ -134,7 +134,7 @@ def read_with_encoding(file, f_enc=nil, pri=None) @@resource_proc_class.instance_variable_set('@method_tbl', TkCore::INTERP.create_table) @@resource_proc_class.instance_variable_set('@add_method', false) - @@resource_proc_class.instance_variable_set('@safe_mode', 4) + @@resource_proc_class.instance_variable_set('@safe_mode', 1) class << @@resource_proc_class private :new @@ -246,7 +246,7 @@ class #{klass} < TkOptionDB.module_eval('@@resource_proc_class') end end =end - def __create_new_class(klass, func, safe = 4, add = false, parent = nil) + def __create_new_class(klass, func, safe = 1, add = false, parent = nil) if klass.kind_of?(TkWindow) carrier = klass.path CmdClassID.mutex.synchronize{ @@ -342,7 +342,7 @@ def __get_random_basename # If you want to modify the new class or create a new subclass, # you must do such operation in the block parameter. # Because the created class is frozen after evaluating the block. - def new_proc_class(klass, func, safe = 4, add = false, parent = nil, &b) + def new_proc_class(klass, func, safe = 1, add = false, parent = nil, &b) new_klass = __create_new_class(klass, func, safe, add, parent) new_klass.class_eval(&b) if block_given? __remove_methods_of_proc_class(new_klass) @@ -361,7 +361,7 @@ def eval_under_random_base(parent = nil, &b) end module_function :eval_under_random_base - def new_proc_class_random(klass, func, safe = 4, add = false, &b) + def new_proc_class_random(klass, func, safe = 1, add = false, &b) eval_under_random_base(){ TkOptionDB.new_proc_class(klass, func, safe, add, self, &b) } diff --git a/ext/tk/sample/cmd_res_test.rb b/ext/tk/sample/cmd_res_test.rb index 52c5bc7..c4739de 100644 --- a/ext/tk/sample/cmd_res_test.rb +++ b/ext/tk/sample/cmd_res_test.rb @@ -4,10 +4,10 @@ File.dirname(__FILE__))) f = TkFrame.new(:class=>'BtnFrame').pack b = TkButton.new(:parent=>f, :widgetname=>'hello').pack -cmd1 = TkOptionDB.new_proc_class(b, [:show_msg, :bye_msg], 3) -cmd2 = TkOptionDB.new_proc_class(:ZZZ, [:show_msg, :bye_msg], 3, false, cmd1) -cmd3 = TkOptionDB.new_proc_class(:ZZZ, [:show_msg, :bye_msg], 3, false, b) -cmd4 = TkOptionDB.new_proc_class(:BTN_CMD, [:show_msg, :bye_msg], 3){ +cmd1 = TkOptionDB.new_proc_class(b, [:show_msg, :bye_msg], 1) +cmd2 = TkOptionDB.new_proc_class(:ZZZ, [:show_msg, :bye_msg], 1, false, cmd1) +cmd3 = TkOptionDB.new_proc_class(:ZZZ, [:show_msg, :bye_msg], 1, false, b) +cmd4 = TkOptionDB.new_proc_class(:BTN_CMD, [:show_msg, :bye_msg], 1){ def self.__check_proc_string__(str) "{|arg| print [arg, $SAFE].inspect, ': '; Proc.new#{str}.call(arg)}" end diff --git a/ext/tk/sample/tkoptdb.rb b/ext/tk/sample/tkoptdb.rb index 3fb2464..a75993a 100644 --- a/ext/tk/sample/tkoptdb.rb +++ b/ext/tk/sample/tkoptdb.rb @@ -24,7 +24,7 @@ # 'show_msg' and 'bye_msg' procedures can be defined on BTN_CMD resource. # Those procedures are called under $SAFE==2 -cmd = TkOptionDB.new_proc_class(:BTN_CMD, [:show_msg, :bye_msg], 3) { +cmd = TkOptionDB.new_proc_class(:BTN_CMD, [:show_msg, :bye_msg], 1) { # If you want to check resource string (str), # please define __check_proc_string__(str) like this. class << self -- 2.6.4