diff options
author | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-07-12 23:08:32 +0000 |
---|---|---|
committer | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-07-12 23:08:32 +0000 |
commit | ed6ce8b43b6f25df1d4809ac799de4dd1c85c1f3 (patch) | |
tree | 09bc05d679d0f224a29fee44d10beea321bdc0b5 /ext/tk/tkutil | |
parent | e13fb8029b87943ab8af2211226b7c9347d3976d (diff) | |
download | ruby-ed6ce8b43b6f25df1d4809ac799de4dd1c85c1f3.tar.gz |
* ext/tk/extconf.rb: New strategy for searching Tcl/Tk libraries.
* ext/tk/*: Support new features of Tcl/Tk8.6b1 and minor bug fixes.
( [KNOWN BUG] Ruby/Tk on Ruby 1.9 will not work on Cygwin. )
* ext/tk/*: Unify sources between Ruby 1.8 & 1.9.
Improve default_widget_set handling.
* ext/tk/*: Multi-TkInterpreter (multi-tk.rb) works on Ruby 1.8 & 1.9.
( [KNOWN BUG] On Ruby 1.8, join to a long term Thread on Tk
callbacks may freeze. On Ruby 1.9, cannot create a second
master interpreter (creating slaves are OK); supported master
interpreter is the default master interpreter only. )
* ext/tk/lib/tkextlib/*: Update supported versions of Tk extensions.
Tcllib 1.8/Tklib 0.4.1 ==> Tcllib 1.11.1/Tklib 0.5
BWidgets 1.7 ==> BWidgets 1.8
TkTable 2.9 ==> TkTable 2.10
TkTreeCtrl 2005-12-02 ==> TkTreeCtrl 2.2.9
Tile 0.8.0/8.5.1 ==> Tile 0.8.3/8.6b1
IncrTcl 2005-02-14 ==> IncrTcl 2008-12-15
TclX 2005-02-07 ==> TclX 2008-12-15
Trofs 0.4.3 ==> Trofs 0.4.4
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24063 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/tkutil')
-rw-r--r-- | ext/tk/tkutil/extconf.rb | 4 | ||||
-rw-r--r-- | ext/tk/tkutil/tkutil.c | 60 |
2 files changed, 62 insertions, 2 deletions
diff --git a/ext/tk/tkutil/extconf.rb b/ext/tk/tkutil/extconf.rb index 34b91632eb..57de973c0a 100644 --- a/ext/tk/tkutil/extconf.rb +++ b/ext/tk/tkutil/extconf.rb @@ -7,8 +7,12 @@ end if has_tk require 'mkmf' + have_func("rb_obj_instance_exec", "ruby.h") + have_func("rb_obj_untrust", "ruby.h") + have_func("rb_obj_taint", "ruby.h") have_func("rb_sym_to_s", "ruby.h") have_func("strndup", "string.h") + create_makefile('tkutil') end diff --git a/ext/tk/tkutil/tkutil.c b/ext/tk/tkutil/tkutil.c index 42c9330766..25011bb473 100644 --- a/ext/tk/tkutil/tkutil.c +++ b/ext/tk/tkutil/tkutil.c @@ -7,10 +7,16 @@ ************************************************/ -#define TKUTIL_RELEASE_DATE "2008-05-23" +#define TKUTIL_RELEASE_DATE "2009-07-12" #include "ruby.h" +#ifdef RUBY_VM +static VALUE rb_thread_critical; /* dummy */ +#else +/* On Ruby 1.8.x, use rb_thread_critical (defined at rubysig.h) */ +#include "rubysig.h" +#endif #ifdef HAVE_RUBY_ST_H #include "ruby/st.h" #else @@ -54,6 +60,9 @@ static unsigned long CALLBACK_ID_NUM = 0; /*************************************/ +#if defined(HAVE_RB_OBJ_INSTANCE_EXEC) && !defined(RUBY_VM) +extern VALUE rb_obj_instance_exec _((int, VALUE*, VALUE)); +#endif static VALUE tk_s_new(argc, argv, klass) int argc; @@ -78,12 +87,34 @@ static VALUE tkNone_to_s(self) VALUE self; { + return rb_str_new2(""); +} + +static VALUE +tkNone_inspect(self) + VALUE self; +{ return rb_str_new2("None"); } /*************************************/ static VALUE +tk_obj_untrust(self, obj) + VALUE self; + VALUE obj; +{ +#ifdef HAVE_RB_OBJ_TAINT + rb_obj_taint(obj); +#endif +#ifdef HAVE_RB_OBJ_UNTRUST + rb_obj_untrust(obj); +#endif + + return obj; +} + +static VALUE tk_eval_cmd(argc, argv, self) int argc; VALUE argv[]; @@ -890,12 +921,15 @@ tk_conv_args(argc, argv, self) { int idx, size; volatile VALUE dst; + int thr_crit_bup; VALUE old_gc; if (argc < 2) { rb_raise(rb_eArgError, "too few arguments"); } + thr_crit_bup = rb_thread_critical; + rb_thread_critical = Qtrue; old_gc = rb_gc_disable(); for(size = 0, idx = 2; idx < argc; idx++) { @@ -920,6 +954,7 @@ tk_conv_args(argc, argv, self) } if (old_gc == Qfalse) rb_gc_enable(); + rb_thread_critical = thr_crit_bup; return rb_ary_plus(argv[0], dst); } @@ -1065,6 +1100,18 @@ tcl2rb_num_or_str(self, value) rb_eArgError, 0); } +static VALUE +tcl2rb_num_or_nil(self, value) + VALUE self; + VALUE value; +{ + rb_check_type(value, T_STRING); + + if (RSTRING_LEN(value) == 0) return Qnil; + + return tkstr_to_number(value); +} + /*************************************/ @@ -1590,8 +1637,12 @@ cbsubst_scan_args(self, arg_key, val_ary) unsigned char type_chr; volatile VALUE dst = rb_ary_new2(vallen); volatile VALUE proc; + int thr_crit_bup; VALUE old_gc; + thr_crit_bup = rb_thread_critical; + rb_thread_critical = Qtrue; + old_gc = rb_gc_disable(); Data_Get_Struct(rb_const_get(self, ID_SUBST_INFO), @@ -1619,6 +1670,7 @@ cbsubst_scan_args(self, arg_key, val_ary) } if (old_gc == Qfalse) rb_gc_enable(); + rb_thread_critical = thr_crit_bup; return dst; } @@ -1743,7 +1795,7 @@ Init_tkutil() TK_None = rb_obj_alloc(rb_cObject); rb_define_const(mTK, "None", TK_None); rb_define_singleton_method(TK_None, "to_s", tkNone_to_s, 0); - rb_define_singleton_method(TK_None, "inspect", tkNone_to_s, 0); + rb_define_singleton_method(TK_None, "inspect", tkNone_inspect, 0); OBJ_FREEZE(TK_None); /* --------------------- */ @@ -1751,6 +1803,8 @@ Init_tkutil() CALLBACK_TABLE = rb_hash_new(); /* --------------------- */ + rb_define_singleton_method(mTK, "untrust", tk_obj_untrust, 1); + rb_define_singleton_method(mTK, "eval_cmd", tk_eval_cmd, -1); rb_define_singleton_method(mTK, "callback", tk_do_callback, -1); rb_define_singleton_method(mTK, "install_cmd", tk_install_cmd, -1); @@ -1767,6 +1821,7 @@ Init_tkutil() rb_define_singleton_method(mTK, "number", tcl2rb_number, 1); rb_define_singleton_method(mTK, "string", tcl2rb_string, 1); rb_define_singleton_method(mTK, "num_or_str", tcl2rb_num_or_str, 1); + rb_define_singleton_method(mTK, "num_or_nil", tcl2rb_num_or_nil, 1); rb_define_method(mTK, "_toUTF8", tk_toUTF8, -1); rb_define_method(mTK, "_fromUTF8", tk_fromUTF8, -1); @@ -1780,6 +1835,7 @@ Init_tkutil() rb_define_method(mTK, "number", tcl2rb_number, 1); rb_define_method(mTK, "string", tcl2rb_string, 1); rb_define_method(mTK, "num_or_str", tcl2rb_num_or_str, 1); + rb_define_method(mTK, "num_or_nil", tcl2rb_num_or_nil, 1); /* --------------------- */ rb_global_variable(&ENCODING_NAME_UTF8); |