[前][次][番号順一覧][スレッド一覧]

ruby-changes:31844

From: nagai <ko1@a...>
Date: Sat, 30 Nov 2013 00:44:34 +0900 (JST)
Subject: [ruby-changes:31844] nagai:r43923 (trunk): * ext/tk/lib/tkextlib/tktable/tktable.rb: fix bug on arguments for Proc object.

nagai	2013-11-30 00:44:25 +0900 (Sat, 30 Nov 2013)

  New Revision: 43923

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43923

  Log:
    * ext/tk/lib/tkextlib/tktable/tktable.rb: fix bug on arguments for Proc object.
    
    * ext/tk/sample/scrollframe.rb: forgot a Module definition.
    
    * ext/tk/extconf.rb: check unsupported version of tclConfig.sh/tkConfig.sh. It is because current Ruby/Tk doesn't support Tcl/Tk8.6.
    
    * ext/tk/extconf.rb: change search step of Tcl/Tk libraries.
    
    * ext/tk/lib/tk/namespace.rb: instance_exec() cannot accept a script string.
    
    * ext/tk/lib/tk/msgcat.rb: bug fix on treating encodings. Now, ext/tk/sample/tkmsgcat-load_rb*.rb will work.

  Modified files:
    trunk/ext/tk/extconf.rb
    trunk/ext/tk/lib/tk/msgcat.rb
    trunk/ext/tk/lib/tk/namespace.rb
    trunk/ext/tk/lib/tkextlib/tktable/tktable.rb
    trunk/ext/tk/sample/scrollframe.rb
Index: ext/tk/sample/scrollframe.rb
===================================================================
--- ext/tk/sample/scrollframe.rb	(revision 43922)
+++ ext/tk/sample/scrollframe.rb	(revision 43923)
@@ -13,6 +13,8 @@ https://github.com/ruby/ruby/blob/trunk/ext/tk/sample/scrollframe.rb#L13
 #
 require 'tk'
 
+module Tk::RbWidget; end
+
 class Tk::RbWidget::ScrollFrame < TkFrame
   include TkComposite
 
Index: ext/tk/lib/tkextlib/tktable/tktable.rb
===================================================================
--- ext/tk/lib/tkextlib/tktable/tktable.rb	(revision 43922)
+++ ext/tk/lib/tkextlib/tktable/tktable.rb	(revision 43923)
@@ -70,7 +70,7 @@ module Tk::TkTable::ConfigMethod https://github.com/ruby/ruby/blob/trunk/ext/tk/lib/tkextlib/tktable/tktable.rb#L70
   private :__item_strval_optkeys
 
   def __item_val2ruby_optkeys(id)  # { key=>method, ... }
-    super(id).update('window'=>proc{|v| window(v)})
+    super(id).update('window'=>proc{|k,v| window(v)})
   end
   private :__item_val2ruby_optkeys
 
Index: ext/tk/lib/tk/msgcat.rb
===================================================================
--- ext/tk/lib/tk/msgcat.rb	(revision 43922)
+++ ext/tk/lib/tk/msgcat.rb	(revision 43923)
@@ -125,6 +125,8 @@ class TkMsgCatalog < TkObject https://github.com/ruby/ruby/blob/trunk/ext/tk/lib/tk/msgcat.rb#L125
 
     when 2 # src and trans, or, trans_list and enc
       if args[0].kind_of?(Array)
+        # trans_list
+        self.set_translation_list(loc, *args)
       else
         #self.set_translation(loc, args[0], Tk::UTF8_String.new(args[1]))
         self.set_translation(loc, *args)
@@ -199,7 +201,11 @@ class TkMsgCatalog < TkObject https://github.com/ruby/ruby/blob/trunk/ext/tk/lib/tk/msgcat.rb#L201
       file = File.join(dir, loc + self::MSGCAT_EXT)
       if File.readable?(file)
         count += 1
-        eval(open(file){|f| f.read})
+        if TkCore::WITH_ENCODING
+          eval(IO.read(file, :encoding=>"ASCII-8BIT"))
+        else
+          eval(IO.read(file))
+        end
       end
     }
     count
@@ -215,7 +221,11 @@ class TkMsgCatalog < TkObject https://github.com/ruby/ruby/blob/trunk/ext/tk/lib/tk/msgcat.rb#L221
       file = File.join(dir, loc + @msgcat_ext)
       if File.readable?(file)
         count += 1
-        @namespace.eval(open(file){|f| f.read})
+        if TkCore::WITH_ENCODING
+          @namespace.eval(IO.read(file, :encoding=>"ASCII-8BIT"))
+        else
+          @namespace.eval(IO.read(file))
+        end
       end
     }
     count
