7 #define TCLTKLIB_RELEASE_DATE "2010-08-25" 12 #ifdef HAVE_RUBY_ENCODING_H 16 #define RUBY_VERSION "(unknown version)" 18 #ifndef RUBY_RELEASE_DATE 19 #define RUBY_RELEASE_DATE "unknown release-date" 22 #ifdef HAVE_RB_THREAD_CHECK_TRAP_PENDING 28 #define rb_thread_check_trap_pending() (0+rb_trap_pending) 31 #if !defined(RSTRING_PTR) 32 #define RSTRING_PTR(s) (RSTRING(s)->ptr) 33 #define RSTRING_LEN(s) (RSTRING(s)->len) 35 #if !defined(RSTRING_LENINT) 36 #define RSTRING_LENINT(s) ((int)RSTRING_LEN(s)) 38 #if !defined(RARRAY_PTR) 39 #define RARRAY_PTR(s) (RARRAY(s)->ptr) 40 #define RARRAY_LEN(s) (RARRAY(s)->len) 44 #define RbTk_OBJ_UNTRUST(x) do {OBJ_TAINT(x); OBJ_UNTRUST(x);} while (0) 46 #define RbTk_OBJ_UNTRUST(x) OBJ_TAINT(x) 48 #define RbTk_ALLOC_N(type, n) (type *)ckalloc((int)(sizeof(type) * (n))) 50 #if defined(HAVE_RB_PROC_NEW) && !defined(RUBY_VM) 57 #ifdef HAVE_STDARG_PROTOTYPES 59 #define va_init_list(a,b) va_start(a,b) 62 #define va_init_list(a,b) va_start(a) 66 #if !defined HAVE_VSNPRINTF && !defined vsnprintf 69 # define vsnprintf _vsnprintf 71 # ifdef HAVE_RUBY_RUBY_H 82 #ifndef HAVE_RUBY_NATIVE_THREAD_P 83 #define ruby_native_thread_p() is_ruby_native_thread() 84 #undef RUBY_USE_NATIVE_THREAD 86 #define RUBY_USE_NATIVE_THREAD 1 89 #ifndef HAVE_RB_ERRINFO 90 #define rb_errinfo() (ruby_errinfo+0) 94 #ifndef HAVE_RB_SAFE_LEVEL 95 #define rb_safe_level() (ruby_safe_level+0) 97 #ifndef HAVE_RB_SOURCEFILE 98 #define rb_sourcefile() (ruby_sourcefile+0) 103 #ifndef TCL_ALPHA_RELEASE 104 #define TCL_ALPHA_RELEASE 0 105 #define TCL_BETA_RELEASE 1 106 #define TCL_FINAL_RELEASE 2 127 #if TCL_MAJOR_VERSION >= 8 129 # if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION <= 4 133 # define CONST84 CONST 141 # define CONST84 CONST 149 # if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION <= 5 152 # define CONST86 CONST84 157 #define TAG_RETURN 0x1 158 #define TAG_BREAK 0x2 160 #define TAG_RETRY 0x4 162 #define TAG_RAISE 0x6 163 #define TAG_THROW 0x7 164 #define TAG_FATAL 0x8 167 #define DUMP1(ARG1) if (ruby_debug) { fprintf(stderr, "tcltklib: %s\n", ARG1); fflush(stderr); } 168 #define DUMP2(ARG1, ARG2) if (ruby_debug) { fprintf(stderr, "tcltklib: ");\ 169 fprintf(stderr, ARG1, ARG2); fprintf(stderr, "\n"); fflush(stderr); } 170 #define DUMP3(ARG1, ARG2, ARG3) if (ruby_debug) { fprintf(stderr, "tcltklib: ");\ 171 fprintf(stderr, ARG1, ARG2, ARG3); fprintf(stderr, "\n"); fflush(stderr); } 188 #ifdef HAVE_RUBY_ENCODING_H 254 #if TCL_MAJOR_VERSION >= 8 255 static const char Tcl_ObjTypeName_ByteArray[] =
"bytearray";
256 static CONST86 Tcl_ObjType *Tcl_ObjType_ByteArray;
258 static const char Tcl_ObjTypeName_String[] =
"string";
259 static CONST86 Tcl_ObjType *Tcl_ObjType_String;
261 #if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 1) 262 #define IS_TCL_BYTEARRAY(obj) ((obj)->typePtr == Tcl_ObjType_ByteArray) 263 #define IS_TCL_STRING(obj) ((obj)->typePtr == Tcl_ObjType_String) 264 #define IS_TCL_VALID_STRING(obj) ((obj)->bytes != (char*)NULL) 268 #ifndef HAVE_RB_HASH_LOOKUP 269 #define rb_hash_lookup rb_hash_aref 272 #ifndef HAVE_RB_THREAD_ALIVE_P 273 #define rb_thread_alive_p(thread) rb_funcall2((thread), ID_alive_p, 0, NULL) 278 #ifdef HAVE_PROTOTYPES 279 tcl_eval(Tcl_Interp *interp,
const char *cmd)
289 Tcl_AllowExceptions(interp);
296 #define Tcl_Eval tcl_eval 299 #ifdef HAVE_PROTOTYPES 310 Tcl_AllowExceptions(interp);
316 #undef Tcl_GlobalEval 317 #define Tcl_GlobalEval tcl_global_eval 320 #if TCL_MAJOR_VERSION < 8 321 #define Tcl_IncrRefCount(obj) (1) 322 #define Tcl_DecrRefCount(obj) (1) 326 #if TCL_MAJOR_VERSION < 8 327 #define Tcl_GetStringResult(interp) ((interp)->result) 331 #if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 333 Tcl_GetVar2Ex(interp, name1, name2, flags)
339 Tcl_Obj *nameObj1, *nameObj2 =
NULL, *retObj;
341 nameObj1 = Tcl_NewStringObj((
char*)name1, -1);
345 nameObj2 = Tcl_NewStringObj((
char*)name2, -1);
349 retObj = Tcl_ObjGetVar2(interp, nameObj1, nameObj2, flags);
361 Tcl_SetVar2Ex(interp, name1, name2, newValObj, flags)
368 Tcl_Obj *nameObj1, *nameObj2 =
NULL, *retObj;
370 nameObj1 = Tcl_NewStringObj((
char*)name1, -1);
374 nameObj2 = Tcl_NewStringObj((
char*)name2, -1);
378 retObj = Tcl_ObjSetVar2(interp, nameObj1, nameObj2, newValObj, flags);
392 #if TCL_MAJOR_VERSION < 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION < 4) 393 # if !defined __MINGW32__ && !defined __BORLANDC__ 409 #if TCL_MAJOR_VERSION >= 8 465 for(i = 0; i < q->
argc; i++) {
477 #ifdef RUBY_USE_NATIVE_THREAD 478 Tcl_ThreadId tk_eventloop_thread_id;
493 #ifdef RUBY_USE_NATIVE_THREAD 494 #define CONTROL_BY_STATUS_OF_RB_THREAD_WAITING_FOR_VALUE 1 495 #define USE_TOGGLE_WINDOW_MODE_FOR_IDLE 0 496 #define DO_THREAD_SCHEDULE_AT_CALLBACK_DONE 1 498 #define CONTROL_BY_STATUS_OF_RB_THREAD_WAITING_FOR_VALUE 1 499 #define USE_TOGGLE_WINDOW_MODE_FOR_IDLE 0 500 #define DO_THREAD_SCHEDULE_AT_CALLBACK_DONE 0 503 #if CONTROL_BY_STATUS_OF_RB_THREAD_WAITING_FOR_VALUE 514 #ifdef RUBY_USE_NATIVE_THREAD 515 #define DEFAULT_EVENT_LOOP_MAX 800 516 #define DEFAULT_NO_EVENT_TICK 10 517 #define DEFAULT_NO_EVENT_WAIT 5 518 #define WATCHDOG_INTERVAL 10 519 #define DEFAULT_TIMER_TICK 0 520 #define NO_THREAD_INTERRUPT_TIME 100 522 #define DEFAULT_EVENT_LOOP_MAX 800 523 #define DEFAULT_NO_EVENT_TICK 10 524 #define DEFAULT_NO_EVENT_WAIT 20 525 #define WATCHDOG_INTERVAL 10 526 #define DEFAULT_TIMER_TICK 0 527 #define NO_THREAD_INTERRUPT_TIME 100 530 #define EVENT_HANDLER_TIMEOUT 100 547 #if TCL_MAJOR_VERSION >= 8 551 static int ip_ruby_eval _((ClientData, Tcl_Interp *,
int,
char **));
552 static int ip_ruby_cmd _((ClientData, Tcl_Interp *,
int,
char **));
564 #ifndef TCL_NAMESPACE_DEBUG 565 #define TCL_NAMESPACE_DEBUG 0 568 #if TCL_NAMESPACE_DEBUG 570 #if TCL_MAJOR_VERSION >= 8 571 EXTERN struct TclIntStubs *tclIntStubsPtr;
575 #if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION < 5 578 # ifndef Tcl_GetCurrentNamespace 579 EXTERN Tcl_Namespace * Tcl_GetCurrentNamespace
_((Tcl_Interp *));
581 # if defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS) 582 # ifndef Tcl_GetCurrentNamespace 583 # ifndef FunctionNum_of_GetCurrentNamespace 584 #define FunctionNum_of_GetCurrentNamespace 124 586 struct DummyTclIntStubs_for_GetCurrentNamespace {
588 struct TclIntStubHooks *hooks;
589 void (*
func[FunctionNum_of_GetCurrentNamespace])();
590 Tcl_Namespace * (*tcl_GetCurrentNamespace)
_((Tcl_Interp *));
593 #define Tcl_GetCurrentNamespace \ 594 (((struct DummyTclIntStubs_for_GetCurrentNamespace *)tclIntStubsPtr)->tcl_GetCurrentNamespace) 601 #if TCL_MAJOR_VERSION < 8 602 #define ip_null_namespace(interp) (0) 604 #define ip_null_namespace(interp) \ 605 (Tcl_GetCurrentNamespace(interp) == (Tcl_Namespace *)NULL) 609 #if TCL_MAJOR_VERSION < 8 610 #define rbtk_invalid_namespace(ptr) (0) 612 #define rbtk_invalid_namespace(ptr) \ 613 ((ptr)->default_ns == (Tcl_Namespace*)NULL || Tcl_GetCurrentNamespace((ptr)->ip) != (ptr)->default_ns) 617 #if TCL_MAJOR_VERSION >= 8 619 typedef struct CallFrame {
620 Tcl_Namespace *nsPtr;
624 struct CallFrame *callerPtr;
625 struct CallFrame *callerVarPtr;
634 # if !defined(TclGetFrame) && !defined(TclGetFrame_TCL_DECLARED) 635 EXTERN int TclGetFrame
_((Tcl_Interp *,
CONST char *, CallFrame **));
637 # if defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS) 639 # ifndef FunctionNum_of_GetFrame 640 #define FunctionNum_of_GetFrame 32 642 struct DummyTclIntStubs_for_GetFrame {
644 struct TclIntStubHooks *hooks;
645 void (*
func[FunctionNum_of_GetFrame])();
646 int (*tclGetFrame)
_((Tcl_Interp *,
CONST char *, CallFrame **));
648 #define TclGetFrame \ 649 (((struct DummyTclIntStubs_for_GetFrame *)tclIntStubsPtr)->tclGetFrame) 653 # if !defined(Tcl_PopCallFrame) && !defined(Tcl_PopCallFrame_TCL_DECLARED) 654 EXTERN void Tcl_PopCallFrame
_((Tcl_Interp *));
655 EXTERN int Tcl_PushCallFrame
_((Tcl_Interp *, Tcl_CallFrame *, Tcl_Namespace *,
int));
657 # if defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS) 658 # ifndef Tcl_PopCallFrame 659 # ifndef FunctionNum_of_PopCallFrame 660 #define FunctionNum_of_PopCallFrame 128 662 struct DummyTclIntStubs_for_PopCallFrame {
664 struct TclIntStubHooks *hooks;
665 void (*
func[FunctionNum_of_PopCallFrame])();
666 void (*tcl_PopCallFrame)
_((Tcl_Interp *));
667 int (*tcl_PushCallFrame)
_((Tcl_Interp *, Tcl_CallFrame *, Tcl_Namespace *,
int));
670 #define Tcl_PopCallFrame \ 671 (((struct DummyTclIntStubs_for_PopCallFrame *)tclIntStubsPtr)->tcl_PopCallFrame) 672 #define Tcl_PushCallFrame \ 673 (((struct DummyTclIntStubs_for_PopCallFrame *)tclIntStubsPtr)->tcl_PushCallFrame) 679 typedef struct CallFrame {
680 Tcl_HashTable varTable;
684 struct CallFrame *callerPtr;
685 struct CallFrame *callerVarPtr;
688 # ifndef Tcl_CallFrame 689 #define Tcl_CallFrame CallFrame 692 # if !defined(TclGetFrame) && !defined(TclGetFrame_TCL_DECLARED) 693 EXTERN int TclGetFrame
_((Tcl_Interp *,
CONST char *, CallFrame **));
696 # if !defined(Tcl_PopCallFrame) && !defined(Tcl_PopCallFrame_TCL_DECLARED) 697 typedef struct DummyInterp {
701 Tcl_HashTable dummy4;
702 Tcl_HashTable dummy5;
703 Tcl_HashTable dummy6;
707 CallFrame *varFramePtr;
711 Tcl_PopCallFrame(interp)
714 DummyInterp *iPtr = (DummyInterp*)interp;
715 CallFrame *frame = iPtr->varFramePtr;
718 iPtr->framePtr = frame.callerPtr;
719 iPtr->varFramePtr = frame.callerVarPtr;
725 #define Tcl_Namespace char 728 Tcl_PushCallFrame(interp, framePtr, nsPtr, isProcCallFrame)
730 Tcl_CallFrame *framePtr;
731 Tcl_Namespace *nsPtr;
734 DummyInterp *iPtr = (DummyInterp*)interp;
735 CallFrame *frame = (CallFrame *)framePtr;
738 Tcl_InitHashTable(&frame.varTable, TCL_STRING_KEYS);
739 if (iPtr->varFramePtr !=
NULL) {
740 frame.level = iPtr->varFramePtr->level + 1;
744 frame.callerPtr = iPtr->framePtr;
745 frame.callerVarPtr = iPtr->varFramePtr;
746 iPtr->framePtr = &frame;
747 iPtr->varFramePtr = &frame;
761 #if TCL_NAMESPACE_DEBUG 762 Tcl_Namespace *default_ns;
764 #ifdef RUBY_USE_NATIVE_THREAD 765 Tcl_ThreadId tk_thread_id;
785 if (ptr->
ip == (Tcl_Interp*)
NULL) {
796 if (!ptr || !ptr->
ip || Tcl_InterpDeleted(ptr->
ip)
798 || rbtk_invalid_namespace(ptr)
801 DUMP1(
"ip is deleted");
813 if (ptr->
ip == (Tcl_Interp*)
NULL) {
817 Tcl_Preserve((ClientData)ptr->
ip);
829 }
else if (ptr->
ip == (Tcl_Interp*)
NULL) {
833 Tcl_Release((ClientData)ptr->
ip);
840 #ifdef HAVE_STDARG_PROTOTYPES 861 Tcl_ResetResult(ptr->
ip);
869 #if defined CREATE_RUBYTK_KIT || defined CREATE_RUBYKIT 873 #if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION < 84 874 #error Ruby/Tk-Kit requires Tcl/Tk8.4 or later. 894 #if defined USE_TCL_STUBS || defined USE_TK_STUBS 895 # error Not support Tcl/Tk stubs with Ruby/Tk-Kit or Rubykit. 898 #ifndef KIT_INCLUDES_ZLIB 899 #if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION < 86 900 #define KIT_INCLUDES_ZLIB 1 902 #define KIT_INCLUDES_ZLIB 0 907 #define WIN32_LEAN_AND_MEAN 909 #undef WIN32_LEAN_AND_MEAN 912 #if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION < 86 913 EXTERN Tcl_Obj* TclGetStartupScriptPath();
914 EXTERN void TclSetStartupScriptPath
_((Tcl_Obj*));
915 #define Tcl_GetStartupScript(encPtr) TclGetStartupScriptPath() 916 #define Tcl_SetStartupScript(path,enc) TclSetStartupScriptPath(path) 918 #if !defined(TclSetPreInitScript) && !defined(TclSetPreInitScript_TCL_DECLARED) 919 EXTERN char* TclSetPreInitScript
_((
char *));
922 #ifndef KIT_INCLUDES_TK 923 # define KIT_INCLUDES_TK 1 928 Tcl_AppInitProc Vfs_Init, Rechan_Init;
929 #if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION < 85 930 Tcl_AppInitProc Pwb_Init;
934 Tcl_AppInitProc Vlerq_Init, Vlerq_SafeInit;
936 Tcl_AppInitProc Mk4tcl_Init;
939 #if defined TCL_THREADS && defined KIT_INCLUDES_THREAD 940 Tcl_AppInitProc Thread_Init;
943 #if KIT_INCLUDES_ZLIB 944 Tcl_AppInitProc Zlib_Init;
947 #ifdef KIT_INCLUDES_ITCL 948 Tcl_AppInitProc Itcl_Init;
952 Tcl_AppInitProc Dde_Init, Dde_SafeInit, Registry_Init;
957 #define RUBYTK_KITPATH_CONST_NAME "RUBYTK_KITPATH" 959 static char *rubytk_kitpath =
NULL;
961 static char rubytkkit_preInitCmd[] =
962 "proc tclKitPreInit {} {\n" 963 "rename tclKitPreInit {}\n" 964 "load {} rubytk_kitpath\n" 965 #if KIT_INCLUDES_ZLIB 966 "catch {load {} zlib}\n" 970 "namespace eval ::vlerq {}\n" 971 "if {[catch { vlerq open $::tcl::kitpath } ::vlerq::starkit_root]} {\n" 974 "set files [vlerq get $::vlerq::starkit_root 0 dirs 0 files]\n" 975 "set n [lsearch [vlerq get $files * name] boot.tcl]\n" 978 "array set a [vlerq get $files $n]\n" 981 #if defined KIT_VFS_WRITABLE && !defined CREATE_RUBYKIT 983 "mk::file open exe $::tcl::kitpath\n" 985 "mk::file open exe $::tcl::kitpath -readonly\n" 987 "set n [mk::select exe.dirs!0.files name boot.tcl]\n" 988 "if {[llength $n] == 1} {\n" 989 "array set a [mk::get exe.dirs!0.files!$n]\n" 991 "if {![info exists a(contents)]} { error {no boot.tcl file} }\n" 992 "if {$a(size) != [string length $a(contents)]} {\n" 993 "set a(contents) [zlib decompress $a(contents)]\n" 995 "if {$a(contents) eq \"\"} { error {empty boot.tcl} }\n" 996 "uplevel #0 $a(contents)\n" 998 "} elseif {[lindex $::argv 0] eq \"-init-\"} {\n" 999 "uplevel #0 { source [lindex $::argv 1] }\n" 1004 "set vfsdir \"[file rootname $::tcl::kitpath].vfs\"\n" 1005 "if {[file isdirectory $vfsdir]} {\n" 1006 "set ::tcl_library [file join $vfsdir lib tcl$::tcl_version]\n" 1007 "set ::tcl_libPath [list $::tcl_library [file join $vfsdir lib]]\n" 1008 "catch {uplevel #0 [list source [file join $vfsdir config.tcl]]}\n" 1009 "uplevel #0 [list source [file join $::tcl_library init.tcl]]\n" 1010 "set ::auto_path $::tcl_libPath\n" 1012 "error \"\n $::tcl::kitpath has no VFS data to start up\"\n" 1022 static const char initScript[] =
1023 "if {[file isfile [file join $::tcl::kitpath main.tcl]]} {\n" 1024 "if {[info commands console] != {}} { console hide }\n" 1025 "set tcl_interactive 0\n" 1027 "set argv [linsert $argv 0 $argv0]\n" 1028 "set argv0 [file join $::tcl::kitpath main.tcl]\n" 1036 set_rubytk_kitpath(
const char *kitpath)
1039 int len = (int)
strlen(kitpath);
1040 if (rubytk_kitpath) {
1041 ckfree(rubytk_kitpath);
1044 rubytk_kitpath = (
char *)ckalloc(len + 1);
1045 memcpy(rubytk_kitpath, kitpath, len);
1046 rubytk_kitpath[len] =
'\0';
1048 return rubytk_kitpath;
1054 #define DEV_NULL "NUL" 1056 #define DEV_NULL "/dev/null" 1060 check_tclkit_std_channels()
1069 chan = Tcl_GetStdChannel(TCL_STDIN);
1071 chan = Tcl_OpenFileChannel(
NULL, DEV_NULL,
"r", 0);
1073 Tcl_SetChannelOption(
NULL, chan,
"-encoding",
"utf-8");
1075 Tcl_SetStdChannel(chan, TCL_STDIN);
1077 chan = Tcl_GetStdChannel(TCL_STDOUT);
1079 chan = Tcl_OpenFileChannel(
NULL, DEV_NULL,
"w", 0);
1081 Tcl_SetChannelOption(
NULL, chan,
"-encoding",
"utf-8");
1083 Tcl_SetStdChannel(chan, TCL_STDOUT);
1085 chan = Tcl_GetStdChannel(TCL_STDERR);
1087 chan = Tcl_OpenFileChannel(
NULL, DEV_NULL,
"w", 0);
1089 Tcl_SetChannelOption(
NULL, chan,
"-encoding",
"utf-8");
1091 Tcl_SetStdChannel(chan, TCL_STDERR);
1098 rubytk_kitpathObjCmd(ClientData dummy, Tcl_Interp *interp,
int objc, Tcl_Obj *
const objv[])
1102 set_rubytk_kitpath(Tcl_GetString(objv[1]));
1103 }
else if (objc > 2) {
1104 Tcl_WrongNumArgs(interp, 1, objv,
"?path?");
1106 str = rubytk_kitpath ? rubytk_kitpath : Tcl_GetNameOfExecutable();
1107 Tcl_SetObjResult(interp, Tcl_NewStringObj(str, -1));
1116 rubytk_kitpath_init(Tcl_Interp *interp)
1118 Tcl_CreateObjCommand(interp,
"::tcl::kitpath", rubytk_kitpathObjCmd, 0, 0);
1119 if (Tcl_LinkVar(interp,
"::tcl::kitpath", (
char *) &rubytk_kitpath,
1120 TCL_LINK_STRING | TCL_LINK_READ_ONLY) != TCL_OK) {
1121 Tcl_ResetResult(interp);
1124 Tcl_CreateObjCommand(interp,
"::tcl::rubytk_kitpath", rubytk_kitpathObjCmd, 0, 0);
1125 if (Tcl_LinkVar(interp,
"::tcl::rubytk_kitpath", (
char *) &rubytk_kitpath,
1126 TCL_LINK_STRING | TCL_LINK_READ_ONLY) != TCL_OK) {
1127 Tcl_ResetResult(interp);
1130 if (rubytk_kitpath ==
NULL) {
1135 set_rubytk_kitpath(Tcl_GetNameOfExecutable());
1138 return Tcl_PkgProvide(interp,
"rubytk_kitpath",
"1.0");
1144 init_static_tcltk_packages()
1149 check_tclkit_std_channels();
1151 #ifdef KIT_INCLUDES_ITCL 1152 Tcl_StaticPackage(0,
"Itcl", Itcl_Init,
NULL);
1155 Tcl_StaticPackage(0,
"Vlerq", Vlerq_Init, Vlerq_SafeInit);
1157 Tcl_StaticPackage(0,
"Mk4tcl", Mk4tcl_Init,
NULL);
1159 #if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION < 85 1160 Tcl_StaticPackage(0,
"pwb", Pwb_Init,
NULL);
1162 Tcl_StaticPackage(0,
"rubytk_kitpath", rubytk_kitpath_init,
NULL);
1163 Tcl_StaticPackage(0,
"rechan", Rechan_Init,
NULL);
1164 Tcl_StaticPackage(0,
"vfs", Vfs_Init,
NULL);
1165 #if KIT_INCLUDES_ZLIB 1166 Tcl_StaticPackage(0,
"zlib", Zlib_Init,
NULL);
1168 #if defined TCL_THREADS && defined KIT_INCLUDES_THREAD 1169 Tcl_StaticPackage(0,
"Thread", Thread_Init, Thread_SafeInit);
1172 #if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION > 84 1173 Tcl_StaticPackage(0,
"dde", Dde_Init, Dde_SafeInit);
1175 Tcl_StaticPackage(0,
"dde", Dde_Init,
NULL);
1177 Tcl_StaticPackage(0,
"registry", Registry_Init,
NULL);
1179 #ifdef KIT_INCLUDES_TK 1180 Tcl_StaticPackage(0,
"Tk", Tk_Init, Tk_SafeInit);
1187 call_tclkit_init_script(Tcl_Interp *interp)
1193 if (Tcl_EvalEx(interp, initScript, -1, TCL_EVAL_GLOBAL) == TCL_OK) {
1194 const char *encoding =
NULL;
1195 Tcl_Obj* path = Tcl_GetStartupScript(&encoding);
1196 Tcl_SetStartupScript(Tcl_GetObjResult(interp), encoding);
1198 Tcl_Eval(interp,
"incr argc -1; set argv [lrange $argv 1 end]");
1212 EXTERN void TkWinSetHINSTANCE(HINSTANCE hInstance);
1213 void rbtk_win32_SetHINSTANCE(
const char *module_name)
1220 hInst = GetModuleHandle(module_name);
1221 TkWinSetHINSTANCE(hInst);
1233 init_static_tcltk_packages();
1237 const_id =
rb_intern(RUBYTK_KITPATH_CONST_NAME);
1240 volatile VALUE pathobj;
1244 #ifdef HAVE_RUBY_ENCODING_H 1252 #ifdef CREATE_RUBYTK_KIT 1253 if (rubytk_kitpath ==
NULL) {
1257 volatile VALUE basename;
1267 if (rubytk_kitpath ==
NULL) {
1268 set_rubytk_kitpath(Tcl_GetNameOfExecutable());
1271 TclSetPreInitScript(rubytkkit_preInitCmd);
1316 #if TCL_MAJOR_VERSION >= 8 1319 if (Tcl_IsSafe(ptr->
ip)) {
1320 DUMP1(
"Tk_SafeInit");
1327 "tcltklib: can't find Tk_SafeInit()");
1330 "tcltklib: fail to Tk_SafeInit(). %s",
1334 "tcltklib: fail to Tk_InitStubs(). %s",
1338 "tcltklib: unknown error(%d) on ruby_tk_stubs_safeinit", st);
1348 "tcltklib: can't find Tk_Init()");
1351 "tcltklib: fail to Tk_Init(). %s",
1355 "tcltklib: fail to Tk_InitStubs(). %s",
1359 "tcltklib: unknown error(%d) on ruby_tk_stubs_init", st);
1370 #ifdef RUBY_USE_NATIVE_THREAD 1371 ptr->tk_thread_id = Tcl_GetCurrentThread();
1390 DUMP1(
"find a pending exception");
1399 DUMP1(
"pending_exception_check0: call rb_jump_tag(retry)");
1402 DUMP1(
"pending_exception_check0: call rb_jump_tag(redo)");
1405 DUMP1(
"pending_exception_check0: call rb_jump_tag(throw)");
1426 DUMP1(
"find a pending exception");
1443 DUMP1(
"pending_exception_check1: call rb_jump_tag(retry)");
1446 DUMP1(
"pending_exception_check1: call rb_jump_tag(redo)");
1449 DUMP1(
"pending_exception_check1: call rb_jump_tag(throw)");
1470 #if TCL_MAJOR_VERSION >= 8 1474 DUMP1(
"original_exit is called");
1481 Tcl_ResetResult(ptr->
ip);
1486 #if TCL_MAJOR_VERSION >= 8 1487 state_obj = Tcl_NewIntObj(state);
1490 if (info->isNativeObjectProc) {
1492 #define USE_RUBY_ALLOC 0 1498 Tcl_Preserve((ClientData)
argv);
1501 cmd_obj = Tcl_NewStringObj(
"exit", 4);
1505 argv[1] = state_obj;
1509 = (*(info->objProc))(info->objClientData, ptr->
ip, 2,
argv);
1517 Tcl_EventuallyFree((ClientData)
argv, TCL_DYNAMIC);
1520 Tcl_Release((ClientData)
argv);
1523 ckfree((
char*)
argv);
1527 #undef USE_RUBY_ALLOC 1532 #define USE_RUBY_ALLOC 0 1538 Tcl_Preserve((ClientData)
argv);
1541 argv[0] = (
char *)
"exit";
1543 argv[1] = Tcl_GetStringFromObj(state_obj, (
int*)
NULL);
1552 Tcl_EventuallyFree((ClientData)
argv, TCL_DYNAMIC);
1555 Tcl_Release((ClientData)
argv);
1558 ckfree((
char*)
argv);
1562 #undef USE_RUBY_ALLOC 1571 #define USE_RUBY_ALLOC 0 1577 Tcl_Preserve((ClientData)
argv);
1591 Tcl_EventuallyFree((ClientData)
argv, TCL_DYNAMIC);
1594 Tcl_Release((ClientData)
argv);
1601 #undef USE_RUBY_ALLOC 1604 DUMP1(
"complete original_exit");
1616 ClientData clientData;
1623 DUMP1(
"call _timer_for_tcl");
1645 #ifdef RUBY_USE_NATIVE_THREAD 1646 #if USE_TOGGLE_WINDOW_MODE_FOR_IDLE 1648 toggle_eventloop_window_mode_for_idle()
1702 "timer-tick parameter must be 0 or positive number");
1744 if (Tcl_GetMaster(ptr->
ip) != (Tcl_Interp*)
NULL) {
1768 "no_event_wait parameter must be positive number");
1795 if (Tcl_GetMaster(ptr->
ip) != (Tcl_Interp*)
NULL) {
1815 int lpmax =
NUM2INT(loop_max);
1816 int no_ev =
NUM2INT(no_event);
1819 if (lpmax <= 0 || no_ev <= 0) {
1849 if (Tcl_GetMaster(ptr->
ip) != (Tcl_Interp*)
NULL) {
1868 struct Tcl_Time tcl_time;
1871 switch(
TYPE(time)) {
1894 Tcl_SetMaxBlockTime(&tcl_time);
1958 if (Tcl_GetMaster(ptr->
ip) != (Tcl_Interp*)
NULL) {
1972 return INT2FIX(Tk_GetNumMainWindows());
1982 #ifdef RUBY_USE_NATIVE_THREAD 1995 Tcl_SetMaxBlockTime(&tcl_time);
2005 #ifdef RUBY_USE_NATIVE_THREAD 2007 #ifdef HAVE_PROTOTYPES 2008 call_DoOneEvent_core(
VALUE flag_val)
2010 call_DoOneEvent_core(flag_val)
2017 if (Tcl_DoOneEvent(flag)) {
2025 #ifdef HAVE_PROTOTYPES 2037 #ifdef HAVE_PROTOTYPES 2047 if (Tcl_DoOneEvent(flag)) {
2058 #ifdef HAVE_PROTOTYPES 2059 eventloop_sleep(
VALUE dummy)
2061 eventloop_sleep(dummy)
2074 #ifdef HAVE_NATIVETHREAD 2075 #ifndef RUBY_USE_NATIVE_THREAD 2077 rb_bug(
"cross-thread violation on eventloop_sleep()");
2086 #ifdef HAVE_NATIVETHREAD 2087 #ifndef RUBY_USE_NATIVE_THREAD 2089 rb_bug(
"cross-thread violation on eventloop_sleep()");
2098 #define USE_EVLOOP_THREAD_ALONE_CHECK_FLAG 0 2100 #if USE_EVLOOP_THREAD_ALONE_CHECK_FLAG 2102 get_thread_alone_check_flag()
2104 #ifdef RUBY_USE_NATIVE_THREAD 2136 #define TRAP_CHECK() do { \ 2137 if (trap_check(check_var) == 0) return 0; \ 2143 DUMP1(
"trap check");
2147 if (check_var != (
int*)
NULL) {
2156 if (rb_trap_pending) {
2158 if (rb_prohibit_interrupt || check_var != (
int*)
NULL) {
2173 DUMP1(
"check eventloop_interp");
2191 int found_event = 1;
2199 #if USE_EVLOOP_THREAD_ALONE_CHECK_FLAG 2200 int thread_alone_check_flag = 1;
2202 enum {thread_alone_check_flag = 1};
2205 if (update_flag)
DUMP1(
"update loop start!!");
2224 #if USE_EVLOOP_THREAD_ALONE_CHECK_FLAG 2226 thread_alone_check_flag = get_thread_alone_check_flag();
2233 DUMP1(
"no other thread");
2237 event_flag = update_flag;
2240 event_flag = TCL_ALL_EVENTS;
2251 if (check_var != (
int *)
NULL) {
2252 if (*check_var || !found_event) {
2255 if (interp != (Tcl_Interp*)
NULL 2256 && Tcl_InterpDeleted(interp)) {
2264 INT2FIX(event_flag), &status));
2296 DUMP2(
"DoOneEvent(1) abnormal exit!! %d",
2301 DUMP1(
"exception on wait");
2310 if (update_flag != 0) {
2312 DUMP1(
"next update loop");
2315 DUMP1(
"update complete");
2323 DUMP1(
"check Root Widget");
2338 DUMP1(
"there are other threads");
2344 event_flag = update_flag;
2347 event_flag = TCL_ALL_EVENTS;
2354 if (check_var != (
int *)
NULL) {
2355 if (*check_var || !found_event) {
2358 if (interp != (Tcl_Interp*)
NULL 2359 && Tcl_InterpDeleted(interp)) {
2369 #ifdef RUBY_USE_NATIVE_THREAD 2372 INT2FIX(event_flag), &status));
2377 #if USE_TOGGLE_WINDOW_MODE_FOR_IDLE 2379 if (toggle_eventloop_window_mode_for_idle()) {
2392 INT2FIX(event_flag), &status));
2395 #if CONTROL_BY_STATUS_OF_RB_THREAD_WAITING_FOR_VALUE 2408 "unknown exception");
2434 DUMP2(
"DoOneEvent(2) abnormal exit!! %d",
2441 if (check_var != (
int*)
NULL 2443 DUMP1(
"exception on wait");
2455 if (update_flag != 0) {
2456 DUMP1(
"update complete");
2472 "unknown exception");
2501 DUMP2(
"sleep eventloop %lx", current);
2514 DUMP1(
"check Root Widget");
2535 DUMP1(
"thread scheduling");
2539 DUMP1(
"check interrupts");
2540 #if defined(RUBY_USE_NATIVE_THREAD) || defined(RUBY_VM) 2623 DUMP2(
"eventloop_ensure: current-thread : %lx", current_evloop);
2626 DUMP2(
"finish eventloop %lx (NOT current eventloop)", current_evloop);
2637 DUMP2(
"eventloop-ensure: new eventloop-thread -> %lx",
2642 DUMP2(
"eventloop %lx : back from recursive call", current_evloop);
2661 #ifdef RUBY_USE_NATIVE_THREAD 2663 tk_eventloop_thread_id = (Tcl_ThreadId) 0;
2672 DUMP2(
"finish current eventloop %lx", current_evloop);
2690 #ifdef RUBY_USE_NATIVE_THREAD 2691 tk_eventloop_thread_id = Tcl_GetCurrentThread();
2695 DUMP2(
"eventloop: recursive call on %lx", parent_evloop);
2700 DUMP2(
"wait for stop of parent_evloop %lx", parent_evloop);
2702 DUMP2(
"parent_evloop %lx doesn't stop", parent_evloop);
2705 DUMP1(
"succeed to stop parent");
2710 DUMP3(
"tcltklib: eventloop-thread : %lx -> %lx\n",
2736 VALUE check_rootwidget;
2739 check_rootwidget =
Qtrue;
2740 }
else if (
RTEST(check_rootwidget)) {
2741 check_rootwidget =
Qtrue;
2743 check_rootwidget =
Qfalse;
2764 if (Tcl_GetMaster(ptr->
ip) != (Tcl_Interp*)
NULL) {
2778 VALUE check_rootwidget;
2784 #define EVLOOP_WAKEUP_CHANCE 3 2788 VALUE check_rootwidget;
2793 int check =
RTEST(check_rootwidget);
2816 DUMP2(
"eventloop thread %lx is sleeping or dead",
2819 (
void*)&check_rootwidget);
2820 DUMP2(
"create new eventloop thread %lx", evloop);
2848 #ifdef RUBY_USE_NATIVE_THREAD 2849 tk_eventloop_thread_id = (Tcl_ThreadId) 0;
2860 VALUE check_rootwidget;
2864 "eventloop_watchdog is not implemented on Ruby VM.");
2868 check_rootwidget =
Qtrue;
2869 }
else if (
RTEST(check_rootwidget)) {
2870 check_rootwidget =
Qtrue;
2872 check_rootwidget =
Qfalse;
2892 if (Tcl_GetMaster(ptr->
ip) != (Tcl_Interp*)
NULL) {
2940 #ifdef HAVE_PROTOTYPES 2978 q->done, (Tcl_Interp*)
NULL);
3016 volatile VALUE vflags;
3027 flags = TCL_ALL_EVENTS | TCL_DONT_WAIT;
3034 flags |= TCL_DONT_WAIT;
3046 if (Tcl_GetMaster(ptr->
ip) != (Tcl_Interp*)
NULL) {
3048 flags |= TCL_DONT_WAIT;
3053 found_event = Tcl_DoOneEvent(flags);
3095 #if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION > 0) 3097 Tcl_Encoding encoding;
3106 #if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION > 0) 3112 encoding = (Tcl_Encoding)
NULL;
3131 Tcl_DStringInit(&dstr);
3132 Tcl_DStringFree(&dstr);
3135 Tcl_AppendResult(interp, Tcl_DStringValue(&dstr), (
char*)
NULL);
3136 DUMP2(
"error message:%s", Tcl_DStringValue(&dstr));
3137 Tcl_DStringFree(&dstr);
3178 #ifdef HAVE_PROTOTYPES 3191 Tcl_ResetResult(interp);
3221 DUMP1(
"rb_protect: retry");
3230 DUMP1(
"rb_protect: redo");
3255 DUMP1(
"rb_protect: throw");
3265 sprintf(
buf,
"unknown loncaljmp status %d", status);
3279 Tcl_ResetResult(interp);
3284 volatile VALUE backtrace;
3291 DUMP1(
"set backtrace");
3308 return TCL_CONTINUE;
3331 return TCL_CONTINUE;
3345 DUMP1(
"Tcl_AppendResult");
3364 #ifdef HAVE_NATIVETHREAD 3365 #ifndef RUBY_USE_NATIVE_THREAD 3367 rb_bug(
"cross-thread violation on tcl_protect()");
3376 int old_trapflag = rb_trap_immediate;
3377 rb_trap_immediate = 0;
3379 rb_trap_immediate = old_trapflag;
3387 #if TCL_MAJOR_VERSION >= 8 3389 ClientData clientData;
3395 ClientData clientData;
3405 if (interp == (Tcl_Interp*)
NULL) {
3415 "wrong number of arguments (%d for 1)",
argc - 1);
3417 char buf[
sizeof(int)*8 + 1];
3418 Tcl_ResetResult(interp);
3420 Tcl_AppendResult(interp,
"wrong number of arguments (",
3421 buf,
" for 1)", (
char *)
NULL);
3429 #if TCL_MAJOR_VERSION >= 8 3437 str = Tcl_GetStringFromObj(
argv[1], &len);
3440 memcpy(arg, str, len);
3451 DUMP2(
"rb_eval_string(%s)", arg);
3455 #if TCL_MAJOR_VERSION >= 8 3472 DUMP1(
"call ip_ruby_cmd_core");
3476 DUMP2(
"rb_apply return:%lx", ret);
3478 DUMP1(
"finish ip_ruby_cmd_core");
3483 #define SUPPORT_NESTED_CONST_AS_IP_RUBY_CMD_RECEIVER 1 3495 #if SUPPORT_NESTED_CONST_AS_IP_RUBY_CMD_RECEIVER 3542 #if !SUPPORT_NESTED_CONST_AS_IP_RUBY_CMD_RECEIVER 3546 if (str[0] ==
':' || (
'A' <= str[0] && str[0] <=
'Z')) {
3548 #if SUPPORT_NESTED_CONST_AS_IP_RUBY_CMD_RECEIVER 3552 if (state)
return Qnil;
3554 }
else if (str[0] ==
'$') {
3566 memcpy(
buf + 1, str, len);
3578 #if TCL_MAJOR_VERSION >= 8 3580 ClientData clientData;
3586 ClientData clientData;
3603 if (interp == (Tcl_Interp*)
NULL) {
3613 Tcl_ResetResult(interp);
3614 Tcl_AppendResult(interp,
"too few arguments", (
char *)
NULL);
3627 #if TCL_MAJOR_VERSION >= 8 3628 str = Tcl_GetStringFromObj(
argv[1], &len);
3632 DUMP2(
"receiver:%s",str);
3638 "unknown class/module/global-variable '%s'", str);
3640 Tcl_ResetResult(interp);
3641 Tcl_AppendResult(interp,
"unknown class/module/global-variable '",
3642 str,
"'", (
char *)
NULL);
3651 #if TCL_MAJOR_VERSION >= 8 3652 str = Tcl_GetStringFromObj(
argv[2], &len);
3660 for(i = 3; i <
argc; i++) {
3662 #if TCL_MAJOR_VERSION >= 8 3663 str = Tcl_GetStringFromObj(
argv[i], &len);
3669 DUMP2(
"arg:%s",str);
3670 #ifndef HAVE_STRUCT_RARRAY_LEN 3702 #if TCL_MAJOR_VERSION >= 8 3703 #ifdef HAVE_PROTOTYPES 3704 ip_InterpExitObjCmd(ClientData clientData, Tcl_Interp *interp,
3707 ip_InterpExitObjCmd(clientData, interp,
argc,
argv)
3708 ClientData clientData;
3714 #ifdef HAVE_PROTOTYPES 3719 ClientData clientData;
3726 DUMP1(
"start ip_InterpExitCommand");
3727 if (interp != (Tcl_Interp*)
NULL 3728 && !Tcl_InterpDeleted(interp)
3730 && !ip_null_namespace(interp)
3733 Tcl_ResetResult(interp);
3736 if (!Tcl_InterpDeleted(interp)) {
3739 Tcl_DeleteInterp(interp);
3740 Tcl_Release(interp);
3747 #if TCL_MAJOR_VERSION >= 8 3748 #ifdef HAVE_PROTOTYPES 3749 ip_RubyExitObjCmd(ClientData clientData, Tcl_Interp *interp,
3752 ip_RubyExitObjCmd(clientData, interp,
argc,
argv)
3753 ClientData clientData;
3759 #ifdef HAVE_PROTOTYPES 3764 ClientData clientData;
3773 #if TCL_MAJOR_VERSION < 8 3778 DUMP1(
"start ip_RubyExitCommand");
3780 #if TCL_MAJOR_VERSION >= 8 3782 cmd = Tcl_GetStringFromObj(
argv[0], (
int*)
NULL);
3785 if (argc < 1 || argc > 2) {
3787 Tcl_AppendResult(interp,
3788 "wrong number of arguments: should be \"",
3789 cmd,
" ?returnCode?\"", (
char *)
NULL);
3793 if (interp == (Tcl_Interp*)
NULL)
return TCL_OK;
3795 Tcl_ResetResult(interp);
3798 if (!Tcl_InterpDeleted(interp)) {
3801 Tcl_DeleteInterp(interp);
3802 Tcl_Release(interp);
3810 Tcl_AppendResult(interp,
3811 "fail to call \"", cmd,
"\"", (
char *)
NULL);
3820 #if TCL_MAJOR_VERSION >= 8 3821 if (Tcl_GetIntFromObj(interp,
argv[1], &state) == TCL_ERROR) {
3825 param = Tcl_GetStringFromObj(
argv[1], (
int*)
NULL);
3829 Tcl_AppendResult(interp,
3830 "expected integer but got \"",
3838 Tcl_AppendResult(interp,
"fail to call \"", cmd,
" ",
3839 param,
"\"", (
char *)
NULL);
3849 Tcl_AppendResult(interp,
3850 "wrong number of arguments: should be \"",
3851 cmd,
" ?returnCode?\"", (
char *)
NULL);
3864 #if TCL_MAJOR_VERSION >= 8 3865 static int ip_rbUpdateObjCmd
_((ClientData, Tcl_Interp *,
int,
3866 Tcl_Obj *
CONST []));
3868 ip_rbUpdateObjCmd(clientData, interp, objc, objv)
3869 ClientData clientData;
3872 Tcl_Obj *
CONST objv[];
3877 ClientData clientData;
3884 static CONST char *updateOptions[] = {
"idletasks", (
char *)
NULL};
3885 enum updateOptions {REGEXP_IDLETASKS};
3887 DUMP1(
"Ruby's 'update' is called");
3888 if (interp == (Tcl_Interp*)
NULL) {
3893 #ifdef HAVE_NATIVETHREAD 3894 #ifndef RUBY_USE_NATIVE_THREAD 3896 rb_bug(
"cross-thread violation on ip_ruby_eval()");
3901 Tcl_ResetResult(interp);
3904 flags = TCL_DONT_WAIT;
3906 }
else if (objc == 2) {
3907 #if TCL_MAJOR_VERSION >= 8 3909 if (Tcl_GetIndexFromObj(interp, objv[1], (
CONST84 char **)updateOptions,
3910 "option", 0, &optionIndex) != TCL_OK) {
3913 switch ((
enum updateOptions) optionIndex) {
3914 case REGEXP_IDLETASKS: {
3915 flags = TCL_IDLE_EVENTS;
3919 rb_bug(
"ip_rbUpdateObjCmd: bad option index to UpdateOptions");
3923 if (strncmp(objv[1],
"idletasks",
strlen(objv[1])) != 0) {
3924 Tcl_AppendResult(interp,
"bad option \"", objv[1],
3925 "\": must be idletasks", (
char *)
NULL);
3928 flags = TCL_IDLE_EVENTS;
3931 #ifdef Tcl_WrongNumArgs 3932 Tcl_WrongNumArgs(interp, 1, objv,
"[ idletasks ]");
3934 # if TCL_MAJOR_VERSION >= 8 3936 Tcl_AppendResult(interp,
"wrong number of arguments: should be \"",
3937 Tcl_GetStringFromObj(objv[0], &dummy),
3941 Tcl_AppendResult(interp,
"wrong number of arguments: should be \"",
3942 objv[0],
" [ idletasks ]\"", (
char *)
NULL);
3948 Tcl_Preserve(interp);
3956 Tcl_Release(interp);
3971 Tcl_Release(interp);
3982 Tcl_ResetResult(interp);
3983 Tcl_Release(interp);
3985 DUMP1(
"finish Ruby's 'update'");
4001 ClientData clientData;
4005 DUMP1(
"threadUpdateProc is called");
4012 #if TCL_MAJOR_VERSION >= 8 4013 static int ip_rb_threadUpdateObjCmd
_((ClientData, Tcl_Interp *,
int,
4014 Tcl_Obj *
CONST []));
4016 ip_rb_threadUpdateObjCmd(clientData, interp, objc, objv)
4017 ClientData clientData;
4020 Tcl_Obj *
CONST objv[];
4026 ClientData clientData;
4036 static CONST char *updateOptions[] = {
"idletasks", (
char *)
NULL};
4037 enum updateOptions {REGEXP_IDLETASKS};
4041 DUMP1(
"Ruby's 'thread_update' is called");
4042 if (interp == (Tcl_Interp*)
NULL) {
4047 #ifdef HAVE_NATIVETHREAD 4048 #ifndef RUBY_USE_NATIVE_THREAD 4050 rb_bug(
"cross-thread violation on ip_rb_threadUpdateCommand()");
4057 #if TCL_MAJOR_VERSION >= 8 4058 DUMP1(
"call ip_rbUpdateObjCmd");
4059 return ip_rbUpdateObjCmd(clientData, interp, objc, objv);
4061 DUMP1(
"call ip_rbUpdateCommand");
4066 DUMP1(
"start Ruby's 'thread_update' body");
4068 Tcl_ResetResult(interp);
4072 flags = TCL_DONT_WAIT;
4074 }
else if (objc == 2) {
4075 #if TCL_MAJOR_VERSION >= 8 4077 if (Tcl_GetIndexFromObj(interp, objv[1], (
CONST84 char **)updateOptions,
4078 "option", 0, &optionIndex) != TCL_OK) {
4081 switch ((
enum updateOptions) optionIndex) {
4082 case REGEXP_IDLETASKS: {
4084 flags = TCL_IDLE_EVENTS;
4089 rb_bug(
"ip_rb_threadUpdateObjCmd: bad option index to UpdateOptions");
4093 if (strncmp(objv[1],
"idletasks",
strlen(objv[1])) != 0) {
4094 Tcl_AppendResult(interp,
"bad option \"", objv[1],
4095 "\": must be idletasks", (
char *)
NULL);
4099 flags = TCL_IDLE_EVENTS;
4103 #ifdef Tcl_WrongNumArgs 4104 Tcl_WrongNumArgs(interp, 1, objv,
"[ idletasks ]");
4106 # if TCL_MAJOR_VERSION >= 8 4108 Tcl_AppendResult(interp,
"wrong number of arguments: should be \"",
4109 Tcl_GetStringFromObj(objv[0], &dummy),
4113 Tcl_AppendResult(interp,
"wrong number of arguments: should be \"",
4114 objv[0],
" [ idletasks ]\"", (
char *)
NULL);
4120 DUMP1(
"pass argument check");
4125 Tcl_Preserve((ClientData)param);
4127 param->thread = current_thread;
4130 DUMP1(
"set idle proc");
4136 while(!param->done) {
4137 DUMP1(
"wait for complete idle proc");
4147 Tcl_EventuallyFree((ClientData)param, TCL_DYNAMIC);
4150 Tcl_Release((ClientData)param);
4153 ckfree((
char *)param);
4157 DUMP1(
"finish Ruby's 'thread_update'");
4165 #if TCL_MAJOR_VERSION >= 8 4166 static int ip_rbVwaitObjCmd
_((ClientData, Tcl_Interp *,
int,
4167 Tcl_Obj *
CONST []));
4168 static int ip_rb_threadVwaitObjCmd
_((ClientData, Tcl_Interp *,
int,
4169 Tcl_Obj *
CONST []));
4170 static int ip_rbTkWaitObjCmd
_((ClientData, Tcl_Interp *,
int,
4171 Tcl_Obj *
CONST []));
4172 static int ip_rb_threadTkWaitObjCmd
_((ClientData, Tcl_Interp *,
int,
4173 Tcl_Obj *
CONST []));
4183 #if TCL_MAJOR_VERSION >= 8 4188 ClientData clientData;
4194 static char *
VwaitVarProc _((ClientData, Tcl_Interp *,
char *,
char *,
int));
4197 ClientData clientData;
4204 int *donePtr = (
int *) clientData;
4207 return (
char *)
NULL;
4210 #if TCL_MAJOR_VERSION >= 8 4212 ip_rbVwaitObjCmd(clientData, interp, objc, objv)
4213 ClientData clientData;
4216 Tcl_Obj *
CONST objv[];
4220 ClientData clientData;
4226 int ret, done, foundEvent;
4231 DUMP1(
"Ruby's 'vwait' is called");
4232 if (interp == (Tcl_Interp*)
NULL) {
4242 #if TCL_MAJOR_VERSION >= 8 4243 DUMP1(
"call ip_rb_threadVwaitObjCmd");
4244 return ip_rb_threadVwaitObjCmd(clientData, interp, objc, objv);
4246 DUMP1(
"call ip_rb_threadVwaitCommand");
4252 Tcl_Preserve(interp);
4253 #ifdef HAVE_NATIVETHREAD 4254 #ifndef RUBY_USE_NATIVE_THREAD 4256 rb_bug(
"cross-thread violation on ip_rbVwaitCommand()");
4261 Tcl_ResetResult(interp);
4264 #ifdef Tcl_WrongNumArgs 4265 Tcl_WrongNumArgs(interp, 1, objv,
"name");
4270 #if TCL_MAJOR_VERSION >= 8 4272 nameString = Tcl_GetStringFromObj(objv[0], &dummy);
4274 nameString = objv[0];
4276 Tcl_AppendResult(interp,
"wrong number of arguments: should be \"",
4277 nameString,
" name\"", (
char *)
NULL);
4282 Tcl_Release(interp);
4289 #if TCL_MAJOR_VERSION >= 8 4292 nameString = Tcl_GetStringFromObj(objv[1], &dummy);
4294 nameString = objv[1];
4304 ret = Tcl_TraceVar(interp, nameString,
4305 TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
4310 if (ret != TCL_OK) {
4311 #if TCL_MAJOR_VERSION >= 8 4314 Tcl_Release(interp);
4326 Tcl_UntraceVar(interp, nameString,
4327 TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
4334 #if TCL_MAJOR_VERSION >= 8 4337 Tcl_Release(interp);
4352 #if TCL_MAJOR_VERSION >= 8 4355 Tcl_Release(interp);
4365 Tcl_ResetResult(interp);
4370 Tcl_AppendResult(interp,
"can't wait for variable \"", nameString,
4371 "\": would wait forever", (
char *)
NULL);
4375 #if TCL_MAJOR_VERSION >= 8 4378 Tcl_Release(interp);
4382 #if TCL_MAJOR_VERSION >= 8 4385 Tcl_Release(interp);
4393 #if TCL_MAJOR_VERSION >= 8 4398 ClientData clientData;
4405 char *,
char *,
int));
4408 ClientData clientData;
4415 int *donePtr = (
int *) clientData;
4418 return (
char *)
NULL;
4424 ClientData clientData;
4427 int *donePtr = (
int *) clientData;
4429 if (eventPtr->type == VisibilityNotify) {
4432 if (eventPtr->type == DestroyNotify) {
4440 ClientData clientData;
4443 int *donePtr = (
int *) clientData;
4445 if (eventPtr->type == DestroyNotify) {
4450 #if TCL_MAJOR_VERSION >= 8 4452 ip_rbTkWaitObjCmd(clientData, interp, objc, objv)
4453 ClientData clientData;
4456 Tcl_Obj *
CONST objv[];
4460 ClientData clientData;
4466 Tk_Window tkwin = (Tk_Window) clientData;
4469 static CONST char *optionStrings[] = {
"variable",
"visibility",
"window",
4471 enum options { TKWAIT_VARIABLE, TKWAIT_VISIBILITY, TKWAIT_WINDOW };
4476 DUMP1(
"Ruby's 'tkwait' is called");
4477 if (interp == (Tcl_Interp*)
NULL) {
4487 #if TCL_MAJOR_VERSION >= 8 4488 DUMP1(
"call ip_rb_threadTkWaitObjCmd");
4489 return ip_rb_threadTkWaitObjCmd((ClientData)tkwin, interp, objc, objv);
4491 DUMP1(
"call ip_rb_threadTkWaitCommand");
4492 return ip_rb_threadTkWwaitCommand((ClientData)tkwin, interp, objc, objv);
4497 Tcl_Preserve(interp);
4498 Tcl_ResetResult(interp);
4501 #ifdef Tcl_WrongNumArgs 4502 Tcl_WrongNumArgs(interp, 1, objv,
"variable|visibility|window name");
4507 #if TCL_MAJOR_VERSION >= 8 4508 Tcl_AppendResult(interp,
"wrong number of arguments: should be \"",
4509 Tcl_GetStringFromObj(objv[0], &dummy),
4510 " variable|visibility|window name\"",
4513 Tcl_AppendResult(interp,
"wrong number of arguments: should be \"",
4514 objv[0],
" variable|visibility|window name\"",
4521 Tcl_Release(interp);
4525 #if TCL_MAJOR_VERSION >= 8 4536 ret = Tcl_GetIndexFromObj(interp, objv[1],
4537 (
CONST84 char **)optionStrings,
4538 "option", 0, &index);
4542 if (ret != TCL_OK) {
4543 Tcl_Release(interp);
4549 size_t length =
strlen(objv[1]);
4551 if ((c ==
'v') && (strncmp(objv[1],
"variable", length) == 0)
4553 index = TKWAIT_VARIABLE;
4554 }
else if ((c ==
'v') && (strncmp(objv[1],
"visibility", length) == 0)
4556 index = TKWAIT_VISIBILITY;
4557 }
else if ((c ==
'w') && (strncmp(objv[1],
"window", length) == 0)) {
4558 index = TKWAIT_WINDOW;
4560 Tcl_AppendResult(interp,
"bad option \"", objv[1],
4561 "\": must be variable, visibility, or window",
4563 Tcl_Release(interp);
4572 #if TCL_MAJOR_VERSION >= 8 4575 nameString = Tcl_GetStringFromObj(objv[2], &dummy);
4577 nameString = objv[2];
4582 switch ((
enum options) index) {
4583 case TKWAIT_VARIABLE:
4593 ret = Tcl_TraceVar(interp, nameString,
4594 TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
4599 if (ret != TCL_OK) {
4600 #if TCL_MAJOR_VERSION >= 8 4603 Tcl_Release(interp);
4614 Tcl_UntraceVar(interp, nameString,
4615 TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
4618 #if TCL_MAJOR_VERSION >= 8 4626 Tcl_Release(interp);
4641 Tcl_Release(interp);
4648 case TKWAIT_VISIBILITY:
4656 window = Tk_NameToWindow(interp, nameString, tkwin);
4659 if (window ==
NULL) {
4660 Tcl_AppendResult(interp,
": tkwait: ",
4661 "no main-window (not Tk application?)",
4664 #if TCL_MAJOR_VERSION >= 8 4667 Tcl_Release(interp);
4671 Tk_CreateEventHandler(window,
4672 VisibilityChangeMask|StructureNotifyMask,
4683 #if TCL_MAJOR_VERSION >= 8 4686 Tcl_Release(interp);
4701 #if TCL_MAJOR_VERSION >= 8 4704 Tcl_Release(interp);
4717 Tcl_ResetResult(interp);
4718 Tcl_AppendResult(interp,
"window \"", nameString,
4719 "\" was deleted before its visibility changed",
4724 #if TCL_MAJOR_VERSION >= 8 4727 Tcl_Release(interp);
4734 #if TCL_MAJOR_VERSION >= 8 4738 Tk_DeleteEventHandler(window,
4739 VisibilityChangeMask|StructureNotifyMask,
4754 window = Tk_NameToWindow(interp, nameString, tkwin);
4757 #if TCL_MAJOR_VERSION >= 8 4761 if (window ==
NULL) {
4762 Tcl_AppendResult(interp,
": tkwait: ",
4763 "no main-window (not Tk application?)",
4766 Tcl_Release(interp);
4770 Tk_CreateEventHandler(window, StructureNotifyMask,
4781 Tcl_Release(interp);
4796 Tcl_Release(interp);
4813 Tcl_ResetResult(interp);
4814 Tcl_Release(interp);
4826 #if TCL_MAJOR_VERSION >= 8 4831 ClientData clientData;
4838 char *,
char *,
int));
4841 ClientData clientData;
4850 if (flags & (TCL_INTERP_DESTROYED | TCL_TRACE_DESTROYED)) {
4857 return (
char *)
NULL;
4860 #define TKWAIT_MODE_VISIBILITY 1 4861 #define TKWAIT_MODE_DESTROY 2 4866 ClientData clientData;
4871 if (eventPtr->type == VisibilityNotify) {
4874 if (eventPtr->type == DestroyNotify) {
4883 ClientData clientData;
4888 if (eventPtr->type == DestroyNotify) {
4894 #if TCL_MAJOR_VERSION >= 8 4896 ip_rb_threadVwaitObjCmd(clientData, interp, objc, objv)
4897 ClientData clientData;
4900 Tcl_Obj *
CONST objv[];
4904 ClientData clientData;
4917 DUMP1(
"Ruby's 'thread_vwait' is called");
4918 if (interp == (Tcl_Interp*)
NULL) {
4925 #if TCL_MAJOR_VERSION >= 8 4926 DUMP1(
"call ip_rbVwaitObjCmd");
4927 return ip_rbVwaitObjCmd(clientData, interp, objc, objv);
4929 DUMP1(
"call ip_rbVwaitCommand");
4934 Tcl_Preserve(interp);
4935 Tcl_ResetResult(interp);
4938 #ifdef Tcl_WrongNumArgs 4939 Tcl_WrongNumArgs(interp, 1, objv,
"name");
4944 #if TCL_MAJOR_VERSION >= 8 4946 nameString = Tcl_GetStringFromObj(objv[0], &dummy);
4948 nameString = objv[0];
4950 Tcl_AppendResult(interp,
"wrong number of arguments: should be \"",
4951 nameString,
" name\"", (
char *)
NULL);
4956 Tcl_Release(interp);
4960 #if TCL_MAJOR_VERSION >= 8 4963 nameString = Tcl_GetStringFromObj(objv[1], &dummy);
4965 nameString = objv[1];
4973 Tcl_Preserve((ClientData)param);
4975 param->thread = current_thread;
4985 ret = Tcl_TraceVar(interp, nameString,
4986 TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
4991 if (ret != TCL_OK) {
4993 Tcl_EventuallyFree((ClientData)param, TCL_DYNAMIC);
4996 Tcl_Release((ClientData)param);
4999 ckfree((
char *)param);
5003 #if TCL_MAJOR_VERSION >= 8 5006 Tcl_Release(interp);
5013 while(!param->done) {
5025 if (param->done > 0) {
5026 Tcl_UntraceVar(interp, nameString,
5027 TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
5032 Tcl_EventuallyFree((ClientData)param, TCL_DYNAMIC);
5035 Tcl_Release((ClientData)param);
5038 ckfree((
char *)param);
5044 #if TCL_MAJOR_VERSION >= 8 5047 Tcl_Release(interp);
5051 #if TCL_MAJOR_VERSION >= 8 5053 ip_rb_threadTkWaitObjCmd(clientData, interp, objc, objv)
5054 ClientData clientData;
5057 Tcl_Obj *
CONST objv[];
5061 ClientData clientData;
5068 Tk_Window tkwin = (Tk_Window) clientData;
5071 static CONST char *optionStrings[] = {
"variable",
"visibility",
"window",
5073 enum options { TKWAIT_VARIABLE, TKWAIT_VISIBILITY, TKWAIT_WINDOW };
5080 DUMP1(
"Ruby's 'thread_tkwait' is called");
5081 if (interp == (Tcl_Interp*)
NULL) {
5088 #if TCL_MAJOR_VERSION >= 8 5089 DUMP1(
"call ip_rbTkWaitObjCmd");
5091 DUMP2(
"current_thread %lx", current_thread);
5092 return ip_rbTkWaitObjCmd(clientData, interp, objc, objv);
5094 DUMP1(
"call rb_VwaitCommand");
5099 Tcl_Preserve(interp);
5100 Tcl_Preserve(tkwin);
5102 Tcl_ResetResult(interp);
5105 #ifdef Tcl_WrongNumArgs 5106 Tcl_WrongNumArgs(interp, 1, objv,
"variable|visibility|window name");
5111 #if TCL_MAJOR_VERSION >= 8 5112 Tcl_AppendResult(interp,
"wrong number of arguments: should be \"",
5113 Tcl_GetStringFromObj(objv[0], &dummy),
5114 " variable|visibility|window name\"",
5117 Tcl_AppendResult(interp,
"wrong number of arguments: should be \"",
5118 objv[0],
" variable|visibility|window name\"",
5126 Tcl_Release(interp);
5130 #if TCL_MAJOR_VERSION >= 8 5140 ret = Tcl_GetIndexFromObj(interp, objv[1],
5141 (
CONST84 char **)optionStrings,
5142 "option", 0, &index);
5146 if (ret != TCL_OK) {
5148 Tcl_Release(interp);
5154 size_t length =
strlen(objv[1]);
5156 if ((c ==
'v') && (strncmp(objv[1],
"variable", length) == 0)
5158 index = TKWAIT_VARIABLE;
5159 }
else if ((c ==
'v') && (strncmp(objv[1],
"visibility", length) == 0)
5161 index = TKWAIT_VISIBILITY;
5162 }
else if ((c ==
'w') && (strncmp(objv[1],
"window", length) == 0)) {
5163 index = TKWAIT_WINDOW;
5165 Tcl_AppendResult(interp,
"bad option \"", objv[1],
5166 "\": must be variable, visibility, or window",
5169 Tcl_Release(interp);
5178 #if TCL_MAJOR_VERSION >= 8 5181 nameString = Tcl_GetStringFromObj(objv[2], &dummy);
5183 nameString = objv[2];
5189 Tcl_Preserve((ClientData)param);
5191 param->thread = current_thread;
5196 switch ((
enum options) index) {
5197 case TKWAIT_VARIABLE:
5207 ret = Tcl_TraceVar(interp, nameString,
5208 TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
5213 if (ret != TCL_OK) {
5215 Tcl_EventuallyFree((ClientData)param, TCL_DYNAMIC);
5221 ckfree((
char *)param);
5225 #if TCL_MAJOR_VERSION >= 8 5230 Tcl_Release(interp);
5237 while(!param->done) {
5249 if (param->done > 0) {
5250 Tcl_UntraceVar(interp, nameString,
5251 TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
5255 #if TCL_MAJOR_VERSION >= 8 5263 case TKWAIT_VISIBILITY:
5271 window = Tk_NameToWindow(interp, nameString, tkwin);
5279 if (Tcl_GetCommandInfo(interp,
".", &info)) {
5280 window = Tk_NameToWindow(interp, nameString, tkwin);
5287 if (window ==
NULL) {
5288 Tcl_AppendResult(interp,
": thread_tkwait: ",
5289 "no main-window (not Tk application?)",
5295 Tcl_EventuallyFree((ClientData)param, TCL_DYNAMIC);
5301 ckfree((
char *)param);
5305 #if TCL_MAJOR_VERSION >= 8 5309 Tcl_Release(interp);
5312 Tcl_Preserve(window);
5314 Tk_CreateEventHandler(window,
5315 VisibilityChangeMask|StructureNotifyMask,
5338 Tk_DeleteEventHandler(window,
5339 VisibilityChangeMask|StructureNotifyMask,
5341 (ClientData) param);
5344 if (param->done != 1) {
5345 Tcl_ResetResult(interp);
5346 Tcl_AppendResult(interp,
"window \"", nameString,
5347 "\" was deleted before its visibility changed",
5352 Tcl_Release(window);
5355 Tcl_EventuallyFree((ClientData)param, TCL_DYNAMIC);
5361 ckfree((
char *)param);
5365 #if TCL_MAJOR_VERSION >= 8 5370 Tcl_Release(interp);
5374 Tcl_Release(window);
5376 #if TCL_MAJOR_VERSION >= 8 5392 window = Tk_NameToWindow(interp, nameString, tkwin);
5400 if (Tcl_GetCommandInfo(interp,
".", &info)) {
5401 window = Tk_NameToWindow(interp, nameString, tkwin);
5408 #if TCL_MAJOR_VERSION >= 8 5412 if (window ==
NULL) {
5413 Tcl_AppendResult(interp,
": thread_tkwait: ",
5414 "no main-window (not Tk application?)",
5420 Tcl_EventuallyFree((ClientData)param, TCL_DYNAMIC);
5426 ckfree((
char *)param);
5431 Tcl_Release(interp);
5435 Tcl_Preserve(window);
5437 Tk_CreateEventHandler(window, StructureNotifyMask,
5454 Tcl_Release(window);
5470 Tcl_EventuallyFree((ClientData)param, TCL_DYNAMIC);
5473 Tcl_Release((ClientData)param);
5476 ckfree((
char *)param);
5485 Tcl_ResetResult(interp);
5488 Tcl_Release(interp);
5524 #if TCL_MAJOR_VERSION >= 8 5531 Tcl_Obj *slave_list, *elem;
5535 DUMP1(
"delete slaves");
5539 if (!Tcl_InterpDeleted(ip) &&
Tcl_Eval(ip,
"interp slaves") == TCL_OK) {
5540 slave_list = Tcl_GetObjResult(ip);
5543 if (Tcl_ListObjLength((Tcl_Interp*)
NULL, slave_list, &len) == TCL_OK) {
5544 for(i = 0; i < len; i++) {
5545 Tcl_ListObjIndex((Tcl_Interp*)
NULL, slave_list, i, &elem);
5547 if (elem == (Tcl_Obj*)
NULL)
continue;
5553 slave_name = Tcl_GetStringFromObj(elem, (
int*)
NULL);
5554 DUMP2(
"delete slave:'%s'", slave_name);
5558 slave = Tcl_GetSlave(ip, slave_name);
5559 if (slave == (Tcl_Interp*)
NULL)
continue;
5561 if (!Tcl_InterpDeleted(slave)) {
5565 Tcl_DeleteInterp(slave);
5589 DUMP1(
"delete slaves");
5593 if (!Tcl_InterpDeleted(ip) &&
Tcl_Eval(ip,
"interp slaves") == TCL_OK) {
5594 slave_list = ip->result;
5595 if (Tcl_SplitList((Tcl_Interp*)
NULL,
5596 slave_list, &
argc, &
argv) == TCL_OK) {
5597 for(i = 0; i <
argc; i++) {
5598 slave_name =
argv[i];
5600 DUMP2(
"delete slave:'%s'", slave_name);
5602 slave = Tcl_GetSlave(ip, slave_name);
5603 if (slave == (Tcl_Interp*)
NULL)
continue;
5605 if (!Tcl_InterpDeleted(slave)) {
5609 Tcl_DeleteInterp(slave);
5622 #ifdef HAVE_PROTOTYPES 5633 #if TCL_MAJOR_VERSION >= 8 5634 #ifdef HAVE_PROTOTYPES 5635 ip_null_proc(ClientData clientData, Tcl_Interp *interp,
5639 ClientData clientData;
5645 #ifdef HAVE_PROTOTYPES 5649 ClientData clientData;
5656 Tcl_ResetResult(interp);
5667 VALUE rb_debug_bup, rb_verbose_bup;
5675 DUMP1(
"start ip_finalize");
5677 if (ip == (Tcl_Interp*)
NULL) {
5678 DUMP1(
"ip is NULL");
5682 if (Tcl_InterpDeleted(ip)) {
5683 DUMP2(
"ip(%p) is already deleted", ip);
5687 #if TCL_NAMESPACE_DEBUG 5688 if (ip_null_namespace(ip)) {
5689 DUMP2(
"ip(%p) has null namespace", ip);
5711 #if TCL_MAJOR_VERSION >= 8 5713 (ClientData)
NULL, (Tcl_CmdDeleteProc *)
NULL);
5715 (ClientData)
NULL, (Tcl_CmdDeleteProc *)
NULL);
5717 (ClientData)
NULL, (Tcl_CmdDeleteProc *)
NULL);
5720 (ClientData)
NULL, (Tcl_CmdDeleteProc *)
NULL);
5722 (ClientData)
NULL, (Tcl_CmdDeleteProc *)
NULL);
5724 (ClientData)
NULL, (Tcl_CmdDeleteProc *)
NULL);
5736 DUMP1(
"check `destroy'");
5737 if (Tcl_GetCommandInfo(ip,
"destroy", &info)) {
5738 DUMP1(
"call `destroy .'");
5743 DUMP1(
"destroy root widget");
5757 Tk_Window win = Tk_MainWindow(ip);
5759 DUMP1(
"call Tk_DestroyWindow");
5762 if (! (((Tk_FakeWin*)win)->flags & TK_ALREADY_DEAD)) {
5763 Tk_DestroyWindow(win);
5771 DUMP1(
"check `finalize-hook-proc'");
5781 DUMP1(
"check `foreach' & `after'");
5782 if ( Tcl_GetCommandInfo(ip,
"foreach", &info)
5783 && Tcl_GetCommandInfo(ip,
"after", &info) ) {
5784 DUMP1(
"cancel after callbacks");
5787 Tcl_GlobalEval(ip,
"catch {foreach id [after info] {after cancel $id}}");
5794 DUMP1(
"finish ip_finalize");
5808 DUMP2(
"free Tcl Interp %lx", (
unsigned long)ptr->
ip);
5813 if ( ptr->
ip != (Tcl_Interp*)
NULL 5814 && !Tcl_InterpDeleted(ptr->
ip)
5815 && Tcl_GetMaster(ptr->
ip) != (Tcl_Interp*)
NULL 5816 && !Tcl_InterpDeleted(Tcl_GetMaster(ptr->
ip)) ) {
5817 DUMP2(
"parent IP(%lx) is not deleted",
5818 (
unsigned long)Tcl_GetMaster(ptr->
ip));
5819 DUMP2(
"slave IP(%lx) should not be deleted",
5820 (
unsigned long)ptr->
ip);
5827 if (ptr->
ip == (Tcl_Interp*)
NULL) {
5828 DUMP1(
"ip_free is called for deleted IP");
5835 if (!Tcl_InterpDeleted(ptr->
ip)) {
5838 Tcl_DeleteInterp(ptr->
ip);
5839 Tcl_Release(ptr->
ip);
5842 ptr->
ip = (Tcl_Interp*)
NULL;
5849 DUMP1(
"complete freeing Tcl Interp");
5868 #if TCL_MAJOR_VERSION >= 8 5869 DUMP1(
"Tcl_CreateObjCommand(\"vwait\")");
5870 Tcl_CreateObjCommand(interp,
"vwait", ip_rbVwaitObjCmd,
5871 (ClientData)
NULL, (Tcl_CmdDeleteProc *)
NULL);
5873 DUMP1(
"Tcl_CreateCommand(\"vwait\")");
5875 (ClientData)
NULL, (Tcl_CmdDeleteProc *)
NULL);
5879 #if TCL_MAJOR_VERSION >= 8 5880 DUMP1(
"Tcl_CreateObjCommand(\"tkwait\")");
5881 Tcl_CreateObjCommand(interp,
"tkwait", ip_rbTkWaitObjCmd,
5882 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
5884 DUMP1(
"Tcl_CreateCommand(\"tkwait\")");
5886 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
5890 #if TCL_MAJOR_VERSION >= 8 5891 DUMP1(
"Tcl_CreateObjCommand(\"thread_vwait\")");
5892 Tcl_CreateObjCommand(interp,
"thread_vwait", ip_rb_threadVwaitObjCmd,
5893 (ClientData)
NULL, (Tcl_CmdDeleteProc *)
NULL);
5895 DUMP1(
"Tcl_CreateCommand(\"thread_vwait\")");
5897 (ClientData)
NULL, (Tcl_CmdDeleteProc *)
NULL);
5901 #if TCL_MAJOR_VERSION >= 8 5902 DUMP1(
"Tcl_CreateObjCommand(\"thread_tkwait\")");
5903 Tcl_CreateObjCommand(interp,
"thread_tkwait", ip_rb_threadTkWaitObjCmd,
5904 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
5906 DUMP1(
"Tcl_CreateCommand(\"thread_tkwait\")");
5908 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
5912 #if TCL_MAJOR_VERSION >= 8 5913 DUMP1(
"Tcl_CreateObjCommand(\"update\")");
5914 Tcl_CreateObjCommand(interp,
"update", ip_rbUpdateObjCmd,
5915 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
5917 DUMP1(
"Tcl_CreateCommand(\"update\")");
5919 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
5923 #if TCL_MAJOR_VERSION >= 8 5924 DUMP1(
"Tcl_CreateObjCommand(\"thread_update\")");
5925 Tcl_CreateObjCommand(interp,
"thread_update", ip_rb_threadUpdateObjCmd,
5926 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
5928 DUMP1(
"Tcl_CreateCommand(\"thread_update\")");
5930 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
5935 #if TCL_MAJOR_VERSION >= 8 5937 ip_rb_replaceSlaveTkCmdsObjCmd(clientData, interp, objc, objv)
5938 ClientData clientData;
5941 Tcl_Obj *
CONST objv[];
5945 ClientData clientData;
5956 #ifdef Tcl_WrongNumArgs 5957 Tcl_WrongNumArgs(interp, 1, objv,
"slave_name");
5960 #if TCL_MAJOR_VERSION >= 8 5961 nameString = Tcl_GetStringFromObj(objv[0], (
int*)
NULL);
5963 nameString = objv[0];
5965 Tcl_AppendResult(interp,
"wrong number of arguments: should be \"",
5966 nameString,
" slave_name\"", (
char *)
NULL);
5970 #if TCL_MAJOR_VERSION >= 8 5971 slave_name = Tcl_GetStringFromObj(objv[1], (
int*)
NULL);
5973 slave_name = objv[1];
5976 slave = Tcl_GetSlave(interp, slave_name);
5977 if (slave ==
NULL) {
5978 Tcl_AppendResult(interp,
"cannot find slave \"",
5979 slave_name,
"\"", (
char *)
NULL);
5982 mainWin = Tk_MainWindow(slave);
5985 #if TCL_MAJOR_VERSION >= 8 5986 DUMP1(
"Tcl_CreateObjCommand(\"exit\") --> \"interp_exit\"");
5987 Tcl_CreateObjCommand(slave,
"exit", ip_InterpExitObjCmd,
5988 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
5990 DUMP1(
"Tcl_CreateCommand(\"exit\") --> \"interp_exit\"");
5992 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
6002 #if TCL_MAJOR_VERSION >= 8 6003 static int ip_rbNamespaceObjCmd
_((ClientData, Tcl_Interp *,
int,
6004 Tcl_Obj *
CONST []));
6006 ip_rbNamespaceObjCmd(clientData, interp, objc, objv)
6007 ClientData clientData;
6010 Tcl_Obj *
CONST objv[];
6015 DUMP1(
"call ip_rbNamespaceObjCmd");
6016 DUMP2(
"objc = %d", objc);
6017 DUMP2(
"objv[0] = '%s'", Tcl_GetString(objv[0]));
6018 DUMP2(
"objv[1] = '%s'", Tcl_GetString(objv[1]));
6019 if (!Tcl_GetCommandInfo(interp,
"__orig_namespace_command__", &(info))) {
6020 DUMP1(
"fail to get __orig_namespace_command__");
6021 Tcl_ResetResult(interp);
6022 Tcl_AppendResult(interp,
6023 "invalid command name \"namespace\"", (
char*)
NULL);
6030 if (info.isNativeObjectProc) {
6031 #if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION < 6 6032 DUMP1(
"call a native-object-proc");
6033 ret = (*(info.objProc))(info.objClientData, interp, objc, objv);
6038 char org_ns_cmd_name[] =
"__orig_namespace_command__";
6040 DUMP1(
"call a native-object-proc for tcl8.6 or later");
6043 cp_objv[0] = Tcl_NewStringObj(org_ns_cmd_name,
strlen(org_ns_cmd_name));
6044 for(i = 1; i < objc; i++) {
6045 cp_objv[i] = objv[i];
6047 cp_objv[objc] = (Tcl_Obj *)
NULL;
6050 ret = Tcl_EvalObjv(interp, objc, cp_objv, 0);
6052 ckfree((
char*)cp_objv);
6059 DUMP1(
"call with the string-interface");
6063 Tcl_Preserve((ClientData)
argv);
6066 for(i = 0; i < objc; i++) {
6068 argv[i] = Tcl_GetStringFromObj(objv[i], (
int*)
NULL);
6072 ret = (*(info.proc))(info.clientData, interp,
6076 Tcl_EventuallyFree((ClientData)
argv, TCL_DYNAMIC);
6079 Tcl_Release((ClientData)
argv);
6082 ckfree((
char*)
argv);
6090 DUMP1(
"end of ip_rbNamespaceObjCmd");
6099 #if TCL_MAJOR_VERSION >= 8 6101 #if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION < 6 6102 Tcl_CmdInfo orig_info;
6104 if (!Tcl_GetCommandInfo(interp,
"namespace", &(orig_info))) {
6108 if (orig_info.isNativeObjectProc) {
6109 Tcl_CreateObjCommand(interp,
"__orig_namespace_command__",
6110 orig_info.objProc, orig_info.objClientData,
6111 orig_info.deleteProc);
6113 Tcl_CreateCommand(interp,
"__orig_namespace_command__",
6114 orig_info.proc, orig_info.clientData,
6115 orig_info.deleteProc);
6119 Tcl_GlobalEval(interp,
"rename namespace __orig_namespace_command__");
6123 Tcl_CreateObjCommand(interp,
"namespace", ip_rbNamespaceObjCmd,
6124 (ClientData) 0, (Tcl_CmdDeleteProc *)
NULL);
6131 #ifdef HAVE_PROTOTYPES 6135 ClientData clientData;
6142 DUMP1(
"start ip_CallWhenDeleted");
6148 DUMP1(
"finish ip_CallWhenDeleted");
6166 Tk_Window mainWin = (Tk_Window)
NULL;
6171 "Cannot create a TclTkIp object at level %d",
6180 #ifdef RUBY_USE_NATIVE_THREAD 6181 ptr->tk_thread_id = 0;
6188 DUMP1(
"Tcl_CreateInterp");
6211 #if TCL_MAJOR_VERSION >= 8 6212 #if TCL_NAMESPACE_DEBUG 6213 DUMP1(
"get current namespace");
6214 if ((ptr->default_ns = Tcl_GetCurrentNamespace(ptr->
ip))
6215 == (Tcl_Namespace*)
NULL) {
6228 #if defined CREATE_RUBYTK_KIT || defined CREATE_RUBYKIT 6231 # if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION > 84 6233 Tcl_DString encodingName;
6234 Tcl_GetEncodingNameFromEnvironment(&encodingName);
6235 if (strcmp(Tcl_DStringValue(&encodingName), Tcl_GetEncodingName(
NULL))) {
6237 Tcl_SetSystemEncoding(
NULL, Tcl_DStringValue(&encodingName));
6239 Tcl_SetVar(
current_interp,
"tclkit_system_encoding", Tcl_DStringValue(&encodingName), 0);
6240 Tcl_DStringFree(&encodingName);
6246 Tcl_Eval(ptr->
ip,
"set argc 0; set argv {}; set argv0 tcltklib.so");
6258 Tcl_Eval(ptr->
ip,
"set argc [llength $argv]");
6262 if (!
NIL_P(argv0)) {
6265 Tcl_SetVar(ptr->
ip,
"argv0",
"ruby", TCL_GLOBAL_ONLY);
6279 #if (defined CREATE_RUBYTK_KIT || defined CREATE_RUBYKIT) && (!defined KIT_LITE) && (10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION == 85) 6286 Tcl_Eval(ptr->
ip,
"catch {rename ::chan ::_tmp_chan}");
6287 if (Tcl_Init(ptr->
ip) == TCL_ERROR) {
6290 Tcl_Eval(ptr->
ip,
"catch {rename ::_tmp_chan ::chan}");
6292 if (Tcl_Init(ptr->
ip) == TCL_ERROR) {
6317 DUMP1(
"Tcl_StaticPackage(\"Tk\")");
6318 #if TCL_MAJOR_VERSION >= 8 6319 Tcl_StaticPackage(ptr->
ip,
"Tk", Tk_Init, Tk_SafeInit);
6321 Tcl_StaticPackage(ptr->
ip,
"Tk", Tk_Init,
6322 (Tcl_PackageInitProc *)
NULL);
6325 #ifdef RUBY_USE_NATIVE_THREAD 6327 ptr->tk_thread_id = Tcl_GetCurrentThread();
6330 mainWin = Tk_MainWindow(ptr->
ip);
6331 Tk_Preserve((ClientData)mainWin);
6335 #if TCL_MAJOR_VERSION >= 8 6336 DUMP1(
"Tcl_CreateObjCommand(\"ruby\")");
6338 (Tcl_CmdDeleteProc *)
NULL);
6339 DUMP1(
"Tcl_CreateObjCommand(\"ruby_eval\")");
6341 (Tcl_CmdDeleteProc *)
NULL);
6342 DUMP1(
"Tcl_CreateObjCommand(\"ruby_cmd\")");
6344 (Tcl_CmdDeleteProc *)
NULL);
6346 DUMP1(
"Tcl_CreateCommand(\"ruby\")");
6348 (Tcl_CmdDeleteProc *)
NULL);
6349 DUMP1(
"Tcl_CreateCommand(\"ruby_eval\")");
6351 (Tcl_CmdDeleteProc *)
NULL);
6352 DUMP1(
"Tcl_CreateCommand(\"ruby_cmd\")");
6354 (Tcl_CmdDeleteProc *)
NULL);
6358 #if TCL_MAJOR_VERSION >= 8 6359 DUMP1(
"Tcl_CreateObjCommand(\"interp_exit\")");
6360 Tcl_CreateObjCommand(ptr->
ip,
"interp_exit", ip_InterpExitObjCmd,
6361 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
6362 DUMP1(
"Tcl_CreateObjCommand(\"ruby_exit\")");
6363 Tcl_CreateObjCommand(ptr->
ip,
"ruby_exit", ip_RubyExitObjCmd,
6364 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
6365 DUMP1(
"Tcl_CreateObjCommand(\"exit\") --> \"ruby_exit\"");
6366 Tcl_CreateObjCommand(ptr->
ip,
"exit", ip_RubyExitObjCmd,
6367 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
6369 DUMP1(
"Tcl_CreateCommand(\"interp_exit\")");
6371 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
6372 DUMP1(
"Tcl_CreateCommand(\"ruby_exit\")");
6374 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
6375 DUMP1(
"Tcl_CreateCommand(\"exit\") --> \"ruby_exit\"");
6377 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
6387 #if TCL_MAJOR_VERSION >= 8 6388 Tcl_CreateObjCommand(ptr->
ip,
"__replace_slave_tk_commands__",
6389 ip_rb_replaceSlaveTkCmdsObjCmd,
6390 (ClientData)
NULL, (Tcl_CmdDeleteProc *)
NULL);
6392 Tcl_CreateCommand(ptr->
ip,
"__replace_slave_tk_commands__",
6394 (ClientData)
NULL, (Tcl_CmdDeleteProc *)
NULL);
6400 if (mainWin != (Tk_Window)
NULL) {
6401 Tk_Release((ClientData)mainWin);
6425 "deleted master cannot create a new slave");
6431 if (Tcl_IsSafe(master->
ip) == 1) {
6433 }
else if (safemode ==
Qfalse ||
NIL_P(safemode)) {
6444 if (
RTEST(with_tk)) {
6457 #ifdef RUBY_USE_NATIVE_THREAD 6459 slave->tk_thread_id = master->tk_thread_id;
6469 "fail to create the new slave interpreter");
6471 #if TCL_MAJOR_VERSION >= 8 6472 #if TCL_NAMESPACE_DEBUG 6473 slave->default_ns = Tcl_GetCurrentNamespace(slave->
ip);
6483 #if TCL_MAJOR_VERSION >= 8 6484 DUMP1(
"Tcl_CreateObjCommand(\"exit\") --> \"interp_exit\"");
6485 Tcl_CreateObjCommand(slave->
ip,
"exit", ip_InterpExitObjCmd,
6486 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
6488 DUMP1(
"Tcl_CreateCommand(\"exit\") --> \"interp_exit\"");
6490 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
6500 #if TCL_MAJOR_VERSION >= 8 6501 Tcl_CreateObjCommand(slave->
ip,
"__replace_slave_tk_commands__",
6502 ip_rb_replaceSlaveTkCmdsObjCmd,
6503 (ClientData)
NULL, (Tcl_CmdDeleteProc *)
NULL);
6505 Tcl_CreateCommand(slave->
ip,
"__replace_slave_tk_commands__",
6507 (ClientData)
NULL, (Tcl_CmdDeleteProc *)
NULL);
6532 "deleted master cannot create a new slave interpreter");
6539 if (Tcl_IsSafe(master->
ip) != 1
6545 callargv[1] = safemode;
6569 #if defined(MAC_TCL) || defined(__WIN32__) 6570 #if TCL_MAJOR_VERSION < 8 \ 6571 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0) \ 6572 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 1 \ 6573 && (TCL_RELEASE_LEVEL == TCL_ALPHA_RELEASE \ 6574 || (TCL_RELEASE_LEVEL == TCL_BETA_RELEASE \ 6575 && TCL_RELEASE_SERIAL < 2) ) ) 6576 EXTERN void TkConsoleCreate
_((
void));
6578 #if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 1 \ 6579 && ( (TCL_RELEASE_LEVEL == TCL_FINAL_RELEASE \ 6580 && TCL_RELEASE_SERIAL == 0) \ 6581 || (TCL_RELEASE_LEVEL == TCL_BETA_RELEASE \ 6582 && TCL_RELEASE_SERIAL >= 2) ) 6583 EXTERN void TkConsoleCreate_
_((
void));
6598 if (Tcl_GetVar(ptr->
ip,
"tcl_interactive",TCL_GLOBAL_ONLY) == (
char*)
NULL) {
6599 Tcl_SetVar(ptr->
ip,
"tcl_interactive",
"0", TCL_GLOBAL_ONLY);
6602 #if TCL_MAJOR_VERSION > 8 \ 6603 || (TCL_MAJOR_VERSION == 8 \ 6604 && (TCL_MINOR_VERSION > 1 \ 6605 || (TCL_MINOR_VERSION == 1 \ 6606 && TCL_RELEASE_LEVEL == TCL_FINAL_RELEASE \ 6607 && TCL_RELEASE_SERIAL >= 1) ) ) 6608 Tk_InitConsoleChannels(ptr->
ip);
6610 if (Tk_CreateConsoleWindow(ptr->
ip) != TCL_OK) {
6614 #if defined(MAC_TCL) || defined(__WIN32__) 6615 #if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 1 \ 6616 && ( (TCL_RELEASE_LEVEL == TCL_FINAL_RELEASE && TCL_RELEASE_SERIAL == 0) \ 6617 || (TCL_RELEASE_LEVEL == TCL_BETA_RELEASE && TCL_RELEASE_SERIAL >= 2) ) 6623 if (TkConsoleInit(ptr->
ip) != TCL_OK) {
6663 if (Tcl_MakeSafe(ptr->
ip) == TCL_ERROR) {
6674 #if TCL_MAJOR_VERSION >= 8 6675 DUMP1(
"Tcl_CreateObjCommand(\"exit\") --> \"interp_exit\"");
6676 Tcl_CreateObjCommand(ptr->
ip,
"exit", ip_InterpExitObjCmd,
6677 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
6679 DUMP1(
"Tcl_CreateCommand(\"exit\") --> \"interp_exit\"");
6681 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
6713 if (Tcl_IsSafe(ptr->
ip)) {
6753 if (Tcl_IsSafe(ptr->
ip)) {
6755 "insecure operation on a safe interpreter");
6768 #if TCL_MAJOR_VERSION >= 8 6769 DUMP1(
"Tcl_CreateObjCommand(\"exit\") --> \"ruby_exit\"");
6770 Tcl_CreateObjCommand(ptr->
ip,
"exit", ip_RubyExitObjCmd,
6771 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
6773 DUMP1(
"Tcl_CreateCommand(\"exit\") --> \"ruby_exit\"");
6775 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
6781 #if TCL_MAJOR_VERSION >= 8 6782 DUMP1(
"Tcl_CreateObjCommand(\"exit\") --> \"interp_exit\"");
6783 Tcl_CreateObjCommand(ptr->
ip,
"exit", ip_InterpExitObjCmd,
6784 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
6786 DUMP1(
"Tcl_CreateCommand(\"exit\") --> \"interp_exit\"");
6788 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
6804 DUMP1(
"delete deleted IP");
6811 DUMP1(
"delete interp");
6812 if (!Tcl_InterpDeleted(ptr->
ip)) {
6813 DUMP1(
"call ip_finalize");
6816 Tcl_DeleteInterp(ptr->
ip);
6817 Tcl_Release(ptr->
ip);
6838 #if TCL_NAMESPACE_DEBUG 6839 if (rbtk_invalid_namespace(ptr)) {
6872 }
else if (Tk_MainWindow(ptr->
ip) == (Tk_Window)
NULL) {
6888 #if TCL_MAJOR_VERSION >= 8 6890 get_str_from_obj(obj)
6893 int len, binary = 0;
6897 #if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 6898 s = Tcl_GetStringFromObj(obj, &len);
6900 #if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION <= 3 6902 if (Tcl_GetCharLength(obj) != Tcl_UniCharLen(Tcl_GetUnicode(obj))) {
6904 s = (
char *)Tcl_GetByteArrayFromObj(obj, &len);
6908 s = Tcl_GetStringFromObj(obj, &len);
6911 if (IS_TCL_BYTEARRAY(obj)) {
6912 s = (
char *)Tcl_GetByteArrayFromObj(obj, &len);
6915 s = Tcl_GetStringFromObj(obj, &len);
6922 #ifdef HAVE_RUBY_ENCODING_H 6926 #if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 1) 6928 #ifdef HAVE_RUBY_ENCODING_H 6938 get_obj_from_str(str)
6943 #if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 6944 return Tcl_NewStringObj((
char*)s,
RSTRING_LEN(str));
6952 return Tcl_NewByteArrayObj((
const unsigned char *)s,
RSTRING_LENINT(str));
6957 #ifdef HAVE_RUBY_ENCODING_H 6960 return Tcl_NewByteArrayObj((
const unsigned char *)s,
RSTRING_LENINT(str));
6964 return Tcl_NewByteArrayObj((
const unsigned char *)s,
RSTRING_LENINT(str));
6977 #if TCL_MAJOR_VERSION >= 8 6979 volatile VALUE strval;
6981 retObj = Tcl_GetObjResult(interp);
6983 strval = get_str_from_obj(retObj);
6985 Tcl_ResetResult(interp);
7015 volatile VALUE q_dat;
7019 DUMP2(
"do_call_queue_handler : evPtr = %p", evPtr);
7021 DUMP2(
"added by thread : %lx", thread);
7024 DUMP1(
"processed by another event-loop");
7027 DUMP1(
"process it on current event-loop");
7032 DUMP1(
"caller is not yet ready to receive the result -> pending");
7058 DUMP2(
"call function (for caller thread:%lx)", thread);
7081 DUMP2(
"back to caller (caller thread:%lx)", thread);
7083 #if CONTROL_BY_STATUS_OF_RB_THREAD_WAITING_FOR_VALUE 7089 DUMP1(
"finish back to caller");
7090 #if DO_THREAD_SCHEDULE_AT_CALLBACK_DONE 7094 DUMP2(
"caller is dead (caller thread:%lx)", thread);
7113 int is_tk_evloop_thread;
7115 volatile VALUE ip_obj = obj;
7127 #ifdef RUBY_USE_NATIVE_THREAD 7130 is_tk_evloop_thread = (ptr->tk_thread_id == (Tcl_ThreadId) 0
7131 || ptr->tk_thread_id == Tcl_GetCurrentThread());
7134 is_tk_evloop_thread = (tk_eventloop_thread_id == (Tcl_ThreadId) 0
7135 || tk_eventloop_thread_id == Tcl_GetCurrentThread());
7138 is_tk_evloop_thread = 1;
7141 if (is_tk_evloop_thread
7145 DUMP2(
"tk_funcall from thread:%lx but no eventloop", current);
7147 DUMP2(
"tk_funcall from current eventloop %lx", current);
7156 DUMP2(
"tk_funcall from thread %lx (NOT current eventloop)", current);
7166 Tcl_Preserve((ClientData)temp);
7176 Tcl_Preserve((ClientData)alloc_done);
7184 Tcl_Preserve(callq);
7191 callq->
done = alloc_done;
7202 DUMP1(
"add handler");
7203 #ifdef RUBY_USE_NATIVE_THREAD 7204 if (ptr && ptr->tk_thread_id) {
7207 Tcl_ThreadQueueEvent(ptr->tk_thread_id,
7208 (Tcl_Event*)callq, TCL_QUEUE_HEAD);
7209 Tcl_ThreadAlert(ptr->tk_thread_id);
7210 }
else if (tk_eventloop_thread_id) {
7213 Tcl_ThreadQueueEvent(tk_eventloop_thread_id,
7214 (Tcl_Event*)callq, TCL_QUEUE_HEAD);
7215 Tcl_ThreadAlert(tk_eventloop_thread_id);
7218 Tcl_QueueEvent((Tcl_Event*)callq, TCL_QUEUE_HEAD);
7222 Tcl_QueueEvent((Tcl_Event*)callq, TCL_QUEUE_HEAD);
7231 DUMP2(
"callq wait for handler (current thread:%lx)", current);
7232 while(*alloc_done >= 0) {
7233 DUMP2(
"*** callq wait for handler (current thread:%lx)", current);
7237 DUMP2(
"*** callq wakeup (current thread:%lx)", current);
7240 DUMP1(
"*** callq lost eventloop thread");
7244 DUMP2(
"back from handler (current thread:%lx)", current);
7249 Tcl_EventuallyFree((ClientData)alloc_done, TCL_DYNAMIC);
7252 Tcl_Release((ClientData)alloc_done);
7255 ckfree((
char*)alloc_done);
7265 Tcl_EventuallyFree((ClientData)
argv, TCL_DYNAMIC);
7268 Tcl_Release((ClientData)
argv);
7270 ckfree((
char*)
argv);
7279 ckfree((
char*)callq);
7285 DUMP1(
"raise exception");
7291 DUMP1(
"exit tk_funcall");
7297 #if TCL_MAJOR_VERSION >= 8 7298 struct call_eval_info {
7304 #ifdef HAVE_PROTOTYPES 7305 call_tcl_eval(
VALUE arg)
7311 struct call_eval_info *
inf = (
struct call_eval_info *)arg;
7313 Tcl_AllowExceptions(
inf->ptr->ip);
7314 inf->ptr->return_value = Tcl_EvalObj(
inf->ptr->ip,
inf->cmd);
7330 #if TCL_MAJOR_VERSION >= 8 7338 cmd = Tcl_NewStringObj(cmd_str, cmd_len);
7349 struct call_eval_info
inf;
7365 "unknown exception");
7398 "ip_eval_real receives TCL_RETURN");
7401 "ip_eval_real receives TCL_BREAK");
7404 "ip_eval_real receives TCL_CONTINUE");
7419 Tcl_ResetResult(ptr->
ip);
7433 DUMP2(
"Tcl_Eval(%s)", cmd_str);
7458 "ip_eval_real receives TCL_RETURN");
7461 "ip_eval_real receives TCL_BREAK");
7464 "ip_eval_real receives TCL_CONTINUE");
7502 volatile VALUE q_dat;
7506 DUMP2(
"do_eval_queue_handler : evPtr = %p", evPtr);
7508 DUMP2(
"added by thread : %lx", thread);
7511 DUMP1(
"processed by another event-loop");
7514 DUMP1(
"process it on current event-loop");
7519 DUMP1(
"caller is not yet ready to receive the result -> pending");
7538 #ifdef HAVE_NATIVETHREAD 7539 #ifndef RUBY_USE_NATIVE_THREAD 7541 rb_bug(
"cross-thread violation on eval_queue_handler()");
7572 DUMP2(
"back to caller (caller thread:%lx)", thread);
7574 #if CONTROL_BY_STATUS_OF_RB_THREAD_WAITING_FOR_VALUE 7580 DUMP1(
"finish back to caller");
7581 #if DO_THREAD_SCHEDULE_AT_CALLBACK_DONE 7585 DUMP2(
"caller is dead (caller thread:%lx)", thread);
7599 #ifdef RUBY_USE_NATIVE_THREAD 7606 volatile VALUE ip_obj =
self;
7609 Tcl_QueuePosition position;
7617 #ifdef RUBY_USE_NATIVE_THREAD 7619 DUMP2(
"eval status: ptr->tk_thread_id %p", ptr->tk_thread_id);
7620 DUMP2(
"eval status: Tcl_GetCurrentThread %p", Tcl_GetCurrentThread());
7622 DUMP2(
"status: Tcl_GetCurrentThread %p", Tcl_GetCurrentThread());
7627 #ifdef RUBY_USE_NATIVE_THREAD
7628 (ptr->tk_thread_id == 0 || ptr->tk_thread_id == Tcl_GetCurrentThread())
7634 DUMP2(
"eval from thread:%lx but no eventloop", current);
7636 DUMP2(
"eval from current eventloop %lx", current);
7645 DUMP2(
"eval from thread %lx (NOT current eventloop)", current);
7654 Tcl_Preserve((ClientData)alloc_done);
7661 Tcl_Preserve((ClientData)eval_str);
7677 evq->
done = alloc_done;
7678 evq->
str = eval_str;
7686 position = TCL_QUEUE_TAIL;
7689 DUMP1(
"add handler");
7690 #ifdef RUBY_USE_NATIVE_THREAD 7691 if (ptr->tk_thread_id) {
7693 Tcl_ThreadQueueEvent(ptr->tk_thread_id, (Tcl_Event*)evq, position);
7694 Tcl_ThreadAlert(ptr->tk_thread_id);
7695 }
else if (tk_eventloop_thread_id) {
7696 Tcl_ThreadQueueEvent(tk_eventloop_thread_id, (Tcl_Event*)evq, position);
7699 Tcl_ThreadAlert(tk_eventloop_thread_id);
7702 Tcl_QueueEvent((Tcl_Event*)evq, position);
7706 Tcl_QueueEvent((Tcl_Event*)evq, position);
7715 DUMP2(
"evq wait for handler (current thread:%lx)", current);
7716 while(*alloc_done >= 0) {
7717 DUMP2(
"*** evq wait for handler (current thread:%lx)", current);
7721 DUMP2(
"*** evq wakeup (current thread:%lx)", current);
7724 DUMP1(
"*** evq lost eventloop thread");
7728 DUMP2(
"back from handler (current thread:%lx)", current);
7734 Tcl_EventuallyFree((ClientData)alloc_done, TCL_DYNAMIC);
7737 Tcl_Release((ClientData)alloc_done);
7740 ckfree((
char*)alloc_done);
7744 Tcl_EventuallyFree((ClientData)eval_str, TCL_DYNAMIC);
7747 Tcl_Release((ClientData)eval_str);
7762 DUMP1(
"raise exception");
7778 #if TCL_MAJOR_VERSION < 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION < 6) 7780 "cancel_eval is supported Tcl/Tk8.6 or later.");
7793 return Tcl_CancelEval(interp, msg_obj, 0, flag);
7815 #ifndef TCL_CANCEL_UNWIND 7816 #define TCL_CANCEL_UNWIND 0x100000 7868 Tcl_ResetResult(ptr->
ip);
7870 #if TCL_MAJOR_VERSION >= 8 7875 Tcl_ResetResult(ptr->
ip);
7882 Tcl_ResetResult(ptr->
ip);
7933 if (Tcl_GetMaster(ptr->
ip) != (Tcl_Interp*)
NULL) {
7946 volatile VALUE str = src;
7952 Tcl_Encoding encoding;
7967 if (
NIL_P(ip_obj)) {
7969 interp = (Tcl_Interp *)
NULL;
7977 interp = (Tcl_Interp *)
NULL;
7987 if (
NIL_P(encodename)) {
7991 #ifdef HAVE_RUBY_ENCODING_H 7997 if (
NIL_P(ip_obj)) {
7998 encoding = (Tcl_Encoding)
NULL;
8002 encoding = (Tcl_Encoding)
NULL;
8008 encoding = (Tcl_Encoding)
NULL;
8010 encoding = Tcl_GetEncoding((Tcl_Interp*)
NULL,
8012 if (encoding == (Tcl_Encoding)
NULL) {
8021 #ifdef HAVE_RUBY_ENCODING_H 8029 encoding = Tcl_GetEncoding((Tcl_Interp*)
NULL,
8031 if (encoding == (Tcl_Encoding)
NULL) {
8036 encoding = (Tcl_Encoding)
NULL;
8040 if (strcmp(
RSTRING_PTR(encodename),
"binary") == 0) {
8041 #ifdef HAVE_RUBY_ENCODING_H 8049 encoding = Tcl_GetEncoding((Tcl_Interp*)
NULL,
RSTRING_PTR(encodename));
8050 if (encoding == (Tcl_Encoding)
NULL) {
8070 Tcl_DStringInit(&dstr);
8071 Tcl_DStringFree(&dstr);
8077 str =
rb_str_new(Tcl_DStringValue(&dstr), Tcl_DStringLength(&dstr));
8078 #ifdef HAVE_RUBY_ENCODING_H 8089 Tcl_DStringFree(&dstr);
8106 VALUE str, encodename;
8120 VALUE str, encodename;
8134 volatile VALUE str = src;
8138 Tcl_Encoding encoding;
8152 if (
NIL_P(ip_obj)) {
8153 interp = (Tcl_Interp *)
NULL;
8155 interp = (Tcl_Interp *)
NULL;
8163 if (
NIL_P(encodename)) {
8171 #ifdef HAVE_RUBY_ENCODING_H 8178 #ifdef HAVE_RUBY_ENCODING_H 8188 if (
NIL_P(ip_obj)) {
8189 encoding = (Tcl_Encoding)
NULL;
8193 encoding = (Tcl_Encoding)
NULL;
8199 encoding = (Tcl_Encoding)
NULL;
8201 encoding = Tcl_GetEncoding((Tcl_Interp*)
NULL,
8203 if (encoding == (Tcl_Encoding)
NULL) {
8215 if (strcmp(
RSTRING_PTR(encodename),
"binary") == 0) {
8223 s = (
char*)Tcl_GetByteArrayFromObj(tclstr, &len);
8227 #ifdef HAVE_RUBY_ENCODING_H 8237 encoding = Tcl_GetEncoding((Tcl_Interp*)
NULL,
RSTRING_PTR(encodename));
8238 if (encoding == (Tcl_Encoding)
NULL) {
8261 Tcl_DStringInit(&dstr);
8262 Tcl_DStringFree(&dstr);
8268 str =
rb_str_new(Tcl_DStringValue(&dstr), Tcl_DStringLength(&dstr));
8269 #ifdef HAVE_RUBY_ENCODING_H 8291 Tcl_DStringFree(&dstr);
8308 VALUE str, encodename;
8322 VALUE str, encodename;
8337 char *src_buf, *dst_buf, *ptr;
8338 int read_len = 0, dst_len = 0;
8355 Tcl_Preserve((ClientData)src_buf);
8363 Tcl_Preserve((ClientData)dst_buf);
8368 if (*ptr ==
'\\' && (all_bs || *(ptr + 1) ==
'u')) {
8369 dst_len += Tcl_UtfBackslash(ptr, &read_len, (dst_buf + dst_len));
8372 *(dst_buf + (dst_len++)) = *(ptr++);
8378 #ifdef HAVE_RUBY_ENCODING_H 8384 Tcl_EventuallyFree((ClientData)src_buf, TCL_DYNAMIC);
8387 Tcl_Release((ClientData)src_buf);
8394 Tcl_EventuallyFree((ClientData)dst_buf, TCL_DYNAMIC);
8397 Tcl_Release((ClientData)dst_buf);
8430 #if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION > 0) 8443 #if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION > 0) 8447 Tcl_SetSystemEncoding((Tcl_Interp *)
NULL, (
CONST char *)
NULL);
8452 if (Tcl_SetSystemEncoding((Tcl_Interp *)
NULL,
8469 #if TCL_MAJOR_VERSION >= 8 8479 #ifdef HAVE_PROTOTYPES 8488 #if TCL_MAJOR_VERSION >= 8 && TCL_MINOR_VERSION < 6 8494 DUMP1(
"call invoke_tcl_proc");
8496 #if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 6) 8499 inf->ptr->return_value = Tcl_EvalObjv(
inf->ptr->ip,
inf->objc,
inf->objv, TCL_EVAL_DIRECT);
8505 #if TCL_MAJOR_VERSION == 8 8507 if (!
inf->cmdinfo.isNativeObjectProc) {
8508 DUMP1(
"called proc is not a native-obj-proc");
8513 Tcl_Preserve((ClientData)
argv);
8515 for (i = 0; i <
argc; ++i) {
8516 argv[i] = Tcl_GetStringFromObj(
inf->objv[i], &len);
8522 DUMP1(
"reset result of tcl-interp");
8523 Tcl_ResetResult(
inf->ptr->ip);
8526 #if TCL_MAJOR_VERSION == 8 8528 if (
inf->cmdinfo.isNativeObjectProc) {
8529 DUMP1(
"call tcl_proc as a native-obj-proc");
8530 inf->ptr->return_value
8531 = (*(
inf->cmdinfo.objProc))(
inf->cmdinfo.objClientData,
8537 #if TCL_MAJOR_VERSION == 8 8539 DUMP1(
"call tcl_proc as not a native-obj-proc");
8540 inf->ptr->return_value
8541 = (*(
inf->cmdinfo.proc))(
inf->cmdinfo.clientData,
inf->ptr->ip,
8545 Tcl_EventuallyFree((ClientData)
argv, TCL_DYNAMIC);
8548 Tcl_Release((ClientData)
argv);
8551 ckfree((
char*)
argv);
8556 inf->ptr->return_value
8557 = (*(
inf->cmdinfo.proc))(
inf->cmdinfo.clientData,
inf->ptr->ip,
8564 DUMP1(
"end of invoke_tcl_proc");
8569 #if TCL_MAJOR_VERSION >= 8 8588 int unknown_flag = 0;
8594 #if TCL_MAJOR_VERSION >= 8 8605 #if TCL_MAJOR_VERSION >= 8 8606 cmd = Tcl_GetStringFromObj(objv[0], &len);
8623 DUMP2(
"call Tcl_GetCommandInfo, %s", cmd);
8624 if (!Tcl_GetCommandInfo(
ptr->
ip, cmd, &info)) {
8625 DUMP1(
"error Tcl_GetCommandInfo");
8626 DUMP1(
"try auto_load (call 'unknown' command)");
8627 if (!Tcl_GetCommandInfo(
ptr->
ip,
8628 #
if TCL_MAJOR_VERSION >= 8
8634 DUMP1(
"fail to get 'unknown' command");
8641 "invalid command name `%s'", cmd);
8644 rb_warning(
"invalid command name `%s' (ignore)", cmd);
8646 rb_warn(
"invalid command name `%s' (ignore)", cmd);
8648 Tcl_ResetResult(
ptr->
ip);
8654 #if TCL_MAJOR_VERSION >= 8 8655 Tcl_Obj **unknown_objv;
8657 char **unknown_argv;
8659 DUMP1(
"find 'unknown' command -> set arguemnts");
8662 #if TCL_MAJOR_VERSION >= 8 8666 Tcl_Preserve((ClientData)unknown_objv);
8668 unknown_objv[0] = Tcl_NewStringObj(
"::unknown", 9);
8670 memcpy(unknown_objv + 1, objv,
sizeof(Tcl_Obj *)*objc);
8671 unknown_objv[++objc] = (Tcl_Obj*)
NULL;
8672 objv = unknown_objv;
8677 Tcl_Preserve((ClientData)unknown_argv);
8679 unknown_argv[0] =
strdup(
"unknown");
8680 memcpy(unknown_argv + 1,
argv,
sizeof(
char *)*
argc);
8681 unknown_argv[++
argc] = (
char *)
NULL;
8682 argv = unknown_argv;
8686 DUMP1(
"end Tcl_GetCommandInfo");
8695 #if TCL_MAJOR_VERSION >= 8 8704 DUMP1(
"invoke tcl-proc");
8706 DUMP2(
"status of tcl-proc, %d", status);
8711 "unknown exception");
8728 #if TCL_MAJOR_VERSION >= 8 8729 if (!info.isNativeObjectProc) {
8736 Tcl_Preserve((ClientData)
argv);
8738 for (i = 0; i <
argc; ++i) {
8739 argv[i] = Tcl_GetStringFromObj(objv[i], &len);
8745 Tcl_ResetResult(
ptr->
ip);
8748 #if TCL_MAJOR_VERSION >= 8 8749 if (info.isNativeObjectProc) {
8754 resultPtr = Tcl_GetObjResult(
ptr->
ip);
8755 Tcl_SetResult(
ptr->
ip, Tcl_GetStringFromObj(resultPtr, &len),
8762 #if TCL_MAJOR_VERSION >= 8 8767 Tcl_EventuallyFree((ClientData)
argv, TCL_DYNAMIC);
8770 Tcl_Release((ClientData)
argv);
8773 ckfree((
char*)
argv);
8786 #if TCL_MAJOR_VERSION >= 8 8789 Tcl_EventuallyFree((ClientData)objv, TCL_DYNAMIC);
8792 Tcl_Release((ClientData)objv);
8795 ckfree((
char*)objv);
8802 Tcl_EventuallyFree((ClientData)
argv, TCL_DYNAMIC);
8805 Tcl_Release((ClientData)
argv);
8808 ckfree((
char*)
argv);
8827 "ip_invoke_core receives TCL_RETURN");
8830 "ip_invoke_core receives TCL_BREAK");
8833 "ip_invoke_core receives TCL_CONTINUE");
8845 Tcl_ResetResult(
ptr->
ip);
8855 #if TCL_MAJOR_VERSION >= 8 8867 #if TCL_MAJOR_VERSION >= 8 8877 #if TCL_MAJOR_VERSION >= 8 8881 Tcl_Preserve((ClientData)av);
8883 for (i = 0; i <
argc; ++i) {
8884 av[i] = get_obj_from_str(
argv[i]);
8894 Tcl_Preserve((ClientData)av);
8896 for (i = 0; i <
argc; ++i) {
8910 #if TCL_MAJOR_VERSION >= 8 8918 for (i = 0; i <
argc; ++i) {
8919 #if TCL_MAJOR_VERSION >= 8 8921 av[i] = (Tcl_Obj*)
NULL;
8924 av[i] = (
char*)
NULL;
8927 #if TCL_MAJOR_VERSION >= 8 8929 Tcl_EventuallyFree((ClientData)av, TCL_DYNAMIC);
8932 Tcl_Release((ClientData)av);
8939 Tcl_EventuallyFree((ClientData)av, TCL_DYNAMIC);
8942 Tcl_Release((ClientData)av);
8960 #if TCL_MAJOR_VERSION >= 8 8961 Tcl_Obj **av = (Tcl_Obj **)
NULL;
8963 char **av = (
char **)
NULL;
8980 Tcl_ResetResult(ptr->
ip);
9010 volatile VALUE q_dat;
9014 DUMP2(
"do_invoke_queue_handler : evPtr = %p", evPtr);
9016 DUMP2(
"added by thread : %lx", thread);
9019 DUMP1(
"processed by another event-loop");
9022 DUMP1(
"process it on current event-loop");
9027 DUMP1(
"caller is not yet ready to receive the result -> pending");
9053 DUMP2(
"call invoke_real (for caller thread:%lx)", thread);
9075 DUMP2(
"back to caller (caller thread:%lx)", thread);
9077 #if CONTROL_BY_STATUS_OF_RB_THREAD_WAITING_FOR_VALUE 9083 DUMP1(
"finish back to caller");
9084 #if DO_THREAD_SCHEDULE_AT_CALLBACK_DONE 9088 DUMP2(
"caller is dead (caller thread:%lx)", thread);
9101 Tcl_QueuePosition position;
9104 #ifdef RUBY_USE_NATIVE_THREAD 9110 volatile VALUE ip_obj = obj;
9115 #if TCL_MAJOR_VERSION >= 8 9116 Tcl_Obj **av = (Tcl_Obj **)
NULL;
9118 char **av = (
char **)
NULL;
9125 #ifdef RUBY_USE_NATIVE_THREAD 9127 DUMP2(
"invoke status: ptr->tk_thread_id %p", ptr->tk_thread_id);
9128 DUMP2(
"invoke status: Tcl_GetCurrentThread %p", Tcl_GetCurrentThread());
9130 DUMP2(
"status: Tcl_GetCurrentThread %p", Tcl_GetCurrentThread());
9135 #ifdef RUBY_USE_NATIVE_THREAD
9136 (ptr->tk_thread_id == 0 || ptr->tk_thread_id == Tcl_GetCurrentThread())
9142 DUMP2(
"invoke from thread:%lx but no eventloop", current);
9144 DUMP2(
"invoke from current eventloop %lx", current);
9153 DUMP2(
"invoke from thread %lx (NOT current eventloop)", current);
9165 Tcl_Preserve((ClientData)alloc_done);
9173 Tcl_Preserve((ClientData)ivq);
9180 ivq->done = alloc_done;
9183 ivq->interp = ip_obj;
9185 ivq->thread = current;
9190 DUMP1(
"add handler");
9191 #ifdef RUBY_USE_NATIVE_THREAD 9192 if (ptr->tk_thread_id) {
9194 Tcl_ThreadQueueEvent(ptr->tk_thread_id, (Tcl_Event*)ivq, position);
9195 Tcl_ThreadAlert(ptr->tk_thread_id);
9196 }
else if (tk_eventloop_thread_id) {
9199 Tcl_ThreadQueueEvent(tk_eventloop_thread_id,
9200 (Tcl_Event*)ivq, position);
9201 Tcl_ThreadAlert(tk_eventloop_thread_id);
9204 Tcl_QueueEvent((Tcl_Event*)ivq, position);
9208 Tcl_QueueEvent((Tcl_Event*)ivq, position);
9217 DUMP2(
"ivq wait for handler (current thread:%lx)", current);
9218 while(*alloc_done >= 0) {
9222 DUMP2(
"*** ivq wakeup (current thread:%lx)", current);
9225 DUMP1(
"*** ivq lost eventloop thread");
9229 DUMP2(
"back from handler (current thread:%lx)", current);
9234 Tcl_EventuallyFree((ClientData)alloc_done, TCL_DYNAMIC);
9237 Tcl_Release((ClientData)alloc_done);
9240 ckfree((
char*)alloc_done);
9246 Tcl_EventuallyFree((ClientData)ivq, TCL_DYNAMIC);
9261 DUMP1(
"raise exception");
9267 DUMP1(
"exit ip_invoke");
9319 volatile VALUE varname, index, flag;
9330 #if TCL_MAJOR_VERSION >= 8 9333 volatile VALUE strval;
9350 if (ret == (Tcl_Obj*)
NULL) {
9363 strval = get_str_from_obj(ret);
9375 volatile VALUE strval;
9388 if (ret == (
char*)
NULL) {
9426 if (
NIL_P(retval)) {
9450 volatile VALUE varname, index, value, flag;
9463 #if TCL_MAJOR_VERSION >= 8 9465 Tcl_Obj *valobj, *ret;
9466 volatile VALUE strval;
9471 valobj = get_obj_from_str(value);
9489 if (ret == (Tcl_Obj*)
NULL) {
9502 strval = get_str_from_obj(ret);
9515 volatile VALUE strval;
9528 if (ret == (
char*)
NULL) {
9565 if (
NIL_P(retval)) {
9589 volatile VALUE varname, index, flag;
9610 if (
FIX2INT(flag) & TCL_LEAVE_ERR_MSG) {
9640 if (
NIL_P(retval)) {
9662 INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
9672 INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
9682 INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
9693 INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
9702 INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
9712 INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
9723 volatile VALUE ary, elem;
9726 #ifdef HAVE_RUBY_ENCODING_H 9728 volatile VALUE list_ivar_enc;
9735 if (
NIL_P(ip_obj)) {
9736 interp = (Tcl_Interp *)
NULL;
9738 interp = (Tcl_Interp *)
NULL;
9744 #ifdef HAVE_RUBY_ENCODING_H 9750 #if TCL_MAJOR_VERSION >= 8 9757 listobj = get_obj_from_str(list_str);
9761 result = Tcl_ListObjGetElements(interp, listobj, &objc, &objv);
9763 if (
result == TCL_ERROR) {
9765 if (interp == (Tcl_Interp*)
NULL) {
9772 for(idx = 0; idx < objc; idx++) {
9784 for(idx = 0; idx < objc; idx++) {
9785 elem = get_str_from_obj(objv[idx]);
9788 #ifdef HAVE_RUBY_ENCODING_H 9807 for(idx = 0; idx < objc; idx++) {
9820 if (interp == (Tcl_Interp*)
NULL) {
9832 for(idx = 0; idx <
argc; idx++) {
9894 Tcl_Preserve((ClientData)flagPtr);
9899 for(num = 0; num <
argc; num++) {
9902 #if TCL_MAJOR_VERSION >= 8 9906 len += Tcl_ScanElement(dst, &flagPtr[num]) + 1;
9912 result = (
char *)ckalloc(len);
9914 Tcl_Preserve((ClientData)
result);
9917 for(num = 0; num <
argc; num++) {
9918 #if TCL_MAJOR_VERSION >= 8 9936 Tcl_EventuallyFree((ClientData)flagPtr, TCL_DYNAMIC);
9939 Tcl_Release((ClientData)flagPtr);
9942 ckfree((
char*)flagPtr);
9950 Tcl_EventuallyFree((ClientData)
result, TCL_DYNAMIC);
9953 Tcl_Release((ClientData)
result);
9983 #if TCL_MAJOR_VERSION >= 8 9990 len = Tcl_ScanElement(
RSTRING_PTR(src), &scan_flag);
10039 volatile VALUE ret;
10041 static CONST char form[]
10042 =
"tcltklib %s :: Ruby%s (%s) %s pthread :: Tcl%s(%s)/Tk%s(%s) %s";
10050 +
strlen(TCL_PATCH_LEVEL)
10051 +
strlen(
"without stub")
10052 +
strlen(TK_PATCH_LEVEL)
10053 +
strlen(
"without stub")
10054 +
strlen(
"unknown tcl_threads");
10059 sprintf(info, form,
10068 #ifdef USE_TCL_STUBS
10074 #ifdef USE_TK_STUBS
10079 #ifdef WITH_TCL_ENABLE_THREAD
10080 #
if WITH_TCL_ENABLE_THREAD
10083 "without tcl_threads" 10086 "unknown tcl_threads" 10112 #if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 1) 10114 if (
RTEST(error_mode)) {
10123 #ifdef HAVE_RUBY_ENCODING_H 10128 if (
RTEST(error_mode)) {
10150 #ifdef HAVE_RUBY_ENCODING_H 10166 if (
NIL_P(interp))
return 0;
10172 Tcl_GetEncodingNames(ptr->
ip);
10176 if (Tcl_ListObjGetElements(ptr->
ip,
enc_list,
10177 &objc, &objv) != TCL_OK) {
10184 for(i = 0; i < objc; i++) {
10222 if (!
NIL_P(interp)) {
10231 if (ptr &&
NIL_P(enc)) {
10309 if (
RTEST(error_mode)) {
10333 #if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 1) 10348 if (
NIL_P(interp))
return 0;
10354 Tcl_GetEncodingNames(ptr->
ip);
10358 if (Tcl_ListObjGetElements(ptr->
ip,
enc_list, &objc, &objv) != TCL_OK) {
10365 for(i = 0; i < objc; i++) {
10408 if (
RTEST(error_mode)) {
10457 #ifdef HAVE_RUBY_ENCODING_H 10471 #ifdef HAVE_RB_SET_SAFE_LEVEL_FORCE 10487 Tcl_GetEncodingNames(ptr->
ip);
10491 if (Tcl_ListObjGetElements(ptr->
ip,
enc_list, &objc, &objv) != TCL_OK) {
10497 for(i = 0; i < objc; i++) {
10498 int name2obj, obj2name;
10500 name2obj = 1; obj2name = 1;
10505 if (strcmp(
RSTRING_PTR(encname),
"identity") == 0) {
10506 name2obj = 1; obj2name = 0;
10509 }
else if (strcmp(
RSTRING_PTR(encname),
"shiftjis") == 0) {
10510 name2obj = 1; obj2name = 0;
10513 }
else if (strcmp(
RSTRING_PTR(encname),
"unicode") == 0) {
10514 name2obj = 1; obj2name = 0;
10517 }
else if (strcmp(
RSTRING_PTR(encname),
"symbol") == 0) {
10518 name2obj = 1; obj2name = 0;
10523 name2obj = 1; obj2name = 1;
10553 #if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 1) 10571 Tcl_GetEncodingNames(ptr->
ip);
10575 if (Tcl_ListObjGetElements(ptr->
ip,
enc_list, &objc, &objv) != TCL_OK) {
10581 for(i = 0; i < objc; i++) {
10623 if (
NIL_P(table)) {
10640 #if TCL_MAJOR_VERSION >= 8 10642 #define MASTER_MENU 0 10643 #define TEAROFF_MENU 1 10646 struct dummy_TkMenuEntry {
10648 struct dummy_TkMenu *menuPtr;
10652 struct dummy_TkMenu {
10655 Tcl_Interp *interp;
10656 Tcl_Command widgetCmd;
10657 struct dummy_TkMenuEntry **entries;
10661 Tcl_Obj *menuTypePtr;
10665 struct dummy_TkMenuRef {
10666 struct dummy_TkMenu *menuPtr;
10673 EXTERN struct dummy_TkMenuRef *TkFindMenuReferences(Tcl_Interp*,
char*);
10675 #define MENU_HASH_KEY "tkMenus" 10686 #if TCL_MAJOR_VERSION >= 8 10687 volatile VALUE menu_path;
10689 struct dummy_TkMenuRef *menuRefPtr =
NULL;
10691 Tcl_HashTable *menuTablePtr;
10692 Tcl_HashEntry *hashEntryPtr;
10694 menu_path =
argv[0];
10698 menuRefPtr = TkFindMenuReferences(ptr->
ip,
RSTRING_PTR(menu_path));
10701 = (Tcl_HashTable *) Tcl_GetAssocData(ptr->
ip, MENU_HASH_KEY,
NULL))
10704 = Tcl_FindHashEntry(menuTablePtr,
RSTRING_PTR(menu_path)))
10706 menuRefPtr = (
struct dummy_TkMenuRef *) Tcl_GetHashValue(hashEntryPtr);
10711 if (menuRefPtr == (
struct dummy_TkMenuRef *)
NULL) {
10715 if (menuRefPtr->menuPtr == (
struct dummy_TkMenu *)
NULL) {
10717 "invalid menu widget (maybe already destroyed)");
10720 if ((menuRefPtr->menuPtr)->menuType != MENUBAR) {
10722 "target menu widget must be a MENUBAR type");
10725 (menuRefPtr->menuPtr)->menuType = TEAROFF_MENU;
10729 char *s =
"normal";
10731 (menuRefPtr->menuPtr)->menuTypePtr = Tcl_NewStringObj(s,
strlen(s));
10734 (menuRefPtr->menuPtr)->menuType = MASTER_MENU;
10739 TkEventuallyRecomputeMenu(menuRefPtr->menuPtr);
10740 TkEventuallyRedrawMenu(menuRefPtr->menuPtr,
10741 (
struct dummy_TkMenuEntry *)
NULL);
10743 memset((
void *) &event, 0,
sizeof(event));
10744 event.xany.type = ConfigureNotify;
10745 event.xany.serial = NextRequest(Tk_Display((menuRefPtr->menuPtr)->tkwin));
10746 event.xany.send_event = 0;
10747 event.xany.window = Tk_WindowId((menuRefPtr->menuPtr)->tkwin);
10748 event.xany.display = Tk_Display((menuRefPtr->menuPtr)->tkwin);
10749 event.xconfigure.window =
event.xany.window;
10750 Tk_HandleEvent(&event);
10767 argv[0] = menu_path;
10793 #ifdef HAVE_RUBY_ENCODING_H 10832 # define TK_WINDOWING_SYSTEM "win32" 10835 # define TK_WINDOWING_SYSTEM "classic" 10838 # define TK_WINDOWING_SYSTEM "aqua" 10840 # define TK_WINDOWING_SYSTEM "x11" 10861 #ifdef TCL_NAMESPACE_ONLY 10869 #ifdef TCL_PARSE_PART1 10910 #ifndef HAVE_RB_THREAD_ALIVE_P 11062 #ifndef DEFAULT_EVENTLOOP_DEPTH 11063 #define DEFAULT_EVENTLOOP_DEPTH 7 11074 #ifdef HAVE_NATIVETHREAD 11100 #if defined CREATE_RUBYTK_KIT || defined CREATE_RUBYKIT 11109 Tcl_ObjType_ByteArray = Tcl_GetObjType(Tcl_ObjTypeName_ByteArray);
11110 Tcl_ObjType_String = Tcl_GetObjType(Tcl_ObjTypeName_String);
RUBY_EXTERN VALUE rb_cString
static VALUE tk_funcall(VALUE(*func)(), int argc, VALUE *argv, VALUE obj)
VALUE rb_apply(VALUE, ID, VALUE)
Calls a method.
static VALUE lib_fromUTF8(int argc, VALUE *argv, VALUE self)
void invoke_queue_mark(struct invoke_queue *q)
void rb_thread_schedule(void)
int rb_enc_get_index(VALUE obj)
static VALUE eTkCallbackRetry
RUBY_EXTERN VALUE rb_cData
static VALUE lib_restart(VALUE self)
static void tcl_stubs_check()
Tcl_Interp * current_interp
static void lib_mark_at_exit(VALUE self)
static VALUE ip_has_invalid_namespace_p(VALUE self)
static void WaitVisibilityProc(ClientData clientData, XEvent *eventPtr)
VALUE rb_ary_pop(VALUE ary)
#define TCL_FINAL_RELEASE
#define TKWAIT_MODE_VISIBILITY
void rb_bug(const char *fmt,...)
int ruby_tcl_stubs_init()
static VALUE ip_set_global_var2(VALUE self, VALUE varname, VALUE index, VALUE value)
static VALUE ip_set_eventloop_tick(VALUE self, VALUE tick)
static VALUE eTkCallbackRedo
static VALUE ip_set_global_var(VALUE self, VALUE varname, VALUE value)
static VALUE lib_UTF_backslash_core(VALUE self, VALUE str, int all_bs)
size_t strlen(const char *)
static void ip_finalize(Tcl_Interp *ip)
static VALUE ip_fromUTF8(int argc, VALUE *argv, VALUE self)
static VALUE ip_get_variable(VALUE self, VALUE varname, VALUE flag)
#define FAIL_Tcl_InitStubs
#define TCL_ALPHA_RELEASE
static VALUE ip_mainloop(int argc, VALUE *argv, VALUE self)
static int tcl_protect_core(Tcl_Interp *interp, VALUE(*proc)(), VALUE data)
static VALUE ip_evloop_abort_on_exc(VALUE self)
static VALUE get_no_event_wait(VALUE self)
static VALUE lib_mainloop(int argc, VALUE *argv, VALUE self)
static int lib_eventloop_core(int check_root, int update_flag, int *check_var, Tcl_Interp *interp)
static VALUE set_no_event_wait(VALUE self, VALUE wait)
static VALUE lib_evloop_abort_on_exc(VALUE self)
static VALUE tcltkip_class
static char * WaitVariableProc(ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags)
#define Data_Get_Struct(obj, type, sval)
void rb_define_singleton_method(VALUE obj, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a singleton method for obj.
static void rb_threadWaitVisibilityProc(ClientData clientData, XEvent *eventPtr)
#define NO_THREAD_INTERRUPT_TIME
#define RUBY_RELEASE_DATE
#define TK_WINDOWING_SYSTEM
static VALUE ip_has_mainwindow_p_core(VALUE self, int argc, VALUE *argv)
#define DEFAULT_EVENTLOOP_DEPTH
static VALUE enc_list(VALUE klass)
static VALUE ip_ruby_cmd_receiver_get(char *str)
static VALUE watchdog_evloop_launcher(VALUE check_rootwidget)
void rbtk_EventCheckProc(ClientData clientData, int flag)
void call_queue_mark(struct call_queue *q)
static int enc_arg(volatile VALUE *arg, const char **name_p, rb_encoding **enc_p)
static VALUE ip_toUTF8(int argc, VALUE *argv, VALUE self)
static int tcl_eval(Tcl_Interp *interp, const char *cmd)
static void rb_threadUpdateProc(ClientData clientData)
static int rbtk_internal_eventloop_handler
static int call_queue_handler(Tcl_Event *evPtr, int flags)
VALUE rb_exc_new_str(VALUE etype, VALUE str)
#define FAIL_CreateInterp
static struct tcltkip * get_ip(VALUE self)
static void ip_replace_wait_commands(Tcl_Interp *interp, Tk_Window mainWin)
static Tcl_TimerToken timer_token
static int event_loop_max
VALUE rb_enc_from_encoding(rb_encoding *encoding)
static VALUE lib_thread_callback(int argc, VALUE *argv, VALUE self)
static VALUE ip_eval(VALUE self, VALUE str)
static void delete_slaves(Tcl_Interp *ip)
static VALUE set_max_block_time(VALUE self, VALUE time)
static ID ID_encoding_name
static void ip_CallWhenDeleted(ClientData clientData, Tcl_Interp *ip)
VALUE rb_ary_push(VALUE ary, VALUE item)
static VALUE eventloop_thread
static int rbtk_release_ip(struct tcltkip *ptr)
SSL_METHOD *(* func)(void)
static VALUE ip_get_variable2_core(VALUE interp, int argc, VALUE *argv)
static VALUE create_dummy_encoding_for_tk_core(VALUE interp, VALUE name, VALUE error_mode)
static void ip_wrap_namespace_command(Tcl_Interp *interp)
int rb_thread_alone(void)
static VALUE ip_create_slave(int argc, VALUE *argv, VALUE self)
static VALUE ip_unset_global_var(VALUE self, VALUE varname)
void eval_queue_mark(struct eval_queue *q)
static int update_encoding_table(VALUE table, VALUE interp, VALUE error_mode)
VALUE rb_thread_wakeup(VALUE)
VALUE lib_eventloop_ensure(VALUE args)
static VALUE lib_num_of_mainwindows_core(VALUE self, int argc, VALUE *argv)
static int run_timer_flag
#define TKWAIT_MODE_DESTROY
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
VALUE rb_iv_set(VALUE, const char *, VALUE)
VALUE rb_protect(VALUE(*proc)(VALUE), VALUE data, int *state)
static int rbtk_eventloop_depth
static VALUE ip_create_slave_core(VALUE interp, int argc, VALUE *argv)
static VALUE cRubyEncoding
void rb_raise(VALUE exc, const char *fmt,...)
static VALUE ip_cancel_eval_unwind(int argc, VALUE *argv, VALUE self)
VALUE rb_ivar_get(VALUE, ID)
static int ENCODING_INDEX_BINARY
static VALUE ip_thread_tkwait(VALUE self, VALUE mode, VALUE target)
static void WaitWindowProc(ClientData clientData, XEvent *eventPtr)
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
VALUE rb_obj_is_kind_of(VALUE, VALUE)
int rb_const_defined(VALUE, ID)
static VALUE ip_unset_global_var2(VALUE self, VALUE varname, VALUE index)
static VALUE _thread_call_proc(VALUE arg)
static VALUE invoke_tcl_proc(VALUE arg)
VALUE rb_locale_charmap(VALUE klass)
static VALUE eLocalJumpError
static VALUE ip_ruby_cmd_receiver_const_get(char *name)
void rb_gc_mark(VALUE ptr)
static VALUE lib_fromUTF8_core(VALUE ip_obj, VALUE src, VALUE encodename)
static struct @96 tcltk_version
static int check_rootwidget_flag
VALUE lib_watchdog_ensure(VALUE arg)
static VALUE ip_get_global_var2(VALUE self, VALUE varname, VALUE index)
static VALUE ip_invoke(int argc, VALUE *argv, VALUE obj)
static int ip_rb_threadTkWaitCommand(ClientData clientData, Tcl_Interp *interp, int objc, objv)
static int deleted_ip(struct tcltkip *ptr)
VALUE rb_path2class(const char *)
static VALUE set_eventloop_tick(VALUE self, VALUE tick)
rb_encoding * rb_utf8_encoding(void)
static void set_tcltk_version()
static VALUE ip_make_menu_embeddable(VALUE interp, VALUE menu_path)
static VALUE ip_unset_variable(VALUE self, VALUE varname, VALUE flag)
static VALUE ip_allow_ruby_exit_set(VALUE self, VALUE val)
VALUE rb_fix2str(VALUE, int)
static VALUE lib_mainloop_watchdog(int argc, VALUE *argv, VALUE self)
#define rb_thread_alive_p(thread)
static VALUE call_DoOneEvent(VALUE flag_val)
#define Tcl_GetStringResult(interp)
static char * rb_threadVwaitProc(ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags)
void rb_gc_force_recycle(VALUE p)
static VALUE ip_split_tklist(VALUE self, VALUE list_str)
static VALUE ip_is_deleted_p(VALUE self)
static VALUE ip_set_no_event_wait(VALUE self, VALUE wait)
static VALUE ip_invoke_core(VALUE interp, int argc, char **argv)
static VALUE lib_get_system_encoding(VALUE self)
#define Data_Wrap_Struct(klass, mark, free, sval)
static const char finalize_hook_name[]
static VALUE ip_delete(VALUE self)
void rb_global_variable(VALUE *var)
#define DEFAULT_NO_EVENT_TICK
void rb_exc_raise(VALUE mesg)
static VALUE ip_alloc(VALUE self)
static VALUE ip_is_slave_of_p(VALUE self, VALUE master)
static VALUE ip_make_menu_embeddable_core(VALUE interp, int argc, VALUE *argv)
VALUE ivq_safelevel_handler(VALUE arg, VALUE ivq)
static VALUE ip_has_mainwindow_p(VALUE self)
static VALUE ip_set_variable2_core(VALUE interp, int argc, VALUE *argv)
static VALUE create_encoding_table(VALUE interp)
#define WATCHDOG_INTERVAL
static int ip_rb_replaceSlaveTkCmdsCommand(ClientData clientData, Tcl_Interp *interp, int objc, objv)
static VALUE rbtk_pending_exception
static VALUE get_eventloop_window_mode(VALUE self)
#define RbTk_OBJ_UNTRUST(x)
VALUE rb_gv_get(const char *)
void rb_set_safe_level(int)
static VALUE ip_invoke_immediate(int argc, VALUE *argv, VALUE obj)
int rb_to_encoding_index(VALUE enc)
static VALUE encoding_table_get_name(VALUE table, VALUE enc)
static VALUE lib_evloop_abort_on_exc_set(VALUE self, VALUE val)
static VALUE encoding_table_get_obj(VALUE table, VALUE enc)
static int have_rb_thread_waiting_for_value
static VALUE ip_create_console_core(VALUE interp, int argc, VALUE *argv)
VALUE rb_hash_aset(VALUE hash, VALUE key, VALUE val)
static int ip_rbUpdateCommand(ClientData clientData, Tcl_Interp *interp, int objc, objv)
static VALUE ip_invoke_real(int argc, VALUE *argv, VALUE interp)
RUBY_EXTERN VALUE rb_cObject
#define HAVE_NATIVETHREAD
VALUE rb_eval_string_protect(const char *, int *)
Evaluates the given string in an isolated binding.
VALUE rb_obj_as_string(VALUE)
static char * VwaitVarProc(ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags)
static VALUE create_dummy_encoding_for_tk(VALUE interp, VALUE name)
VALUE rb_enc_default_external(void)
VALUE rb_thread_current(void)
static VALUE enc_name(VALUE self)
VALUE rb_define_class(const char *name, VALUE super)
Defines a top-level class.
static VALUE ip_get_result_string_obj(Tcl_Interp *interp)
static VALUE eventloop_stack
void rb_define_const(VALUE, const char *, VALUE)
#define Tcl_IncrRefCount(obj)
static int ip_RubyExitCommand(ClientData clientData, Tcl_Interp *interp, int argc, argv)
static int ip_rb_threadVwaitCommand(ClientData clientData, Tcl_Interp *interp, int objc, objv)
static int ip_rb_threadUpdateCommand(ClientData clientData, Tcl_Interp *interp, int objc, objv)
VALUE rb_eval_string(const char *)
Evaluates the given string in an isolated binding.
rb_atomic_t cnt[RUBY_NSIG]
static ID ID_encoding_table
static VALUE get_eventloop_tick(VALUE self)
static Tcl_Interp * eventloop_interp
static VALUE lib_eventloop_launcher(int check_root, int update_flag, int *check_var, Tcl_Interp *interp)
static VALUE ip_get_variable2(VALUE self, VALUE varname, VALUE index, VALUE flag)
static VALUE lib_do_one_event(int argc, VALUE *argv, VALUE self)
static int window_event_mode
static VALUE watchdog_thread
static void ip_finalize _((Tcl_Interp *))
static VALUE ip_get_eventloop_weight(VALUE self)
static VALUE evq_safelevel_handler(VALUE arg, VALUE evq)
static VALUE lib_UTF_backslash(VALUE self, VALUE str)
#define MEMCPY(p1, p2, type, n)
VALUE rb_enc_associate_index(VALUE obj, int idx)
static VALUE encoding_table_get_obj_core(VALUE table, VALUE enc, VALUE error_mode)
#define Tcl_DecrRefCount(obj)
VALUE rb_str_resize(VALUE, long)
static VALUE lib_toUTF8(int argc, VALUE *argv, VALUE self)
static const char tcltklib_release_date[]
static VALUE ip_unset_variable2(VALUE self, VALUE varname, VALUE index, VALUE flag)
VALUE rb_const_get(VALUE, ID)
static VALUE tcltklib_compile_info()
static int tcl_protect(Tcl_Interp *interp, VALUE(*proc)(), VALUE data)
void rb_define_module_function(VALUE module, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a module function for module.
static int pending_exception_check1(int thr_crit_bup, struct tcltkip *ptr)
#define DEFAULT_NO_EVENT_WAIT
static VALUE _thread_call_proc_ensure(VALUE arg)
static VALUE lib_Tcl_backslash(VALUE self, VALUE str)
static VALUE set_eventloop_weight(VALUE self, VALUE loop_max, VALUE no_event)
static VALUE TkStringValue(VALUE obj)
static VALUE lib_split_tklist_core(VALUE ip_obj, VALUE list_str)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
static VALUE ip_do_one_event(int argc, VALUE *argv, VALUE self)
static VALUE create_ip_exc(interp, VALUE interp:VALUE exc, const char *fmt, va_alist)
VALUE rb_ivar_set(VALUE, ID, VALUE)
unsigned char buf[MIME_BUF_SIZE]
static VALUE lib_split_tklist(VALUE self, VALUE list_str)
int ruby_tk_stubs_safeinit(Tcl_Interp *tcl_ip)
int ruby_tk_stubs_init(Tcl_Interp *tcl_ip)
static int rb_thread_critical
int rb_define_dummy_encoding(const char *name)
static int options(unsigned char *cp)
Tcl_CmdInfo orig_exit_info
static VALUE lib_evloop_thread_p(VALUE self)
static VALUE eTkCallbackContinue
static int event_loop_abort_on_exc
#define RbTk_ALLOC_N(type, n)
static VALUE lib_getversion(VALUE self)
static VALUE ip_thread_vwait(VALUE self, VALUE var)
VALUE rb_obj_encoding(VALUE obj)
VALUE rb_gc_disable(void)
static VALUE encoding_table_get_name_core(VALUE table, VALUE enc_arg, VALUE error_mode)
VALUE rb_ensure(VALUE(*b_proc)(ANYARGS), VALUE data1, VALUE(*e_proc)(ANYARGS), VALUE data2)
#define FAIL_Tk_InitStubs
#define DUMP2(ARG1, ARG2)
#define rb_tainted_str_new2
static int ip_null_proc(ClientData clientData, Tcl_Interp *interp, int argc, argv)
VALUE lib_eventloop_main(VALUE args)
#define TCL_NAMESPACE_DEBUG
static VALUE ip_make_safe(VALUE self)
VALUE lib_eventloop_main_core(VALUE args)
void rb_jump_tag(int tag)
static int trap_check(int *check_var)
static void ip_set_exc_message(Tcl_Interp *interp, VALUE exc)
static VALUE set_eventloop_window_mode(VALUE self, VALUE mode)
long strtol(const char *nptr, char **endptr, int base)
#define NO_FindExecutable
static void _timer_for_tcl(ClientData clientData)
void rb_set_end_proc(void(*func)(VALUE), VALUE data)
int rb_respond_to(VALUE, ID)
static void ip_free(struct tcltkip *ptr)
static int ip_ruby_eval(ClientData clientData, Tcl_Interp *interp, int argc, argv)
VALUE rb_define_module_under(VALUE outer, const char *name)
#define TCL_CANCEL_UNWIND
static VALUE get_eventloop_weight(VALUE self)
#define StringValueCStr(v)
void rb_set_safe_level_force(int)
static VALUE eTkLocalJumpError
#define va_init_list(a, b)
void rb_thread_wait_for(struct timeval)
static VALUE ENCODING_NAME_BINARY
static void call_original_exit(struct tcltkip *ptr, int state)
static VALUE lib_watchdog_core(VALUE check_rootwidget)
static VALUE ip_set_variable2(VALUE self, VALUE varname, VALUE index, VALUE value, VALUE flag)
static VALUE lib_restart_core(VALUE interp, int argc, VALUE *argv)
static VALUE lib_num_of_mainwindows(VALUE self)
static int pending_exception_check0()
static int ip_rbVwaitCommand(ClientData clientData, Tcl_Interp *interp, int objc, objv)
Tcl_Interp * ruby_tcl_create_ip_and_stubs_init(int *st)
static VALUE eTkCallbackBreak
static VALUE ip_mainloop_watchdog(int argc, VALUE *argv, VALUE self)
VALUE rb_block_proc(void)
void rbtk_EventSetupProc(ClientData clientData, int flag)
static VALUE ip_allow_ruby_exit_p(VALUE self)
#define EVENT_HANDLER_TIMEOUT
static VALUE lib_conv_listelement(VALUE self, VALUE src)
static int ip_InterpExitCommand(ClientData clientData, Tcl_Interp *interp, int argc, argv)
#define DUMP3(ARG1, ARG2, ARG3)
static VALUE lib_do_one_event_core(int argc, VALUE *argv, VALUE self, int is_ip)
int invoke_queue_handler(Tcl_Event *evPtr, int flags)
static VALUE create_encoding_table_core(VALUE arg, VALUE interp)
static int req_timer_tick
static void free_invoke_arguments(int argc, char **av)
static VALUE ip_init(int argc, VALUE *argv, VALUE self)
static VALUE ip_get_no_event_wait(VALUE self)
static VALUE lib_set_system_encoding(VALUE self, VALUE enc_name)
static VALUE ip_restart(VALUE self)
VALUE rb_proc_new(VALUE(*)(ANYARGS), VALUE)
void rb_thread_check_ints(void)
static int event_loop_wait_event
VALUE rb_thread_run(VALUE)
static int tcl_global_eval(Tcl_Interp *interp, const char *cmd)
static VALUE lib_merge_tklist(int argc, VALUE *argv, VALUE obj)
static int ip_ruby_cmd(ClientData clientData, Tcl_Interp *interp, int argc, argv)
static VALUE ENCODING_NAME_UTF8
static VALUE lib_toUTF8_core(VALUE ip_obj, VALUE src, VALUE encodename)
VALUE rb_str_export_to_enc(VALUE, rb_encoding *)
static VALUE eTkCallbackReturn
static char ** alloc_invoke_arguments(int argc, VALUE *argv)
void rb_notimplement(void)
static VALUE ip_get_global_var(VALUE self, VALUE varname)
VALUE rb_ary_join(VALUE ary, VALUE sep)
VALUE rb_enc_default_internal(void)
static int ip_cancel_eval_core(Tcl_Interp *interp, VALUE msg, int flag)
static VALUE ip_set_eventloop_weight(VALUE self, VALUE loop_max, VALUE no_event)
#define DEFAULT_EVENT_LOOP_MAX
static VALUE tcltkip_init_tk(VALUE interp)
static VALUE ip_cancel_eval(int argc, VALUE *argv, VALUE self)
static VALUE callq_safelevel_handler(VALUE arg, VALUE callq)
static VALUE eTkCallbackThrow
static VALUE ip_evloop_abort_on_exc_set(VALUE self, VALUE val)
static int ip_rbTkWaitCommand(ClientData clientData, Tcl_Interp *interp, int objc, objv)
#define StringValuePtr(v)
#define ruby_native_thread_p()
#define rb_enc_to_index(enc)
int eval_queue_handler(Tcl_Event *evPtr, int flags)
static VALUE ip_create_console(VALUE self)
static VALUE _thread_call_proc_core(VALUE arg)
void rb_warning(const char *fmt,...)
#define TCLTKLIB_RELEASE_DATE
int rb_enc_find_index(const char *name)
#define RSTRING_LENINT(str)
int ruby_open_tcl_dll(char *appname)
static VALUE ip_make_safe_core(VALUE interp, int argc, VALUE *argv)
VALUE rb_obj_freeze(VALUE)
void _thread_call_proc_arg_mark(struct thread_call_proc_arg *q)
static int rbtk_preserve_ip(struct tcltkip *ptr)
static VALUE ip_get_eventloop_tick(VALUE self)
VALUE rb_tainted_str_new(const char *, long)
VALUE rb_define_module(const char *name)
static VALUE ip_retval(VALUE self)
static VALUE ip_unset_variable2_core(VALUE interp, int argc, VALUE *argv)
static VALUE ip_invoke_with_position(int argc, VALUE *argv, VALUE obj, Tcl_QueuePosition position)
static VALUE ip_set_variable(VALUE self, VALUE varname, VALUE value, VALUE flag)
static void rb_threadWaitWindowProc(ClientData clientData, XEvent *eventPtr)
VALUE rb_vsprintf(const char *, va_list)
static VALUE ip_get_encoding_table(VALUE interp)
static int check_eventloop_interp()
static VALUE ip_is_safe_p(VALUE self)
VALUE rb_thread_create(VALUE(*)(ANYARGS), void *)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
VALUE rb_str_append(VALUE, VALUE)
void rb_warn(const char *fmt,...)
static VALUE lib_get_reltype_name(VALUE self)
#define EVLOOP_WAKEUP_CHANCE
static int ENCODING_INDEX_UTF8
#define rb_thread_check_trap_pending()
VALUE rb_attr_get(VALUE, ID)
static VALUE _thread_call_proc_value(VALUE th)
#define DEFAULT_TIMER_TICK
static VALUE ip_ruby_cmd_core(struct cmd_body_arg *arg)
rb_encoding * rb_enc_from_index(int index)
static VALUE ip_eval_real(VALUE self, char *cmd_str, int cmd_len)
RUBY_EXTERN VALUE rb_argv0
void rb_thread_sleep_forever(void)
VALUE rb_str_new(const char *, long)
VALUE rb_obj_class(VALUE)