From fd46a1da0a41b7939424bc5a393027be7940908e Mon Sep 17 00:00:00 2001 From: nagai Date: Wed, 23 Jul 2003 16:07:35 +0000 Subject: process.c : unify indentation configure.in : add --enable-setreuid option tcltklib.c : TclTkIp.new accepts 'ip-name' and 'options' ( e.g. TclTkIp.new('FOO', '-geometry 500x200 -use 0x2200009') ) tk.rb : support arguments of TclTkIp.new ( see TkCore::IP_NAME, TkCore::IP_OPTS ) tk*.rb : preparations for multi-Tk interpreter support git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4127 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/tcltklib/tcltklib.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'ext/tcltklib') diff --git a/ext/tcltklib/tcltklib.c b/ext/tcltklib/tcltklib.c index 72ca933424..9ebdbb31e7 100644 --- a/ext/tcltklib/tcltklib.c +++ b/ext/tcltklib/tcltklib.c @@ -530,7 +530,7 @@ ip_ruby(clientData, interp, argc, argv) DUMP2("rb_eval_string(%s)", arg); old_trapflg = rb_trap_immediate; rb_trap_immediate = 0; - res = rb_rescue2(rb_eval_string, (VALUE)arg, + res = rb_rescue2(rb_eval_string, (VALUE)arg, ip_eval_rescue, (VALUE)&failed, rb_eStandardError, rb_eScriptError, 0); rb_trap_immediate = old_trapflg; @@ -584,10 +584,14 @@ ip_alloc(self) } static VALUE -ip_init(self) +ip_init(argc, argv, self) + int argc; + VALUE *argv; VALUE self; { struct tcltkip *ptr; /* tcltkip data struct */ + VALUE argv0, opts, opt_n; + int cnt; /* create object */ Data_Get_Struct(self, struct tcltkip, ptr); @@ -605,6 +609,23 @@ ip_init(self) if (Tcl_Init(ptr->ip) == TCL_ERROR) { rb_raise(rb_eRuntimeError, "%s", ptr->ip->result); } + + /* set variables */ + cnt = rb_scan_args(argc, argv, "02", &argv0, &opts); + switch(cnt) { + case 2: + /* options */ + Tcl_SetVar(ptr->ip, "argv", StringValuePtr(opts), 0); + case 1: + /* argv0 */ + if (argv0 != Qnil) { + Tcl_SetVar(ptr->ip, "argv0", StringValuePtr(argv0), 0); + } + case 0: + /* no args */ + } + + /* from Tcl_AppInit() */ DUMP1("Tk_Init"); if (Tk_Init(ptr->ip) == TCL_ERROR) { rb_raise(rb_eRuntimeError, "%s", ptr->ip->result); @@ -989,7 +1010,7 @@ Init_tcltklib() get_eventloop_weight, 0); rb_define_alloc_func(ip, ip_alloc); - rb_define_method(ip, "initialize", ip_init, 0); + rb_define_method(ip, "initialize", ip_init, -1); rb_define_method(ip, "_eval", ip_eval, 1); rb_define_method(ip, "_toUTF8",ip_toUTF8,2); rb_define_method(ip, "_fromUTF8",ip_fromUTF8,2); -- cgit v1.2.3