@@ -229,30 +239,21 @@ class TkMsgCatalog < TkObject https://github.com/ruby/ruby/blob/trunk/ext/tk/lib/tk/msgcat.rb#L239
   def self.set_translation(locale, src_str, trans_str=None, enc='utf-8')
     if trans_str && trans_str != None
       trans_str = Tk.UTF8_String(_toUTF8(trans_str, enc))
-      Tk.UTF8_String(tk_call_without_enc('::msgcat::mcset',
-                                         locale,
-                                         _get_eval_string(src_str, true),
-                                         trans_str))
+      Tk.UTF8_String(ip_eval_without_enc("::msgcat::mcset {#{locale}} {#{_get_eval_string(src_str, true)}} {#{trans_str}}"))
     else
-      Tk.UTF8_String(tk_call_without_enc('::msgcat::mcset',
-                                         locale,
-                                         _get_eval_string(src_str, true)))
+      Tk.UTF8_String(ip_eval_without_enc("::msgcat::mcset {#{locale}} {#{_get_eval_string(src_str, true)}}"))
     end
   end
   def set_translation(locale, src_str, trans_str=None, enc='utf-8')
     if trans_str && trans_str != None
       trans_str = Tk.UTF8_String(_toUTF8(trans_str, enc))
       Tk.UTF8_String(@namespace.eval{
-                       tk_call_without_enc('::msgcat::mcset',
-                                           locale,
-                                           _get_eval_string(src_str, true),
-                                           trans_str)
+                       ip_eval_without_enc("::msgcat::mcset {#{locale}} {#{_get_eval_string(src_str, true)}} {#{trans_str}}")
                      })
     else
       Tk.UTF8_String(@namespace.eval{
-                       tk_call_without_enc('::msgcat::mcset',
-                                           locale,
-                                           _get_eval_string(src_str, true))})
+                       ip_eval_without_enc("::msgcat::mcset {#{locale}} {#{_get_eval_string(src_str, true)}}")
+                     })
     end
   end
 
@@ -262,12 +263,13 @@ class TkMsgCatalog < TkObject https://github.com/ruby/ruby/blob/trunk/ext/tk/lib/tk/msgcat.rb#L263
     trans_list.each{|src, trans|
       if trans && trans != None
         list << _get_eval_string(src, true)
-        list << Tk.UTF8_Stirng(_toUTF8(trans, enc))
+        list << Tk.UTF8_String(_toUTF8(trans, enc))
       else
         list << _get_eval_string(src, true) << ''
       end
     }
-    number(tk_call_without_enc('::msgcat::mcmset', locale, list))
+    #number(tk_call_without_enc('::msgcat::mcmset', locale, list))
+    number(ip_eval_without_enc("::msgcat::mcmset {#{locale}} {#{_get_eval_string(list)}}"))
   end
   def set_translation_list(locale, trans_list, enc='utf-8')
     # trans_list ::= [ [src, trans], [src, trans], ... ]
@@ -281,7 +283,8 @@ class TkMsgCatalog < TkObject https://github.com/ruby/ruby/blob/trunk/ext/tk/lib/tk/msgcat.rb#L283
       end
     }
     number(@namespace.eval{
-             tk_call_without_enc('::msgcat::mcmset', locale, list)
+             #tk_call_without_enc('::msgcat::mcmset', locale, list)
+             ip_eval_without_enc("::msgcat::mcmset {#{locale}} {#{_get_eval_string(list)}}")
            })
   end
 
