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" 30 #if !defined(RSTRING_PTR) 31 #define RSTRING_PTR(s) (RSTRING(s)->ptr) 32 #define RSTRING_LEN(s) (RSTRING(s)->len) 34 #if !defined(RSTRING_LENINT) 35 #define RSTRING_LENINT(s) ((int)RSTRING_LEN(s)) 37 #if !defined(RARRAY_PTR) 38 #define RARRAY_PTR(s) (RARRAY(s)->ptr) 39 #define RARRAY_LEN(s) (RARRAY(s)->len) 43 #define RbTk_OBJ_UNTRUST(x) do {OBJ_TAINT(x); OBJ_UNTRUST(x);} while (0) 45 #define RbTk_OBJ_UNTRUST(x) OBJ_TAINT(x) 47 #define RbTk_ALLOC_N(type, n) (type *)ckalloc((int)(sizeof(type) * (n))) 49 #if defined(HAVE_RB_PROC_NEW) && !defined(RUBY_VM) 56 #ifdef HAVE_STDARG_PROTOTYPES 58 #define va_init_list(a,b) va_start(a,b) 61 #define va_init_list(a,b) va_start(a) 65 #if !defined HAVE_VSNPRINTF && !defined vsnprintf 68 # define vsnprintf _vsnprintf 70 # ifdef HAVE_RUBY_RUBY_H 81 #ifndef HAVE_RUBY_NATIVE_THREAD_P 82 #define ruby_native_thread_p() is_ruby_native_thread() 83 #undef RUBY_USE_NATIVE_THREAD 85 #define RUBY_USE_NATIVE_THREAD 1 88 #ifndef HAVE_RB_ERRINFO 89 #define rb_errinfo() (ruby_errinfo+0) 93 #ifndef HAVE_RB_SAFE_LEVEL 94 #define rb_safe_level() (ruby_safe_level+0) 96 #ifndef HAVE_RB_SOURCEFILE 97 #define rb_sourcefile() (ruby_sourcefile+0) 102 #ifndef TCL_ALPHA_RELEASE 103 #define TCL_ALPHA_RELEASE 0 104 #define TCL_BETA_RELEASE 1 105 #define TCL_FINAL_RELEASE 2 126 #if TCL_MAJOR_VERSION >= 8 128 # if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION <= 4 132 # define CONST84 CONST 140 # define CONST84 CONST 148 # if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION <= 5 151 # define CONST86 CONST84 156 #define TAG_RETURN 0x1 157 #define TAG_BREAK 0x2 159 #define TAG_RETRY 0x4 161 #define TAG_RAISE 0x6 162 #define TAG_THROW 0x7 163 #define TAG_FATAL 0x8 166 #define DUMP1(ARG1) if (ruby_debug) { fprintf(stderr, "tcltklib: %s\n", ARG1); fflush(stderr); } 167 #define DUMP2(ARG1, ARG2) if (ruby_debug) { fprintf(stderr, "tcltklib: ");\ 168 fprintf(stderr, ARG1, ARG2); fprintf(stderr, "\n"); fflush(stderr); } 169 #define DUMP3(ARG1, ARG2, ARG3) if (ruby_debug) { fprintf(stderr, "tcltklib: ");\ 170 fprintf(stderr, ARG1, ARG2, ARG3); fprintf(stderr, "\n"); fflush(stderr); } 187 #ifdef HAVE_RUBY_ENCODING_H 253 #if TCL_MAJOR_VERSION >= 8 254 static const char Tcl_ObjTypeName_ByteArray[] =
"bytearray";
255 static CONST86 Tcl_ObjType *Tcl_ObjType_ByteArray;
257 static const char Tcl_ObjTypeName_String[] =
"string";
258 static CONST86 Tcl_ObjType *Tcl_ObjType_String;
260 #if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 1) 261 #define IS_TCL_BYTEARRAY(obj) ((obj)->typePtr == Tcl_ObjType_ByteArray) 262 #define IS_TCL_STRING(obj) ((obj)->typePtr == Tcl_ObjType_String) 263 #define IS_TCL_VALID_STRING(obj) ((obj)->bytes != (char*)NULL) 267 #ifndef HAVE_RB_HASH_LOOKUP 268 #define rb_hash_lookup rb_hash_aref 273 #ifdef HAVE_PROTOTYPES 274 tcl_eval(Tcl_Interp *interp,
const char *cmd)
284 Tcl_AllowExceptions(interp);
291 #define Tcl_Eval tcl_eval 294 #ifdef HAVE_PROTOTYPES 305 Tcl_AllowExceptions(interp);
311 #undef Tcl_GlobalEval 312 #define Tcl_GlobalEval tcl_global_eval 315 #if TCL_MAJOR_VERSION < 8 316 #define Tcl_IncrRefCount(obj) (1) 317 #define Tcl_DecrRefCount(obj) (1) 321 #if TCL_MAJOR_VERSION < 8 322 #define Tcl_GetStringResult(interp) ((interp)->result) 326 #if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 328 Tcl_GetVar2Ex(interp, name1, name2, flags)
334 Tcl_Obj *nameObj1, *nameObj2 =
NULL, *retObj;
336 nameObj1 = Tcl_NewStringObj((
char*)name1, -1);
340 nameObj2 = Tcl_NewStringObj((
char*)name2, -1);
344 retObj = Tcl_ObjGetVar2(interp, nameObj1, nameObj2, flags);
356 Tcl_SetVar2Ex(interp, name1, name2, newValObj, flags)
363 Tcl_Obj *nameObj1, *nameObj2 =
NULL, *retObj;
365 nameObj1 = Tcl_NewStringObj((
char*)name1, -1);
369 nameObj2 = Tcl_NewStringObj((
char*)name2, -1);
373 retObj = Tcl_ObjSetVar2(interp, nameObj1, nameObj2, newValObj, flags);
387 #if TCL_MAJOR_VERSION < 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION < 4) 388 # if !defined __MINGW32__ && !defined __BORLANDC__ 404 #if TCL_MAJOR_VERSION >= 8 472 #ifdef RUBY_USE_NATIVE_THREAD 473 Tcl_ThreadId tk_eventloop_thread_id;
488 #ifdef RUBY_USE_NATIVE_THREAD 489 #define CONTROL_BY_STATUS_OF_RB_THREAD_WAITING_FOR_VALUE 1 490 #define USE_TOGGLE_WINDOW_MODE_FOR_IDLE 0 491 #define DO_THREAD_SCHEDULE_AT_CALLBACK_DONE 1 493 #define CONTROL_BY_STATUS_OF_RB_THREAD_WAITING_FOR_VALUE 1 494 #define USE_TOGGLE_WINDOW_MODE_FOR_IDLE 0 495 #define DO_THREAD_SCHEDULE_AT_CALLBACK_DONE 0 498 #if CONTROL_BY_STATUS_OF_RB_THREAD_WAITING_FOR_VALUE 509 #ifdef RUBY_USE_NATIVE_THREAD 510 #define DEFAULT_EVENT_LOOP_MAX 800 511 #define DEFAULT_NO_EVENT_TICK 10 512 #define DEFAULT_NO_EVENT_WAIT 5 513 #define WATCHDOG_INTERVAL 10 514 #define DEFAULT_TIMER_TICK 0 515 #define NO_THREAD_INTERRUPT_TIME 100 517 #define DEFAULT_EVENT_LOOP_MAX 800 518 #define DEFAULT_NO_EVENT_TICK 10 519 #define DEFAULT_NO_EVENT_WAIT 20 520 #define WATCHDOG_INTERVAL 10 521 #define DEFAULT_TIMER_TICK 0 522 #define NO_THREAD_INTERRUPT_TIME 100 525 #define EVENT_HANDLER_TIMEOUT 100 542 #if TCL_MAJOR_VERSION >= 8 546 static int ip_ruby_eval _((ClientData, Tcl_Interp *,
int,
char **));
547 static int ip_ruby_cmd _((ClientData, Tcl_Interp *,
int,
char **));
559 #ifndef TCL_NAMESPACE_DEBUG 560 #define TCL_NAMESPACE_DEBUG 0 563 #if TCL_NAMESPACE_DEBUG 565 #if TCL_MAJOR_VERSION >= 8 566 EXTERN struct TclIntStubs *tclIntStubsPtr;
570 #if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION < 5 573 # ifndef Tcl_GetCurrentNamespace 574 EXTERN Tcl_Namespace * Tcl_GetCurrentNamespace
_((Tcl_Interp *));
576 # if defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS) 577 # ifndef Tcl_GetCurrentNamespace 578 # ifndef FunctionNum_of_GetCurrentNamespace 579 #define FunctionNum_of_GetCurrentNamespace 124 581 struct DummyTclIntStubs_for_GetCurrentNamespace {
583 struct TclIntStubHooks *hooks;
584 void (*
func[FunctionNum_of_GetCurrentNamespace])();
585 Tcl_Namespace * (*tcl_GetCurrentNamespace)
_((Tcl_Interp *));
588 #define Tcl_GetCurrentNamespace \ 589 (((struct DummyTclIntStubs_for_GetCurrentNamespace *)tclIntStubsPtr)->tcl_GetCurrentNamespace) 596 #if TCL_MAJOR_VERSION < 8 597 #define ip_null_namespace(interp) (0) 599 #define ip_null_namespace(interp) \ 600 (Tcl_GetCurrentNamespace(interp) == (Tcl_Namespace *)NULL) 604 #if TCL_MAJOR_VERSION < 8 605 #define rbtk_invalid_namespace(ptr) (0) 607 #define rbtk_invalid_namespace(ptr) \ 608 ((ptr)->default_ns == (Tcl_Namespace*)NULL || Tcl_GetCurrentNamespace((ptr)->ip) != (ptr)->default_ns) 612 #if TCL_MAJOR_VERSION >= 8 614 typedef struct CallFrame {
615 Tcl_Namespace *nsPtr;
619 struct CallFrame *callerPtr;
620 struct CallFrame *callerVarPtr;
629 # if !defined(TclGetFrame) && !defined(TclGetFrame_TCL_DECLARED) 630 EXTERN int TclGetFrame
_((Tcl_Interp *,
CONST char *, CallFrame **));
632 # if defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS) 634 # ifndef FunctionNum_of_GetFrame 635 #define FunctionNum_of_GetFrame 32 637 struct DummyTclIntStubs_for_GetFrame {
639 struct TclIntStubHooks *hooks;
640 void (*
func[FunctionNum_of_GetFrame])();
641 int (*tclGetFrame)
_((Tcl_Interp *,
CONST char *, CallFrame **));
643 #define TclGetFrame \ 644 (((struct DummyTclIntStubs_for_GetFrame *)tclIntStubsPtr)->tclGetFrame) 648 # if !defined(Tcl_PopCallFrame) && !defined(Tcl_PopCallFrame_TCL_DECLARED) 649 EXTERN void Tcl_PopCallFrame
_((Tcl_Interp *));
650 EXTERN int Tcl_PushCallFrame
_((Tcl_Interp *, Tcl_CallFrame *, Tcl_Namespace *,
int));
652 # if defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS) 653 # ifndef Tcl_PopCallFrame 654 # ifndef FunctionNum_of_PopCallFrame 655 #define FunctionNum_of_PopCallFrame 128 657 struct DummyTclIntStubs_for_PopCallFrame {
659 struct TclIntStubHooks *hooks;
660 void (*
func[FunctionNum_of_PopCallFrame])();
661 void (*tcl_PopCallFrame)
_((Tcl_Interp *));
662 int (*tcl_PushCallFrame)
_((Tcl_Interp *, Tcl_CallFrame *, Tcl_Namespace *,
int));
665 #define Tcl_PopCallFrame \ 666 (((struct DummyTclIntStubs_for_PopCallFrame *)tclIntStubsPtr)->tcl_PopCallFrame) 667 #define Tcl_PushCallFrame \ 668 (((struct DummyTclIntStubs_for_PopCallFrame *)tclIntStubsPtr)->tcl_PushCallFrame) 674 typedef struct CallFrame {
675 Tcl_HashTable varTable;
679 struct CallFrame *callerPtr;
680 struct CallFrame *callerVarPtr;
683 # ifndef Tcl_CallFrame 684 #define Tcl_CallFrame CallFrame 687 # if !defined(TclGetFrame) && !defined(TclGetFrame_TCL_DECLARED) 688 EXTERN int TclGetFrame
_((Tcl_Interp *,
CONST char *, CallFrame **));
691 # if !defined(Tcl_PopCallFrame) && !defined(Tcl_PopCallFrame_TCL_DECLARED) 692 typedef struct DummyInterp {
696 Tcl_HashTable dummy4;
697 Tcl_HashTable dummy5;
698 Tcl_HashTable dummy6;
702 CallFrame *varFramePtr;
706 Tcl_PopCallFrame(interp)
709 DummyInterp *iPtr = (DummyInterp*)interp;
710 CallFrame *frame = iPtr->varFramePtr;
713 iPtr->framePtr = frame.callerPtr;
714 iPtr->varFramePtr = frame.callerVarPtr;
720 #define Tcl_Namespace char 723 Tcl_PushCallFrame(interp, framePtr, nsPtr, isProcCallFrame)
725 Tcl_CallFrame *framePtr;
726 Tcl_Namespace *nsPtr;
729 DummyInterp *iPtr = (DummyInterp*)interp;
730 CallFrame *frame = (CallFrame *)framePtr;
733 Tcl_InitHashTable(&frame.varTable, TCL_STRING_KEYS);
734 if (iPtr->varFramePtr !=
NULL) {
735 frame.level = iPtr->varFramePtr->level + 1;
739 frame.callerPtr = iPtr->framePtr;
740 frame.callerVarPtr = iPtr->varFramePtr;
741 iPtr->framePtr = &frame;
742 iPtr->varFramePtr = &frame;
756 #if TCL_NAMESPACE_DEBUG 757 Tcl_Namespace *default_ns;
759 #ifdef RUBY_USE_NATIVE_THREAD 760 Tcl_ThreadId tk_thread_id;
780 if (ptr->
ip == (Tcl_Interp*)
NULL) {
791 if (!ptr || !ptr->
ip || Tcl_InterpDeleted(ptr->
ip)
793 || rbtk_invalid_namespace(ptr)
796 DUMP1(
"ip is deleted");
808 if (ptr->
ip == (Tcl_Interp*)
NULL) {
812 Tcl_Preserve((ClientData)ptr->
ip);
824 }
else if (ptr->
ip == (Tcl_Interp*)
NULL) {
828 Tcl_Release((ClientData)ptr->
ip);
835 #ifdef HAVE_STDARG_PROTOTYPES 856 Tcl_ResetResult(ptr->
ip);
864 #if defined CREATE_RUBYTK_KIT || defined CREATE_RUBYKIT 868 #if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION < 84 869 #error Ruby/Tk-Kit requires Tcl/Tk8.4 or later. 889 #if defined USE_TCL_STUBS || defined USE_TK_STUBS 890 # error Not support Tcl/Tk stubs with Ruby/Tk-Kit or Rubykit. 893 #ifndef KIT_INCLUDES_ZLIB 894 #if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION < 86 895 #define KIT_INCLUDES_ZLIB 1 897 #define KIT_INCLUDES_ZLIB 0 902 #define WIN32_LEAN_AND_MEAN 904 #undef WIN32_LEAN_AND_MEAN 907 #if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION < 86 908 EXTERN Tcl_Obj* TclGetStartupScriptPath();
909 EXTERN void TclSetStartupScriptPath
_((Tcl_Obj*));
910 #define Tcl_GetStartupScript(encPtr) TclGetStartupScriptPath() 911 #define Tcl_SetStartupScript(path,enc) TclSetStartupScriptPath(path) 913 #if !defined(TclSetPreInitScript) && !defined(TclSetPreInitScript_TCL_DECLARED) 914 EXTERN char* TclSetPreInitScript
_((
char *));
917 #ifndef KIT_INCLUDES_TK 918 # define KIT_INCLUDES_TK 1 923 Tcl_AppInitProc Vfs_Init, Rechan_Init;
924 #if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION < 85 925 Tcl_AppInitProc Pwb_Init;
929 Tcl_AppInitProc Vlerq_Init, Vlerq_SafeInit;
931 Tcl_AppInitProc Mk4tcl_Init;
934 #if defined TCL_THREADS && defined KIT_INCLUDES_THREAD 935 Tcl_AppInitProc Thread_Init;
938 #if KIT_INCLUDES_ZLIB 939 Tcl_AppInitProc Zlib_Init;
942 #ifdef KIT_INCLUDES_ITCL 943 Tcl_AppInitProc Itcl_Init;
947 Tcl_AppInitProc Dde_Init, Dde_SafeInit, Registry_Init;
952 #define RUBYTK_KITPATH_CONST_NAME "RUBYTK_KITPATH" 954 static char *rubytk_kitpath =
NULL;
956 static char rubytkkit_preInitCmd[] =
957 "proc tclKitPreInit {} {\n" 958 "rename tclKitPreInit {}\n" 959 "load {} rubytk_kitpath\n" 960 #if KIT_INCLUDES_ZLIB 961 "catch {load {} zlib}\n" 965 "namespace eval ::vlerq {}\n" 966 "if {[catch { vlerq open $::tcl::kitpath } ::vlerq::starkit_root]} {\n" 969 "set files [vlerq get $::vlerq::starkit_root 0 dirs 0 files]\n" 970 "set n [lsearch [vlerq get $files * name] boot.tcl]\n" 973 "array set a [vlerq get $files $n]\n" 976 #if defined KIT_VFS_WRITABLE && !defined CREATE_RUBYKIT 978 "mk::file open exe $::tcl::kitpath\n" 980 "mk::file open exe $::tcl::kitpath -readonly\n" 982 "set n [mk::select exe.dirs!0.files name boot.tcl]\n" 983 "if {[llength $n] == 1} {\n" 984 "array set a [mk::get exe.dirs!0.files!$n]\n" 986 "if {![info exists a(contents)]} { error {no boot.tcl file} }\n" 987 "if {$a(size) != [string length $a(contents)]} {\n" 988 "set a(contents) [zlib decompress $a(contents)]\n" 990 "if {$a(contents) eq \"\"} { error {empty boot.tcl} }\n" 991 "uplevel #0 $a(contents)\n" 993 "} elseif {[lindex $::argv 0] eq \"-init-\"} {\n" 994 "uplevel #0 { source [lindex $::argv 1] }\n" 999 "set vfsdir \"[file rootname $::tcl::kitpath].vfs\"\n" 1000 "if {[file isdirectory $vfsdir]} {\n" 1001 "set ::tcl_library [file join $vfsdir lib tcl$::tcl_version]\n" 1002 "set ::tcl_libPath [list $::tcl_library [file join $vfsdir lib]]\n" 1003 "catch {uplevel #0 [list source [file join $vfsdir config.tcl]]}\n" 1004 "uplevel #0 [list source [file join $::tcl_library init.tcl]]\n" 1005 "set ::auto_path $::tcl_libPath\n" 1007 "error \"\n $::tcl::kitpath has no VFS data to start up\"\n" 1017 static const char initScript[] =
1018 "if {[file isfile [file join $::tcl::kitpath main.tcl]]} {\n" 1019 "if {[info commands console] != {}} { console hide }\n" 1020 "set tcl_interactive 0\n" 1022 "set argv [linsert $argv 0 $argv0]\n" 1023 "set argv0 [file join $::tcl::kitpath main.tcl]\n" 1031 set_rubytk_kitpath(
const char *kitpath)
1034 int len = (int)
strlen(kitpath);
1035 if (rubytk_kitpath) {
1036 ckfree(rubytk_kitpath);
1039 rubytk_kitpath = (
char *)ckalloc(len + 1);
1040 memcpy(rubytk_kitpath, kitpath, len);
1041 rubytk_kitpath[len] =
'\0';
1043 return rubytk_kitpath;
1049 #define DEV_NULL "NUL" 1051 #define DEV_NULL "/dev/null" 1055 check_tclkit_std_channels()
1064 chan = Tcl_GetStdChannel(TCL_STDIN);
1066 chan = Tcl_OpenFileChannel(
NULL, DEV_NULL,
"r", 0);
1068 Tcl_SetChannelOption(
NULL, chan,
"-encoding",
"utf-8");
1070 Tcl_SetStdChannel(chan, TCL_STDIN);
1072 chan = Tcl_GetStdChannel(TCL_STDOUT);
1074 chan = Tcl_OpenFileChannel(
NULL, DEV_NULL,
"w", 0);
1076 Tcl_SetChannelOption(
NULL, chan,
"-encoding",
"utf-8");
1078 Tcl_SetStdChannel(chan, TCL_STDOUT);
1080 chan = Tcl_GetStdChannel(TCL_STDERR);
1082 chan = Tcl_OpenFileChannel(
NULL, DEV_NULL,
"w", 0);
1084 Tcl_SetChannelOption(
NULL, chan,
"-encoding",
"utf-8");
1086 Tcl_SetStdChannel(chan, TCL_STDERR);
1093 rubytk_kitpathObjCmd(ClientData dummy, Tcl_Interp *interp,
int objc, Tcl_Obj *
const objv[])
1097 set_rubytk_kitpath(Tcl_GetString(objv[1]));
1098 }
else if (objc > 2) {
1099 Tcl_WrongNumArgs(interp, 1, objv,
"?path?");
1101 str = rubytk_kitpath ? rubytk_kitpath : Tcl_GetNameOfExecutable();
1102 Tcl_SetObjResult(interp, Tcl_NewStringObj(str, -1));
1111 rubytk_kitpath_init(Tcl_Interp *interp)
1113 Tcl_CreateObjCommand(interp,
"::tcl::kitpath", rubytk_kitpathObjCmd, 0, 0);
1114 if (Tcl_LinkVar(interp,
"::tcl::kitpath", (
char *) &rubytk_kitpath,
1115 TCL_LINK_STRING | TCL_LINK_READ_ONLY) != TCL_OK) {
1116 Tcl_ResetResult(interp);
1119 Tcl_CreateObjCommand(interp,
"::tcl::rubytk_kitpath", rubytk_kitpathObjCmd, 0, 0);
1120 if (Tcl_LinkVar(interp,
"::tcl::rubytk_kitpath", (
char *) &rubytk_kitpath,
1121 TCL_LINK_STRING | TCL_LINK_READ_ONLY) != TCL_OK) {
1122 Tcl_ResetResult(interp);
1125 if (rubytk_kitpath ==
NULL) {
1130 set_rubytk_kitpath(Tcl_GetNameOfExecutable());
1133 return Tcl_PkgProvide(interp,
"rubytk_kitpath",
"1.0");
1139 init_static_tcltk_packages()
1144 check_tclkit_std_channels();
1146 #ifdef KIT_INCLUDES_ITCL 1147 Tcl_StaticPackage(0,
"Itcl", Itcl_Init,
NULL);
1150 Tcl_StaticPackage(0,
"Vlerq", Vlerq_Init, Vlerq_SafeInit);
1152 Tcl_StaticPackage(0,
"Mk4tcl", Mk4tcl_Init,
NULL);
1154 #if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION < 85 1155 Tcl_StaticPackage(0,
"pwb", Pwb_Init,
NULL);
1157 Tcl_StaticPackage(0,
"rubytk_kitpath", rubytk_kitpath_init,
NULL);
1158 Tcl_StaticPackage(0,
"rechan", Rechan_Init,
NULL);
1159 Tcl_StaticPackage(0,
"vfs", Vfs_Init,
NULL);
1160 #if KIT_INCLUDES_ZLIB 1161 Tcl_StaticPackage(0,
"zlib", Zlib_Init,
NULL);
1163 #if defined TCL_THREADS && defined KIT_INCLUDES_THREAD 1164 Tcl_StaticPackage(0,
"Thread", Thread_Init, Thread_SafeInit);
1167 #if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION > 84 1168 Tcl_StaticPackage(0,
"dde", Dde_Init, Dde_SafeInit);
1170 Tcl_StaticPackage(0,
"dde", Dde_Init,
NULL);
1172 Tcl_StaticPackage(0,
"registry", Registry_Init,
NULL);
1174 #ifdef KIT_INCLUDES_TK 1175 Tcl_StaticPackage(0,
"Tk", Tk_Init, Tk_SafeInit);
1182 call_tclkit_init_script(Tcl_Interp *interp)
1188 if (Tcl_EvalEx(interp, initScript, -1, TCL_EVAL_GLOBAL) == TCL_OK) {
1189 const char *encoding =
NULL;
1190 Tcl_Obj* path = Tcl_GetStartupScript(&encoding);
1191 Tcl_SetStartupScript(Tcl_GetObjResult(interp), encoding);
1193 Tcl_Eval(interp,
"incr argc -1; set argv [lrange $argv 1 end]");
1207 EXTERN void TkWinSetHINSTANCE(HINSTANCE hInstance);
1208 void rbtk_win32_SetHINSTANCE(
const char *module_name)
1215 hInst = GetModuleHandle(module_name);
1216 TkWinSetHINSTANCE(hInst);
1228 init_static_tcltk_packages();
1232 const_id =
rb_intern(RUBYTK_KITPATH_CONST_NAME);
1235 volatile VALUE pathobj;
1239 #ifdef HAVE_RUBY_ENCODING_H 1247 #ifdef CREATE_RUBYTK_KIT 1248 if (rubytk_kitpath ==
NULL) {
1252 volatile VALUE basename;
1262 if (rubytk_kitpath ==
NULL) {
1263 set_rubytk_kitpath(Tcl_GetNameOfExecutable());
1266 TclSetPreInitScript(rubytkkit_preInitCmd);
1311 #if TCL_MAJOR_VERSION >= 8 1314 if (Tcl_IsSafe(ptr->
ip)) {
1315 DUMP1(
"Tk_SafeInit");
1322 "tcltklib: can't find Tk_SafeInit()");
1325 "tcltklib: fail to Tk_SafeInit(). %s",
1329 "tcltklib: fail to Tk_InitStubs(). %s",
1333 "tcltklib: unknown error(%d) on ruby_tk_stubs_safeinit", st);
1343 "tcltklib: can't find Tk_Init()");
1346 "tcltklib: fail to Tk_Init(). %s",
1350 "tcltklib: fail to Tk_InitStubs(). %s",
1354 "tcltklib: unknown error(%d) on ruby_tk_stubs_init", st);
1365 #ifdef RUBY_USE_NATIVE_THREAD 1366 ptr->tk_thread_id = Tcl_GetCurrentThread();
1385 DUMP1(
"find a pending exception");
1394 DUMP1(
"pending_exception_check0: call rb_jump_tag(retry)");
1397 DUMP1(
"pending_exception_check0: call rb_jump_tag(redo)");
1400 DUMP1(
"pending_exception_check0: call rb_jump_tag(throw)");
1421 DUMP1(
"find a pending exception");
1438 DUMP1(
"pending_exception_check1: call rb_jump_tag(retry)");
1441 DUMP1(
"pending_exception_check1: call rb_jump_tag(redo)");
1444 DUMP1(
"pending_exception_check1: call rb_jump_tag(throw)");
1465 #if TCL_MAJOR_VERSION >= 8 1469 DUMP1(
"original_exit is called");
1476 Tcl_ResetResult(ptr->
ip);
1481 #if TCL_MAJOR_VERSION >= 8 1482 state_obj = Tcl_NewIntObj(state);
1485 if (info->isNativeObjectProc) {
1487 #define USE_RUBY_ALLOC 0 1493 Tcl_Preserve((ClientData)
argv);
1496 cmd_obj = Tcl_NewStringObj(
"exit", 4);
1500 argv[1] = state_obj;
1504 = (*(info->objProc))(info->objClientData, ptr->
ip, 2,
argv);
1512 Tcl_EventuallyFree((ClientData)
argv, TCL_DYNAMIC);
1515 Tcl_Release((ClientData)
argv);
1518 ckfree((
char*)
argv);
1522 #undef USE_RUBY_ALLOC 1527 #define USE_RUBY_ALLOC 0 1533 Tcl_Preserve((ClientData)
argv);
1536 argv[0] = (
char *)
"exit";
1538 argv[1] = Tcl_GetStringFromObj(state_obj, (
int*)
NULL);
1547 Tcl_EventuallyFree((ClientData)
argv, TCL_DYNAMIC);
1550 Tcl_Release((ClientData)
argv);
1553 ckfree((
char*)
argv);
1557 #undef USE_RUBY_ALLOC 1566 #define USE_RUBY_ALLOC 0 1572 Tcl_Preserve((ClientData)
argv);
1586 Tcl_EventuallyFree((ClientData)
argv, TCL_DYNAMIC);
1589 Tcl_Release((ClientData)
argv);
1596 #undef USE_RUBY_ALLOC 1599 DUMP1(
"complete original_exit");
1611 ClientData clientData;
1618 DUMP1(
"call _timer_for_tcl");
1640 #ifdef RUBY_USE_NATIVE_THREAD 1641 #if USE_TOGGLE_WINDOW_MODE_FOR_IDLE 1643 toggle_eventloop_window_mode_for_idle()
1699 "timer-tick parameter must be 0 or positive number");
1741 if (Tcl_GetMaster(ptr->
ip) != (Tcl_Interp*)
NULL) {
1766 "no_event_wait parameter must be positive number");
1793 if (Tcl_GetMaster(ptr->
ip) != (Tcl_Interp*)
NULL) {
1813 int lpmax =
NUM2INT(loop_max);
1814 int no_ev =
NUM2INT(no_event);
1818 if (lpmax <= 0 || no_ev <= 0) {
1848 if (Tcl_GetMaster(ptr->
ip) != (Tcl_Interp*)
NULL) {
1867 struct Tcl_Time tcl_time;
1870 switch(
TYPE(time)) {
1893 Tcl_SetMaxBlockTime(&tcl_time);
1959 if (Tcl_GetMaster(ptr->
ip) != (Tcl_Interp*)
NULL) {
1973 return INT2FIX(Tk_GetNumMainWindows());
1983 #ifdef RUBY_USE_NATIVE_THREAD 1996 Tcl_SetMaxBlockTime(&tcl_time);
2006 #ifdef RUBY_USE_NATIVE_THREAD 2008 #ifdef HAVE_PROTOTYPES 2009 call_DoOneEvent_core(
VALUE flag_val)
2011 call_DoOneEvent_core(flag_val)
2018 if (Tcl_DoOneEvent(flag)) {
2026 #ifdef HAVE_PROTOTYPES 2038 #ifdef HAVE_PROTOTYPES 2048 if (Tcl_DoOneEvent(flag)) {
2059 #ifdef HAVE_PROTOTYPES 2060 eventloop_sleep(
VALUE dummy)
2062 eventloop_sleep(dummy)
2075 #ifdef HAVE_NATIVETHREAD 2076 #ifndef RUBY_USE_NATIVE_THREAD 2078 rb_bug(
"cross-thread violation on eventloop_sleep()");
2087 #ifdef HAVE_NATIVETHREAD 2088 #ifndef RUBY_USE_NATIVE_THREAD 2090 rb_bug(
"cross-thread violation on eventloop_sleep()");
2099 #define USE_EVLOOP_THREAD_ALONE_CHECK_FLAG 0 2101 #if USE_EVLOOP_THREAD_ALONE_CHECK_FLAG 2103 get_thread_alone_check_flag()
2105 #ifdef RUBY_USE_NATIVE_THREAD 2137 #define TRAP_CHECK() do { \ 2138 if (trap_check(check_var) == 0) return 0; \ 2144 DUMP1(
"trap check");
2148 if (check_var != (
int*)
NULL) {
2157 if (rb_trap_pending) {
2159 if (rb_prohibit_interrupt || check_var != (
int*)
NULL) {
2174 DUMP1(
"check eventloop_interp");
2192 int found_event = 1;
2198 #if USE_EVLOOP_THREAD_ALONE_CHECK_FLAG 2199 int thread_alone_check_flag = 1;
2202 if (update_flag)
DUMP1(
"update loop start!!");
2219 #if USE_EVLOOP_THREAD_ALONE_CHECK_FLAG 2221 thread_alone_check_flag = get_thread_alone_check_flag();
2227 #if USE_EVLOOP_THREAD_ALONE_CHECK_FLAG 2232 DUMP1(
"no other thread");
2236 event_flag = update_flag;
2239 event_flag = TCL_ALL_EVENTS;
2250 if (check_var != (
int *)
NULL) {
2251 if (*check_var || !found_event) {
2254 if (interp != (Tcl_Interp*)
NULL 2255 && Tcl_InterpDeleted(interp)) {
2263 INT2FIX(event_flag), &status));
2295 DUMP2(
"DoOneEvent(1) abnormal exit!! %d",
2300 DUMP1(
"exception on wait");
2309 if (update_flag != 0) {
2311 DUMP1(
"next update loop");
2314 DUMP1(
"update complete");
2322 DUMP1(
"check Root Widget");
2337 DUMP1(
"there are other threads");
2343 event_flag = update_flag;
2346 event_flag = TCL_ALL_EVENTS;
2353 if (check_var != (
int *)
NULL) {
2354 if (*check_var || !found_event) {
2357 if (interp != (Tcl_Interp*)
NULL 2358 && Tcl_InterpDeleted(interp)) {
2368 #ifdef RUBY_USE_NATIVE_THREAD 2371 INT2FIX(event_flag), &status));
2376 #if USE_TOGGLE_WINDOW_MODE_FOR_IDLE 2378 if (toggle_eventloop_window_mode_for_idle()) {
2391 INT2FIX(event_flag), &status));
2394 #if CONTROL_BY_STATUS_OF_RB_THREAD_WAITING_FOR_VALUE 2407 "unknown exception");
2433 DUMP2(
"DoOneEvent(2) abnormal exit!! %d",
2440 if (check_var != (
int*)
NULL 2442 DUMP1(
"exception on wait");
2454 if (update_flag != 0) {
2455 DUMP1(
"update complete");
2471 "unknown exception");
2500 DUMP2(
"sleep eventloop %lx", current);
2513 DUMP1(
"check Root Widget");
2534 DUMP1(
"thread scheduling");
2538 DUMP1(
"check interrupts");
2539 #if defined(RUBY_USE_NATIVE_THREAD) || defined(RUBY_VM) 2622 DUMP2(
"eventloop_ensure: current-thread : %lx", current_evloop);
2625 DUMP2(
"finish eventloop %lx (NOT current eventloop)", current_evloop);
2636 DUMP2(
"eventloop-ensure: new eventloop-thread -> %lx",
2641 DUMP2(
"eventloop %lx : back from recursive call", current_evloop);
2664 #ifdef RUBY_USE_NATIVE_THREAD 2666 tk_eventloop_thread_id = (Tcl_ThreadId) 0;
2675 DUMP2(
"finish current eventloop %lx", current_evloop);
2693 #ifdef RUBY_USE_NATIVE_THREAD 2694 tk_eventloop_thread_id = Tcl_GetCurrentThread();
2698 DUMP2(
"eventloop: recursive call on %lx", parent_evloop);
2703 DUMP2(
"wait for stop of parent_evloop %lx", parent_evloop);
2705 DUMP2(
"parent_evloop %lx doesn't stop", parent_evloop);
2708 DUMP1(
"succeed to stop parent");
2713 DUMP3(
"tcltklib: eventloop-thread : %lx -> %lx\n",
2739 VALUE check_rootwidget;
2742 check_rootwidget =
Qtrue;
2743 }
else if (
RTEST(check_rootwidget)) {
2744 check_rootwidget =
Qtrue;
2746 check_rootwidget =
Qfalse;
2767 if (Tcl_GetMaster(ptr->
ip) != (Tcl_Interp*)
NULL) {
2781 VALUE check_rootwidget;
2787 #define EVLOOP_WAKEUP_CHANCE 3 2791 VALUE check_rootwidget;
2796 int check =
RTEST(check_rootwidget);
2819 DUMP2(
"eventloop thread %lx is sleeping or dead",
2822 (
void*)&check_rootwidget);
2823 DUMP2(
"create new eventloop thread %lx", evloop);
2851 #ifdef RUBY_USE_NATIVE_THREAD 2852 tk_eventloop_thread_id = (Tcl_ThreadId) 0;
2863 VALUE check_rootwidget;
2867 "eventloop_watchdog is not implemented on Ruby VM.");
2871 check_rootwidget =
Qtrue;
2872 }
else if (
RTEST(check_rootwidget)) {
2873 check_rootwidget =
Qtrue;
2875 check_rootwidget =
Qfalse;
2895 if (Tcl_GetMaster(ptr->
ip) != (Tcl_Interp*)
NULL) {
2943 #ifdef HAVE_PROTOTYPES 2961 int status, foundEvent;
2981 q->done, (Tcl_Interp*)
NULL));
3023 volatile VALUE vflags;
3034 flags = TCL_ALL_EVENTS | TCL_DONT_WAIT;
3041 flags |= TCL_DONT_WAIT;
3053 if (Tcl_GetMaster(ptr->
ip) != (Tcl_Interp*)
NULL) {
3055 flags |= TCL_DONT_WAIT;
3060 found_event = Tcl_DoOneEvent(flags);
3102 #if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION > 0) 3104 Tcl_Encoding encoding;
3113 #if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION > 0) 3119 encoding = (Tcl_Encoding)
NULL;
3138 Tcl_DStringInit(&dstr);
3139 Tcl_DStringFree(&dstr);
3142 Tcl_AppendResult(interp, Tcl_DStringValue(&dstr), (
char*)
NULL);
3143 DUMP2(
"error message:%s", Tcl_DStringValue(&dstr));
3144 Tcl_DStringFree(&dstr);
3185 #ifdef HAVE_PROTOTYPES 3198 Tcl_ResetResult(interp);
3228 DUMP1(
"rb_protect: retry");
3237 DUMP1(
"rb_protect: redo");
3262 DUMP1(
"rb_protect: throw");
3272 sprintf(
buf,
"unknown loncaljmp status %d", status);
3286 Tcl_ResetResult(interp);
3291 volatile VALUE backtrace;
3298 DUMP1(
"set backtrace");
3315 return TCL_CONTINUE;
3338 return TCL_CONTINUE;
3352 DUMP1(
"Tcl_AppendResult");
3371 #ifdef HAVE_NATIVETHREAD 3372 #ifndef RUBY_USE_NATIVE_THREAD 3374 rb_bug(
"cross-thread violation on tcl_protect()");
3383 int old_trapflag = rb_trap_immediate;
3384 rb_trap_immediate = 0;
3386 rb_trap_immediate = old_trapflag;
3394 #if TCL_MAJOR_VERSION >= 8 3396 ClientData clientData;
3402 ClientData clientData;
3412 if (interp == (Tcl_Interp*)
NULL) {
3422 "wrong number of arguments (%d for 1)",
argc - 1);
3424 char buf[
sizeof(int)*8 + 1];
3425 Tcl_ResetResult(interp);
3427 Tcl_AppendResult(interp,
"wrong number of arguments (",
3428 buf,
" for 1)", (
char *)
NULL);
3436 #if TCL_MAJOR_VERSION >= 8 3444 str = Tcl_GetStringFromObj(
argv[1], &len);
3447 memcpy(arg, str, len);
3458 DUMP2(
"rb_eval_string(%s)", arg);
3462 #if TCL_MAJOR_VERSION >= 8 3479 DUMP1(
"call ip_ruby_cmd_core");
3483 DUMP2(
"rb_apply return:%lx", ret);
3485 DUMP1(
"finish ip_ruby_cmd_core");
3490 #define SUPPORT_NESTED_CONST_AS_IP_RUBY_CMD_RECEIVER 1 3502 #if SUPPORT_NESTED_CONST_AS_IP_RUBY_CMD_RECEIVER 3549 #if !SUPPORT_NESTED_CONST_AS_IP_RUBY_CMD_RECEIVER 3553 if (str[0] ==
':' || (
'A' <= str[0] && str[0] <=
'Z')) {
3555 #if SUPPORT_NESTED_CONST_AS_IP_RUBY_CMD_RECEIVER 3559 if (state)
return Qnil;
3561 }
else if (str[0] ==
'$') {
3573 memcpy(
buf + 1, str, len);
3585 #if TCL_MAJOR_VERSION >= 8 3587 ClientData clientData;
3593 ClientData clientData;
3610 if (interp == (Tcl_Interp*)
NULL) {
3620 Tcl_ResetResult(interp);
3621 Tcl_AppendResult(interp,
"too few arguments", (
char *)
NULL);
3634 #if TCL_MAJOR_VERSION >= 8 3635 str = Tcl_GetStringFromObj(
argv[1], &len);
3639 DUMP2(
"receiver:%s",str);
3645 "unknown class/module/global-variable '%s'", str);
3647 Tcl_ResetResult(interp);
3648 Tcl_AppendResult(interp,
"unknown class/module/global-variable '",
3649 str,
"'", (
char *)
NULL);
3658 #if TCL_MAJOR_VERSION >= 8 3659 str = Tcl_GetStringFromObj(
argv[2], &len);
3669 #if TCL_MAJOR_VERSION >= 8 3670 str = Tcl_GetStringFromObj(
argv[
i], &len);
3676 DUMP2(
"arg:%s",str);
3677 #ifndef HAVE_STRUCT_RARRAY_LEN 3709 #if TCL_MAJOR_VERSION >= 8 3710 #ifdef HAVE_PROTOTYPES 3711 ip_InterpExitObjCmd(ClientData clientData, Tcl_Interp *interp,
3714 ip_InterpExitObjCmd(clientData, interp,
argc,
argv)
3715 ClientData clientData;
3721 #ifdef HAVE_PROTOTYPES 3726 ClientData clientData;
3733 DUMP1(
"start ip_InterpExitCommand");
3734 if (interp != (Tcl_Interp*)
NULL 3735 && !Tcl_InterpDeleted(interp)
3737 && !ip_null_namespace(interp)
3740 Tcl_ResetResult(interp);
3743 if (!Tcl_InterpDeleted(interp)) {
3746 Tcl_DeleteInterp(interp);
3747 Tcl_Release(interp);
3754 #if TCL_MAJOR_VERSION >= 8 3755 #ifdef HAVE_PROTOTYPES 3756 ip_RubyExitObjCmd(ClientData clientData, Tcl_Interp *interp,
3759 ip_RubyExitObjCmd(clientData, interp,
argc,
argv)
3760 ClientData clientData;
3766 #ifdef HAVE_PROTOTYPES 3771 ClientData clientData;
3780 #if TCL_MAJOR_VERSION < 8 3785 DUMP1(
"start ip_RubyExitCommand");
3787 #if TCL_MAJOR_VERSION >= 8 3789 cmd = Tcl_GetStringFromObj(
argv[0], (
int*)
NULL);
3792 if (argc < 1 || argc > 2) {
3794 Tcl_AppendResult(interp,
3795 "wrong number of arguments: should be \"",
3796 cmd,
" ?returnCode?\"", (
char *)
NULL);
3800 if (interp == (Tcl_Interp*)
NULL)
return TCL_OK;
3802 Tcl_ResetResult(interp);
3805 if (!Tcl_InterpDeleted(interp)) {
3808 Tcl_DeleteInterp(interp);
3809 Tcl_Release(interp);
3817 Tcl_AppendResult(interp,
3818 "fail to call \"", cmd,
"\"", (
char *)
NULL);
3827 #if TCL_MAJOR_VERSION >= 8 3828 if (Tcl_GetIntFromObj(interp,
argv[1], &state) == TCL_ERROR) {
3832 param = Tcl_GetStringFromObj(
argv[1], (
int*)
NULL);
3836 Tcl_AppendResult(interp,
3837 "expected integer but got \"",
3845 Tcl_AppendResult(interp,
"fail to call \"", cmd,
" ",
3846 param,
"\"", (
char *)
NULL);
3856 Tcl_AppendResult(interp,
3857 "wrong number of arguments: should be \"",
3858 cmd,
" ?returnCode?\"", (
char *)
NULL);
3871 #if TCL_MAJOR_VERSION >= 8 3872 static int ip_rbUpdateObjCmd
_((ClientData, Tcl_Interp *,
int,
3873 Tcl_Obj *
CONST []));
3875 ip_rbUpdateObjCmd(clientData, interp, objc, objv)
3876 ClientData clientData;
3879 Tcl_Obj *
CONST objv[];
3884 ClientData clientData;
3893 static CONST char *updateOptions[] = {
"idletasks", (
char *)
NULL};
3894 enum updateOptions {REGEXP_IDLETASKS};
3896 DUMP1(
"Ruby's 'update' is called");
3897 if (interp == (Tcl_Interp*)
NULL) {
3902 #ifdef HAVE_NATIVETHREAD 3903 #ifndef RUBY_USE_NATIVE_THREAD 3905 rb_bug(
"cross-thread violation on ip_ruby_eval()");
3910 Tcl_ResetResult(interp);
3913 flags = TCL_DONT_WAIT;
3915 }
else if (objc == 2) {
3916 #if TCL_MAJOR_VERSION >= 8 3917 if (Tcl_GetIndexFromObj(interp, objv[1], (
CONST84 char **)updateOptions,
3918 "option", 0, &optionIndex) != TCL_OK) {
3921 switch ((
enum updateOptions) optionIndex) {
3922 case REGEXP_IDLETASKS: {
3923 flags = TCL_IDLE_EVENTS;
3927 rb_bug(
"ip_rbUpdateObjCmd: bad option index to UpdateOptions");
3931 if (strncmp(objv[1],
"idletasks",
strlen(objv[1])) != 0) {
3932 Tcl_AppendResult(interp,
"bad option \"", objv[1],
3933 "\": must be idletasks", (
char *)
NULL);
3936 flags = TCL_IDLE_EVENTS;
3939 #ifdef Tcl_WrongNumArgs 3940 Tcl_WrongNumArgs(interp, 1, objv,
"[ idletasks ]");
3942 # if TCL_MAJOR_VERSION >= 8 3944 Tcl_AppendResult(interp,
"wrong number of arguments: should be \"",
3945 Tcl_GetStringFromObj(objv[0], &dummy),
3949 Tcl_AppendResult(interp,
"wrong number of arguments: should be \"",
3950 objv[0],
" [ idletasks ]\"", (
char *)
NULL);
3956 Tcl_Preserve(interp);
3964 Tcl_Release(interp);
3981 if (rb_trap_pending) {
3983 Tcl_Release(interp);
3994 Tcl_ResetResult(interp);
3995 Tcl_Release(interp);
3997 DUMP1(
"finish Ruby's 'update'");
4013 ClientData clientData;
4017 DUMP1(
"threadUpdateProc is called");
4024 #if TCL_MAJOR_VERSION >= 8 4025 static int ip_rb_threadUpdateObjCmd
_((ClientData, Tcl_Interp *,
int,
4026 Tcl_Obj *
CONST []));
4028 ip_rb_threadUpdateObjCmd(clientData, interp, objc, objv)
4029 ClientData clientData;
4032 Tcl_Obj *
CONST objv[];
4038 ClientData clientData;
4047 static CONST char *updateOptions[] = {
"idletasks", (
char *)
NULL};
4048 enum updateOptions {REGEXP_IDLETASKS};
4052 DUMP1(
"Ruby's 'thread_update' is called");
4053 if (interp == (Tcl_Interp*)
NULL) {
4058 #ifdef HAVE_NATIVETHREAD 4059 #ifndef RUBY_USE_NATIVE_THREAD 4061 rb_bug(
"cross-thread violation on ip_rb_threadUpdateCommand()");
4068 #if TCL_MAJOR_VERSION >= 8 4069 DUMP1(
"call ip_rbUpdateObjCmd");
4070 return ip_rbUpdateObjCmd(clientData, interp, objc, objv);
4072 DUMP1(
"call ip_rbUpdateCommand");
4077 DUMP1(
"start Ruby's 'thread_update' body");
4079 Tcl_ResetResult(interp);
4082 flags = TCL_DONT_WAIT;
4084 }
else if (objc == 2) {
4085 #if TCL_MAJOR_VERSION >= 8 4086 if (Tcl_GetIndexFromObj(interp, objv[1], (
CONST84 char **)updateOptions,
4087 "option", 0, &optionIndex) != TCL_OK) {
4090 switch ((
enum updateOptions) optionIndex) {
4091 case REGEXP_IDLETASKS: {
4092 flags = TCL_IDLE_EVENTS;
4096 rb_bug(
"ip_rb_threadUpdateObjCmd: bad option index to UpdateOptions");
4100 if (strncmp(objv[1],
"idletasks",
strlen(objv[1])) != 0) {
4101 Tcl_AppendResult(interp,
"bad option \"", objv[1],
4102 "\": must be idletasks", (
char *)
NULL);
4105 flags = TCL_IDLE_EVENTS;
4108 #ifdef Tcl_WrongNumArgs 4109 Tcl_WrongNumArgs(interp, 1, objv,
"[ idletasks ]");
4111 # if TCL_MAJOR_VERSION >= 8 4113 Tcl_AppendResult(interp,
"wrong number of arguments: should be \"",
4114 Tcl_GetStringFromObj(objv[0], &dummy),
4118 Tcl_AppendResult(interp,
"wrong number of arguments: should be \"",
4119 objv[0],
" [ idletasks ]\"", (
char *)
NULL);
4125 DUMP1(
"pass argument check");
4130 Tcl_Preserve((ClientData)param);
4132 param->thread = current_thread;
4135 DUMP1(
"set idle proc");
4141 while(!param->done) {
4142 DUMP1(
"wait for complete idle proc");
4152 Tcl_EventuallyFree((ClientData)param, TCL_DYNAMIC);
4155 Tcl_Release((ClientData)param);
4158 ckfree((
char *)param);
4162 DUMP1(
"finish Ruby's 'thread_update'");
4170 #if TCL_MAJOR_VERSION >= 8 4171 static int ip_rbVwaitObjCmd
_((ClientData, Tcl_Interp *,
int,
4172 Tcl_Obj *
CONST []));
4173 static int ip_rb_threadVwaitObjCmd
_((ClientData, Tcl_Interp *,
int,
4174 Tcl_Obj *
CONST []));
4175 static int ip_rbTkWaitObjCmd
_((ClientData, Tcl_Interp *,
int,
4176 Tcl_Obj *
CONST []));
4177 static int ip_rb_threadTkWaitObjCmd
_((ClientData, Tcl_Interp *,
int,
4178 Tcl_Obj *
CONST []));
4188 #if TCL_MAJOR_VERSION >= 8 4193 ClientData clientData;
4199 static char *
VwaitVarProc _((ClientData, Tcl_Interp *,
char *,
char *,
int));
4202 ClientData clientData;
4209 int *donePtr = (
int *) clientData;
4212 return (
char *)
NULL;
4215 #if TCL_MAJOR_VERSION >= 8 4217 ip_rbVwaitObjCmd(clientData, interp, objc, objv)
4218 ClientData clientData;
4221 Tcl_Obj *
CONST objv[];
4225 ClientData clientData;
4231 int ret, done, foundEvent;
4236 DUMP1(
"Ruby's 'vwait' is called");
4237 if (interp == (Tcl_Interp*)
NULL) {
4247 #if TCL_MAJOR_VERSION >= 8 4248 DUMP1(
"call ip_rb_threadVwaitObjCmd");
4249 return ip_rb_threadVwaitObjCmd(clientData, interp, objc, objv);
4251 DUMP1(
"call ip_rb_threadVwaitCommand");
4257 Tcl_Preserve(interp);
4258 #ifdef HAVE_NATIVETHREAD 4259 #ifndef RUBY_USE_NATIVE_THREAD 4261 rb_bug(
"cross-thread violation on ip_rbVwaitCommand()");
4266 Tcl_ResetResult(interp);
4269 #ifdef Tcl_WrongNumArgs 4270 Tcl_WrongNumArgs(interp, 1, objv,
"name");
4275 #if TCL_MAJOR_VERSION >= 8 4277 nameString = Tcl_GetStringFromObj(objv[0], &dummy);
4279 nameString = objv[0];
4281 Tcl_AppendResult(interp,
"wrong number of arguments: should be \"",
4282 nameString,
" name\"", (
char *)
NULL);
4287 Tcl_Release(interp);
4294 #if TCL_MAJOR_VERSION >= 8 4297 nameString = Tcl_GetStringFromObj(objv[1], &dummy);
4299 nameString = objv[1];
4309 ret = Tcl_TraceVar(interp, nameString,
4310 TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
4315 if (ret != TCL_OK) {
4316 #if TCL_MAJOR_VERSION >= 8 4319 Tcl_Release(interp);
4331 Tcl_UntraceVar(interp, nameString,
4332 TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
4339 #if TCL_MAJOR_VERSION >= 8 4342 Tcl_Release(interp);
4359 if (rb_trap_pending) {
4361 #if TCL_MAJOR_VERSION >= 8 4364 Tcl_Release(interp);
4374 Tcl_ResetResult(interp);
4379 Tcl_AppendResult(interp,
"can't wait for variable \"", nameString,
4380 "\": would wait forever", (
char *)
NULL);
4384 #if TCL_MAJOR_VERSION >= 8 4387 Tcl_Release(interp);
4391 #if TCL_MAJOR_VERSION >= 8 4394 Tcl_Release(interp);
4402 #if TCL_MAJOR_VERSION >= 8 4407 ClientData clientData;
4414 char *,
char *,
int));
4417 ClientData clientData;
4424 int *donePtr = (
int *) clientData;
4427 return (
char *)
NULL;
4433 ClientData clientData;
4436 int *donePtr = (
int *) clientData;
4438 if (eventPtr->type == VisibilityNotify) {
4441 if (eventPtr->type == DestroyNotify) {
4449 ClientData clientData;
4452 int *donePtr = (
int *) clientData;
4454 if (eventPtr->type == DestroyNotify) {
4459 #if TCL_MAJOR_VERSION >= 8 4461 ip_rbTkWaitObjCmd(clientData, interp, objc, objv)
4462 ClientData clientData;
4465 Tcl_Obj *
CONST objv[];
4469 ClientData clientData;
4475 Tk_Window tkwin = (Tk_Window) clientData;
4478 static CONST char *optionStrings[] = {
"variable",
"visibility",
"window",
4480 enum options { TKWAIT_VARIABLE, TKWAIT_VISIBILITY, TKWAIT_WINDOW };
4485 DUMP1(
"Ruby's 'tkwait' is called");
4486 if (interp == (Tcl_Interp*)
NULL) {
4496 #if TCL_MAJOR_VERSION >= 8 4497 DUMP1(
"call ip_rb_threadTkWaitObjCmd");
4498 return ip_rb_threadTkWaitObjCmd((ClientData)tkwin, interp, objc, objv);
4500 DUMP1(
"call ip_rb_threadTkWaitCommand");
4501 return ip_rb_threadTkWwaitCommand((ClientData)tkwin, interp, objc, objv);
4506 Tcl_Preserve(interp);
4507 Tcl_ResetResult(interp);
4510 #ifdef Tcl_WrongNumArgs 4511 Tcl_WrongNumArgs(interp, 1, objv,
"variable|visibility|window name");
4516 #if TCL_MAJOR_VERSION >= 8 4517 Tcl_AppendResult(interp,
"wrong number of arguments: should be \"",
4518 Tcl_GetStringFromObj(objv[0], &dummy),
4519 " variable|visibility|window name\"",
4522 Tcl_AppendResult(interp,
"wrong number of arguments: should be \"",
4523 objv[0],
" variable|visibility|window name\"",
4530 Tcl_Release(interp);
4534 #if TCL_MAJOR_VERSION >= 8 4545 ret = Tcl_GetIndexFromObj(interp, objv[1],
4546 (
CONST84 char **)optionStrings,
4547 "option", 0, &index);
4551 if (ret != TCL_OK) {
4552 Tcl_Release(interp);
4558 size_t length =
strlen(objv[1]);
4560 if ((c ==
'v') && (strncmp(objv[1],
"variable", length) == 0)
4562 index = TKWAIT_VARIABLE;
4563 }
else if ((c ==
'v') && (strncmp(objv[1],
"visibility", length) == 0)
4565 index = TKWAIT_VISIBILITY;
4566 }
else if ((c ==
'w') && (strncmp(objv[1],
"window", length) == 0)) {
4567 index = TKWAIT_WINDOW;
4569 Tcl_AppendResult(interp,
"bad option \"", objv[1],
4570 "\": must be variable, visibility, or window",
4572 Tcl_Release(interp);
4581 #if TCL_MAJOR_VERSION >= 8 4584 nameString = Tcl_GetStringFromObj(objv[2], &dummy);
4586 nameString = objv[2];
4591 switch ((
enum options) index) {
4592 case TKWAIT_VARIABLE:
4602 ret = Tcl_TraceVar(interp, nameString,
4603 TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
4608 if (ret != TCL_OK) {
4609 #if TCL_MAJOR_VERSION >= 8 4612 Tcl_Release(interp);
4623 Tcl_UntraceVar(interp, nameString,
4624 TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
4627 #if TCL_MAJOR_VERSION >= 8 4635 Tcl_Release(interp);
4652 if (rb_trap_pending) {
4654 Tcl_Release(interp);
4661 case TKWAIT_VISIBILITY:
4669 window = Tk_NameToWindow(interp, nameString, tkwin);
4672 if (window ==
NULL) {
4673 Tcl_AppendResult(interp,
": tkwait: ",
4674 "no main-window (not Tk application?)",
4677 #if TCL_MAJOR_VERSION >= 8 4680 Tcl_Release(interp);
4684 Tk_CreateEventHandler(window,
4685 VisibilityChangeMask|StructureNotifyMask,
4696 #if TCL_MAJOR_VERSION >= 8 4699 Tcl_Release(interp);
4716 if (rb_trap_pending) {
4718 #if TCL_MAJOR_VERSION >= 8 4721 Tcl_Release(interp);
4734 Tcl_ResetResult(interp);
4735 Tcl_AppendResult(interp,
"window \"", nameString,
4736 "\" was deleted before its visibility changed",
4741 #if TCL_MAJOR_VERSION >= 8 4744 Tcl_Release(interp);
4751 #if TCL_MAJOR_VERSION >= 8 4755 Tk_DeleteEventHandler(window,
4756 VisibilityChangeMask|StructureNotifyMask,
4771 window = Tk_NameToWindow(interp, nameString, tkwin);
4774 #if TCL_MAJOR_VERSION >= 8 4778 if (window ==
NULL) {
4779 Tcl_AppendResult(interp,
": tkwait: ",
4780 "no main-window (not Tk application?)",
4783 Tcl_Release(interp);
4787 Tk_CreateEventHandler(window, StructureNotifyMask,
4798 Tcl_Release(interp);
4815 if (rb_trap_pending) {
4817 Tcl_Release(interp);
4834 Tcl_ResetResult(interp);
4835 Tcl_Release(interp);
4847 #if TCL_MAJOR_VERSION >= 8 4852 ClientData clientData;
4859 char *,
char *,
int));
4862 ClientData clientData;
4871 if (flags & (TCL_INTERP_DESTROYED | TCL_TRACE_DESTROYED)) {
4878 return (
char *)
NULL;
4881 #define TKWAIT_MODE_VISIBILITY 1 4882 #define TKWAIT_MODE_DESTROY 2 4887 ClientData clientData;
4892 if (eventPtr->type == VisibilityNotify) {
4895 if (eventPtr->type == DestroyNotify) {
4904 ClientData clientData;
4909 if (eventPtr->type == DestroyNotify) {
4915 #if TCL_MAJOR_VERSION >= 8 4917 ip_rb_threadVwaitObjCmd(clientData, interp, objc, objv)
4918 ClientData clientData;
4921 Tcl_Obj *
CONST objv[];
4925 ClientData clientData;
4938 DUMP1(
"Ruby's 'thread_vwait' is called");
4939 if (interp == (Tcl_Interp*)
NULL) {
4946 #if TCL_MAJOR_VERSION >= 8 4947 DUMP1(
"call ip_rbVwaitObjCmd");
4948 return ip_rbVwaitObjCmd(clientData, interp, objc, objv);
4950 DUMP1(
"call ip_rbVwaitCommand");
4955 Tcl_Preserve(interp);
4956 Tcl_ResetResult(interp);
4959 #ifdef Tcl_WrongNumArgs 4960 Tcl_WrongNumArgs(interp, 1, objv,
"name");
4965 #if TCL_MAJOR_VERSION >= 8 4967 nameString = Tcl_GetStringFromObj(objv[0], &dummy);
4969 nameString = objv[0];
4971 Tcl_AppendResult(interp,
"wrong number of arguments: should be \"",
4972 nameString,
" name\"", (
char *)
NULL);
4977 Tcl_Release(interp);
4981 #if TCL_MAJOR_VERSION >= 8 4984 nameString = Tcl_GetStringFromObj(objv[1], &dummy);
4986 nameString = objv[1];
4994 Tcl_Preserve((ClientData)param);
4996 param->thread = current_thread;
5006 ret = Tcl_TraceVar(interp, nameString,
5007 TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
5012 if (ret != TCL_OK) {
5014 Tcl_EventuallyFree((ClientData)param, TCL_DYNAMIC);
5017 Tcl_Release((ClientData)param);
5020 ckfree((
char *)param);
5024 #if TCL_MAJOR_VERSION >= 8 5027 Tcl_Release(interp);
5034 while(!param->done) {
5046 if (param->done > 0) {
5047 Tcl_UntraceVar(interp, nameString,
5048 TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
5053 Tcl_EventuallyFree((ClientData)param, TCL_DYNAMIC);
5056 Tcl_Release((ClientData)param);
5059 ckfree((
char *)param);
5065 #if TCL_MAJOR_VERSION >= 8 5068 Tcl_Release(interp);
5072 #if TCL_MAJOR_VERSION >= 8 5074 ip_rb_threadTkWaitObjCmd(clientData, interp, objc, objv)
5075 ClientData clientData;
5078 Tcl_Obj *
CONST objv[];
5082 ClientData clientData;
5089 Tk_Window tkwin = (Tk_Window) clientData;
5092 static CONST char *optionStrings[] = {
"variable",
"visibility",
"window",
5094 enum options { TKWAIT_VARIABLE, TKWAIT_VISIBILITY, TKWAIT_WINDOW };
5101 DUMP1(
"Ruby's 'thread_tkwait' is called");
5102 if (interp == (Tcl_Interp*)
NULL) {
5109 #if TCL_MAJOR_VERSION >= 8 5110 DUMP1(
"call ip_rbTkWaitObjCmd");
5112 DUMP2(
"current_thread %lx", current_thread);
5113 return ip_rbTkWaitObjCmd(clientData, interp, objc, objv);
5115 DUMP1(
"call rb_VwaitCommand");
5120 Tcl_Preserve(interp);
5121 Tcl_Preserve(tkwin);
5123 Tcl_ResetResult(interp);
5126 #ifdef Tcl_WrongNumArgs 5127 Tcl_WrongNumArgs(interp, 1, objv,
"variable|visibility|window name");
5132 #if TCL_MAJOR_VERSION >= 8 5133 Tcl_AppendResult(interp,
"wrong number of arguments: should be \"",
5134 Tcl_GetStringFromObj(objv[0], &dummy),
5135 " variable|visibility|window name\"",
5138 Tcl_AppendResult(interp,
"wrong number of arguments: should be \"",
5139 objv[0],
" variable|visibility|window name\"",
5147 Tcl_Release(interp);
5151 #if TCL_MAJOR_VERSION >= 8 5161 ret = Tcl_GetIndexFromObj(interp, objv[1],
5162 (
CONST84 char **)optionStrings,
5163 "option", 0, &index);
5167 if (ret != TCL_OK) {
5169 Tcl_Release(interp);
5175 size_t length =
strlen(objv[1]);
5177 if ((c ==
'v') && (strncmp(objv[1],
"variable", length) == 0)
5179 index = TKWAIT_VARIABLE;
5180 }
else if ((c ==
'v') && (strncmp(objv[1],
"visibility", length) == 0)
5182 index = TKWAIT_VISIBILITY;
5183 }
else if ((c ==
'w') && (strncmp(objv[1],
"window", length) == 0)) {
5184 index = TKWAIT_WINDOW;
5186 Tcl_AppendResult(interp,
"bad option \"", objv[1],
5187 "\": must be variable, visibility, or window",
5190 Tcl_Release(interp);
5199 #if TCL_MAJOR_VERSION >= 8 5202 nameString = Tcl_GetStringFromObj(objv[2], &dummy);
5204 nameString = objv[2];
5210 Tcl_Preserve((ClientData)param);
5212 param->thread = current_thread;
5217 switch ((
enum options) index) {
5218 case TKWAIT_VARIABLE:
5228 ret = Tcl_TraceVar(interp, nameString,
5229 TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
5234 if (ret != TCL_OK) {
5236 Tcl_EventuallyFree((ClientData)param, TCL_DYNAMIC);
5242 ckfree((
char *)param);
5246 #if TCL_MAJOR_VERSION >= 8 5251 Tcl_Release(interp);
5258 while(!param->done) {
5270 if (param->done > 0) {
5271 Tcl_UntraceVar(interp, nameString,
5272 TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
5276 #if TCL_MAJOR_VERSION >= 8 5284 case TKWAIT_VISIBILITY:
5292 window = Tk_NameToWindow(interp, nameString, tkwin);
5300 if (Tcl_GetCommandInfo(interp,
".", &info)) {
5301 window = Tk_NameToWindow(interp, nameString, tkwin);
5308 if (window ==
NULL) {
5309 Tcl_AppendResult(interp,
": thread_tkwait: ",
5310 "no main-window (not Tk application?)",
5316 Tcl_EventuallyFree((ClientData)param, TCL_DYNAMIC);
5322 ckfree((
char *)param);
5326 #if TCL_MAJOR_VERSION >= 8 5330 Tcl_Release(interp);
5333 Tcl_Preserve(window);
5335 Tk_CreateEventHandler(window,
5336 VisibilityChangeMask|StructureNotifyMask,
5359 Tk_DeleteEventHandler(window,
5360 VisibilityChangeMask|StructureNotifyMask,
5362 (ClientData) param);
5365 if (param->done != 1) {
5366 Tcl_ResetResult(interp);
5367 Tcl_AppendResult(interp,
"window \"", nameString,
5368 "\" was deleted before its visibility changed",
5373 Tcl_Release(window);
5376 Tcl_EventuallyFree((ClientData)param, TCL_DYNAMIC);
5382 ckfree((
char *)param);
5386 #if TCL_MAJOR_VERSION >= 8 5391 Tcl_Release(interp);
5395 Tcl_Release(window);
5397 #if TCL_MAJOR_VERSION >= 8 5413 window = Tk_NameToWindow(interp, nameString, tkwin);
5421 if (Tcl_GetCommandInfo(interp,
".", &info)) {
5422 window = Tk_NameToWindow(interp, nameString, tkwin);
5429 #if TCL_MAJOR_VERSION >= 8 5433 if (window ==
NULL) {
5434 Tcl_AppendResult(interp,
": thread_tkwait: ",
5435 "no main-window (not Tk application?)",
5441 Tcl_EventuallyFree((ClientData)param, TCL_DYNAMIC);
5447 ckfree((
char *)param);
5452 Tcl_Release(interp);
5456 Tcl_Preserve(window);
5458 Tk_CreateEventHandler(window, StructureNotifyMask,
5475 Tcl_Release(window);
5491 Tcl_EventuallyFree((ClientData)param, TCL_DYNAMIC);
5494 Tcl_Release((ClientData)param);
5497 ckfree((
char *)param);
5506 Tcl_ResetResult(interp);
5509 Tcl_Release(interp);
5545 #if TCL_MAJOR_VERSION >= 8 5552 Tcl_Obj *slave_list, *elem;
5556 DUMP1(
"delete slaves");
5560 if (!Tcl_InterpDeleted(ip) &&
Tcl_Eval(ip,
"interp slaves") == TCL_OK) {
5561 slave_list = Tcl_GetObjResult(ip);
5564 if (Tcl_ListObjLength((Tcl_Interp*)
NULL, slave_list, &len) == TCL_OK) {
5565 for(
i = 0;
i < len;
i++) {
5566 Tcl_ListObjIndex((Tcl_Interp*)
NULL, slave_list,
i, &elem);
5568 if (elem == (Tcl_Obj*)
NULL)
continue;
5574 slave_name = Tcl_GetStringFromObj(elem, (
int*)
NULL);
5575 DUMP2(
"delete slave:'%s'", slave_name);
5579 slave = Tcl_GetSlave(ip, slave_name);
5580 if (slave == (Tcl_Interp*)
NULL)
continue;
5582 if (!Tcl_InterpDeleted(slave)) {
5586 Tcl_DeleteInterp(slave);
5610 DUMP1(
"delete slaves");
5614 if (!Tcl_InterpDeleted(ip) &&
Tcl_Eval(ip,
"interp slaves") == TCL_OK) {
5615 slave_list = ip->result;
5616 if (Tcl_SplitList((Tcl_Interp*)
NULL,
5617 slave_list, &
argc, &
argv) == TCL_OK) {
5619 slave_name =
argv[
i];
5621 DUMP2(
"delete slave:'%s'", slave_name);
5623 slave = Tcl_GetSlave(ip, slave_name);
5624 if (slave == (Tcl_Interp*)
NULL)
continue;
5626 if (!Tcl_InterpDeleted(slave)) {
5630 Tcl_DeleteInterp(slave);
5643 #ifdef HAVE_PROTOTYPES 5654 #if TCL_MAJOR_VERSION >= 8 5655 #ifdef HAVE_PROTOTYPES 5656 ip_null_proc(ClientData clientData, Tcl_Interp *interp,
5660 ClientData clientData;
5666 #ifdef HAVE_PROTOTYPES 5670 ClientData clientData;
5677 Tcl_ResetResult(interp);
5688 VALUE rb_debug_bup, rb_verbose_bup;
5696 DUMP1(
"start ip_finalize");
5698 if (ip == (Tcl_Interp*)
NULL) {
5699 DUMP1(
"ip is NULL");
5703 if (Tcl_InterpDeleted(ip)) {
5704 DUMP2(
"ip(%p) is already deleted", ip);
5708 #if TCL_NAMESPACE_DEBUG 5709 if (ip_null_namespace(ip)) {
5710 DUMP2(
"ip(%p) has null namespace", ip);
5732 #if TCL_MAJOR_VERSION >= 8 5734 (ClientData)
NULL, (Tcl_CmdDeleteProc *)
NULL);
5736 (ClientData)
NULL, (Tcl_CmdDeleteProc *)
NULL);
5738 (ClientData)
NULL, (Tcl_CmdDeleteProc *)
NULL);
5741 (ClientData)
NULL, (Tcl_CmdDeleteProc *)
NULL);
5743 (ClientData)
NULL, (Tcl_CmdDeleteProc *)
NULL);
5745 (ClientData)
NULL, (Tcl_CmdDeleteProc *)
NULL);
5757 DUMP1(
"check `destroy'");
5758 if (Tcl_GetCommandInfo(ip,
"destroy", &info)) {
5759 DUMP1(
"call `destroy .'");
5764 DUMP1(
"destroy root widget");
5778 Tk_Window win = Tk_MainWindow(ip);
5780 DUMP1(
"call Tk_DestroyWindow");
5783 if (! (((Tk_FakeWin*)win)->flags & TK_ALREADY_DEAD)) {
5784 Tk_DestroyWindow(win);
5792 DUMP1(
"check `finalize-hook-proc'");
5802 DUMP1(
"check `foreach' & `after'");
5803 if ( Tcl_GetCommandInfo(ip,
"foreach", &info)
5804 && Tcl_GetCommandInfo(ip,
"after", &info) ) {
5805 DUMP1(
"cancel after callbacks");
5808 Tcl_GlobalEval(ip,
"catch {foreach id [after info] {after cancel $id}}");
5815 DUMP1(
"finish ip_finalize");
5829 DUMP2(
"free Tcl Interp %lx", (
unsigned long)ptr->
ip);
5834 if ( ptr->
ip != (Tcl_Interp*)
NULL 5835 && !Tcl_InterpDeleted(ptr->
ip)
5836 && Tcl_GetMaster(ptr->
ip) != (Tcl_Interp*)
NULL 5837 && !Tcl_InterpDeleted(Tcl_GetMaster(ptr->
ip)) ) {
5838 DUMP2(
"parent IP(%lx) is not deleted",
5839 (
unsigned long)Tcl_GetMaster(ptr->
ip));
5840 DUMP2(
"slave IP(%lx) should not be deleted",
5841 (
unsigned long)ptr->
ip);
5848 if (ptr->
ip == (Tcl_Interp*)
NULL) {
5849 DUMP1(
"ip_free is called for deleted IP");
5856 if (!Tcl_InterpDeleted(ptr->
ip)) {
5859 Tcl_DeleteInterp(ptr->
ip);
5860 Tcl_Release(ptr->
ip);
5863 ptr->
ip = (Tcl_Interp*)
NULL;
5870 DUMP1(
"complete freeing Tcl Interp");
5889 #if TCL_MAJOR_VERSION >= 8 5890 DUMP1(
"Tcl_CreateObjCommand(\"vwait\")");
5891 Tcl_CreateObjCommand(interp,
"vwait", ip_rbVwaitObjCmd,
5892 (ClientData)
NULL, (Tcl_CmdDeleteProc *)
NULL);
5894 DUMP1(
"Tcl_CreateCommand(\"vwait\")");
5896 (ClientData)
NULL, (Tcl_CmdDeleteProc *)
NULL);
5900 #if TCL_MAJOR_VERSION >= 8 5901 DUMP1(
"Tcl_CreateObjCommand(\"tkwait\")");
5902 Tcl_CreateObjCommand(interp,
"tkwait", ip_rbTkWaitObjCmd,
5903 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
5905 DUMP1(
"Tcl_CreateCommand(\"tkwait\")");
5907 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
5911 #if TCL_MAJOR_VERSION >= 8 5912 DUMP1(
"Tcl_CreateObjCommand(\"thread_vwait\")");
5913 Tcl_CreateObjCommand(interp,
"thread_vwait", ip_rb_threadVwaitObjCmd,
5914 (ClientData)
NULL, (Tcl_CmdDeleteProc *)
NULL);
5916 DUMP1(
"Tcl_CreateCommand(\"thread_vwait\")");
5918 (ClientData)
NULL, (Tcl_CmdDeleteProc *)
NULL);
5922 #if TCL_MAJOR_VERSION >= 8 5923 DUMP1(
"Tcl_CreateObjCommand(\"thread_tkwait\")");
5924 Tcl_CreateObjCommand(interp,
"thread_tkwait", ip_rb_threadTkWaitObjCmd,
5925 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
5927 DUMP1(
"Tcl_CreateCommand(\"thread_tkwait\")");
5929 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
5933 #if TCL_MAJOR_VERSION >= 8 5934 DUMP1(
"Tcl_CreateObjCommand(\"update\")");
5935 Tcl_CreateObjCommand(interp,
"update", ip_rbUpdateObjCmd,
5936 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
5938 DUMP1(
"Tcl_CreateCommand(\"update\")");
5940 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
5944 #if TCL_MAJOR_VERSION >= 8 5945 DUMP1(
"Tcl_CreateObjCommand(\"thread_update\")");
5946 Tcl_CreateObjCommand(interp,
"thread_update", ip_rb_threadUpdateObjCmd,
5947 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
5949 DUMP1(
"Tcl_CreateCommand(\"thread_update\")");
5951 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
5956 #if TCL_MAJOR_VERSION >= 8 5958 ip_rb_replaceSlaveTkCmdsObjCmd(clientData, interp, objc, objv)
5959 ClientData clientData;
5962 Tcl_Obj *
CONST objv[];
5966 ClientData clientData;
5977 #ifdef Tcl_WrongNumArgs 5978 Tcl_WrongNumArgs(interp, 1, objv,
"slave_name");
5981 #if TCL_MAJOR_VERSION >= 8 5982 nameString = Tcl_GetStringFromObj(objv[0], (
int*)
NULL);
5984 nameString = objv[0];
5986 Tcl_AppendResult(interp,
"wrong number of arguments: should be \"",
5987 nameString,
" slave_name\"", (
char *)
NULL);
5991 #if TCL_MAJOR_VERSION >= 8 5992 slave_name = Tcl_GetStringFromObj(objv[1], (
int*)
NULL);
5994 slave_name = objv[1];
5997 slave = Tcl_GetSlave(interp, slave_name);
5998 if (slave ==
NULL) {
5999 Tcl_AppendResult(interp,
"cannot find slave \"",
6000 slave_name,
"\"", (
char *)
NULL);
6003 mainWin = Tk_MainWindow(slave);
6006 #if TCL_MAJOR_VERSION >= 8 6007 DUMP1(
"Tcl_CreateObjCommand(\"exit\") --> \"interp_exit\"");
6008 Tcl_CreateObjCommand(slave,
"exit", ip_InterpExitObjCmd,
6009 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
6011 DUMP1(
"Tcl_CreateCommand(\"exit\") --> \"interp_exit\"");
6013 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
6023 #if TCL_MAJOR_VERSION >= 8 6024 static int ip_rbNamespaceObjCmd
_((ClientData, Tcl_Interp *,
int,
6025 Tcl_Obj *
CONST []));
6027 ip_rbNamespaceObjCmd(clientData, interp, objc, objv)
6028 ClientData clientData;
6031 Tcl_Obj *
CONST objv[];
6036 if (!Tcl_GetCommandInfo(interp,
"__orig_namespace_command__", &(info))) {
6037 Tcl_ResetResult(interp);
6038 Tcl_AppendResult(interp,
6039 "invalid command name \"namespace\"", (
char*)
NULL);
6046 if (info.isNativeObjectProc) {
6047 ret = (*(info.objProc))(info.objClientData, interp, objc, objv);
6056 Tcl_Preserve((ClientData)
argv);
6059 for(
i = 0;
i < objc;
i++) {
6061 argv[
i] = Tcl_GetStringFromObj(objv[
i], (
int*)
NULL);
6065 ret = (*(info.proc))(info.clientData, interp,
6069 Tcl_EventuallyFree((ClientData)
argv, TCL_DYNAMIC);
6072 Tcl_Release((ClientData)
argv);
6075 ckfree((
char*)
argv);
6091 #if TCL_MAJOR_VERSION >= 8 6092 Tcl_CmdInfo orig_info;
6094 if (!Tcl_GetCommandInfo(interp,
"namespace", &(orig_info))) {
6098 if (orig_info.isNativeObjectProc) {
6099 Tcl_CreateObjCommand(interp,
"__orig_namespace_command__",
6100 orig_info.objProc, orig_info.objClientData,
6101 orig_info.deleteProc);
6103 Tcl_CreateCommand(interp,
"__orig_namespace_command__",
6104 orig_info.proc, orig_info.clientData,
6105 orig_info.deleteProc);
6108 Tcl_CreateObjCommand(interp,
"namespace", ip_rbNamespaceObjCmd,
6109 (ClientData) 0, (Tcl_CmdDeleteProc *)
NULL);
6116 #ifdef HAVE_PROTOTYPES 6120 ClientData clientData;
6127 DUMP1(
"start ip_CallWhenDeleted");
6133 DUMP1(
"finish ip_CallWhenDeleted");
6151 Tk_Window mainWin = (Tk_Window)
NULL;
6156 "Cannot create a TclTkIp object at level %d",
6165 #ifdef RUBY_USE_NATIVE_THREAD 6166 ptr->tk_thread_id = 0;
6173 DUMP1(
"Tcl_CreateInterp");
6196 #if TCL_MAJOR_VERSION >= 8 6197 #if TCL_NAMESPACE_DEBUG 6198 DUMP1(
"get current namespace");
6199 if ((ptr->default_ns = Tcl_GetCurrentNamespace(ptr->
ip))
6200 == (Tcl_Namespace*)
NULL) {
6213 #if defined CREATE_RUBYTK_KIT || defined CREATE_RUBYKIT 6216 # if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION > 84 6218 Tcl_DString encodingName;
6219 Tcl_GetEncodingNameFromEnvironment(&encodingName);
6220 if (strcmp(Tcl_DStringValue(&encodingName), Tcl_GetEncodingName(
NULL))) {
6222 Tcl_SetSystemEncoding(
NULL, Tcl_DStringValue(&encodingName));
6224 Tcl_SetVar(
current_interp,
"tclkit_system_encoding", Tcl_DStringValue(&encodingName), 0);
6225 Tcl_DStringFree(&encodingName);
6231 Tcl_Eval(ptr->
ip,
"set argc 0; set argv {}; set argv0 tcltklib.so");
6243 Tcl_Eval(ptr->
ip,
"set argc [llength $argv]");
6247 if (!
NIL_P(argv0)) {
6250 Tcl_SetVar(ptr->
ip,
"argv0",
"ruby", TCL_GLOBAL_ONLY);
6264 #if (defined CREATE_RUBYTK_KIT || defined CREATE_RUBYKIT) && (!defined KIT_LITE) && (10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION == 85) 6271 Tcl_Eval(ptr->
ip,
"catch {rename ::chan ::_tmp_chan}");
6272 if (Tcl_Init(ptr->
ip) == TCL_ERROR) {
6275 Tcl_Eval(ptr->
ip,
"catch {rename ::_tmp_chan ::chan}");
6277 if (Tcl_Init(ptr->
ip) == TCL_ERROR) {
6302 DUMP1(
"Tcl_StaticPackage(\"Tk\")");
6303 #if TCL_MAJOR_VERSION >= 8 6304 Tcl_StaticPackage(ptr->
ip,
"Tk", Tk_Init, Tk_SafeInit);
6306 Tcl_StaticPackage(ptr->
ip,
"Tk", Tk_Init,
6307 (Tcl_PackageInitProc *)
NULL);
6310 #ifdef RUBY_USE_NATIVE_THREAD 6312 ptr->tk_thread_id = Tcl_GetCurrentThread();
6315 mainWin = Tk_MainWindow(ptr->
ip);
6316 Tk_Preserve((ClientData)mainWin);
6320 #if TCL_MAJOR_VERSION >= 8 6321 DUMP1(
"Tcl_CreateObjCommand(\"ruby\")");
6323 (Tcl_CmdDeleteProc *)
NULL);
6324 DUMP1(
"Tcl_CreateObjCommand(\"ruby_eval\")");
6326 (Tcl_CmdDeleteProc *)
NULL);
6327 DUMP1(
"Tcl_CreateObjCommand(\"ruby_cmd\")");
6329 (Tcl_CmdDeleteProc *)
NULL);
6331 DUMP1(
"Tcl_CreateCommand(\"ruby\")");
6333 (Tcl_CmdDeleteProc *)
NULL);
6334 DUMP1(
"Tcl_CreateCommand(\"ruby_eval\")");
6336 (Tcl_CmdDeleteProc *)
NULL);
6337 DUMP1(
"Tcl_CreateCommand(\"ruby_cmd\")");
6339 (Tcl_CmdDeleteProc *)
NULL);
6343 #if TCL_MAJOR_VERSION >= 8 6344 DUMP1(
"Tcl_CreateObjCommand(\"interp_exit\")");
6345 Tcl_CreateObjCommand(ptr->
ip,
"interp_exit", ip_InterpExitObjCmd,
6346 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
6347 DUMP1(
"Tcl_CreateObjCommand(\"ruby_exit\")");
6348 Tcl_CreateObjCommand(ptr->
ip,
"ruby_exit", ip_RubyExitObjCmd,
6349 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
6350 DUMP1(
"Tcl_CreateObjCommand(\"exit\") --> \"ruby_exit\"");
6351 Tcl_CreateObjCommand(ptr->
ip,
"exit", ip_RubyExitObjCmd,
6352 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
6354 DUMP1(
"Tcl_CreateCommand(\"interp_exit\")");
6356 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
6357 DUMP1(
"Tcl_CreateCommand(\"ruby_exit\")");
6359 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
6360 DUMP1(
"Tcl_CreateCommand(\"exit\") --> \"ruby_exit\"");
6362 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
6372 #if TCL_MAJOR_VERSION >= 8 6373 Tcl_CreateObjCommand(ptr->
ip,
"__replace_slave_tk_commands__",
6374 ip_rb_replaceSlaveTkCmdsObjCmd,
6375 (ClientData)
NULL, (Tcl_CmdDeleteProc *)
NULL);
6377 Tcl_CreateCommand(ptr->
ip,
"__replace_slave_tk_commands__",
6379 (ClientData)
NULL, (Tcl_CmdDeleteProc *)
NULL);
6385 if (mainWin != (Tk_Window)
NULL) {
6386 Tk_Release((ClientData)mainWin);
6410 "deleted master cannot create a new slave");
6416 if (Tcl_IsSafe(master->
ip) == 1) {
6418 }
else if (safemode ==
Qfalse ||
NIL_P(safemode)) {
6430 if (
RTEST(with_tk)) {
6443 #ifdef RUBY_USE_NATIVE_THREAD 6445 slave->tk_thread_id = master->tk_thread_id;
6455 "fail to create the new slave interpreter");
6457 #if TCL_MAJOR_VERSION >= 8 6458 #if TCL_NAMESPACE_DEBUG 6459 slave->default_ns = Tcl_GetCurrentNamespace(slave->
ip);
6469 #if TCL_MAJOR_VERSION >= 8 6470 DUMP1(
"Tcl_CreateObjCommand(\"exit\") --> \"interp_exit\"");
6471 Tcl_CreateObjCommand(slave->
ip,
"exit", ip_InterpExitObjCmd,
6472 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
6474 DUMP1(
"Tcl_CreateCommand(\"exit\") --> \"interp_exit\"");
6476 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
6486 #if TCL_MAJOR_VERSION >= 8 6487 Tcl_CreateObjCommand(slave->
ip,
"__replace_slave_tk_commands__",
6488 ip_rb_replaceSlaveTkCmdsObjCmd,
6489 (ClientData)
NULL, (Tcl_CmdDeleteProc *)
NULL);
6491 Tcl_CreateCommand(slave->
ip,
"__replace_slave_tk_commands__",
6493 (ClientData)
NULL, (Tcl_CmdDeleteProc *)
NULL);
6518 "deleted master cannot create a new slave interpreter");
6525 if (Tcl_IsSafe(master->
ip) != 1
6532 callargv[1] = safemode;
6556 #if defined(MAC_TCL) || defined(__WIN32__) 6557 #if TCL_MAJOR_VERSION < 8 \ 6558 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0) \ 6559 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 1 \ 6560 && (TCL_RELEASE_LEVEL == TCL_ALPHA_RELEASE \ 6561 || (TCL_RELEASE_LEVEL == TCL_BETA_RELEASE \ 6562 && TCL_RELEASE_SERIAL < 2) ) ) 6563 EXTERN void TkConsoleCreate
_((
void));
6565 #if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 1 \ 6566 && ( (TCL_RELEASE_LEVEL == TCL_FINAL_RELEASE \ 6567 && TCL_RELEASE_SERIAL == 0) \ 6568 || (TCL_RELEASE_LEVEL == TCL_BETA_RELEASE \ 6569 && TCL_RELEASE_SERIAL >= 2) ) 6570 EXTERN void TkConsoleCreate_
_((
void));
6585 if (Tcl_GetVar(ptr->
ip,
"tcl_interactive",TCL_GLOBAL_ONLY) == (
char*)
NULL) {
6586 Tcl_SetVar(ptr->
ip,
"tcl_interactive",
"0", TCL_GLOBAL_ONLY);
6589 #if TCL_MAJOR_VERSION > 8 \ 6590 || (TCL_MAJOR_VERSION == 8 \ 6591 && (TCL_MINOR_VERSION > 1 \ 6592 || (TCL_MINOR_VERSION == 1 \ 6593 && TCL_RELEASE_LEVEL == TCL_FINAL_RELEASE \ 6594 && TCL_RELEASE_SERIAL >= 1) ) ) 6595 Tk_InitConsoleChannels(ptr->
ip);
6597 if (Tk_CreateConsoleWindow(ptr->
ip) != TCL_OK) {
6601 #if defined(MAC_TCL) || defined(__WIN32__) 6602 #if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 1 \ 6603 && ( (TCL_RELEASE_LEVEL == TCL_FINAL_RELEASE && TCL_RELEASE_SERIAL == 0) \ 6604 || (TCL_RELEASE_LEVEL == TCL_BETA_RELEASE && TCL_RELEASE_SERIAL >= 2) ) 6610 if (TkConsoleInit(ptr->
ip) != TCL_OK) {
6650 if (Tcl_MakeSafe(ptr->
ip) == TCL_ERROR) {
6661 #if TCL_MAJOR_VERSION >= 8 6662 DUMP1(
"Tcl_CreateObjCommand(\"exit\") --> \"interp_exit\"");
6663 Tcl_CreateObjCommand(ptr->
ip,
"exit", ip_InterpExitObjCmd,
6664 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
6666 DUMP1(
"Tcl_CreateCommand(\"exit\") --> \"interp_exit\"");
6668 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
6700 if (Tcl_IsSafe(ptr->
ip)) {
6741 if (Tcl_IsSafe(ptr->
ip)) {
6743 "insecure operation on a safe interpreter");
6756 #if TCL_MAJOR_VERSION >= 8 6757 DUMP1(
"Tcl_CreateObjCommand(\"exit\") --> \"ruby_exit\"");
6758 Tcl_CreateObjCommand(ptr->
ip,
"exit", ip_RubyExitObjCmd,
6759 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
6761 DUMP1(
"Tcl_CreateCommand(\"exit\") --> \"ruby_exit\"");
6763 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
6769 #if TCL_MAJOR_VERSION >= 8 6770 DUMP1(
"Tcl_CreateObjCommand(\"exit\") --> \"interp_exit\"");
6771 Tcl_CreateObjCommand(ptr->
ip,
"exit", ip_InterpExitObjCmd,
6772 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
6774 DUMP1(
"Tcl_CreateCommand(\"exit\") --> \"interp_exit\"");
6776 (ClientData)mainWin, (Tcl_CmdDeleteProc *)
NULL);
6792 DUMP1(
"delete deleted IP");
6799 DUMP1(
"delete interp");
6800 if (!Tcl_InterpDeleted(ptr->
ip)) {
6801 DUMP1(
"call ip_finalize");
6804 Tcl_DeleteInterp(ptr->
ip);
6805 Tcl_Release(ptr->
ip);
6826 #if TCL_NAMESPACE_DEBUG 6827 if (rbtk_invalid_namespace(ptr)) {
6860 }
else if (Tk_MainWindow(ptr->
ip) == (Tk_Window)
NULL) {
6876 #if TCL_MAJOR_VERSION >= 8 6878 get_str_from_obj(obj)
6881 int len, binary = 0;
6885 #if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 6886 s = Tcl_GetStringFromObj(obj, &len);
6888 #if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION <= 3 6890 if (Tcl_GetCharLength(obj) != Tcl_UniCharLen(Tcl_GetUnicode(obj))) {
6892 s = (
char *)Tcl_GetByteArrayFromObj(obj, &len);
6896 s = Tcl_GetStringFromObj(obj, &len);
6899 if (IS_TCL_BYTEARRAY(obj)) {
6900 s = (
char *)Tcl_GetByteArrayFromObj(obj, &len);
6903 s = Tcl_GetStringFromObj(obj, &len);
6910 #ifdef HAVE_RUBY_ENCODING_H 6914 #if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 1) 6916 #ifdef HAVE_RUBY_ENCODING_H 6926 get_obj_from_str(str)
6931 #if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 6932 return Tcl_NewStringObj((
char*)s,
RSTRING_LEN(str));
6940 return Tcl_NewByteArrayObj((
const unsigned char *)s,
RSTRING_LENINT(str));
6945 #ifdef HAVE_RUBY_ENCODING_H 6948 return Tcl_NewByteArrayObj((
const unsigned char *)s,
RSTRING_LENINT(str));
6952 return Tcl_NewByteArrayObj((
const unsigned char *)s,
RSTRING_LENINT(str));
6965 #if TCL_MAJOR_VERSION >= 8 6967 volatile VALUE strval;
6969 retObj = Tcl_GetObjResult(interp);
6971 strval = get_str_from_obj(retObj);
6973 Tcl_ResetResult(interp);
7003 volatile VALUE q_dat;
7007 DUMP2(
"do_call_queue_handler : evPtr = %p", evPtr);
7009 DUMP2(
"added by thread : %lx", thread);
7012 DUMP1(
"processed by another event-loop");
7015 DUMP1(
"process it on current event-loop");
7025 DUMP1(
"caller is not yet ready to receive the result -> pending");
7051 DUMP2(
"call function (for caller thread:%lx)", thread);
7078 DUMP2(
"back to caller (caller thread:%lx)", thread);
7080 #if CONTROL_BY_STATUS_OF_RB_THREAD_WAITING_FOR_VALUE 7086 DUMP1(
"finish back to caller");
7087 #if DO_THREAD_SCHEDULE_AT_CALLBACK_DONE 7091 DUMP2(
"caller is dead (caller thread:%lx)", thread);
7110 int is_tk_evloop_thread;
7112 volatile VALUE ip_obj = obj;
7124 #ifdef RUBY_USE_NATIVE_THREAD 7127 is_tk_evloop_thread = (ptr->tk_thread_id == (Tcl_ThreadId) 0
7128 || ptr->tk_thread_id == Tcl_GetCurrentThread());
7131 is_tk_evloop_thread = (tk_eventloop_thread_id == (Tcl_ThreadId) 0
7132 || tk_eventloop_thread_id == Tcl_GetCurrentThread());
7135 is_tk_evloop_thread = 1;
7138 if (is_tk_evloop_thread
7142 DUMP2(
"tk_funcall from thread:%lx but no eventloop", current);
7144 DUMP2(
"tk_funcall from current eventloop %lx", current);
7153 DUMP2(
"tk_funcall from thread %lx (NOT current eventloop)", current);
7163 Tcl_Preserve((ClientData)temp);
7173 Tcl_Preserve((ClientData)alloc_done);
7181 Tcl_Preserve(callq);
7188 callq->
done = alloc_done;
7199 DUMP1(
"add handler");
7200 #ifdef RUBY_USE_NATIVE_THREAD 7201 if (ptr && ptr->tk_thread_id) {
7204 Tcl_ThreadQueueEvent(ptr->tk_thread_id,
7205 (Tcl_Event*)callq, TCL_QUEUE_HEAD);
7206 Tcl_ThreadAlert(ptr->tk_thread_id);
7207 }
else if (tk_eventloop_thread_id) {
7210 Tcl_ThreadQueueEvent(tk_eventloop_thread_id,
7211 (Tcl_Event*)callq, TCL_QUEUE_HEAD);
7212 Tcl_ThreadAlert(tk_eventloop_thread_id);
7215 Tcl_QueueEvent((Tcl_Event*)callq, TCL_QUEUE_HEAD);
7219 Tcl_QueueEvent((Tcl_Event*)callq, TCL_QUEUE_HEAD);
7228 DUMP2(
"callq wait for handler (current thread:%lx)", current);
7229 while(*alloc_done >= 0) {
7230 DUMP2(
"*** callq wait for handler (current thread:%lx)", current);
7234 DUMP2(
"*** callq wakeup (current thread:%lx)", current);
7237 DUMP1(
"*** callq lost eventloop thread");
7241 DUMP2(
"back from handler (current thread:%lx)", current);
7246 Tcl_EventuallyFree((ClientData)alloc_done, TCL_DYNAMIC);
7249 Tcl_Release((ClientData)alloc_done);
7252 ckfree((
char*)alloc_done);
7262 Tcl_EventuallyFree((ClientData)
argv, TCL_DYNAMIC);
7265 Tcl_Release((ClientData)
argv);
7267 ckfree((
char*)
argv);
7276 ckfree((
char*)callq);
7282 DUMP1(
"raise exception");
7288 DUMP1(
"exit tk_funcall");
7294 #if TCL_MAJOR_VERSION >= 8 7295 struct call_eval_info {
7301 #ifdef HAVE_PROTOTYPES 7302 call_tcl_eval(
VALUE arg)
7308 struct call_eval_info *
inf = (
struct call_eval_info *)arg;
7310 Tcl_AllowExceptions(
inf->ptr->ip);
7311 inf->ptr->return_value = Tcl_EvalObj(
inf->ptr->ip,
inf->cmd);
7327 #if TCL_MAJOR_VERSION >= 8 7335 cmd = Tcl_NewStringObj(cmd_str, cmd_len);
7346 struct call_eval_info
inf;
7362 "unknown exception");
7395 "ip_eval_real receives TCL_RETURN");
7398 "ip_eval_real receives TCL_BREAK");
7401 "ip_eval_real receives TCL_CONTINUE");
7416 Tcl_ResetResult(ptr->
ip);
7430 DUMP2(
"Tcl_Eval(%s)", cmd_str);
7455 "ip_eval_real receives TCL_RETURN");
7458 "ip_eval_real receives TCL_BREAK");
7461 "ip_eval_real receives TCL_CONTINUE");
7499 volatile VALUE q_dat;
7503 DUMP2(
"do_eval_queue_handler : evPtr = %p", evPtr);
7505 DUMP2(
"added by thread : %lx", thread);
7508 DUMP1(
"processed by another event-loop");
7511 DUMP1(
"process it on current event-loop");
7521 DUMP1(
"caller is not yet ready to receive the result -> pending");
7540 #ifdef HAVE_NATIVETHREAD 7541 #ifndef RUBY_USE_NATIVE_THREAD 7543 rb_bug(
"cross-thread violation on eval_queue_handler()");
7578 DUMP2(
"back to caller (caller thread:%lx)", thread);
7580 #if CONTROL_BY_STATUS_OF_RB_THREAD_WAITING_FOR_VALUE 7586 DUMP1(
"finish back to caller");
7587 #if DO_THREAD_SCHEDULE_AT_CALLBACK_DONE 7591 DUMP2(
"caller is dead (caller thread:%lx)", thread);
7605 #ifdef RUBY_USE_NATIVE_THREAD 7612 volatile VALUE ip_obj =
self;
7615 Tcl_QueuePosition position;
7623 #ifdef RUBY_USE_NATIVE_THREAD 7625 DUMP2(
"eval status: ptr->tk_thread_id %p", ptr->tk_thread_id);
7626 DUMP2(
"eval status: Tcl_GetCurrentThread %p", Tcl_GetCurrentThread());
7628 DUMP2(
"status: Tcl_GetCurrentThread %p", Tcl_GetCurrentThread());
7633 #ifdef RUBY_USE_NATIVE_THREAD
7634 (ptr->tk_thread_id == 0 || ptr->tk_thread_id == Tcl_GetCurrentThread())
7640 DUMP2(
"eval from thread:%lx but no eventloop", current);
7642 DUMP2(
"eval from current eventloop %lx", current);
7651 DUMP2(
"eval from thread %lx (NOT current eventloop)", current);
7660 Tcl_Preserve((ClientData)alloc_done);
7667 Tcl_Preserve((ClientData)eval_str);
7683 evq->
done = alloc_done;
7684 evq->
str = eval_str;
7692 position = TCL_QUEUE_TAIL;
7695 DUMP1(
"add handler");
7696 #ifdef RUBY_USE_NATIVE_THREAD 7697 if (ptr->tk_thread_id) {
7699 Tcl_ThreadQueueEvent(ptr->tk_thread_id, (Tcl_Event*)evq, position);
7700 Tcl_ThreadAlert(ptr->tk_thread_id);
7701 }
else if (tk_eventloop_thread_id) {
7702 Tcl_ThreadQueueEvent(tk_eventloop_thread_id, (Tcl_Event*)evq, position);
7705 Tcl_ThreadAlert(tk_eventloop_thread_id);
7708 Tcl_QueueEvent((Tcl_Event*)evq, position);
7712 Tcl_QueueEvent((Tcl_Event*)evq, position);
7721 DUMP2(
"evq wait for handler (current thread:%lx)", current);
7722 while(*alloc_done >= 0) {
7723 DUMP2(
"*** evq wait for handler (current thread:%lx)", current);
7727 DUMP2(
"*** evq wakeup (current thread:%lx)", current);
7730 DUMP1(
"*** evq lost eventloop thread");
7734 DUMP2(
"back from handler (current thread:%lx)", current);
7740 Tcl_EventuallyFree((ClientData)alloc_done, TCL_DYNAMIC);
7743 Tcl_Release((ClientData)alloc_done);
7746 ckfree((
char*)alloc_done);
7750 Tcl_EventuallyFree((ClientData)eval_str, TCL_DYNAMIC);
7753 Tcl_Release((ClientData)eval_str);
7768 DUMP1(
"raise exception");
7784 #if TCL_MAJOR_VERSION < 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION < 6) 7786 "cancel_eval is supported Tcl/Tk8.6 or later.");
7799 return Tcl_CancelEval(interp, msg_obj, 0, flag);
7821 #ifndef TCL_CANCEL_UNWIND 7822 #define TCL_CANCEL_UNWIND 0x100000 7875 Tcl_ResetResult(ptr->
ip);
7877 #if TCL_MAJOR_VERSION >= 8 7882 Tcl_ResetResult(ptr->
ip);
7889 Tcl_ResetResult(ptr->
ip);
7942 if (Tcl_GetMaster(ptr->
ip) != (Tcl_Interp*)
NULL) {
7955 volatile VALUE str = src;
7959 Tcl_Encoding encoding;
7974 if (
NIL_P(ip_obj)) {
7975 interp = (Tcl_Interp *)
NULL;
7981 interp = (Tcl_Interp *)
NULL;
7990 if (
NIL_P(encodename)) {
7994 #ifdef HAVE_RUBY_ENCODING_H 8000 if (
NIL_P(ip_obj)) {
8001 encoding = (Tcl_Encoding)
NULL;
8005 encoding = (Tcl_Encoding)
NULL;
8011 encoding = (Tcl_Encoding)
NULL;
8013 encoding = Tcl_GetEncoding((Tcl_Interp*)
NULL,
8015 if (encoding == (Tcl_Encoding)
NULL) {
8024 #ifdef HAVE_RUBY_ENCODING_H 8032 encoding = Tcl_GetEncoding((Tcl_Interp*)
NULL,
8034 if (encoding == (Tcl_Encoding)
NULL) {
8039 encoding = (Tcl_Encoding)
NULL;
8043 if (strcmp(
RSTRING_PTR(encodename),
"binary") == 0) {
8044 #ifdef HAVE_RUBY_ENCODING_H 8052 encoding = Tcl_GetEncoding((Tcl_Interp*)
NULL,
RSTRING_PTR(encodename));
8053 if (encoding == (Tcl_Encoding)
NULL) {
8073 Tcl_DStringInit(&dstr);
8074 Tcl_DStringFree(&dstr);
8080 str =
rb_str_new(Tcl_DStringValue(&dstr), Tcl_DStringLength(&dstr));
8081 #ifdef HAVE_RUBY_ENCODING_H 8092 Tcl_DStringFree(&dstr);
8109 VALUE str, encodename;
8123 VALUE str, encodename;
8137 volatile VALUE str = src;
8141 Tcl_Encoding encoding;
8155 if (
NIL_P(ip_obj)) {
8156 interp = (Tcl_Interp *)
NULL;
8158 interp = (Tcl_Interp *)
NULL;
8166 if (
NIL_P(encodename)) {
8174 #ifdef HAVE_RUBY_ENCODING_H 8181 #ifdef HAVE_RUBY_ENCODING_H 8191 if (
NIL_P(ip_obj)) {
8192 encoding = (Tcl_Encoding)
NULL;
8196 encoding = (Tcl_Encoding)
NULL;
8202 encoding = (Tcl_Encoding)
NULL;
8204 encoding = Tcl_GetEncoding((Tcl_Interp*)
NULL,
8206 if (encoding == (Tcl_Encoding)
NULL) {
8218 if (strcmp(
RSTRING_PTR(encodename),
"binary") == 0) {
8226 s = (
char*)Tcl_GetByteArrayFromObj(tclstr, &len);
8230 #ifdef HAVE_RUBY_ENCODING_H 8240 encoding = Tcl_GetEncoding((Tcl_Interp*)
NULL,
RSTRING_PTR(encodename));
8241 if (encoding == (Tcl_Encoding)
NULL) {
8264 Tcl_DStringInit(&dstr);
8265 Tcl_DStringFree(&dstr);
8271 str =
rb_str_new(Tcl_DStringValue(&dstr), Tcl_DStringLength(&dstr));
8272 #ifdef HAVE_RUBY_ENCODING_H 8294 Tcl_DStringFree(&dstr);
8311 VALUE str, encodename;
8325 VALUE str, encodename;
8340 char *src_buf, *dst_buf, *ptr;
8341 int read_len = 0, dst_len = 0;
8358 Tcl_Preserve((ClientData)src_buf);
8366 Tcl_Preserve((ClientData)dst_buf);
8371 if (*ptr ==
'\\' && (all_bs || *(ptr + 1) ==
'u')) {
8372 dst_len += Tcl_UtfBackslash(ptr, &read_len, (dst_buf + dst_len));
8375 *(dst_buf + (dst_len++)) = *(ptr++);
8381 #ifdef HAVE_RUBY_ENCODING_H 8387 Tcl_EventuallyFree((ClientData)src_buf, TCL_DYNAMIC);
8390 Tcl_Release((ClientData)src_buf);
8397 Tcl_EventuallyFree((ClientData)dst_buf, TCL_DYNAMIC);
8400 Tcl_Release((ClientData)dst_buf);
8433 #if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION > 0) 8446 #if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION > 0) 8450 Tcl_SetSystemEncoding((Tcl_Interp *)
NULL, (
CONST char *)
NULL);
8455 if (Tcl_SetSystemEncoding((Tcl_Interp *)
NULL,
8472 #if TCL_MAJOR_VERSION >= 8 8482 #ifdef HAVE_PROTOTYPES 8491 #if TCL_MAJOR_VERSION >= 8 8497 #if TCL_MAJOR_VERSION >= 8 8498 if (!
inf->cmdinfo.isNativeObjectProc) {
8503 Tcl_Preserve((ClientData)
argv);
8506 argv[
i] = Tcl_GetStringFromObj(
inf->objv[
i], &len);
8512 Tcl_ResetResult(
inf->ptr->ip);
8515 #if TCL_MAJOR_VERSION >= 8 8516 if (
inf->cmdinfo.isNativeObjectProc) {
8517 inf->ptr->return_value
8518 = (*(
inf->cmdinfo.objProc))(
inf->cmdinfo.objClientData,
8524 #if TCL_MAJOR_VERSION >= 8 8525 inf->ptr->return_value
8526 = (*(
inf->cmdinfo.proc))(
inf->cmdinfo.clientData,
inf->ptr->ip,
8530 Tcl_EventuallyFree((ClientData)
argv, TCL_DYNAMIC);
8533 Tcl_Release((ClientData)
argv);
8536 ckfree((
char*)
argv);
8541 inf->ptr->return_value
8542 = (*(
inf->cmdinfo.proc))(
inf->cmdinfo.clientData,
inf->ptr->ip,
8551 #if TCL_MAJOR_VERSION >= 8 8570 int unknown_flag = 0;
8577 #if TCL_MAJOR_VERSION >= 8 8588 #if TCL_MAJOR_VERSION >= 8 8589 cmd = Tcl_GetStringFromObj(objv[0], &len);
8606 DUMP2(
"call Tcl_GetCommandInfo, %s", cmd);
8607 if (!Tcl_GetCommandInfo(
ptr->
ip, cmd, &info)) {
8608 DUMP1(
"error Tcl_GetCommandInfo");
8609 DUMP1(
"try auto_load (call 'unknown' command)");
8610 if (!Tcl_GetCommandInfo(
ptr->
ip,
8611 #
if TCL_MAJOR_VERSION >= 8
8617 DUMP1(
"fail to get 'unknown' command");
8624 "invalid command name `%s'", cmd);
8627 rb_warning(
"invalid command name `%s' (ignore)", cmd);
8629 rb_warn(
"invalid command name `%s' (ignore)", cmd);
8631 Tcl_ResetResult(
ptr->
ip);
8637 #if TCL_MAJOR_VERSION >= 8 8638 Tcl_Obj **unknown_objv;
8640 char **unknown_argv;
8642 DUMP1(
"find 'unknown' command -> set arguemnts");
8645 #if TCL_MAJOR_VERSION >= 8 8649 Tcl_Preserve((ClientData)unknown_objv);
8651 unknown_objv[0] = Tcl_NewStringObj(
"::unknown", 9);
8653 memcpy(unknown_objv + 1, objv,
sizeof(Tcl_Obj *)*objc);
8654 unknown_objv[++objc] = (Tcl_Obj*)
NULL;
8655 objv = unknown_objv;
8660 Tcl_Preserve((ClientData)unknown_argv);
8662 unknown_argv[0] =
strdup(
"unknown");
8663 memcpy(unknown_argv + 1,
argv,
sizeof(
char *)*
argc);
8664 unknown_argv[++
argc] = (
char *)
NULL;
8665 argv = unknown_argv;
8669 DUMP1(
"end Tcl_GetCommandInfo");
8678 #if TCL_MAJOR_VERSION >= 8 8692 "unknown exception");
8709 #if TCL_MAJOR_VERSION >= 8 8710 if (!info.isNativeObjectProc) {
8717 Tcl_Preserve((ClientData)
argv);
8720 argv[
i] = Tcl_GetStringFromObj(objv[
i], &len);
8726 Tcl_ResetResult(
ptr->
ip);
8729 #if TCL_MAJOR_VERSION >= 8 8730 if (info.isNativeObjectProc) {
8735 resultPtr = Tcl_GetObjResult(
ptr->
ip);
8736 Tcl_SetResult(
ptr->
ip, Tcl_GetStringFromObj(resultPtr, &len),
8743 #if TCL_MAJOR_VERSION >= 8 8748 Tcl_EventuallyFree((ClientData)
argv, TCL_DYNAMIC);
8751 Tcl_Release((ClientData)
argv);
8754 ckfree((
char*)
argv);
8767 #if TCL_MAJOR_VERSION >= 8 8770 Tcl_EventuallyFree((ClientData)objv, TCL_DYNAMIC);
8773 Tcl_Release((ClientData)objv);
8776 ckfree((
char*)objv);
8783 Tcl_EventuallyFree((ClientData)
argv, TCL_DYNAMIC);
8786 Tcl_Release((ClientData)
argv);
8789 ckfree((
char*)
argv);
8808 "ip_invoke_core receives TCL_RETURN");
8811 "ip_invoke_core receives TCL_BREAK");
8814 "ip_invoke_core receives TCL_CONTINUE");
8826 Tcl_ResetResult(
ptr->
ip);
8836 #if TCL_MAJOR_VERSION >= 8 8848 #if TCL_MAJOR_VERSION >= 8 8858 #if TCL_MAJOR_VERSION >= 8 8862 Tcl_Preserve((ClientData)av);
8865 av[
i] = get_obj_from_str(
argv[
i]);
8875 Tcl_Preserve((ClientData)av);
8891 #if TCL_MAJOR_VERSION >= 8 8900 #if TCL_MAJOR_VERSION >= 8 8902 av[
i] = (Tcl_Obj*)
NULL;
8905 av[
i] = (
char*)
NULL;
8908 #if TCL_MAJOR_VERSION >= 8 8910 Tcl_EventuallyFree((ClientData)av, TCL_DYNAMIC);
8913 Tcl_Release((ClientData)av);
8920 Tcl_EventuallyFree((ClientData)av, TCL_DYNAMIC);
8923 Tcl_Release((ClientData)av);
8941 #if TCL_MAJOR_VERSION >= 8 8942 Tcl_Obj **av = (Tcl_Obj **)
NULL;
8944 char **av = (
char **)
NULL;
8961 Tcl_ResetResult(ptr->
ip);
8991 volatile VALUE q_dat;
8995 DUMP2(
"do_invoke_queue_handler : evPtr = %p", evPtr);
8997 DUMP2(
"added by thread : %lx", thread);
9000 DUMP1(
"processed by another event-loop");
9003 DUMP1(
"process it on current event-loop");
9013 DUMP1(
"caller is not yet ready to receive the result -> pending");
9039 DUMP2(
"call invoke_real (for caller thread:%lx)", thread);
9065 DUMP2(
"back to caller (caller thread:%lx)", thread);
9067 #if CONTROL_BY_STATUS_OF_RB_THREAD_WAITING_FOR_VALUE 9073 DUMP1(
"finish back to caller");
9074 #if DO_THREAD_SCHEDULE_AT_CALLBACK_DONE 9078 DUMP2(
"caller is dead (caller thread:%lx)", thread);
9091 Tcl_QueuePosition position;
9094 #ifdef RUBY_USE_NATIVE_THREAD 9100 volatile VALUE ip_obj = obj;
9105 #if TCL_MAJOR_VERSION >= 8 9106 Tcl_Obj **av = (Tcl_Obj **)
NULL;
9108 char **av = (
char **)
NULL;
9115 #ifdef RUBY_USE_NATIVE_THREAD 9117 DUMP2(
"invoke status: ptr->tk_thread_id %p", ptr->tk_thread_id);
9118 DUMP2(
"invoke status: Tcl_GetCurrentThread %p", Tcl_GetCurrentThread());
9120 DUMP2(
"status: Tcl_GetCurrentThread %p", Tcl_GetCurrentThread());
9125 #ifdef RUBY_USE_NATIVE_THREAD
9126 (ptr->tk_thread_id == 0 || ptr->tk_thread_id == Tcl_GetCurrentThread())
9132 DUMP2(
"invoke from thread:%lx but no eventloop", current);
9134 DUMP2(
"invoke from current eventloop %lx", current);
9143 DUMP2(
"invoke from thread %lx (NOT current eventloop)", current);
9155 Tcl_Preserve((ClientData)alloc_done);
9163 Tcl_Preserve((ClientData)ivq);
9170 ivq->done = alloc_done;
9173 ivq->interp = ip_obj;
9175 ivq->thread = current;
9180 DUMP1(
"add handler");
9181 #ifdef RUBY_USE_NATIVE_THREAD 9182 if (ptr->tk_thread_id) {
9184 Tcl_ThreadQueueEvent(ptr->tk_thread_id, (Tcl_Event*)ivq, position);
9185 Tcl_ThreadAlert(ptr->tk_thread_id);
9186 }
else if (tk_eventloop_thread_id) {
9189 Tcl_ThreadQueueEvent(tk_eventloop_thread_id,
9190 (Tcl_Event*)ivq, position);
9191 Tcl_ThreadAlert(tk_eventloop_thread_id);
9194 Tcl_QueueEvent((Tcl_Event*)ivq, position);
9198 Tcl_QueueEvent((Tcl_Event*)ivq, position);
9207 DUMP2(
"ivq wait for handler (current thread:%lx)", current);
9208 while(*alloc_done >= 0) {
9212 DUMP2(
"*** ivq wakeup (current thread:%lx)", current);
9215 DUMP1(
"*** ivq lost eventloop thread");
9219 DUMP2(
"back from handler (current thread:%lx)", current);
9224 Tcl_EventuallyFree((ClientData)alloc_done, TCL_DYNAMIC);
9227 Tcl_Release((ClientData)alloc_done);
9230 ckfree((
char*)alloc_done);
9236 Tcl_EventuallyFree((ClientData)ivq, TCL_DYNAMIC);
9251 DUMP1(
"raise exception");
9257 DUMP1(
"exit ip_invoke");
9310 volatile VALUE varname, index, flag;
9321 #if TCL_MAJOR_VERSION >= 8 9324 volatile VALUE strval;
9341 if (ret == (Tcl_Obj*)
NULL) {
9354 strval = get_str_from_obj(ret);
9366 volatile VALUE strval;
9379 if (ret == (
char*)
NULL) {
9417 if (
NIL_P(retval)) {
9441 volatile VALUE varname, index, value, flag;
9454 #if TCL_MAJOR_VERSION >= 8 9456 Tcl_Obj *valobj, *ret;
9457 volatile VALUE strval;
9462 valobj = get_obj_from_str(value);
9480 if (ret == (Tcl_Obj*)
NULL) {
9493 strval = get_str_from_obj(ret);
9506 volatile VALUE strval;
9519 if (ret == (
char*)
NULL) {
9556 if (
NIL_P(retval)) {
9580 volatile VALUE varname, index, flag;
9601 if (
FIX2INT(flag) & TCL_LEAVE_ERR_MSG) {
9631 if (
NIL_P(retval)) {
9653 INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
9663 INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
9673 INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
9684 INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
9693 INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
9703 INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
9714 volatile VALUE ary, elem;
9717 #ifdef HAVE_RUBY_ENCODING_H 9719 volatile VALUE list_ivar_enc;
9726 if (
NIL_P(ip_obj)) {
9727 interp = (Tcl_Interp *)
NULL;
9729 interp = (Tcl_Interp *)
NULL;
9735 #ifdef HAVE_RUBY_ENCODING_H 9741 #if TCL_MAJOR_VERSION >= 8 9748 listobj = get_obj_from_str(list_str);
9752 result = Tcl_ListObjGetElements(interp, listobj, &objc, &objv);
9754 if (
result == TCL_ERROR) {
9756 if (interp == (Tcl_Interp*)
NULL) {
9763 for(idx = 0; idx < objc; idx++) {
9775 for(idx = 0; idx < objc; idx++) {
9776 elem = get_str_from_obj(objv[idx]);
9779 #ifdef HAVE_RUBY_ENCODING_H 9798 for(idx = 0; idx < objc; idx++) {
9811 if (interp == (Tcl_Interp*)
NULL) {
9823 for(idx = 0; idx <
argc; idx++) {
9885 Tcl_Preserve((ClientData)flagPtr);
9890 for(num = 0; num <
argc; num++) {
9893 #if TCL_MAJOR_VERSION >= 8 9897 len += Tcl_ScanElement(dst, &flagPtr[num]) + 1;
9903 result = (
char *)ckalloc(len);
9905 Tcl_Preserve((ClientData)
result);
9908 for(num = 0; num <
argc; num++) {
9909 #if TCL_MAJOR_VERSION >= 8 9927 Tcl_EventuallyFree((ClientData)flagPtr, TCL_DYNAMIC);
9930 Tcl_Release((ClientData)flagPtr);
9933 ckfree((
char*)flagPtr);
9941 Tcl_EventuallyFree((ClientData)
result, TCL_DYNAMIC);
9944 Tcl_Release((ClientData)
result);
9974 #if TCL_MAJOR_VERSION >= 8 9981 len = Tcl_ScanElement(
RSTRING_PTR(src), &scan_flag);
10030 volatile VALUE ret;
10032 static CONST char form[]
10033 =
"tcltklib %s :: Ruby%s (%s) %s pthread :: Tcl%s(%s)/Tk%s(%s) %s";
10041 +
strlen(TCL_PATCH_LEVEL)
10042 +
strlen(
"without stub")
10043 +
strlen(TK_PATCH_LEVEL)
10044 +
strlen(
"without stub")
10045 +
strlen(
"unknown tcl_threads");
10050 sprintf(info, form,
10059 #ifdef USE_TCL_STUBS
10065 #ifdef USE_TK_STUBS
10070 #ifdef WITH_TCL_ENABLE_THREAD
10071 #
if WITH_TCL_ENABLE_THREAD
10074 "without tcl_threads" 10077 "unknown tcl_threads" 10104 #if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 1) 10106 if (
RTEST(error_mode)) {
10115 #ifdef HAVE_RUBY_ENCODING_H 10120 if (
RTEST(error_mode)) {
10142 #ifdef HAVE_RUBY_ENCODING_H 10158 if (
NIL_P(interp))
return 0;
10164 Tcl_GetEncodingNames(ptr->
ip);
10168 if (Tcl_ListObjGetElements(ptr->
ip,
enc_list,
10169 &objc, &objv) != TCL_OK) {
10176 for(
i = 0;
i < objc;
i++) {
10214 if (!
NIL_P(interp)) {
10223 if (ptr &&
NIL_P(enc)) {
10301 if (
RTEST(error_mode)) {
10325 #if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 1) 10340 if (
NIL_P(interp))
return 0;
10346 Tcl_GetEncodingNames(ptr->
ip);
10350 if (Tcl_ListObjGetElements(ptr->
ip,
enc_list, &objc, &objv) != TCL_OK) {
10357 for(
i = 0;
i < objc;
i++) {
10400 if (
RTEST(error_mode)) {
10449 #ifdef HAVE_RUBY_ENCODING_H 10463 #ifdef HAVE_RB_SET_SAFE_LEVEL_FORCE 10479 Tcl_GetEncodingNames(ptr->
ip);
10483 if (Tcl_ListObjGetElements(ptr->
ip,
enc_list, &objc, &objv) != TCL_OK) {
10489 for(
i = 0;
i < objc;
i++) {
10490 int name2obj, obj2name;
10492 name2obj = 1; obj2name = 1;
10497 if (strcmp(
RSTRING_PTR(encname),
"identity") == 0) {
10498 name2obj = 1; obj2name = 0;
10501 }
else if (strcmp(
RSTRING_PTR(encname),
"shiftjis") == 0) {
10502 name2obj = 1; obj2name = 0;
10505 }
else if (strcmp(
RSTRING_PTR(encname),
"unicode") == 0) {
10506 name2obj = 1; obj2name = 0;
10509 }
else if (strcmp(
RSTRING_PTR(encname),
"symbol") == 0) {
10510 name2obj = 1; obj2name = 0;
10515 name2obj = 1; obj2name = 1;
10545 #if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 1) 10564 Tcl_GetEncodingNames(ptr->
ip);
10568 if (Tcl_ListObjGetElements(ptr->
ip,
enc_list, &objc, &objv) != TCL_OK) {
10574 for(
i = 0;
i < objc;
i++) {
10617 if (
NIL_P(table)) {
10634 #if TCL_MAJOR_VERSION >= 8 10636 #define MASTER_MENU 0 10637 #define TEAROFF_MENU 1 10640 struct dummy_TkMenuEntry {
10642 struct dummy_TkMenu *menuPtr;
10646 struct dummy_TkMenu {
10649 Tcl_Interp *interp;
10650 Tcl_Command widgetCmd;
10651 struct dummy_TkMenuEntry **entries;
10655 Tcl_Obj *menuTypePtr;
10659 struct dummy_TkMenuRef {
10660 struct dummy_TkMenu *menuPtr;
10667 EXTERN struct dummy_TkMenuRef *TkFindMenuReferences(Tcl_Interp*,
char*);
10669 #define MENU_HASH_KEY "tkMenus" 10680 #if TCL_MAJOR_VERSION >= 8 10681 volatile VALUE menu_path;
10683 struct dummy_TkMenuRef *menuRefPtr =
NULL;
10685 Tcl_HashTable *menuTablePtr;
10686 Tcl_HashEntry *hashEntryPtr;
10688 menu_path =
argv[0];
10692 menuRefPtr = TkFindMenuReferences(ptr->
ip,
RSTRING_PTR(menu_path));
10695 = (Tcl_HashTable *) Tcl_GetAssocData(ptr->
ip, MENU_HASH_KEY,
NULL))
10698 = Tcl_FindHashEntry(menuTablePtr,
RSTRING_PTR(menu_path)))
10700 menuRefPtr = (
struct dummy_TkMenuRef *) Tcl_GetHashValue(hashEntryPtr);
10705 if (menuRefPtr == (
struct dummy_TkMenuRef *)
NULL) {
10709 if (menuRefPtr->menuPtr == (
struct dummy_TkMenu *)
NULL) {
10711 "invalid menu widget (maybe already destroyed)");
10714 if ((menuRefPtr->menuPtr)->menuType != MENUBAR) {
10716 "target menu widget must be a MENUBAR type");
10719 (menuRefPtr->menuPtr)->menuType = TEAROFF_MENU;
10723 char *s =
"normal";
10725 (menuRefPtr->menuPtr)->menuTypePtr = Tcl_NewStringObj(s,
strlen(s));
10728 (menuRefPtr->menuPtr)->menuType = MASTER_MENU;
10733 TkEventuallyRecomputeMenu(menuRefPtr->menuPtr);
10734 TkEventuallyRedrawMenu(menuRefPtr->menuPtr,
10735 (
struct dummy_TkMenuEntry *)
NULL);
10737 memset((
void *) &event, 0,
sizeof(event));
10738 event.xany.type = ConfigureNotify;
10739 event.xany.serial = NextRequest(Tk_Display((menuRefPtr->menuPtr)->tkwin));
10740 event.xany.send_event = 0;
10741 event.xany.window = Tk_WindowId((menuRefPtr->menuPtr)->tkwin);
10742 event.xany.display = Tk_Display((menuRefPtr->menuPtr)->tkwin);
10743 event.xconfigure.window =
event.xany.window;
10744 Tk_HandleEvent(&event);
10761 argv[0] = menu_path;
10787 #ifdef HAVE_RUBY_ENCODING_H 10826 # define TK_WINDOWING_SYSTEM "win32" 10829 # define TK_WINDOWING_SYSTEM "classic" 10832 # define TK_WINDOWING_SYSTEM "aqua" 10834 # define TK_WINDOWING_SYSTEM "x11" 10855 #ifdef TCL_NAMESPACE_ONLY 10863 #ifdef TCL_PARSE_PART1 11054 #ifndef DEFAULT_EVENTLOOP_DEPTH 11055 #define DEFAULT_EVENTLOOP_DEPTH 7 11066 #ifdef HAVE_NATIVETHREAD 11092 #if defined CREATE_RUBYTK_KIT || defined CREATE_RUBYKIT 11101 Tcl_ObjType_ByteArray = Tcl_GetObjType(Tcl_ObjTypeName_ByteArray);
11102 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)
int rb_thread_check_trap_pending()
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)
#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_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)
VALUE rb_tainted_str_new2(const char *)
static VALUE ip_unset_global_var2(VALUE self, VALUE varname, VALUE index)
VALUE rb_ary_new3(long n,...)
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 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)
static VALUE rb_thread_alive_p(VALUE thread)
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)
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)
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)
VALUE rb_iv_set(VALUE, const char *, VALUE)
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)
VALUE rb_exc_new2(VALUE etype, const char *s)
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)
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)
VALUE rb_exc_new3(VALUE etype, VALUE str)
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)
VALUE rb_ary_new2(long capa)
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)
static struct @62 tcltk_version
#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)
VALUE rb_hash_aset(VALUE, VALUE, VALUE)
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)
VALUE rb_str_new2(const char *)
void rb_warn(const char *fmt,...)
static VALUE lib_get_reltype_name(VALUE self)
#define EVLOOP_WAKEUP_CHANCE
static int ENCODING_INDEX_UTF8
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)