diff options
author | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-07-28 09:15:37 +0000 |
---|---|---|
committer | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-07-28 09:15:37 +0000 |
commit | 35f3e20164b3a0b277ec9e95d3761e0af7cc84c0 (patch) | |
tree | f62d57e4fd368ad5aa9afc2e4bfc4e34b89f2b27 /ext/tk | |
parent | 28fc2f242c32ad581384848645283310a686faf4 (diff) | |
download | ruby-35f3e20164b3a0b277ec9e95d3761e0af7cc84c0.tar.gz ruby-35f3e20164b3a0b277ec9e95d3761e0af7cc84c0.tar.xz ruby-35f3e20164b3a0b277ec9e95d3761e0af7cc84c0.zip |
* ext/tcltklib/stubs.c: When --enable-tcltk-stubs, the initialize
routine creates a Tcl/Tk interpreter and deletes it. However,
init cost of Tk's MainWindow is not so small. And that makes it
impossible to use libraries written with Tcl functions only on
an environment without a graphical display. This changes support
delaying initalization of Tk_Stubs until the script needs Tk.
* ext/tcltklib/stubs.h: New file. Define prototypes and return
codes of functions on stubs.c.
* ext/tcltklib/tcltklib.c: Support delaying initalization of
Tk_Stubs until the script needs Tk.
* ext/tcltklib/tcltklib.c: Show friendly error messages for errors
on initialization.
* ext/tcltklib/tcltklib.c: Avoid SEGV on ip_finalize() when ruby is
exiting and $DEBUG is true. (Not fix. If you know the reason of
why, please fix it.)
* ext/tk/tkutil.c (ary2list, ary2list2): bug fix on handling of
encoding.
* ext/tk/lib/multi-tk.rb: MultiTkIp#eval_string and bg_eval_string
don't work propery.
* ext/tk/lib/tk.rb: Forget extending Tk::Encoding module to Tk.
* ext/tk/lib/tk/variable.rb: TkVarAccess fails to initialize the
object for an element of a Tcl's array variable.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@8861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk')
-rw-r--r-- | ext/tk/lib/multi-tk.rb | 4 | ||||
-rw-r--r-- | ext/tk/lib/tk.rb | 4 | ||||
-rw-r--r-- | ext/tk/lib/tk/variable.rb | 11 | ||||
-rw-r--r-- | ext/tk/sample/tktree.rb | 2 | ||||
-rw-r--r-- | ext/tk/tkutil.c | 26 |
5 files changed, 33 insertions, 14 deletions
diff --git a/ext/tk/lib/multi-tk.rb b/ext/tk/lib/multi-tk.rb index 8ef3aa62b..c82fa8f4e 100644 --- a/ext/tk/lib/multi-tk.rb +++ b/ext/tk/lib/multi-tk.rb @@ -1579,7 +1579,7 @@ class MultiTkIp proc{|safe| $SAFE=safe if $SAFE < safe Kernel.eval(cmd, *eval_args) - }, safe_level) + }) end alias eval_str eval_string @@ -1593,7 +1593,7 @@ class MultiTkIp proc{|safe| $SAFE=safe if $SAFE < safe Kernel.eval(cmd, *eval_args) - }, safe_level) + }) } end alias background_eval_string bg_eval_string diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index 174d34cea..37f311c6f 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -2325,6 +2325,8 @@ else end alias encoding_convert_to encoding_convertto end + + extend Encoding end end @@ -4199,7 +4201,7 @@ end #Tk.freeze module Tk - RELEASE_DATE = '2005-07-25'.freeze + RELEASE_DATE = '2005-07-28'.freeze autoload :AUTO_PATH, 'tk/variable' autoload :TCL_PACKAGE_PATH, 'tk/variable' diff --git a/ext/tk/lib/tk/variable.rb b/ext/tk/lib/tk/variable.rb index 4cf2eae8e..33cf603a9 100644 --- a/ext/tk/lib/tk/variable.rb +++ b/ext/tk/lib/tk/variable.rb @@ -1531,7 +1531,16 @@ class TkVarAccess<TkVariable @element_type = Hash.new{|k,v| var.default_value_type } # teach Tk-ip that @id is global var - INTERP._invoke_without_enc('global', @id) + begin + INTERP._invoke_without_enc('global', @id) + rescue => e + if @id =~ /^(.+)\([^()]+\)$/ + # is an element --> varname == $1 + INTERP._invoke_without_enc('global', $1) + else + fail e + end + end if val if val.kind_of?(Hash) diff --git a/ext/tk/sample/tktree.rb b/ext/tk/sample/tktree.rb index d16d3344b..56b7211c8 100644 --- a/ext/tk/sample/tktree.rb +++ b/ext/tk/sample/tktree.rb @@ -25,7 +25,7 @@ class TkTree < TkCanvas end begin tk_call('::tktree::treecreate', *args) - rescue NameError + rescue NameError, RuntimeError Tk.load_tclscript(TkTree::TCL_SCRIPT_PATH) tk_call('::tktree::treecreate', *args) end diff --git a/ext/tk/tkutil.c b/ext/tk/tkutil.c index 496649f8c..f191eb162 100644 --- a/ext/tk/tkutil.c +++ b/ext/tk/tkutil.c @@ -8,7 +8,7 @@ ************************************************/ -#define TKUTIL_RELEASE_DATE "2005-07-22" +#define TKUTIL_RELEASE_DATE "2005-07-28" #include "ruby.h" #include "rubysig.h" @@ -246,16 +246,20 @@ ary2list(ary, enc_flag, self) volatile VALUE sys_enc, dst_enc, str_enc; sys_enc = rb_funcall(cTclTkLib, ID_encoding, 0, 0); - if NIL_P(sys_enc) { + if (NIL_P(sys_enc)) { sys_enc = rb_funcall(cTclTkLib, ID_encoding_system, 0, 0); + sys_enc = rb_funcall(sys_enc, ID_to_s, 0, 0); } if NIL_P(enc_flag) { dst_enc = sys_enc; req_chk_flag = 1; - } else { + } else if (TYPE(enc_flag) == T_TRUE || TYPE(enc_flag) == T_FALSE) { dst_enc = enc_flag; req_chk_flag = 0; + } else { + dst_enc = rb_funcall(enc_flag, ID_to_s, 0, 0); + req_chk_flag = 0; } /* size = RARRAY(ary)->len; */ @@ -280,7 +284,7 @@ ary2list(ary, enc_flag, self) if (req_chk_flag) { str_enc = rb_ivar_get(str_val, ID_at_enc); - if NIL_P(str_enc) { + if (!NIL_P(str_enc)) { str_enc = rb_funcall(str_enc, ID_to_s, 0, 0); } else { str_enc = sys_enc; @@ -327,7 +331,7 @@ ary2list(ary, enc_flag, self) if (req_chk_flag) { str_enc = rb_ivar_get(str_val, ID_at_enc); - if NIL_P(str_enc) { + if (!NIL_P(str_enc)) { str_enc = rb_funcall(str_enc, ID_to_s, 0, 0); } else { str_enc = sys_enc; @@ -347,7 +351,7 @@ ary2list(ary, enc_flag, self) if (req_chk_flag) { str_enc = rb_ivar_get(str_val, ID_at_enc); - if NIL_P(str_enc) { + if (!NIL_P(str_enc)) { str_enc = rb_funcall(str_enc, ID_to_s, 0, 0); } else { str_enc = sys_enc; @@ -398,14 +402,18 @@ ary2list2(ary, enc_flag, self) sys_enc = rb_funcall(cTclTkLib, ID_encoding, 0, 0); if NIL_P(sys_enc) { sys_enc = rb_funcall(cTclTkLib, ID_encoding_system, 0, 0); + sys_enc = rb_funcall(sys_enc, ID_to_s, 0, 0); } if NIL_P(enc_flag) { dst_enc = sys_enc; req_chk_flag = 1; - } else { + } else if (TYPE(enc_flag) == T_TRUE || TYPE(enc_flag) == T_FALSE) { dst_enc = enc_flag; req_chk_flag = 0; + } else { + dst_enc = rb_funcall(enc_flag, ID_to_s, 0, 0); + req_chk_flag = 0; } size = RARRAY(ary)->len; @@ -438,7 +446,7 @@ ary2list2(ary, enc_flag, self) if (req_chk_flag) { str_enc = rb_ivar_get(str_val, ID_at_enc); - if NIL_P(str_enc) { + if (!NIL_P(str_enc)) { str_enc = rb_funcall(str_enc, ID_to_s, 0, 0); } else { str_enc = sys_enc; @@ -884,7 +892,7 @@ tk_get_eval_enc_str(self, obj) static VALUE tk_conv_args(argc, argv, self) int argc; - VALUE *argv; + VALUE *argv; /* [0]:base_array, [1]:enc_mode, [2]..[n]:args */ VALUE self; { int idx, size; |