Index: ext/tk/lib/tk/namespace.rb
===================================================================
--- ext/tk/lib/tk/namespace.rb	(revision 43922)
+++ ext/tk/lib/tk/namespace.rb	(revision 43923)
@@ -325,12 +325,7 @@ class TkNamespace < TkObject https://github.com/ruby/ruby/blob/trunk/ext/tk/lib/tk/namespace.rb#L325
   def code(script = Proc.new)
     if script.kind_of?(String)
       cmd = proc{|*args|
-        if TkCore::WITH_RUBY_VM  ### Ruby 1.9 !!!!
-          obj = ScopeArgs.new(@fullname,*args)
-          ret = obj.instance_exec(obj, script)
-        else
-          ret = ScopeArgs.new(@fullname,*args).instance_eval(script)
-        end
+        ret = ScopeArgs.new(@fullname,*args).instance_eval(script)
         id = ret.object_id
         TkNamespace::Tk_NsCode_RetObjID_TBL[id] = ret
         id
Index: ext/tk/extconf.rb
===================================================================
--- ext/tk/extconf.rb	(revision 43922)
+++ ext/tk/extconf.rb	(revision 43923)
@@ -11,10 +11,18 @@ TkLib_Config['search_versions'] = https://github.com/ruby/ruby/blob/trunk/ext/tk/extconf.rb#L11
   # %w[8.7 8.6 8.5 8.4 8.0] # to shorten search steps
   %w[8.5 8.4] # At present, Tcl/Tk8.6 is not supported.
 
+TkLib_Config['unsupported_versions'] =
+  %w[8.8 8.7 8.6] # At present, Tcl/Tk8.6 is not supported.
+
 TkLib_Config['major_nums'] = '87'
 
 
 ##############################################################
+
+TkLib_Config['enable-shared'] = enable_config("shared")
+
+
+##############################################################
 # use old extconf.rb ?
 ##############################################################
 if with_config('tk-old-extconf')
@@ -543,13 +551,13 @@ end https://github.com/ruby/ruby/blob/trunk/ext/tk/extconf.rb#L551
 
 def get_ext_list()
   exts = [CONFIG['DLEXT']]
-  exts.concat %w(dll lib) if is_win32?
+  exts.concat %w(dll) if is_win32?
   exts.concat %w(bundle dylib) if is_macosx?
 
-  if enable_config("shared") == false
-    [CONFIG['LIBEXT'], "a"].concat exts
-  else
-    exts.concat [CONFIG['LIBEXT'], "a"]
+  if TkLib_Config["tcltk-stubs"] || TkLib_Config['enable-shared'] == false
+    exts.unshift "lib" if is_win32?
+    exts.unshift "a"
+    exts.unshift CONFIG['LIBEXT']
   end
 
   if is_win32?
@@ -786,10 +794,20 @@ def search_tclConfig(*paths) # libdir li https://github.com/ruby/ruby/blob/trunk/ext/tk/extconf.rb#L794
 
       # parse tclConfig.sh/tkConfig.sh
       tclconf = (tclpath)? parse_tclConfig(tclpath): nil
-      next if tclconf && tclver && ((tclver_major && tclver_major != tclconf['TCL_MAJOR_VERSION']) || (tclver_minor && tclver_minor != tclconf['TCL_MINOR_VERSION']))
+      if tclconf
+        next if tclver && ((tclver_major && tclver_major != tclconf['TCL_MAJOR_VERSION']) || (tclver_minor && tclver_minor != tclconf['TCL_MINOR_VERSION']))
+        next if TkLib_Config['unsupported_versions'].find{|ver|
+          ver == "#{tclconf['TCL_MAJOR_VERSION']}.#{tclconf['TCL_MINOR_VERSION']}"
+        }
+      end
 
       tkconf = (tkpath)? parse_tclConfig(tkpath): nil
-      next if tkconf && tkver && ((tkver_major && tkver_major != tkconf['TK_MAJOR_VERSION']) || (tkver_minor && tkver_minor != tkconf['TK_MINOR_VERSION']))
+      if tkconf
+        next if tkver && ((tkver_major && tkver_major != tkconf['TK_MAJOR_VERSION']) || (tkver_minor && tkver_minor != tkconf['TK_MINOR_VERSION']))
+        next if TkLib_Config['unsupported_versions'].find{|ver|
+          ver == "#{tkconf['TK_MAJOR_VERSION']}.#{tkconf['TK_MINOR_VERSION']}"
+        }
+      end
 
       # nativethread check
       if !TkLib_Config["ruby_with_thread"]
@@ -1292,6 +1310,10 @@ end https://github.com/ruby/ruby/blob/trunk/ext/tk/extconf.rb#L1310
 def find_tcltk_library(tcllib, tklib, stubs, tclversion, tkversion,
                        tcl_opt_paths, tk_opt_paths)
   st,path,lib,libs,*inc = find_tcl(tcllib, stubs, tclversion, *tcl_opt_paths)
+  if !st && TkLib_Config['enable-shared'] == nil
+    TkLib_Config['enable-shared'] = false
+    st,path,lib,libs,*inc = find_tcl(tcllib, stubs, tclversion, *tcl_opt_paths)
+  end
   unless st
     puts("Warning:: cannot find Tcl library. tcltklib will not be compiled (tcltklib is disabled on your Ruby. That is, Ruby/Tk will not work). Please check configure options.")
     return false
@@ -1304,6 +1326,10 @@ def find_tcltk_library(tcllib, tklib, st https://github.com/ruby/ruby/blob/trunk/ext/tk/extconf.rb#L1326
   end
 
   st,path,lib,libs,*inc = find_tk(tklib, stubs, tkversion, *tk_opt_paths)
+  if !st && TkLib_Config['enable-shared'] == nil
+    TkLib_Config['enable-shared'] = false
+    st,path,lib,libs,*inc = find_tk(tklib, stubs, tkversion, *tk_opt_paths)
+  end
   unless st
     puts("Warning:: cannot find Tk library. tcltklib will not be compiled (tcltklib is disabled on your Ruby. That is, Ruby/Tk will not work). Please check configure options.")
     return false

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]