diff -urN ruby-2.1.3.orig/ext/tk/extconf.rb ruby-2.1.3/ext/tk/extconf.rb --- ruby-2.1.3.orig/ext/tk/extconf.rb 2013-11-30 11:46:47.000000000 +0900 +++ ruby-2.1.3/ext/tk/extconf.rb 2014-10-19 17:50:33.045820645 +0900 @@ -9,10 +9,10 @@ # %w[8.9 8.8 8.7 8.6 8.5 8.4 8.3 8.2 8.1 8.0 7.6 4.2] # %w[8.7 8.6 8.5 8.4 8.3 8.2 8.1 8.0] # %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. + %w[8.6 8.5 8.4] TkLib_Config['unsupported_versions'] = - %w[8.8 8.7 8.6] # At present, Tcl/Tk8.6 is not supported. + %w[8.8 8.7] TkLib_Config['major_nums'] = '87' diff -urN ruby-2.1.3.orig/ext/tk/lib/tk/autoload.rb ruby-2.1.3/ext/tk/lib/tk/autoload.rb --- ruby-2.1.3.orig/ext/tk/lib/tk/autoload.rb 2011-05-15 20:55:52.000000000 +0900 +++ ruby-2.1.3/ext/tk/lib/tk/autoload.rb 2014-10-19 17:48:59.049874246 +0900 @@ -94,6 +94,8 @@ autoload :Y_Scrollable, 'tk/scrollable' autoload :Scrollable, 'tk/scrollable' + autoload :Fontchooser, 'tk/fontchooser' + autoload :Wm, 'tk/wm' autoload :Wm_for_General, 'tk/wm' diff -urN ruby-2.1.3.orig/ext/tk/lib/tk/fontchooser.rb ruby-2.1.3/ext/tk/lib/tk/fontchooser.rb --- ruby-2.1.3.orig/ext/tk/lib/tk/fontchooser.rb 2011-05-15 20:55:52.000000000 +0900 +++ ruby-2.1.3/ext/tk/lib/tk/fontchooser.rb 2014-10-19 17:48:59.048874118 +0900 @@ -8,6 +8,10 @@ extend TkCore end +module Tk + Fontchooser = TkFont::Chooser +end + class << TkFont::Chooser def method_missing(id, *args) name = id.id2name diff -urN ruby-2.1.3.orig/ext/tk/lib/tk/tk_mac.rb ruby-2.1.3/ext/tk/lib/tk/tk_mac.rb --- ruby-2.1.3.orig/ext/tk/lib/tk/tk_mac.rb 1970-01-01 09:00:00.000000000 +0900 +++ ruby-2.1.3/ext/tk/lib/tk/tk_mac.rb 2014-10-19 17:48:59.048874118 +0900 @@ -0,0 +1,158 @@ +# +# tk/tk_mac.rb : Access Mac-Specific functionality on OS X from Tk +# (supported by Tk8.6 or later) +# +# ATTENTION !! +# This is NOT TESTED. Because I have no test-environment. +# +require 'tk' + +module Tk + module Mac + end +end + +module Tk::Mac + extend TkCore + + # event handler callbacks + def self.def_ShowPreferences(cmd=Proc.new) + ip_eval("proc ::tk::mac::ShowPreferences {} { #{install_cmd(cmd)} }") + nil + end + + def self.def_OpenApplication(cmd=Proc.new) + ip_eval("proc ::tk::mac::OpenApplication {} { #{install_cmd(cmd)} }") + nil + end + + def self.def_ReopenApplication(cmd=Proc.new) + ip_eval("proc ::tk::mac::ReopenApplication {} { #{install_cmd(cmd)} }") + nil + end + + def self.def_OpenDocument(cmd=Proc.new) + ip_eval("proc ::tk::mac::OpenDocument {args} { eval #{install_cmd(cmd)} $args }") + nil + end + + def self.def_PrintDocument(cmd=Proc.new) + ip_eval("proc ::tk::mac::PrintDocument {args} { eval #{install_cmd(cmd)} $args }") + nil + end + + def self.def_Quit(cmd=Proc.new) + ip_eval("proc ::tk::mac::Quit {} { #{install_cmd(cmd)} }") + nil + end + + def self.def_OnHide(cmd=Proc.new) + ip_eval("proc ::tk::mac::OnHide {} { #{install_cmd(cmd)} }") + nil + end + + def self.def_OnShow(cmd=Proc.new) + ip_eval("proc ::tk::mac::OnShow {} { #{install_cmd(cmd)} }") + nil + end + + def self.def_ShowHelp(cmd=Proc.new) + ip_eval("proc ::tk::mac::ShowHelp {} { #{install_cmd(cmd)} }") + nil + end + + + # additional dialogs + def self.standardAboutPanel + tk_call('::tk::mac::standardAboutPanel') + nil + end + + + # system configuration + def self.useCompatibilityMetrics(mode) + tk_call('::tk::mac::useCompatibilityMetrics', mode) + nil + end + + def self.CGAntialiasLimit(limit) + tk_call('::tk::mac::CGAntialiasLimit', limit) + nil + end + + def self.antialiasedtext(num) + tk_call('::tk::mac::antialiasedtext', num) + nil + end + + def self.useThemedToplevel(mode) + tk_call('::tk::mac::useThemedToplevel', mode) + nil + end + +end + +class Tk::Mac::IconBitmap < TkImage + TkCommandNames = ['::tk::mac::iconBitmap'].freeze + + def self.new(width, height, keys) + if keys.kind_of?(Hash) + name = nil + if keys.key?(:imagename) + name = keys[:imagename] + elsif keys.key?('imagename') + name = keys['imagename'] + end + if name + if name.kind_of?(TkImage) + obj = name + else + name = _get_eval_string(name) + obj = nil + Tk_IMGTBL.mutex.synchronize{ + obj = Tk_IMGTBL[name] + } + end + if obj + if !(keys[:without_creating] || keys['without_creating']) + keys = _symbolkey2str(keys) + keys.delete('imagename') + keys.delete('without_creating') + obj.instance_eval{ + tk_call_without_enc('::tk::mac::iconBitmap', + @path, width, height, *hash_kv(keys, true)) + } + end + return obj + end + end + end + (obj = self.allocate).instance_eval{ + Tk_IMGTBL.mutex.synchronize{ + initialize(width, height, keys) + Tk_IMGTBL[@path] = self + } + } + obj + end + + def initialize(width, height, keys) + @path = nil + without_creating = false + if keys.kind_of?(Hash) + keys = _symbolkey2str(keys) + @path = keys.delete('imagename') + without_creating = keys.delete('without_creating') + end + unless @path + Tk_Image_ID.mutex.synchronize{ + @path = Tk_Image_ID.join(TkCore::INTERP._ip_id_) + Tk_Image_ID[1].succ! + } + end + unless without_creating + tk_call_without_enc('::tk::mac::iconBitmap', + @path, width, height, *hash_kv(keys, true)) + end + end +end diff -urN ruby-2.1.3.orig/ext/tk/lib/tk.rb ruby-2.1.3/ext/tk/lib/tk.rb --- ruby-2.1.3.orig/ext/tk/lib/tk.rb 2011-05-27 08:36:33.000000000 +0900 +++ ruby-2.1.3/ext/tk/lib/tk.rb 2014-10-19 17:48:59.046873862 +0900 @@ -1309,8 +1309,12 @@ end unless interp.deleted? - #Thread.current[:status].value = TclTkLib.mainloop(false) - Thread.current[:status].value = interp.mainloop(false) + begin + #Thread.current[:status].value = TclTkLib.mainloop(false) + Thread.current[:status].value = interp.mainloop(false) + rescue Exception=>e + puts "ignore exception on interp: #{e.inspect}\n" if $DEBUG + end end ensure @@ -1569,7 +1573,15 @@ EOL =end - at_exit{ INTERP.remove_tk_procs(TclTkLib::FINALIZE_PROC_NAME) } + if !WITH_RUBY_VM || RUN_EVENTLOOP_ON_MAIN_THREAD ### check Ruby 1.9 !!!!!!! + at_exit{ INTERP.remove_tk_procs(TclTkLib::FINALIZE_PROC_NAME) } + else + at_exit{ + Tk.root.destroy + INTERP.remove_tk_procs(TclTkLib::FINALIZE_PROC_NAME) + INTERP_THREAD.kill.join + } + end EventFlag = TclTkLib::EventFlag @@ -5197,6 +5209,8 @@ TkWinfo.exist?(self) end + alias subcommand tk_send + def bind_class @db_class || self.class() end @@ -5742,7 +5756,7 @@ #Tk.freeze module Tk - RELEASE_DATE = '2010-06-03'.freeze + RELEASE_DATE = '2014-10-19'.freeze autoload :AUTO_PATH, 'tk/variable' autoload :TCL_PACKAGE_PATH, 'tk/variable' diff -urN ruby-2.1.3.orig/ext/tk/lib/tkextlib/tcllib/validator.rb ruby-2.1.3/ext/tk/lib/tkextlib/tcllib/validator.rb --- ruby-2.1.3.orig/ext/tk/lib/tkextlib/tcllib/validator.rb 1970-01-01 09:00:00.000000000 +0900 +++ ruby-2.1.3/ext/tk/lib/tkextlib/tcllib/validator.rb 2014-10-19 17:48:59.046873862 +0900 @@ -0,0 +1,65 @@ +# +# tkextlib/tcllib/validator.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# +# * Part of tcllib extension +# * Provides a unified validation API +# + +require 'tk' +require 'tkextlib/tcllib.rb' + +# TkPackage.require('widget::validator', '0.1') +TkPackage.require('widget::validator') + +module Tk::Tcllib + module Validator + PACKAGE_NAME = 'widget::validator'.freeze + def self.package_name + PACKAGE_NAME + end + + def self.package_version + begin + TkPackage.require('widget::validator') + rescue + '' + end + end + end +end + +module Tk::Tcllib::Validator + extend TkCore + + def self.attach(widget, color, cmd=Proc.new) + tk_call_without_enc('::widget::validator', 'attach', widget, color, cmd) + nil + end + + def self.detach(widget) + tk_call_without_enc('::widget::validator', 'detach', widget) + nil + end + + def self.validate(widget) + tk_call_without_enc('::widget::validator', 'validate', widget) + nil + end + + def attach_validator(color, cmd=Proc.new) + tk_call_without_enc('::widget::validator', 'attach', @path, color, cmd) + self + end + + def detach_validator(color, cmd=Proc.new) + tk_call_without_enc('::widget::validator', 'detach', @path) + self + end + + def invoke_validator(color, cmd=Proc.new) + tk_call_without_enc('::widget::validator', 'validate', @path) + self + end + alias validate_validator invoke_validator +end diff -urN ruby-2.1.3.orig/ext/tk/lib/tkextlib/tile/treeview.rb ruby-2.1.3/ext/tk/lib/tkextlib/tile/treeview.rb --- ruby-2.1.3.orig/ext/tk/lib/tkextlib/tile/treeview.rb 2009-10-02 19:45:39.000000000 +0900 +++ ruby-2.1.3/ext/tk/lib/tkextlib/tile/treeview.rb 2014-10-19 21:29:05.432337542 +0900 @@ -986,6 +986,18 @@ end alias added? tag_has? + def tag_has + @t.tag_has(@id) + end + + def add(*items) + @t.tag_add(@id, *items) + end + + def remove(*items) + @t.tag_remove(@id, *items) + end + def bind(seq, *args) if TkComm._callback_entry?(args[0]) || !block_given? cmd = args.shift @@ -1299,6 +1311,24 @@ _bindinfo([@path, 'tag', 'bind', tag], context) end alias tagbindinfo tag_bindinfo + + def tag_names + tk_split_simplelist(tk_send('tag', 'names')).collect{|id| + Tk::Tile::Treeview::Tag.id2obj(self, id) + } + end + + def tag_add(tag, *items) + fail ArgumentError, "no target items" if items.empty? + tk_send('tag', 'add', tagid(tag), *(items.collect{|item| tagid(item)})) + self + end + + def tag_remove(tag, *items) + tk_send('tag', 'remove', tagid(tag), *(items.collect{|item| tagid(item)})) + self + end + end #Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Treeview, :TkTreeview) diff -urN ruby-2.1.3.orig/ext/tk/lib/tkextlib/tkimg/dted.rb ruby-2.1.3/ext/tk/lib/tkextlib/tkimg/dted.rb --- ruby-2.1.3.orig/ext/tk/lib/tkextlib/tkimg/dted.rb 1970-01-01 09:00:00.000000000 +0900 +++ ruby-2.1.3/ext/tk/lib/tkextlib/tkimg/dted.rb 2014-10-19 17:48:59.047873990 +0900 @@ -0,0 +1,33 @@ +# +# TkImg - format 'DTED' +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# +require 'tk' + +# call setup script for general 'tkextlib' libraries +require 'tkextlib/setup.rb' + +# call setup script +require 'tkextlib/tkimg/setup.rb' + +# TkPackage.require('img::dted', '1.4') +TkPackage.require('img::dted') + +module Tk + module Img + module DTED + PACKAGE_NAME = 'img::dted'.freeze + def self.package_name + PACKAGE_NAME + end + + def self.package_version + begin + TkPackage.require('img::dted') + rescue + '' + end + end + end + end +end diff -urN ruby-2.1.3.orig/ext/tk/lib/tkextlib/tkimg/raw.rb ruby-2.1.3/ext/tk/lib/tkextlib/tkimg/raw.rb --- ruby-2.1.3.orig/ext/tk/lib/tkextlib/tkimg/raw.rb 1970-01-01 09:00:00.000000000 +0900 +++ ruby-2.1.3/ext/tk/lib/tkextlib/tkimg/raw.rb 2014-10-19 17:48:59.047873990 +0900 @@ -0,0 +1,33 @@ +# +# TkImg - format 'Raw Data' +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# +require 'tk' + +# call setup script for general 'tkextlib' libraries +require 'tkextlib/setup.rb' + +# call setup script +require 'tkextlib/tkimg/setup.rb' + +# TkPackage.require('img::raw', '1.4') +TkPackage.require('img::raw') + +module Tk + module Img + module Raw + PACKAGE_NAME = 'img::raw'.freeze + def self.package_name + PACKAGE_NAME + end + + def self.package_version + begin + TkPackage.require('img::raw') + rescue + '' + end + end + end + end +end diff -urN ruby-2.1.3.orig/ext/tk/tcltklib.c ruby-2.1.3/ext/tk/tcltklib.c --- ruby-2.1.3.orig/ext/tk/tcltklib.c 2014-02-10 20:45:14.000000000 +0900 +++ ruby-2.1.3/ext/tk/tcltklib.c 2014-10-19 19:17:00.014057636 +0900 @@ -6012,7 +6012,12 @@ Tcl_CmdInfo info; int ret; + DUMP1("call ip_rbNamespaceObjCmd"); + DUMP2("objc = %d", objc); + DUMP2("objv[0] = '%s'", Tcl_GetString(objv[0])); + DUMP2("objv[1] = '%s'", Tcl_GetString(objv[1])); if (!Tcl_GetCommandInfo(interp, "__orig_namespace_command__", &(info))) { + DUMP1("fail to get __orig_namespace_command__"); Tcl_ResetResult(interp); Tcl_AppendResult(interp, "invalid command name \"namespace\"", (char*)NULL); @@ -6020,15 +6025,38 @@ } rbtk_eventloop_depth++; - /* DUMP2("namespace wrapper enter depth == %d", rbtk_eventloop_depth); */ + DUMP2("namespace wrapper enter depth == %d", rbtk_eventloop_depth); if (info.isNativeObjectProc) { +#if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION < 6 + DUMP1("call a native-object-proc"); ret = (*(info.objProc))(info.objClientData, interp, objc, objv); +#else + /* Tcl8.6 or later */ + int i; + Tcl_Obj **cp_objv; + char org_ns_cmd_name[] = "__orig_namespace_command__"; + + DUMP1("call a native-object-proc for tcl8.6 or later"); + cp_objv = RbTk_ALLOC_N(Tcl_Obj *, (objc + 1)); + + cp_objv[0] = Tcl_NewStringObj(org_ns_cmd_name, strlen(org_ns_cmd_name)); + for(i = 1; i < objc; i++) { + cp_objv[i] = objv[i]; + } + cp_objv[objc] = (Tcl_Obj *)NULL; + + /* ret = Tcl_EvalObjv(interp, objc, cp_objv, TCL_EVAL_DIRECT); */ + ret = Tcl_EvalObjv(interp, objc, cp_objv, 0); + + ckfree((char*)cp_objv); +#endif } else { /* string interface */ int i; char **argv; + DUMP1("call with the string-interface"); /* argv = (char **)Tcl_Alloc(sizeof(char *) * (objc + 1)); */ argv = RbTk_ALLOC_N(char *, (objc + 1)); #if 0 /* use Tcl_Preserve/Release */ @@ -6056,9 +6084,10 @@ #endif } - /* DUMP2("namespace wrapper exit depth == %d", rbtk_eventloop_depth); */ + DUMP2("namespace wrapper exit depth == %d", rbtk_eventloop_depth); rbtk_eventloop_depth--; + DUMP1("end of ip_rbNamespaceObjCmd"); return ret; } #endif @@ -6068,6 +6097,8 @@ Tcl_Interp *interp; { #if TCL_MAJOR_VERSION >= 8 + +#if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION < 6 Tcl_CmdInfo orig_info; if (!Tcl_GetCommandInfo(interp, "namespace", &(orig_info))) { @@ -6084,6 +6115,11 @@ orig_info.deleteProc); } +#else /* tcl8.6 or later */ + Tcl_GlobalEval(interp, "rename namespace __orig_namespace_command__"); + +#endif + Tcl_CreateObjCommand(interp, "namespace", ip_rbNamespaceObjCmd, (ClientData) 0, (Tcl_CmdDeleteProc *)NULL); #endif @@ -8448,15 +8484,28 @@ #endif { struct invoke_info *inf = (struct invoke_info *)arg; + +#if TCL_MAJOR_VERSION >= 8 && TCL_MINOR_VERSION < 6 int i, len; -#if TCL_MAJOR_VERSION >= 8 int argc = inf->objc; char **argv = (char **)NULL; #endif + DUMP1("call invoke_tcl_proc"); + +#if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 6) + + /* eval */ + inf->ptr->return_value = Tcl_EvalObjv(inf->ptr->ip, inf->objc, inf->objv, TCL_EVAL_DIRECT); + /* inf->ptr->return_value = Tcl_EvalObjv(inf->ptr->ip, inf->objc, inf->objv, 0); */ + +#else /* Tcl/Tk 7.x, 8.0 -- 8.5 */ + /* memory allocation for arguments of this command */ -#if TCL_MAJOR_VERSION >= 8 +#if TCL_MAJOR_VERSION == 8 + /* Tcl/Tk 8.0 -- 8.5 */ if (!inf->cmdinfo.isNativeObjectProc) { + DUMP1("called proc is not a native-obj-proc"); /* string interface */ /* argv = (char **)ALLOC_N(char *, argc+1);*/ /* XXXXXXXXXX */ argv = RbTk_ALLOC_N(char *, (argc+1)); @@ -8470,11 +8519,14 @@ } #endif + DUMP1("reset result of tcl-interp"); Tcl_ResetResult(inf->ptr->ip); /* Invoke the C procedure */ -#if TCL_MAJOR_VERSION >= 8 +#if TCL_MAJOR_VERSION == 8 + /* Tcl/Tk 8.0 -- 8.5 */ if (inf->cmdinfo.isNativeObjectProc) { + DUMP1("call tcl_proc as a native-obj-proc"); inf->ptr->return_value = (*(inf->cmdinfo.objProc))(inf->cmdinfo.objClientData, inf->ptr->ip, inf->objc, inf->objv); @@ -8482,7 +8534,9 @@ else #endif { -#if TCL_MAJOR_VERSION >= 8 +#if TCL_MAJOR_VERSION == 8 + /* Tcl/Tk 8.0 -- 8.5 */ + DUMP1("call tcl_proc as not a native-obj-proc"); inf->ptr->return_value = (*(inf->cmdinfo.proc))(inf->cmdinfo.clientData, inf->ptr->ip, argc, (CONST84 char **)argv); @@ -8505,6 +8559,9 @@ #endif } +#endif /* Tcl/Tk 8.6 or later || Tcl 7.x, 8.0 -- 8.5 */ + + DUMP1("end of invoke_tcl_proc"); return Qnil; } @@ -8644,7 +8701,9 @@ #endif /* invoke tcl-proc */ + DUMP1("invoke tcl-proc"); rb_protect(invoke_tcl_proc, (VALUE)&inf, &status); + DUMP2("status of tcl-proc, %d", status); switch(status) { case TAG_RAISE: if (NIL_P(rb_errinfo())) {