summaryrefslogtreecommitdiff
path: root/ext/tcltklib/tcltklib.c
diff options
context:
space:
mode:
authornagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-06-21 08:47:22 +0000
committernagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-06-21 08:47:22 +0000
commite8ab40d239baa5a473e81731c828f2c75dfcb06d (patch)
tree86e65b94768a344fbb17971258fb32146c7cca44 /ext/tcltklib/tcltklib.c
parentaa49df66ae0f39d9480cc20d19d7225b762296a0 (diff)
Ruby/Tk libraries except tk.rb :
* remove direct-accesses to a TkComm::INTERP * remove direct-accesses to a TkComm::INITIALIZE_TARGETS * use TkINTERP_SETUP_SCRIPTS constant for setting up the interpreter tcltklib.c : * support to create a safe interpreter with safe-Tk ( Tk8.x ) you can test it by the following --------------------------------------------- require 'tk' safeip = Tk::INTERP._eval('::safe::interpCreate') Tk::INTERP._eval('::safe::loadTk ' + safeip) Tk::INTERP._eval(safeip + ' eval button .b -text SlaveIP -command exit') Tk::INTERP._eval(safeip + ' eval pack .b') Tk.mainloop --------------------------------------------- git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tcltklib/tcltklib.c')
-rw-r--r--ext/tcltklib/tcltklib.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/ext/tcltklib/tcltklib.c b/ext/tcltklib/tcltklib.c
index 9f6f54b5cc..b99b4e94a9 100644
--- a/ext/tcltklib/tcltklib.c
+++ b/ext/tcltklib/tcltklib.c
@@ -470,11 +470,25 @@ lib_restart(self)
/* ignore ERROR */
DUMP2("(TCL_Eval result) %d", ptr->return_value);
- /* execute Tk_Init */
+ /* execute Tk_Init of Tk_SafeInit */
+#if TCL_MAJOR_VERSION >= 8
+ if (Tcl_IsSafe(ptr->ip)) {
+ DUMP1("Tk_SafeInit");
+ if (Tk_SafeInit(ptr->ip) == TCL_ERROR) {
+ rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
+ }
+ } else {
+ DUMP1("Tk_Init");
+ if (Tk_Init(ptr->ip) == TCL_ERROR) {
+ rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
+ }
+ }
+#else
DUMP1("Tk_Init");
if (Tk_Init(ptr->ip) == TCL_ERROR) {
rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
}
+#endif
return Qnil;
}
@@ -596,8 +610,12 @@ ip_init(self)
rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
}
DUMP1("Tcl_StaticPackage(\"Tk\")");
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_StaticPackage(ptr->ip, "Tk", Tk_Init, Tk_SafeInit);
+#else
Tcl_StaticPackage(ptr->ip, "Tk", Tk_Init,
(Tcl_PackageInitProc *) NULL);
+#endif
/* add ruby command to the interpreter */
#if TCL_MAJOR_VERSION >= 8