| 1 |
|
| /* |
| 2 |
|
| * Tcl.xs -- |
| 3 |
|
| * |
| 4 |
|
| * This file contains XS code for the Perl's Tcl bridge module. |
| 5 |
|
| * |
| 6 |
|
| * Copyright (c) 1994-1997, Malcolm Beattie |
| 7 |
|
| * Copyright (c) 2003-2004, Vadim Konovalov |
| 8 |
|
| * Copyright (c) 2004 ActiveState Corp., a division of Sophos PLC |
| 9 |
|
| * |
| 10 |
|
| */ |
| 11 |
|
| |
| 12 |
|
| #define PERL_NO_GET_CONTEXT /* we want efficiency */ |
| 13 |
|
| #include "EXTERN.h" |
| 14 |
|
| #include "perl.h" |
| 15 |
|
| #include "XSUB.h" |
| 16 |
|
| |
| 17 |
|
| #ifndef DEBUG_REFCOUNTS |
| 18 |
|
| #define DEBUG_REFCOUNTS 0 |
| 19 |
|
| #endif |
| 20 |
|
| |
| 21 |
|
| /* |
| 22 |
|
| * Until we update for 8.4 CONST-ness |
| 23 |
|
| */ |
| 24 |
|
| #define USE_NON_CONST |
| 25 |
|
| |
| 26 |
|
| /* |
| 27 |
|
| * Both Perl and Tcl use these macros |
| 28 |
|
| */ |
| 29 |
|
| #undef STRINGIFY |
| 30 |
|
| #undef JOIN |
| 31 |
|
| |
| 32 |
|
| #include <tcl.h> |
| 33 |
|
| |
| 34 |
|
| #ifdef USE_TCL_STUBS |
| 35 |
|
| /* |
| 36 |
|
| * If we use the Tcl stubs mechanism, this provides us Tcl version |
| 37 |
|
| * and direct dll independence, but we must force the loading of |
| 38 |
|
| * the dll ourselves based on a set of heuristics in NpLoadLibrary. |
| 39 |
|
| */ |
| 40 |
|
| |
| 41 |
|
| #ifndef TCL_LIB_FILE |
| 42 |
|
| # ifdef WIN32 |
| 43 |
|
| # define TCL_LIB_FILE "tcl84.dll" |
| 44 |
|
| # elif defined(__APPLE__) |
| 45 |
|
| # define TCL_LIB_FILE "Tcl" |
| 46 |
|
| # elif defined(__hpux) |
| 47 |
|
| # define TCL_LIB_FILE "libtcl8.4.sl" |
| 48 |
|
| # else |
| 49 |
|
| # define TCL_LIB_FILE "libtcl8.4.so" |
| 50 |
|
| # endif |
| 51 |
|
| #endif |
| 52 |
|
| |
| 53 |
|
| /* |
| 54 |
|
| * Default directory in which to look for Tcl/Tk libraries. The |
| 55 |
|
| * symbol is defined by Makefile. |
| 56 |
|
| */ |
| 57 |
|
| |
| 58 |
|
| #ifndef LIB_RUNTIME_DIR |
| 59 |
|
| # define LIB_RUNTIME_DIR "." |
| 60 |
|
| #endif |
| 61 |
|
| static char defaultLibraryDir[sizeof(LIB_RUNTIME_DIR)+200] = LIB_RUNTIME_DIR; |
| 62 |
|
| |
| 63 |
|
| #if defined(WIN32) |
| 64 |
|
| |
| 65 |
|
| #ifndef HMODULE |
| 66 |
|
| #define HMODULE void * |
| 67 |
|
| #endif |
| 68 |
|
| #define WIN32_LEAN_AND_MEAN |
| 69 |
|
| #include <windows.h> |
| 70 |
|
| #undef WIN32_LEAN_AND_MEAN |
| 71 |
|
| #define dlopen(libname, flags) LoadLibrary(libname) |
| 72 |
|
| #define dlclose(path) ((void *) FreeLibrary((HMODULE) path)) |
| 73 |
|
| #define DLSYM(handle, symbol, type, proc) \ |
| 74 |
|
| (proc = (type) GetProcAddress((HINSTANCE) handle, symbol)) |
| 75 |
|
| #define snprintf _snprintf |
| 76 |
|
| |
| 77 |
|
| #elif defined(__APPLE__) |
| 78 |
|
| |
| 79 |
|
| #include <CoreServices/CoreServices.h> |
| 80 |
|
| |
| 81 |
|
| static short DOMAINS[] = { |
| 82 |
|
| kUserDomain, |
| 83 |
|
| kLocalDomain, |
| 84 |
|
| kNetworkDomain, |
| 85 |
|
| kSystemDomain |
| 86 |
|
| }; |
| 87 |
|
| static const int DOMAINS_LEN = sizeof(DOMAINS)/sizeof(DOMAINS[0]); |
| 88 |
|
| |
| 89 |
|
| #elif defined(__hpux) |
| 90 |
|
| /* HPUX requires shl_* routines */ |
| 91 |
|
| #include <dl.h> |
| 92 |
|
| #define HMODULE shl_t |
| 93 |
|
| #define dlopen(libname, flags) shl_load(libname, \ |
| 94 |
|
| BIND_DEFERRED|BIND_VERBOSE|DYNAMIC_PATH, 0L) |
| 95 |
|
| #define dlclose(path) shl_unload((shl_t) path) |
| 96 |
|
| #define DLSYM(handle, symbol, type, proc) \ |
| 97 |
|
| if (shl_findsym(&handle, symbol, (short) TYPE_PROCEDURE, \ |
| 98 |
|
| (void *) &proc) != 0) { proc = NULL; } |
| 99 |
|
| #endif |
| 100 |
|
| |
| 101 |
|
| #ifndef HMODULE |
| 102 |
|
| #include <dlfcn.h> |
| 103 |
|
| #define HMODULE void * |
| 104 |
|
| #define DLSYM(handle, symbol, type, proc) \ |
| 105 |
|
| (proc = (type) dlsym(handle, symbol)) |
| 106 |
|
| #endif |
| 107 |
|
| |
| 108 |
|
| #ifndef MAX_PATH |
| 109 |
|
| #define MAX_PATH 1024 |
| 110 |
|
| #endif |
| 111 |
|
| |
| 112 |
|
| /* |
| 113 |
|
| * Tcl library handle |
| 114 |
|
| */ |
| 115 |
|
| static HMODULE tclHandle = NULL; |
| 116 |
|
| |
| 117 |
|
| static Tcl_Interp *g_Interp = NULL; |
| 118 |
|
| static int (* tclKit_AppInit)(Tcl_Interp *) = NULL; |
| 119 |
|
| |
| 120 |
|
| #else |
| 121 |
|
| |
| 122 |
|
| /* |
| 123 |
|
| * !USE_TCL_STUBS |
| 124 |
|
| */ |
| 125 |
|
| |
| 126 |
|
| static int (* tclKit_AppInit)(Tcl_Interp *) = Tcl_Init; |
| 127 |
|
| |
| 128 |
|
| #if defined(HAVE_TKINIT) && defined(WIN32) |
| 129 |
|
| HANDLE _hinst = 0; |
| 130 |
|
| BOOL APIENTRY |
| 131 |
|
| DllMain(HINSTANCE hInst, DWORD reason, LPVOID reserved) { |
| 132 |
|
| _hinst = hInst; |
| 133 |
|
| return TRUE; |
| 134 |
|
| } |
| 135 |
|
| #endif |
| 136 |
|
| |
| 137 |
|
| #endif |
| 138 |
|
| |
| 139 |
|
| typedef Tcl_Interp *Tcl; |
| 140 |
|
| typedef AV *Tcl__Var; |
| 141 |
|
| |
| 142 |
|
| #ifdef HAVE_TKINIT |
| 143 |
|
| EXTERN char * TclSetPreInitScript (char * string); |
| 144 |
|
| void TclpInitLibraryPath(char **valuePtr, int *lengthPtr, Tcl_Encoding *encodingPtr); |
| 145 |
|
| EXTERN void TkWinSetHINSTANCE (HINSTANCE hInstance); |
| 146 |
|
| #endif |
| 147 |
|
| |
| 148 |
|
| #ifdef HAVE_BLTINIT |
| 149 |
|
| extern Tcl_PackageInitProc Blt_Init, Blt_SafeInit; |
| 150 |
|
| #endif |
| 151 |
|
| |
| 152 |
|
| /* |
| 153 |
|
| * Variables denoting the Tcl object types defined in the core. |
| 154 |
|
| * These may not exist - guard against NULL result. |
| 155 |
|
| */ |
| 156 |
|
| |
| 157 |
|
| static Tcl_ObjType *tclBooleanTypePtr = NULL; |
| 158 |
|
| static Tcl_ObjType *tclByteArrayTypePtr = NULL; |
| 159 |
|
| static Tcl_ObjType *tclDoubleTypePtr = NULL; |
| 160 |
|
| static Tcl_ObjType *tclIntTypePtr = NULL; |
| 161 |
|
| static Tcl_ObjType *tclListTypePtr = NULL; |
| 162 |
|
| static Tcl_ObjType *tclStringTypePtr = NULL; |
| 163 |
|
| static Tcl_ObjType *tclWideIntTypePtr = NULL; |
| 164 |
|
| |
| 165 |
|
| /* |
| 166 |
|
| * This tells us whether Tcl is in a "callable" state. Set to 1 in BOOT |
| 167 |
|
| * and 0 in Tcl__Finalize (END). Once finalized, we should not make any |
| 168 |
|
| * more calls to Tcl_* APIs. |
| 169 |
|
| * hvInterps is a hash that records all live interps, so that we can |
| 170 |
|
| * force their deletion before the finalization. |
| 171 |
|
| */ |
| 172 |
|
| static int initialized = 0; |
| 173 |
|
| static HV *hvInterps = NULL; |
| 174 |
|
| |
| 175 |
|
| /* |
| 176 |
|
| * FUNCTIONS |
| 177 |
|
| */ |
| 178 |
|
| |
| 179 |
|
| #ifdef USE_TCL_STUBS |
| 180 |
|
| /* |
| 181 |
|
| *---------------------------------------------------------------------- |
| 182 |
|
| * |
| 183 |
|
| * NpLoadLibrary -- |
| 184 |
|
| * |
| 185 |
|
| * |
| 186 |
|
| * Results: |
| 187 |
|
| * Stores the handle of the library found in tclHandle and the |
| 188 |
|
| * name it successfully loaded from in dllFilename (if dllFilenameSize |
| 189 |
|
| is != 0). |
| 190 |
|
| * |
| 191 |
|
| * Side effects: |
| 192 |
|
| * Loads the library - user needs to dlclose it.. |
| 193 |
|
| * |
| 194 |
|
| *---------------------------------------------------------------------- |
| 195 |
|
| */ |
| 196 |
|
| |
| 197 |
|
| static int |
| 198 |
12 |
| NpLoadLibrary(pTHX_ HMODULE *tclHandle, char *dllFilename, int dllFilenameSize) |
| 199 |
|
| { |
| 200 |
|
| char *dl_path, libname[MAX_PATH]; |
| 201 |
12 |
| HMODULE handle = (HMODULE) NULL; |
| 202 |
|
| |
| 203 |
|
| /* |
| 204 |
|
| * Try a user-supplied Tcl dll to start with. |
| 205 |
|
| * If the var is supplied, force this to be correct or error out. |
| 206 |
|
| */ |
| 207 |
12 |
| dl_path = SvPV_nolen(get_sv("Tcl::DL_PATH", TRUE)); |
| 208 |
12 |
▶ | if (dl_path && *dl_path) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (dl_path && *dl_path) { |
12 |
0 |
12 |
| if (dl_path && *dl_path) { |
0 |
12 |
12 |
|
| 209 |
0 |
| handle = dlopen(dl_path, RTLD_NOW | RTLD_GLOBAL); |
| 210 |
0 |
▶ | if (handle) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (handle) { |
0 |
0 |
0 |
|
| 211 |
0 |
| memcpy(libname, dl_path, MAX_PATH); |
| 212 |
|
| } else { |
| 213 |
|
| #if !defined(WIN32) && !defined(__hpux) |
| 214 |
0 |
| char *error = dlerror(); |
| 215 |
0 |
▶ | if (error != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (error != NULL) { |
0 |
0 |
0 |
|
| 216 |
0 |
| warn("%s",error); |
| 217 |
|
| } |
| 218 |
|
| #endif |
| 219 |
0 |
| warn("NpLoadLibrary: could not find Tcl library at '%s'", dl_path); |
| 220 |
0 |
| return TCL_ERROR; |
| 221 |
|
| } |
| 222 |
|
| } |
| 223 |
|
| |
| 224 |
|
| #ifdef __APPLE__ |
| 225 |
|
| if (!handle) { |
| 226 |
|
| OSErr oserr; |
| 227 |
|
| FSRef ref; |
| 228 |
|
| int i; |
| 229 |
|
| |
| 230 |
|
| for (i = 0; i < DOMAINS_LEN; i++) { |
| 231 |
|
| oserr = FSFindFolder(DOMAINS[i], kFrameworksFolderType, |
| 232 |
|
| kDontCreateFolder, &ref); |
| 233 |
|
| if (oserr != noErr) { |
| 234 |
|
| continue; |
| 235 |
|
| } |
| 236 |
|
| oserr = FSRefMakePath(&ref, (UInt8*)libname, sizeof(libname)); |
| 237 |
|
| if (oserr != noErr) { |
| 238 |
|
| continue; |
| 239 |
|
| } |
| 240 |
|
| /* |
| 241 |
|
| * This should really just try loading Tcl.framework/Tcl, but will |
| 242 |
|
| * fail if the user has requested an alternate TCL_LIB_FILE. |
| 243 |
|
| */ |
| 244 |
|
| strcat(libname, "/Tcl.framework/" TCL_LIB_FILE); |
| 245 |
|
| /* printf("Try \"%s\"\n", libname); */ |
| 246 |
|
| handle = dlopen(libname, RTLD_NOW | RTLD_GLOBAL); |
| 247 |
|
| if (handle) { |
| 248 |
|
| break; |
| 249 |
|
| } |
| 250 |
|
| } |
| 251 |
|
| } |
| 252 |
|
| #endif |
| 253 |
|
| |
| 254 |
12 |
▶ | if (!handle) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!handle) { |
12 |
0 |
12 |
|
| 255 |
|
| if (strlen(TCL_LIB_FILE) < 3) { |
| 256 |
|
| warn("Invalid base Tcl library filename provided: '%s'", TCL_LIB_FILE); |
| 257 |
|
| return TCL_ERROR; |
| 258 |
|
| } |
| 259 |
|
| |
| 260 |
|
| /* Try based on full path. */ |
| 261 |
12 |
| snprintf(libname, MAX_PATH-1, "%s/%s", defaultLibraryDir, TCL_LIB_FILE); |
| 262 |
12 |
| handle = dlopen(libname, RTLD_NOW | RTLD_GLOBAL); |
| 263 |
12 |
▶ | if (!handle) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!handle) { |
12 |
0 |
12 |
|
| 264 |
|
| /* Try based on anywhere in the path. */ |
| 265 |
12 |
| strcpy(libname, TCL_LIB_FILE); |
| 266 |
12 |
| handle = dlopen(libname, RTLD_NOW | RTLD_GLOBAL); |
| 267 |
|
| } |
| 268 |
12 |
▶ | if (!handle) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!handle) { |
12 |
0 |
12 |
|
| 269 |
|
| /* Try different versions anywhere in the path. */ |
| 270 |
12 |
| char *pos = strstr(libname, "tcl8")+4; |
| 271 |
12 |
▶ | if (*pos == '.') { |
Branch: 1 branch
| Branch | True | False | Total |
| if (*pos == '.') { |
12 |
0 |
12 |
|
| 272 |
12 |
| pos++; |
| 273 |
|
| } |
| 274 |
12 |
| *pos = '9'; /* count down from '8' to '4', and then to '0', it is also ok*/ |
| 275 |
120 |
▶ | while (!handle && (--*pos >= '0')) { |
Branch: 2 branches
| Branch | True | False | Total |
| while (!handle && (--*pos >= '0')) { |
120 |
0 |
120 |
| while (!handle && (--*pos >= '0')) { |
108 |
12 |
120 |
|
| 276 |
108 |
| handle = dlopen(libname, RTLD_NOW | RTLD_GLOBAL); |
| 277 |
|
| } |
| 278 |
12 |
▶ | if (!handle) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!handle) { |
12 |
0 |
12 |
|
| 279 |
12 |
| warn("failed all posible tcl vers 8.x from 9 down to 0"); |
| 280 |
12 |
| return TCL_ERROR; |
| 281 |
|
| } |
| 282 |
|
| } |
| 283 |
|
| } |
| 284 |
|
| |
| 285 |
|
| #ifdef WIN32 |
| 286 |
|
| if (!handle) { |
| 287 |
|
| char path[MAX_PATH], vers[MAX_PATH]; |
| 288 |
|
| DWORD result, size = MAX_PATH; |
| 289 |
|
| HKEY regKey; |
| 290 |
|
| #define TCL_REG_DIR_KEY "Software\\ActiveState\\ActiveTcl" |
| 291 |
|
| |
| 292 |
|
| result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, TCL_REG_DIR_KEY, 0, |
| 293 |
|
| KEY_READ, ®Key); |
| 294 |
|
| if (result != ERROR_SUCCESS) { |
| 295 |
|
| warn("Could not access registry \"HKLM\\%s\"\n", TCL_REG_DIR_KEY); |
| 296 |
|
| |
| 297 |
|
| result = RegOpenKeyEx(HKEY_CURRENT_USER, TCL_REG_DIR_KEY, 0, |
| 298 |
|
| KEY_READ, ®Key); |
| 299 |
|
| if (result != ERROR_SUCCESS) { |
| 300 |
|
| warn("Could not access registry \"HKCU\\%s\"\n", |
| 301 |
|
| TCL_REG_DIR_KEY); |
| 302 |
|
| return TCL_ERROR; |
| 303 |
|
| } |
| 304 |
|
| } |
| 305 |
|
| |
| 306 |
|
| result = RegQueryValueEx(regKey, "CurrentVersion", NULL, NULL, |
| 307 |
|
| vers, &size); |
| 308 |
|
| RegCloseKey(regKey); |
| 309 |
|
| if (result != ERROR_SUCCESS) { |
| 310 |
|
| warn("Could not access registry \"%s\" CurrentVersion\n", |
| 311 |
|
| TCL_REG_DIR_KEY); |
| 312 |
|
| return TCL_ERROR; |
| 313 |
|
| } |
| 314 |
|
| |
| 315 |
|
| snprintf(path, MAX_PATH-1, "%s\\%s", TCL_REG_DIR_KEY, vers); |
| 316 |
|
| |
| 317 |
|
| result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, path, 0, KEY_READ, ®Key); |
| 318 |
|
| if (result != ERROR_SUCCESS) { |
| 319 |
|
| warn("Could not access registry \"%s\"\n", path); |
| 320 |
|
| return TCL_ERROR; |
| 321 |
|
| } |
| 322 |
|
| |
| 323 |
|
| size = MAX_PATH; |
| 324 |
|
| result = RegQueryValueEx(regKey, NULL, NULL, NULL, path, &size); |
| 325 |
|
| RegCloseKey(regKey); |
| 326 |
|
| if (result != ERROR_SUCCESS) { |
| 327 |
|
| warn("Could not access registry \"%s\" Default\n", TCL_REG_DIR_KEY); |
| 328 |
|
| return TCL_ERROR; |
| 329 |
|
| } |
| 330 |
|
| |
| 331 |
|
| warn("Found current Tcl installation at \"%s\"\n", path); |
| 332 |
|
| |
| 333 |
|
| snprintf(libname, MAX_PATH-1, "%s\\bin\\%s", path, TCL_LIB_FILE); |
| 334 |
|
| handle = dlopen(libname, RTLD_NOW | RTLD_GLOBAL); |
| 335 |
|
| } |
| 336 |
|
| #endif |
| 337 |
|
| |
| 338 |
0 |
▶ | if (!handle) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!handle) { |
0 |
0 |
0 |
|
| 339 |
0 |
| warn("NpLoadLibrary: could not find Tcl dll\n"); |
| 340 |
0 |
| return TCL_ERROR; |
| 341 |
|
| } |
| 342 |
0 |
| *tclHandle = handle; |
| 343 |
0 |
▶ | if (dllFilenameSize > 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (dllFilenameSize > 0) { |
0 |
0 |
0 |
|
| 344 |
0 |
| memcpy(dllFilename, libname, dllFilenameSize); |
| 345 |
|
| } |
| 346 |
0 |
| return TCL_OK; |
| 347 |
|
| } |
| 348 |
|
| |
| 349 |
|
| /* |
| 350 |
|
| *---------------------------------------------------------------------- |
| 351 |
|
| * |
| 352 |
|
| * NpInitialize -- |
| 353 |
|
| * |
| 354 |
|
| * Create the main interpreter. |
| 355 |
|
| * |
| 356 |
|
| * Results: |
| 357 |
|
| * TCL_OK or TCL_ERROR - whether succeeded or not |
| 358 |
|
| * |
| 359 |
|
| * Side effects: |
| 360 |
|
| * Will panic if called twice. (Must call DestroyMainInterp in between) |
| 361 |
|
| * |
| 362 |
|
| *---------------------------------------------------------------------- |
| 363 |
|
| */ |
| 364 |
|
| |
| 365 |
|
| static int |
| 366 |
12 |
| NpInitialize(pTHX_ SV *X) |
| 367 |
|
| { |
| 368 |
|
| static Tcl_Interp * (* createInterp)() = NULL; |
| 369 |
|
| static void (* findExecutable)(char *) = NULL; |
| 370 |
|
| /* |
| 371 |
|
| * We want the Tcl_InitStubs func static to ourselves - before Tcl |
| 372 |
|
| * is loaded dyanmically and possibly changes it. |
| 373 |
|
| */ |
| 374 |
|
| static CONST char *(*initstubs)(Tcl_Interp *, CONST char *, int) |
| 375 |
|
| = Tcl_InitStubs; |
| 376 |
|
| char dllFilename[MAX_PATH]; |
| 377 |
12 |
| dllFilename[0] = '\0'; |
| 378 |
|
| |
| 379 |
|
| #ifdef USE_TCL_STUBS |
| 380 |
|
| /* |
| 381 |
|
| * Determine the libname and version number dynamically |
| 382 |
|
| */ |
| 383 |
12 |
▶ | if (tclHandle == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (tclHandle == NULL) { |
12 |
0 |
12 |
|
| 384 |
|
| /* |
| 385 |
|
| * First see if some other part didn't already load Tcl. |
| 386 |
|
| */ |
| 387 |
12 |
| DLSYM(tclHandle, "Tcl_CreateInterp", Tcl_Interp * (*)(), createInterp); |
| 388 |
|
| |
| 389 |
12 |
▶ | if (createInterp == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (createInterp == NULL) { |
12 |
0 |
12 |
|
| 390 |
12 |
▶ | if (NpLoadLibrary(aTHX_ &tclHandle, dllFilename, MAX_PATH) |
Branch: 1 branch
| Branch | True | False | Total |
| if (NpLoadLibrary(aTHX_ &tclHandle, dllFilename, MAX_PATH) |
12 |
0 |
12 |
|
| 391 |
|
| != TCL_OK) { |
| 392 |
12 |
| warn("Failed to load Tcl dll!"); |
| 393 |
12 |
| return TCL_ERROR; |
| 394 |
|
| } |
| 395 |
|
| } |
| 396 |
|
| |
| 397 |
0 |
| DLSYM(tclHandle, "Tcl_CreateInterp", Tcl_Interp * (*)(), createInterp); |
| 398 |
0 |
▶ | if (createInterp == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (createInterp == NULL) { |
0 |
0 |
0 |
|
| 399 |
|
| #if !defined(WIN32) && !defined(__hpux) |
| 400 |
0 |
| char *error = dlerror(); |
| 401 |
0 |
▶ | if (error != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (error != NULL) { |
0 |
0 |
0 |
|
| 402 |
0 |
| warn("%s",error); |
| 403 |
|
| } |
| 404 |
|
| #endif |
| 405 |
0 |
| return TCL_ERROR; |
| 406 |
|
| } |
| 407 |
0 |
| DLSYM(tclHandle, "Tcl_FindExecutable", void (*)(char *), |
| 408 |
|
| findExecutable); |
| 409 |
|
| |
| 410 |
0 |
| DLSYM(tclHandle, "TclKit_AppInit", int (*)(Tcl_Interp *), |
| 411 |
|
| tclKit_AppInit); |
| 412 |
|
| } |
| 413 |
|
| #else |
| 414 |
|
| createInterp = Tcl_CreateInterp; |
| 415 |
|
| findExecutable = Tcl_FindExecutable; |
| 416 |
|
| #endif |
| 417 |
|
| |
| 418 |
|
| #ifdef WIN32 |
| 419 |
|
| if (dllFilename[0] == '\0') { |
| 420 |
|
| GetModuleFileNameA((HINSTANCE) tclHandle, dllFilename, MAX_PATH); |
| 421 |
|
| } |
| 422 |
|
| findExecutable(dllFilename); |
| 423 |
|
| #else |
| 424 |
0 |
▶ | findExecutable(X && SvPOK(X) ? SvPV_nolen(X) : NULL); |
Branch: 2 branches
| Branch | True | False | Total |
| findExecutable(X && SvPOK(X) ? SvPV_nolen(X) : NULL); |
0 |
0 |
0 |
| findExecutable(X && SvPOK(X) ? SvPV_nolen(X) : NULL); |
0 |
0 |
0 |
|
| 425 |
|
| #endif |
| 426 |
|
| |
| 427 |
0 |
| g_Interp = createInterp(); |
| 428 |
0 |
▶ | if (g_Interp == (Tcl_Interp *) NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (g_Interp == (Tcl_Interp *) NULL) { |
0 |
0 |
0 |
|
| 429 |
0 |
| warn("Failed to create main Tcl interpreter!"); |
| 430 |
0 |
| return TCL_ERROR; |
| 431 |
|
| } |
| 432 |
|
| |
| 433 |
|
| /* |
| 434 |
|
| * Until Tcl_InitStubs is called, we cannot make any Tcl/Tk API |
| 435 |
|
| * calls without grabbing them by symbol out of the dll. |
| 436 |
|
| * This will be Tcl_PkgRequire for non-stubs builds. |
| 437 |
|
| */ |
| 438 |
0 |
▶ | if (initstubs(g_Interp, "8.4", 0) == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (initstubs(g_Interp, "8.4", 0) == NULL) { |
0 |
0 |
0 |
|
| 439 |
0 |
| warn("Failed to initialize Tcl stubs!"); |
| 440 |
0 |
| return TCL_ERROR; |
| 441 |
|
| } |
| 442 |
|
| |
| 443 |
|
| /* |
| 444 |
|
| * If we didn't find TclKit_AppInit, then this is a regular Tcl |
| 445 |
|
| * installation, so invoke Tcl_Init. |
| 446 |
|
| * Otherwise, we need to set the kit path to indicate we want to |
| 447 |
|
| * use the dll as our base kit. |
| 448 |
|
| */ |
| 449 |
0 |
▶ | if (tclKit_AppInit == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (tclKit_AppInit == NULL) { |
0 |
0 |
0 |
|
| 450 |
0 |
| tclKit_AppInit = Tcl_Init; |
| 451 |
|
| } else { |
| 452 |
0 |
| char * (* tclKit_SetKitPath)(char *) = NULL; |
| 453 |
|
| /* |
| 454 |
|
| * We need to see if this has TclKit_SetKitPath. This is in |
| 455 |
|
| * special base kit dlls that have embedded data in the dll. |
| 456 |
|
| */ |
| 457 |
0 |
▶ | if (dllFilename[0] != '\0') { |
Branch: 1 branch
| Branch | True | False | Total |
| if (dllFilename[0] != '\0') { |
0 |
0 |
0 |
|
| 458 |
0 |
| DLSYM(tclHandle, "TclKit_SetKitPath", char * (*)(char *), |
| 459 |
|
| tclKit_SetKitPath); |
| 460 |
0 |
▶ | if (tclKit_SetKitPath != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (tclKit_SetKitPath != NULL) { |
0 |
0 |
0 |
|
| 461 |
|
| /* |
| 462 |
|
| * XXX: Need to figure out how to populate dllFilename if |
| 463 |
|
| * NpLoadLibrary didn't do it for us on Unix. |
| 464 |
|
| */ |
| 465 |
0 |
| tclKit_SetKitPath(dllFilename); |
| 466 |
|
| } |
| 467 |
|
| } |
| 468 |
|
| } |
| 469 |
0 |
▶ | if (tclKit_AppInit(g_Interp) != TCL_OK) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (tclKit_AppInit(g_Interp) != TCL_OK) { |
0 |
0 |
0 |
|
| 470 |
0 |
| CONST84 char *msg = Tcl_GetVar(g_Interp, "errorInfo", TCL_GLOBAL_ONLY); |
| 471 |
0 |
▶ | warn("Failed to initialize Tcl with %s:\n%s", |
Branch: 1 branch
| Branch | True | False | Total |
| warn("Failed to initialize Tcl with %s:\n%s", |
0 |
0 |
0 |
|
| 472 |
|
| (tclKit_AppInit == Tcl_Init) ? "Tcl_Init" : "TclKit_AppInit", |
| 473 |
|
| msg); |
| 474 |
0 |
| return TCL_ERROR; |
| 475 |
|
| } |
| 476 |
|
| |
| 477 |
|
| /* |
| 478 |
|
| * Hold on to the interp handle until finalize, as special |
| 479 |
|
| * kit-based interps require the first initialized interp to |
| 480 |
|
| * remain alive. |
| 481 |
|
| */ |
| 482 |
|
| |
| 483 |
0 |
| return TCL_OK; |
| 484 |
|
| } |
| 485 |
|
| #endif |
| 486 |
|
| |
| 487 |
|
| #if DEBUG_REFCOUNTS |
| 488 |
|
| static void |
| 489 |
|
| check_refcounts(Tcl_Obj *objPtr) { |
| 490 |
|
| int rc = objPtr->refCount; |
| 491 |
|
| if (rc != 1) { |
| 492 |
|
| fprintf(stderr, "objPtr %p refcount %d\n", objPtr, rc); fflush(stderr); |
| 493 |
|
| } |
| 494 |
|
| if (objPtr->typePtr == tclListTypePtr) { |
| 495 |
|
| int objc, i; |
| 496 |
|
| Tcl_Obj **objv; |
| 497 |
|
| |
| 498 |
|
| Tcl_ListObjGetElements(NULL, objPtr, &objc, &objv); |
| 499 |
|
| for (i = 0; i < objc; i++) { |
| 500 |
|
| check_refcounts(objv[i]); |
| 501 |
|
| } |
| 502 |
|
| } |
| 503 |
|
| } |
| 504 |
|
| #endif |
| 505 |
|
| |
| 506 |
|
| static int |
| 507 |
0 |
| has_highbit(CONST char *s, int len) |
| 508 |
|
| { |
| 509 |
0 |
| CONST char *e = s + len; |
| 510 |
0 |
▶ | while (s < e) { |
Branch: 1 branch
| Branch | True | False | Total |
| while (s < e) { |
0 |
0 |
0 |
|
| 511 |
0 |
▶ | if (*s++ & 0x80) |
Branch: 1 branch
| Branch | True | False | Total |
| if (*s++ & 0x80) |
0 |
0 |
0 |
|
| 512 |
0 |
| return 1; |
| 513 |
|
| } |
| 514 |
0 |
| return 0; |
| 515 |
|
| } |
| 516 |
|
| |
| 517 |
|
| static SV * |
| 518 |
0 |
| SvFromTclObj(pTHX_ Tcl_Obj *objPtr) |
| 519 |
|
| { |
| 520 |
|
| SV *sv; |
| 521 |
|
| int len; |
| 522 |
|
| char *str; |
| 523 |
|
| |
| 524 |
0 |
▶ | if (objPtr == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (objPtr == NULL) { |
0 |
0 |
0 |
|
| 525 |
|
| /* |
| 526 |
|
| * Use newSV(0) instead of &PL_sv_undef as it may be stored in an AV. |
| 527 |
|
| * It also provides symmetry with the other newSV* calls below. |
| 528 |
|
| * This SV will also be mortalized later. |
| 529 |
|
| */ |
| 530 |
0 |
| sv = newSV(0); |
| 531 |
|
| } |
| 532 |
0 |
▶ | else if (objPtr->typePtr == tclIntTypePtr) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (objPtr->typePtr == tclIntTypePtr) { |
0 |
0 |
0 |
|
| 533 |
0 |
| sv = newSViv(objPtr->internalRep.longValue); |
| 534 |
|
| } |
| 535 |
0 |
▶ | else if (objPtr->typePtr == tclDoubleTypePtr) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (objPtr->typePtr == tclDoubleTypePtr) { |
0 |
0 |
0 |
|
| 536 |
0 |
| sv = newSVnv(objPtr->internalRep.doubleValue); |
| 537 |
|
| } |
| 538 |
0 |
▶ | else if (objPtr->typePtr == tclBooleanTypePtr) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (objPtr->typePtr == tclBooleanTypePtr) { |
0 |
0 |
0 |
|
| 539 |
|
| /* |
| 540 |
|
| * Booleans can originate as words (yes/true/...), so if there is a |
| 541 |
|
| * string rep, use it instead. We could check if the first byte |
| 542 |
|
| * isdigit(). No need to check utf-8 as the all valid boolean words |
| 543 |
|
| * are ascii-7. |
| 544 |
|
| */ |
| 545 |
0 |
▶ | if (objPtr->typePtr == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (objPtr->typePtr == NULL) { |
0 |
0 |
0 |
|
| 546 |
0 |
▶ | sv = newSVsv(boolSV(objPtr->internalRep.longValue != 0)); |
Branch: 1 branch
| Branch | True | False | Total |
| sv = newSVsv(boolSV(objPtr->internalRep.longValue != 0)); |
0 |
0 |
0 |
|
| 547 |
|
| } else { |
| 548 |
0 |
| str = Tcl_GetStringFromObj(objPtr, &len); |
| 549 |
0 |
| sv = newSVpvn(str, len); |
| 550 |
|
| } |
| 551 |
|
| } |
| 552 |
0 |
▶ | else if (objPtr->typePtr == tclByteArrayTypePtr) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (objPtr->typePtr == tclByteArrayTypePtr) { |
0 |
0 |
0 |
|
| 553 |
0 |
| str = (char *) Tcl_GetByteArrayFromObj(objPtr, &len); |
| 554 |
0 |
| sv = newSVpvn(str, len); |
| 555 |
|
| } |
| 556 |
0 |
▶ | else if (objPtr->typePtr == tclListTypePtr) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (objPtr->typePtr == tclListTypePtr) { |
0 |
0 |
0 |
|
| 557 |
|
| /* |
| 558 |
|
| * tclListTypePtr should become an AV. |
| 559 |
|
| * This code needs to reconcile with G_ context in prepare_Tcl_result |
| 560 |
|
| * and user's expectations of how data will be passed in. The key is |
| 561 |
|
| * that a stringified-list and pure-list should be operable in the |
| 562 |
|
| * same way in Perl. |
| 563 |
|
| * |
| 564 |
|
| * We have to watch for "empty" lists, which could equate to the |
| 565 |
|
| * empty string. Tcl's literal object sharing means that "" could |
| 566 |
|
| * be typed as a list, although we don't want to see it that way. |
| 567 |
|
| * Just treat empty list objects as an empty (not undef) SV. |
| 568 |
|
| */ |
| 569 |
|
| int objc; |
| 570 |
|
| Tcl_Obj **objv; |
| 571 |
|
| |
| 572 |
0 |
| Tcl_ListObjGetElements(NULL, objPtr, &objc, &objv); |
| 573 |
0 |
▶ | if (objc) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (objc) { |
0 |
0 |
0 |
|
| 574 |
|
| int i; |
| 575 |
0 |
| AV *av = newAV(); |
| 576 |
|
| |
| 577 |
0 |
▶ | for (i = 0; i < objc; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < objc; i++) { |
0 |
0 |
0 |
|
| 578 |
0 |
| av_push(av, SvFromTclObj(aTHX_ objv[i])); |
| 579 |
|
| } |
| 580 |
0 |
| sv = sv_bless(newRV_noinc((SV *) av), gv_stashpv("Tcl::List", 1)); |
| 581 |
|
| } |
| 582 |
|
| else { |
| 583 |
0 |
| sv = newSVpvn("", 0); |
| 584 |
|
| } |
| 585 |
|
| } |
| 586 |
|
| /* tclStringTypePtr is true unicode */ |
| 587 |
|
| /* tclWideIntTypePtr is 64-bit int */ |
| 588 |
|
| else { |
| 589 |
0 |
| str = Tcl_GetStringFromObj(objPtr, &len); |
| 590 |
0 |
| sv = newSVpvn(str, len); |
| 591 |
|
| /* should turn on, but let's check this first for efficiency */ |
| 592 |
0 |
▶ | if (len && has_highbit(str, len)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (len && has_highbit(str, len)) { |
0 |
0 |
0 |
| if (len && has_highbit(str, len)) { |
0 |
0 |
0 |
|
| 593 |
|
| /* |
| 594 |
|
| * Tcl can encode NULL as overlong utf-8 \300\200 (\xC0\x80). |
| 595 |
|
| * Tcl itself doesn't require this, but some extensions do when |
| 596 |
|
| * they pass the string data to native C APIs (like strlen). |
| 597 |
|
| * Tk is the most notable case for this (calling out to native UI |
| 598 |
|
| * toolkit APIs that don't take counted strings). |
| 599 |
|
| * s/\300\200/\0/g |
| 600 |
|
| */ |
| 601 |
|
| char *nul_start; |
| 602 |
|
| STRLEN len; |
| 603 |
0 |
| char *s = SvPV(sv, len); |
| 604 |
0 |
| char *end = s + len; |
| 605 |
0 |
▶ | while ((nul_start = memchr(s, '\300', len))) { |
Branch: 1 branch
| Branch | True | False | Total |
| while ((nul_start = memchr(s, '\300', len))) { |
0 |
0 |
0 |
|
| 606 |
0 |
▶ | if (nul_start + 1 < end && nul_start[1] == '\200') { |
Branch: 2 branches
| Branch | True | False | Total |
| if (nul_start + 1 < end && nul_start[1] == '\200') { |
0 |
0 |
0 |
| if (nul_start + 1 < end && nul_start[1] == '\200') { |
0 |
0 |
0 |
|
| 607 |
|
| /* found it */ |
| 608 |
0 |
| nul_start[0] = '\0'; |
| 609 |
0 |
| memmove(nul_start + 1, nul_start + 2, |
| 610 |
0 |
| end - (nul_start + 2)); |
| 611 |
0 |
| len--; |
| 612 |
0 |
| end--; |
| 613 |
0 |
| *end = '\0'; |
| 614 |
0 |
| SvCUR_set(sv, SvCUR(sv) - 1); |
| 615 |
|
| } |
| 616 |
0 |
| len -= (nul_start + 1) - s; |
| 617 |
0 |
| s = nul_start + 1; |
| 618 |
|
| } |
| 619 |
0 |
| SvUTF8_on(sv); |
| 620 |
|
| } |
| 621 |
|
| } |
| 622 |
0 |
| return sv; |
| 623 |
|
| } |
| 624 |
|
| |
| 625 |
|
| /* |
| 626 |
|
| * Create a Tcl_Obj from a Perl SV. |
| 627 |
|
| * Return Tcl_Obj with refcount = 0. Caller should call Tcl_IncrRefCount |
| 628 |
|
| * or pass of to function that does (manage object lifetime). |
| 629 |
|
| */ |
| 630 |
|
| static Tcl_Obj * |
| 631 |
0 |
| TclObjFromSv(pTHX_ SV *sv) |
| 632 |
|
| { |
| 633 |
0 |
| Tcl_Obj *objPtr = NULL; |
| 634 |
|
| |
| 635 |
0 |
▶ | if (SvGMAGICAL(sv)) |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvGMAGICAL(sv)) |
0 |
0 |
0 |
|
| 636 |
0 |
| mg_get(sv); |
| 637 |
|
| |
| 638 |
0 |
▶ | if (SvROK(sv) && SvTYPE(SvRV(sv)) == SVt_PVAV && |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvROK(sv) && SvTYPE(SvRV(sv)) == SVt_PVAV && |
0 |
0 |
0 |
| if (SvROK(sv) && SvTYPE(SvRV(sv)) == SVt_PVAV && |
0 |
0 |
0 |
|
| 639 |
0 |
▶ | (!SvOBJECT(SvRV(sv)) || sv_isa(sv, "Tcl::List"))) |
Branch: 2 branches
| Branch | True | False | Total |
| (!SvOBJECT(SvRV(sv)) || sv_isa(sv, "Tcl::List"))) |
0 |
0 |
0 |
| (!SvOBJECT(SvRV(sv)) || sv_isa(sv, "Tcl::List"))) |
0 |
0 |
0 |
|
| 640 |
0 |
| { |
| 641 |
|
| /* |
| 642 |
|
| * Recurse into ARRAYs, turning them into Tcl list Objs |
| 643 |
|
| */ |
| 644 |
|
| SV **svp; |
| 645 |
0 |
| AV *av = (AV *) SvRV(sv); |
| 646 |
0 |
| I32 avlen = av_len(av); |
| 647 |
|
| int i; |
| 648 |
|
| |
| 649 |
0 |
| objPtr = Tcl_NewListObj(0, (Tcl_Obj **) NULL); |
| 650 |
|
| |
| 651 |
0 |
▶ | for (i = 0; i <= avlen; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i <= avlen; i++) { |
0 |
0 |
0 |
|
| 652 |
0 |
| svp = av_fetch(av, i, FALSE); |
| 653 |
0 |
▶ | if (svp == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (svp == NULL) { |
0 |
0 |
0 |
|
| 654 |
|
| /* watch for sparse arrays - translate as empty element */ |
| 655 |
|
| /* XXX: Is this handling refcount on NewObj right? */ |
| 656 |
0 |
| Tcl_ListObjAppendElement(NULL, objPtr, Tcl_NewObj()); |
| 657 |
|
| } else { |
| 658 |
0 |
▶ | if ((AV *) SvRV(*svp) == av) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ((AV *) SvRV(*svp) == av) { |
0 |
0 |
0 |
|
| 659 |
|
| /* XXX: Is this a proper check for cyclical reference? */ |
| 660 |
0 |
| croak("cyclical array reference found"); |
| 661 |
|
| abort(); |
| 662 |
|
| } |
| 663 |
0 |
| Tcl_ListObjAppendElement(NULL, objPtr, |
| 664 |
|
| TclObjFromSv(aTHX_ sv_mortalcopy(*svp))); |
| 665 |
|
| } |
| 666 |
|
| } |
| 667 |
|
| } |
| 668 |
0 |
▶ | else if (SvPOK(sv)) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (SvPOK(sv)) { |
0 |
0 |
0 |
|
| 669 |
|
| STRLEN length; |
| 670 |
0 |
| char *str = SvPV(sv, length); |
| 671 |
|
| /* |
| 672 |
|
| * Tcl's "String" object expects utf-8 strings. If we aren't sure |
| 673 |
|
| * that we have a utf-8 data, pass it as a Tcl ByteArray (C char*). |
| 674 |
|
| * |
| 675 |
|
| * XXX Possible optimization opportunity here. Tcl will actually |
| 676 |
|
| * XXX accept and handle most latin-1 char sequences correctly, but |
| 677 |
|
| * XXX not blocks of truly binary data. This code is 100% correct, |
| 678 |
|
| * XXX but could be tweaked to improve performance. |
| 679 |
|
| */ |
| 680 |
0 |
▶ | if (SvUTF8(sv)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvUTF8(sv)) { |
0 |
0 |
0 |
|
| 681 |
|
| /* |
| 682 |
|
| * Tcl allows NULL to be encoded overlong as \300\200 (\xC0\x80). |
| 683 |
|
| * Tcl itself doesn't require this, but some extensions do when |
| 684 |
|
| * they pass the string data to native C APIs (like strlen). |
| 685 |
|
| * Tk is the most notable case for this (calling out to native UI |
| 686 |
|
| * toolkit APIs that don't take counted strings). |
| 687 |
|
| */ |
| 688 |
0 |
▶ | if (memchr(str, '\0', length)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (memchr(str, '\0', length)) { |
0 |
0 |
0 |
|
| 689 |
|
| /* ($sv_copy = $sv) =~ s/\0/\300\200/g */ |
| 690 |
0 |
| SV *sv_copy = sv_mortalcopy(sv); |
| 691 |
|
| STRLEN len; |
| 692 |
0 |
| char *s = SvPV(sv_copy, len); |
| 693 |
|
| char *nul; |
| 694 |
|
| |
| 695 |
0 |
▶ | while ((nul = memchr(s, '\0', len))) { |
Branch: 1 branch
| Branch | True | False | Total |
| while ((nul = memchr(s, '\0', len))) { |
0 |
0 |
0 |
|
| 696 |
0 |
| STRLEN i = nul - SvPVX(sv_copy); |
| 697 |
0 |
▶ | s = SvGROW(sv_copy, SvCUR(sv_copy) + 2); |
Branch: 2 branches
| Branch | True | False | Total |
| s = SvGROW(sv_copy, SvCUR(sv_copy) + 2); |
0 |
0 |
0 |
| s = SvGROW(sv_copy, SvCUR(sv_copy) + 2); |
0 |
0 |
0 |
|
| 698 |
0 |
| nul = s + i; |
| 699 |
0 |
| memmove(nul + 2, nul + 1, SvEND(sv_copy) - (nul + 1)); |
| 700 |
0 |
| nul[0] = '\300'; |
| 701 |
0 |
| nul[1] = '\200'; |
| 702 |
0 |
| SvCUR_set(sv_copy, SvCUR(sv_copy) + 1); |
| 703 |
0 |
| s = nul + 2; |
| 704 |
0 |
| len = SvEND(sv_copy) - s; |
| 705 |
|
| } |
| 706 |
0 |
| str = SvPV(sv_copy, length); |
| 707 |
|
| } |
| 708 |
0 |
| objPtr = Tcl_NewStringObj(str, length); |
| 709 |
|
| } else { |
| 710 |
0 |
| objPtr = Tcl_NewByteArrayObj((unsigned char *)str, length); |
| 711 |
|
| } |
| 712 |
|
| } |
| 713 |
0 |
▶ | else if (SvNOK(sv)) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (SvNOK(sv)) { |
0 |
0 |
0 |
|
| 714 |
0 |
| double dval = SvNV(sv); |
| 715 |
|
| int ival; |
| 716 |
|
| /* |
| 717 |
|
| * Perl does math with doubles by default, so 0 + 1 == 1.0. |
| 718 |
|
| * Check for int-equiv doubles and make those ints. |
| 719 |
|
| * XXX This check possibly only necessary for <=5.6.x |
| 720 |
|
| */ |
| 721 |
0 |
▶ | if (((double)(ival = SvIV(sv)) == dval)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (((double)(ival = SvIV(sv)) == dval)) { |
0 |
0 |
0 |
|
| 722 |
0 |
| objPtr = Tcl_NewIntObj(ival); |
| 723 |
|
| } else { |
| 724 |
0 |
| objPtr = Tcl_NewDoubleObj(dval); |
| 725 |
|
| } |
| 726 |
|
| } |
| 727 |
0 |
▶ | else if (SvIOK(sv)) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (SvIOK(sv)) { |
0 |
0 |
0 |
|
| 728 |
0 |
| objPtr = Tcl_NewIntObj(SvIV(sv)); |
| 729 |
|
| } |
| 730 |
|
| else { |
| 731 |
|
| /* |
| 732 |
|
| * Catch-all |
| 733 |
|
| * XXX: Should we recurse other REFs, or better to stringify them? |
| 734 |
|
| */ |
| 735 |
|
| STRLEN length; |
| 736 |
0 |
| char *str = SvPV(sv, length); |
| 737 |
|
| /* |
| 738 |
|
| * Tcl's "String" object expects utf-8 strings. If we aren't sure |
| 739 |
|
| * that we have a utf-8 data, pass it as a Tcl ByteArray (C char*). |
| 740 |
|
| */ |
| 741 |
0 |
▶ | if (SvUTF8(sv)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvUTF8(sv)) { |
0 |
0 |
0 |
|
| 742 |
|
| /* |
| 743 |
|
| * Should we consider overlong NULL encoding for Tcl here? |
| 744 |
|
| */ |
| 745 |
0 |
| objPtr = Tcl_NewStringObj(str, length); |
| 746 |
|
| } else { |
| 747 |
0 |
| objPtr = Tcl_NewByteArrayObj((unsigned char *) str, length); |
| 748 |
|
| } |
| 749 |
|
| } |
| 750 |
|
| |
| 751 |
0 |
| return objPtr; |
| 752 |
|
| } |
| 753 |
|
| |
| 754 |
0 |
| int Tcl_EvalInPerl(ClientData clientData, Tcl_Interp *interp, |
| 755 |
|
| int objc, Tcl_Obj *CONST objv[]) |
| 756 |
|
| { |
| 757 |
|
| dTHX; /* fetch context */ |
| 758 |
0 |
| dSP; |
| 759 |
|
| I32 count; |
| 760 |
|
| SV *sv; |
| 761 |
|
| int rc; |
| 762 |
|
| |
| 763 |
|
| /* |
| 764 |
|
| * This is the command created in Tcl to eval stuff in Perl |
| 765 |
|
| */ |
| 766 |
|
| |
| 767 |
0 |
▶ | if (objc != 2) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (objc != 2) { |
0 |
0 |
0 |
|
| 768 |
0 |
| Tcl_WrongNumArgs(interp, 1, objv, "string"); |
| 769 |
|
| } |
| 770 |
|
| |
| 771 |
0 |
| ENTER; |
| 772 |
0 |
| SAVETMPS; |
| 773 |
|
| |
| 774 |
0 |
▶ | PUSHMARK(sp); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(sp); |
0 |
0 |
0 |
|
| 775 |
0 |
| PUTBACK; |
| 776 |
0 |
| count = perl_eval_sv(sv_2mortal(SvFromTclObj(aTHX_ objv[1])), |
| 777 |
|
| G_EVAL|G_SCALAR); |
| 778 |
0 |
| SPAGAIN; |
| 779 |
|
| |
| 780 |
0 |
▶ | if (SvTRUE(ERRSV)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvTRUE(ERRSV)) { |
0 |
0 |
0 |
| if (SvTRUE(ERRSV)) { |
0 |
0 |
0 |
|
| 781 |
0 |
▶ | Tcl_SetResult(interp, SvPV_nolen(ERRSV), TCL_VOLATILE); |
Branch: 1 branch
| Branch | True | False | Total |
| Tcl_SetResult(interp, SvPV_nolen(ERRSV), TCL_VOLATILE); |
0 |
0 |
0 |
|
| 782 |
0 |
| POPs; /* pop the undef off the stack */ |
| 783 |
0 |
| rc = TCL_ERROR; |
| 784 |
|
| } |
| 785 |
|
| else { |
| 786 |
0 |
▶ | if (count != 1) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (count != 1) { |
0 |
0 |
0 |
|
| 787 |
0 |
| croak("Perl sub bound to Tcl proc returned %d args, expected 1", |
| 788 |
|
| count); |
| 789 |
|
| } |
| 790 |
0 |
| sv = POPs; /* pop the undef off the stack */ |
| 791 |
|
| |
| 792 |
0 |
▶ | if (SvOK(sv)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv)) { |
0 |
0 |
0 |
|
| 793 |
0 |
| Tcl_Obj *objPtr = TclObjFromSv(aTHX_ sv); |
| 794 |
|
| /* Tcl_SetObjResult will incr refcount */ |
| 795 |
0 |
| Tcl_SetObjResult(interp, objPtr); |
| 796 |
|
| } |
| 797 |
0 |
| rc = TCL_OK; |
| 798 |
|
| } |
| 799 |
|
| |
| 800 |
0 |
| PUTBACK; |
| 801 |
|
| /* |
| 802 |
|
| * If the routine returned undef, it indicates that it has done the |
| 803 |
|
| * SetResult itself and that we should return TCL_ERROR |
| 804 |
|
| */ |
| 805 |
|
| |
| 806 |
0 |
▶ | FREETMPS; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; |
0 |
0 |
0 |
|
| 807 |
0 |
| LEAVE; |
| 808 |
0 |
| return rc; |
| 809 |
|
| } |
| 810 |
|
| |
| 811 |
0 |
| int Tcl_PerlCallWrapper(ClientData clientData, Tcl_Interp *interp, |
| 812 |
|
| int objc, Tcl_Obj *CONST objv[]) |
| 813 |
|
| { |
| 814 |
|
| dTHX; /* fetch context */ |
| 815 |
0 |
| dSP; |
| 816 |
0 |
| AV *av = (AV *) clientData; |
| 817 |
|
| I32 count; |
| 818 |
|
| SV *sv; |
| 819 |
|
| int flag; |
| 820 |
|
| int rc; |
| 821 |
|
| |
| 822 |
|
| /* |
| 823 |
|
| * av = [$perlsub, $realclientdata, $interp, $deleteProc] |
| 824 |
|
| * (where $deleteProc is optional but we don't need it here anyway) |
| 825 |
|
| */ |
| 826 |
|
| |
| 827 |
0 |
▶ | if (AvFILL(av) != 3 && AvFILL(av) != 4) |
Branch: 2 branches
| Branch | True | False | Total |
| if (AvFILL(av) != 3 && AvFILL(av) != 4) |
0 |
0 |
0 |
| if (AvFILL(av) != 3 && AvFILL(av) != 4) |
0 |
0 |
0 |
|
| 828 |
0 |
| croak("bad clientdata argument passed to Tcl_PerlCallWrapper"); |
| 829 |
|
| |
| 830 |
0 |
| flag = SvIV(*av_fetch(av, 3, FALSE)); |
| 831 |
|
| |
| 832 |
0 |
| ENTER; |
| 833 |
0 |
| SAVETMPS; |
| 834 |
|
| |
| 835 |
0 |
▶ | PUSHMARK(sp); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(sp); |
0 |
0 |
0 |
|
| 836 |
0 |
▶ | if (flag & 1) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (flag & 1) { |
0 |
0 |
0 |
|
| 837 |
0 |
▶ | if (objc) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (objc) { |
0 |
0 |
0 |
|
| 838 |
0 |
| objc--; |
| 839 |
0 |
| objv++; |
| 840 |
0 |
▶ | EXTEND(sp, objc); |
Branch: 2 branches
| Branch | True | False | Total |
| EXTEND(sp, objc); |
0 |
0 |
0 |
| EXTEND(sp, objc); |
0 |
0 |
0 |
|
| 841 |
|
| } |
| 842 |
|
| } |
| 843 |
|
| else { |
| 844 |
0 |
▶ | EXTEND(sp, objc + 2); |
Branch: 2 branches
| Branch | True | False | Total |
| EXTEND(sp, objc + 2); |
0 |
0 |
0 |
| EXTEND(sp, objc + 2); |
0 |
0 |
0 |
|
| 845 |
|
| /* |
| 846 |
|
| * Place clientData and original interp on the stack, then the |
| 847 |
|
| * Tcl object invoke list, including the command name. Users |
| 848 |
|
| * who only want the args from Tcl can splice off the first 3 args |
| 849 |
|
| */ |
| 850 |
0 |
| PUSHs(sv_mortalcopy(*av_fetch(av, 1, FALSE))); |
| 851 |
0 |
| PUSHs(sv_mortalcopy(*av_fetch(av, 2, FALSE))); |
| 852 |
|
| } |
| 853 |
0 |
▶ | while (objc--) { |
Branch: 1 branch
| Branch | True | False | Total |
| while (objc--) { |
0 |
0 |
0 |
|
| 854 |
0 |
| PUSHs(sv_2mortal(SvFromTclObj(aTHX_ *objv++))); |
| 855 |
|
| } |
| 856 |
0 |
| PUTBACK; |
| 857 |
0 |
| count = perl_call_sv(*av_fetch(av, 0, FALSE), G_EVAL|G_SCALAR); |
| 858 |
0 |
| SPAGAIN; |
| 859 |
|
| |
| 860 |
0 |
▶ | if (SvTRUE(ERRSV)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvTRUE(ERRSV)) { |
0 |
0 |
0 |
| if (SvTRUE(ERRSV)) { |
0 |
0 |
0 |
|
| 861 |
0 |
▶ | Tcl_SetResult(interp, SvPV_nolen(ERRSV), TCL_VOLATILE); |
Branch: 1 branch
| Branch | True | False | Total |
| Tcl_SetResult(interp, SvPV_nolen(ERRSV), TCL_VOLATILE); |
0 |
0 |
0 |
|
| 862 |
0 |
| POPs; /* pop the undef off the stack */ |
| 863 |
0 |
| rc = TCL_ERROR; |
| 864 |
|
| } |
| 865 |
|
| else { |
| 866 |
0 |
▶ | if (count != 1) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (count != 1) { |
0 |
0 |
0 |
|
| 867 |
0 |
| croak("Perl sub bound to Tcl proc returned %d args, expected 1", |
| 868 |
|
| count); |
| 869 |
|
| } |
| 870 |
0 |
| sv = POPs; /* pop the undef off the stack */ |
| 871 |
|
| |
| 872 |
0 |
▶ | if (SvOK(sv)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(sv)) { |
0 |
0 |
0 |
|
| 873 |
0 |
| Tcl_Obj *objPtr = TclObjFromSv(aTHX_ sv); |
| 874 |
|
| /* Tcl_SetObjResult will incr refcount */ |
| 875 |
0 |
| Tcl_SetObjResult(interp, objPtr); |
| 876 |
|
| } |
| 877 |
0 |
| rc = TCL_OK; |
| 878 |
|
| } |
| 879 |
|
| |
| 880 |
0 |
| PUTBACK; |
| 881 |
|
| /* |
| 882 |
|
| * If the routine returned undef, it indicates that it has done the |
| 883 |
|
| * SetResult itself and that we should return TCL_ERROR |
| 884 |
|
| */ |
| 885 |
|
| |
| 886 |
0 |
▶ | FREETMPS; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; |
0 |
0 |
0 |
|
| 887 |
0 |
| LEAVE; |
| 888 |
0 |
| return rc; |
| 889 |
|
| } |
| 890 |
|
| |
| 891 |
|
| void |
| 892 |
0 |
| Tcl_PerlCallDeleteProc(ClientData clientData) |
| 893 |
|
| { |
| 894 |
|
| dTHX; /* fetch context */ |
| 895 |
0 |
| AV *av = (AV *) clientData; |
| 896 |
|
| |
| 897 |
|
| /* |
| 898 |
|
| * av = [$perlsub, $realclientdata, $interp, $deleteProc] |
| 899 |
|
| * (where $deleteProc is optional but we don't need it here anyway) |
| 900 |
|
| */ |
| 901 |
|
| |
| 902 |
0 |
▶ | if (AvFILL(av) == 4) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (AvFILL(av) == 4) { |
0 |
0 |
0 |
|
| 903 |
0 |
| dSP; |
| 904 |
|
| |
| 905 |
0 |
▶ | PUSHMARK(sp); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(sp); |
0 |
0 |
0 |
|
| 906 |
0 |
▶ | EXTEND(sp, 1); |
Branch: 1 branch
| Branch | True | False | Total |
| EXTEND(sp, 1); |
0 |
0 |
0 |
|
| 907 |
0 |
| PUSHs(sv_mortalcopy(*av_fetch(av, 1, FALSE))); |
| 908 |
0 |
| PUTBACK; |
| 909 |
0 |
| (void) perl_call_sv(*av_fetch(av, 4, FALSE), G_SCALAR|G_DISCARD); |
| 910 |
|
| } |
| 911 |
0 |
▶ | else if (AvFILL(av) != 3) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (AvFILL(av) != 3) { |
0 |
0 |
0 |
|
| 912 |
0 |
| croak("bad clientdata argument passed to Tcl_PerlCallDeleteProc"); |
| 913 |
|
| } |
| 914 |
|
| |
| 915 |
0 |
| SvREFCNT_dec(av); |
| 916 |
0 |
| } |
| 917 |
|
| |
| 918 |
|
| void |
| 919 |
0 |
| prepare_Tcl_result(pTHX_ Tcl interp, char *caller) |
| 920 |
|
| { |
| 921 |
0 |
| dSP; |
| 922 |
|
| Tcl_Obj *objPtr, **objv; |
| 923 |
|
| int gimme, objc, i; |
| 924 |
|
| |
| 925 |
0 |
| objPtr = Tcl_GetObjResult(interp); |
| 926 |
|
| |
| 927 |
0 |
| gimme = GIMME_V; |
| 928 |
0 |
▶ | if (gimme == G_SCALAR) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (gimme == G_SCALAR) { |
0 |
0 |
0 |
|
| 929 |
|
| /* |
| 930 |
|
| * This checks Tcl_Obj type. XPUSH not needed because we |
| 931 |
|
| * are called when there is enough space on the stack. |
| 932 |
|
| */ |
| 933 |
0 |
| PUSHs(sv_2mortal(SvFromTclObj(aTHX_ objPtr))); |
| 934 |
|
| } |
| 935 |
0 |
▶ | else if (gimme == G_ARRAY) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (gimme == G_ARRAY) { |
0 |
0 |
0 |
|
| 936 |
0 |
▶ | if (Tcl_ListObjGetElements(interp, objPtr, &objc, &objv) |
Branch: 1 branch
| Branch | True | False | Total |
| if (Tcl_ListObjGetElements(interp, objPtr, &objc, &objv) |
0 |
0 |
0 |
|
| 937 |
|
| != TCL_OK) { |
| 938 |
0 |
| croak("%s called in list context did not return a valid Tcl list", |
| 939 |
|
| caller); |
| 940 |
|
| } |
| 941 |
0 |
▶ | if (objc) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (objc) { |
0 |
0 |
0 |
|
| 942 |
0 |
▶ | EXTEND(sp, objc); |
Branch: 2 branches
| Branch | True | False | Total |
| EXTEND(sp, objc); |
0 |
0 |
0 |
| EXTEND(sp, objc); |
0 |
0 |
0 |
|
| 943 |
0 |
▶ | for (i = 0; i < objc; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < objc; i++) { |
0 |
0 |
0 |
|
| 944 |
|
| /* |
| 945 |
|
| * This checks Tcl_Obj type |
| 946 |
|
| */ |
| 947 |
0 |
| PUSHs(sv_2mortal(SvFromTclObj(aTHX_ objv[i]))); |
| 948 |
|
| } |
| 949 |
|
| } |
| 950 |
|
| } |
| 951 |
|
| else { |
| 952 |
|
| /* G_VOID context - ignore result */ |
| 953 |
|
| } |
| 954 |
0 |
| PUTBACK; |
| 955 |
0 |
| return; |
| 956 |
|
| } |
| 957 |
|
| |
| 958 |
|
| char * |
| 959 |
0 |
| var_trace(ClientData clientData, Tcl_Interp *interp, |
| 960 |
|
| char *name1, char *name2, int flags) |
| 961 |
|
| { |
| 962 |
|
| dTHX; /* fetch context */ |
| 963 |
|
| |
| 964 |
0 |
▶ | if (flags & TCL_TRACE_READS) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (flags & TCL_TRACE_READS) { |
0 |
0 |
0 |
|
| 965 |
0 |
| warn("TCL_TRACE_READS\n"); |
| 966 |
|
| } |
| 967 |
0 |
▶ | else if (flags & TCL_TRACE_WRITES) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (flags & TCL_TRACE_WRITES) { |
0 |
0 |
0 |
|
| 968 |
0 |
| warn("TCL_TRACE_WRITES\n"); |
| 969 |
|
| } |
| 970 |
0 |
▶ | else if (flags & TCL_TRACE_ARRAY) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (flags & TCL_TRACE_ARRAY) { |
0 |
0 |
0 |
|
| 971 |
0 |
| warn("TCL_TRACE_ARRAY\n"); |
| 972 |
|
| } |
| 973 |
0 |
▶ | else if (flags & TCL_TRACE_UNSETS) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (flags & TCL_TRACE_UNSETS) { |
0 |
0 |
0 |
|
| 974 |
0 |
| warn("TCL_TRACE_UNSETS\n"); |
| 975 |
|
| } |
| 976 |
0 |
| return 0; |
| 977 |
|
| } |
| 978 |
|
| |
| 979 |
|
| MODULE = Tcl PACKAGE = Tcl PREFIX = Tcl_ |
| 980 |
|
| |
| 981 |
|
| SV * |
| 982 |
|
| Tcl__new(class = "Tcl") |
| 983 |
|
| char * class |
| 984 |
|
| CODE: |
| 985 |
0 |
| RETVAL = newSV(0); |
| 986 |
|
| /* |
| 987 |
|
| * We might consider Tcl_Preserve/Tcl_Release of the interp. |
| 988 |
|
| */ |
| 989 |
0 |
▶ | if (initialized) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (initialized) { |
0 |
0 |
0 |
|
| 990 |
0 |
| Tcl interp = Tcl_CreateInterp(); |
| 991 |
0 |
| Tcl_CreateObjCommand(interp, "::perl::Eval", Tcl_EvalInPerl, |
| 992 |
|
| (ClientData) NULL, NULL); |
| 993 |
|
| /* |
| 994 |
|
| * Add to the global hash of live interps. |
| 995 |
|
| */ |
| 996 |
0 |
▶ | if (hvInterps) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (hvInterps) { |
0 |
0 |
0 |
|
| 997 |
0 |
| (void) hv_store(hvInterps, (const char *) &interp, |
| 998 |
|
| sizeof(Tcl), &PL_sv_undef, 0); |
| 999 |
|
| } |
| 1000 |
0 |
| sv_setref_pv(RETVAL, class, (void*)interp); |
| 1001 |
|
| } |
| 1002 |
|
| OUTPUT: |
| 1003 |
|
| RETVAL |
| 1004 |
|
| |
| 1005 |
|
| SV * |
| 1006 |
|
| Tcl_CreateSlave(master,name,safe) |
| 1007 |
|
| Tcl master |
| 1008 |
|
| char * name |
| 1009 |
|
| int safe |
| 1010 |
|
| CODE: |
| 1011 |
0 |
| RETVAL = newSV(0); |
| 1012 |
|
| /* |
| 1013 |
|
| * We might consider Tcl_Preserve/Tcl_Release of the interp. |
| 1014 |
|
| */ |
| 1015 |
0 |
▶ | if (initialized) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (initialized) { |
0 |
0 |
0 |
|
| 1016 |
0 |
| Tcl interp = Tcl_CreateSlave(master,name,safe); |
| 1017 |
|
| /* |
| 1018 |
|
| * Add to the global hash of live interps. |
| 1019 |
|
| */ |
| 1020 |
0 |
▶ | if (hvInterps) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (hvInterps) { |
0 |
0 |
0 |
|
| 1021 |
0 |
| (void) hv_store(hvInterps, (const char *) &interp, |
| 1022 |
|
| sizeof(Tcl), &PL_sv_undef, 0); |
| 1023 |
|
| } |
| 1024 |
|
| /* Create lets us set a class, should we do this too? */ |
| 1025 |
0 |
| sv_setref_pv(RETVAL, "Tcl", (void*)interp); |
| 1026 |
|
| } |
| 1027 |
|
| OUTPUT: |
| 1028 |
|
| RETVAL |
| 1029 |
|
| |
| 1030 |
|
| SV * |
| 1031 |
|
| Tcl_result(interp) |
| 1032 |
|
| Tcl interp |
| 1033 |
|
| CODE: |
| 1034 |
0 |
▶ | if (initialized) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (initialized) { |
0 |
0 |
0 |
|
| 1035 |
0 |
| RETVAL = SvFromTclObj(aTHX_ Tcl_GetObjResult(interp)); |
| 1036 |
|
| } |
| 1037 |
|
| else { |
| 1038 |
0 |
| RETVAL = &PL_sv_undef; |
| 1039 |
|
| } |
| 1040 |
|
| OUTPUT: |
| 1041 |
|
| RETVAL |
| 1042 |
|
| |
| 1043 |
|
| void |
| 1044 |
|
| Tcl_Eval(interp, script, flags = 0) |
| 1045 |
|
| Tcl interp |
| 1046 |
|
| SV * script |
| 1047 |
|
| int flags |
| 1048 |
|
| SV * interpsv = ST(0); |
| 1049 |
|
| STRLEN length = NO_INIT |
| 1050 |
|
| char *cscript = NO_INIT |
| 1051 |
|
| PPCODE: |
| 1052 |
0 |
▶ | if (!initialized) { return; } |
Branch: 1 branch
| Branch | True | False | Total |
| if (!initialized) { return; } |
0 |
0 |
0 |
|
| 1053 |
0 |
| (void) sv_2mortal(SvREFCNT_inc(interpsv)); |
| 1054 |
0 |
| PUTBACK; |
| 1055 |
0 |
| Tcl_ResetResult(interp); |
| 1056 |
|
| /* sv_mortalcopy here prevents stringifying script - necessary ?? */ |
| 1057 |
0 |
| cscript = SvPV(sv_mortalcopy(script), length); |
| 1058 |
0 |
▶ | if (Tcl_EvalEx(interp, cscript, length, flags) != TCL_OK) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (Tcl_EvalEx(interp, cscript, length, flags) != TCL_OK) { |
0 |
0 |
0 |
|
| 1059 |
0 |
| croak(Tcl_GetStringResult(interp)); |
| 1060 |
|
| } |
| 1061 |
0 |
| prepare_Tcl_result(aTHX_ interp, "Tcl::Eval"); |
| 1062 |
0 |
| SPAGAIN; |
| 1063 |
|
| |
| 1064 |
|
| #ifdef HAVE_TKINIT |
| 1065 |
|
| |
| 1066 |
|
| char* |
| 1067 |
|
| Tcl_SetPreInitScript(script) |
| 1068 |
|
| char * script |
| 1069 |
|
| CODE: |
| 1070 |
|
| if (!initialized) { return; } |
| 1071 |
|
| RETVAL = TclSetPreInitScript(script); |
| 1072 |
|
| OUTPUT: |
| 1073 |
|
| RETVAL |
| 1074 |
|
| |
| 1075 |
|
| void |
| 1076 |
|
| TclpInitLibraryPath(path) |
| 1077 |
|
| char * path |
| 1078 |
|
| PPCODE: |
| 1079 |
|
| int lengthPtr=0; |
| 1080 |
|
| Tcl_Encoding encodingPtr; |
| 1081 |
|
| |
| 1082 |
|
| if (!initialized) { return; } |
| 1083 |
|
| /* interface to TclpInitLibraryPath changed between 8.4.x and 8.5.x */ |
| 1084 |
|
| TclpInitLibraryPath(&path, &lengthPtr, &encodingPtr); |
| 1085 |
|
| |
| 1086 |
|
| void |
| 1087 |
|
| Tcl_SetDefaultEncodingDir(script) |
| 1088 |
|
| char * script |
| 1089 |
|
| PPCODE: |
| 1090 |
|
| if (!initialized) { return; } |
| 1091 |
|
| Tcl_SetDefaultEncodingDir(script); |
| 1092 |
|
| |
| 1093 |
|
| char* |
| 1094 |
|
| Tcl_GetDefaultEncodingDir(void) |
| 1095 |
|
| CODE: |
| 1096 |
|
| if (!initialized) { return; } |
| 1097 |
|
| RETVAL = Tcl_GetDefaultEncodingDir(); |
| 1098 |
|
| OUTPUT: |
| 1099 |
|
| RETVAL |
| 1100 |
|
| |
| 1101 |
|
| void* |
| 1102 |
|
| Tcl_GetEncoding(interp, enc) |
| 1103 |
|
| Tcl interp |
| 1104 |
|
| char *enc |
| 1105 |
|
| PPCODE: |
| 1106 |
|
| if (!initialized) { return; } |
| 1107 |
|
| Tcl_GetEncoding(interp,enc); |
| 1108 |
|
| |
| 1109 |
|
| #endif /* HAVE_TKINIT */ |
| 1110 |
|
| |
| 1111 |
|
| void |
| 1112 |
|
| Tcl_EvalFile(interp, filename) |
| 1113 |
|
| Tcl interp |
| 1114 |
|
| char * filename |
| 1115 |
|
| SV * interpsv = ST(0); |
| 1116 |
|
| PPCODE: |
| 1117 |
0 |
▶ | if (!initialized) { return; } |
Branch: 1 branch
| Branch | True | False | Total |
| if (!initialized) { return; } |
0 |
0 |
0 |
|
| 1118 |
0 |
| (void) sv_2mortal(SvREFCNT_inc(interpsv)); |
| 1119 |
0 |
| PUTBACK; |
| 1120 |
0 |
| Tcl_ResetResult(interp); |
| 1121 |
0 |
▶ | if (Tcl_EvalFile(interp, filename) != TCL_OK) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (Tcl_EvalFile(interp, filename) != TCL_OK) { |
0 |
0 |
0 |
|
| 1122 |
0 |
| croak(Tcl_GetStringResult(interp)); |
| 1123 |
|
| } |
| 1124 |
0 |
| prepare_Tcl_result(aTHX_ interp, "Tcl::EvalFile"); |
| 1125 |
0 |
| SPAGAIN; |
| 1126 |
|
| |
| 1127 |
|
| void |
| 1128 |
|
| Tcl_EvalFileHandle(interp, handle) |
| 1129 |
|
| Tcl interp |
| 1130 |
|
| PerlIO* handle |
| 1131 |
|
| int append = 0; |
| 1132 |
|
| SV * interpsv = ST(0); |
| 1133 |
|
| SV * sv = sv_newmortal(); |
| 1134 |
|
| char * s = NO_INIT |
| 1135 |
|
| PPCODE: |
| 1136 |
0 |
▶ | if (!initialized) { return; } |
Branch: 1 branch
| Branch | True | False | Total |
| if (!initialized) { return; } |
0 |
0 |
0 |
|
| 1137 |
0 |
| (void) sv_2mortal(SvREFCNT_inc(interpsv)); |
| 1138 |
0 |
| PUTBACK; |
| 1139 |
0 |
▶ | while ((s = sv_gets(sv, handle, append))) |
Branch: 1 branch
| Branch | True | False | Total |
| while ((s = sv_gets(sv, handle, append))) |
0 |
0 |
0 |
|
| 1140 |
|
| { |
| 1141 |
0 |
▶ | if (!Tcl_CommandComplete(s)) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!Tcl_CommandComplete(s)) |
0 |
0 |
0 |
|
| 1142 |
0 |
| append = 1; |
| 1143 |
|
| else |
| 1144 |
|
| { |
| 1145 |
0 |
| Tcl_ResetResult(interp); |
| 1146 |
0 |
▶ | if (Tcl_Eval(interp, s) != TCL_OK) |
Branch: 1 branch
| Branch | True | False | Total |
| if (Tcl_Eval(interp, s) != TCL_OK) |
0 |
0 |
0 |
|
| 1147 |
0 |
| croak(Tcl_GetStringResult(interp)); |
| 1148 |
0 |
| append = 0; |
| 1149 |
|
| } |
| 1150 |
|
| } |
| 1151 |
0 |
▶ | if (append) |
Branch: 1 branch
| Branch | True | False | Total |
| if (append) |
0 |
0 |
0 |
|
| 1152 |
0 |
| croak("unexpected end of file in Tcl::EvalFileHandle"); |
| 1153 |
0 |
| prepare_Tcl_result(aTHX_ interp, "Tcl::EvalFileHandle"); |
| 1154 |
0 |
| SPAGAIN; |
| 1155 |
|
| |
| 1156 |
|
| void |
| 1157 |
|
| Tcl_invoke(interp, sv, ...) |
| 1158 |
|
| Tcl interp |
| 1159 |
|
| SV * sv |
| 1160 |
|
| PPCODE: |
| 1161 |
|
| { |
| 1162 |
|
| /* |
| 1163 |
|
| * 'Tcl::invoke' invokes the command directly, avoiding |
| 1164 |
|
| * command tracing and the ::unknown mechanism. |
| 1165 |
|
| */ |
| 1166 |
|
| #define NUM_OBJS 16 |
| 1167 |
|
| Tcl_Obj *baseobjv[NUM_OBJS]; |
| 1168 |
0 |
| Tcl_Obj **objv = baseobjv; |
| 1169 |
|
| char *cmdName; |
| 1170 |
|
| int objc, i, result; |
| 1171 |
|
| STRLEN length; |
| 1172 |
|
| Tcl_CmdInfo cmdinfo; |
| 1173 |
|
| |
| 1174 |
0 |
▶ | if (!initialized) { return; } |
Branch: 1 branch
| Branch | True | False | Total |
| if (!initialized) { return; } |
0 |
0 |
0 |
|
| 1175 |
|
| |
| 1176 |
0 |
| objv = baseobjv; |
| 1177 |
0 |
| objc = items-1; |
| 1178 |
0 |
▶ | if (objc > NUM_OBJS) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (objc > NUM_OBJS) { |
0 |
0 |
0 |
|
| 1179 |
0 |
| New(666, objv, objc, Tcl_Obj *); |
| 1180 |
|
| } |
| 1181 |
|
| |
| 1182 |
0 |
| SP += items; |
| 1183 |
0 |
| PUTBACK; |
| 1184 |
|
| |
| 1185 |
|
| /* Verify first arg is a Tcl command */ |
| 1186 |
0 |
| cmdName = SvPV(sv, length); |
| 1187 |
0 |
▶ | if (!Tcl_GetCommandInfo(interp, cmdName, &cmdinfo)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!Tcl_GetCommandInfo(interp, cmdName, &cmdinfo)) { |
0 |
0 |
0 |
|
| 1188 |
0 |
| croak("Tcl procedure '%s' not found", cmdName); |
| 1189 |
|
| } |
| 1190 |
|
| |
| 1191 |
0 |
▶ | if (cmdinfo.objProc && cmdinfo.isNativeObjectProc) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (cmdinfo.objProc && cmdinfo.isNativeObjectProc) { |
0 |
0 |
0 |
| if (cmdinfo.objProc && cmdinfo.isNativeObjectProc) { |
0 |
0 |
0 |
|
| 1192 |
|
| /* |
| 1193 |
|
| * We might want to check that this isn't |
| 1194 |
|
| * TclInvokeStringCommand, which just means we waste time |
| 1195 |
|
| * making Tcl_Obj's. |
| 1196 |
|
| * |
| 1197 |
|
| * Emulate TclInvokeObjectCommand (from Tcl), namely create the |
| 1198 |
|
| * object argument array "objv" before calling right procedure |
| 1199 |
|
| */ |
| 1200 |
0 |
| objv[0] = Tcl_NewStringObj(cmdName, length); |
| 1201 |
0 |
| Tcl_IncrRefCount(objv[0]); |
| 1202 |
0 |
▶ | for (i = 1; i < objc; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 1; i < objc; i++) { |
0 |
0 |
0 |
|
| 1203 |
|
| /* |
| 1204 |
|
| * Use efficient Sv to Tcl_Obj conversion. |
| 1205 |
|
| * This returns Tcl_Obj with refcount 1. |
| 1206 |
|
| * This can cause recursive calls if we have tied vars. |
| 1207 |
|
| */ |
| 1208 |
0 |
| objv[i] = TclObjFromSv(aTHX_ sv_mortalcopy(ST(i+1))); |
| 1209 |
0 |
| Tcl_IncrRefCount(objv[i]); |
| 1210 |
|
| } |
| 1211 |
0 |
| SP -= items; |
| 1212 |
0 |
| PUTBACK; |
| 1213 |
|
| |
| 1214 |
|
| /* |
| 1215 |
|
| * Result interp result and invoke the command's object-based |
| 1216 |
|
| * Tcl_ObjCmdProc. |
| 1217 |
|
| */ |
| 1218 |
|
| #if DEBUG_REFCOUNTS |
| 1219 |
|
| for (i = 1; i < objc; i++) { check_refcounts(objv[i]); } |
| 1220 |
|
| #endif |
| 1221 |
0 |
| Tcl_ResetResult(interp); |
| 1222 |
0 |
| result = (*cmdinfo.objProc)(cmdinfo.objClientData, interp, |
| 1223 |
|
| objc, objv); |
| 1224 |
|
| |
| 1225 |
|
| /* |
| 1226 |
|
| * Decrement ref count for first arg, others decr'd below |
| 1227 |
|
| */ |
| 1228 |
0 |
▶ | Tcl_DecrRefCount(objv[0]); |
Branch: 1 branch
| Branch | True | False | Total |
| Tcl_DecrRefCount(objv[0]); |
0 |
0 |
0 |
|
| 1229 |
|
| } |
| 1230 |
|
| else { |
| 1231 |
|
| /* |
| 1232 |
|
| * we have cmdinfo.objProc==0 |
| 1233 |
|
| * prepare string arguments into argv (1st is already done) |
| 1234 |
|
| * and call found procedure |
| 1235 |
|
| */ |
| 1236 |
|
| char *baseargv[NUM_OBJS]; |
| 1237 |
0 |
| char **argv = baseargv; |
| 1238 |
|
| |
| 1239 |
0 |
▶ | if (objc > NUM_OBJS) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (objc > NUM_OBJS) { |
0 |
0 |
0 |
|
| 1240 |
0 |
| New(666, argv, objc, char *); |
| 1241 |
|
| } |
| 1242 |
|
| |
| 1243 |
0 |
| argv[0] = cmdName; |
| 1244 |
0 |
▶ | for (i = 1; i < objc; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 1; i < objc; i++) { |
0 |
0 |
0 |
|
| 1245 |
|
| /* |
| 1246 |
|
| * We need the inefficient round-trip through Tcl_Obj to |
| 1247 |
|
| * ensure that we are listify-ing correctly. |
| 1248 |
|
| * This can cause recursive calls if we have tied vars. |
| 1249 |
|
| */ |
| 1250 |
0 |
| objv[i] = TclObjFromSv(aTHX_ sv_mortalcopy(ST(i+1))); |
| 1251 |
0 |
| Tcl_IncrRefCount(objv[i]); |
| 1252 |
0 |
| argv[i] = Tcl_GetString(objv[i]); |
| 1253 |
|
| } |
| 1254 |
0 |
| SP -= items; |
| 1255 |
0 |
| PUTBACK; |
| 1256 |
|
| |
| 1257 |
|
| /* |
| 1258 |
|
| * Result interp result and invoke the command's string-based |
| 1259 |
|
| * procedure. |
| 1260 |
|
| */ |
| 1261 |
|
| #if DEBUG_REFCOUNTS |
| 1262 |
|
| for (i = 1; i < objc; i++) { check_refcounts(objv[i]); } |
| 1263 |
|
| #endif |
| 1264 |
0 |
| Tcl_ResetResult(interp); |
| 1265 |
0 |
| result = (*cmdinfo.proc)(cmdinfo.clientData, interp, |
| 1266 |
|
| objc, argv); |
| 1267 |
|
| |
| 1268 |
0 |
▶ | if (argv != baseargv) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (argv != baseargv) { |
0 |
0 |
0 |
|
| 1269 |
0 |
| Safefree(argv); |
| 1270 |
|
| } |
| 1271 |
|
| } |
| 1272 |
|
| |
| 1273 |
|
| /* |
| 1274 |
|
| * Decrement the ref counts for the argument objects created above |
| 1275 |
|
| */ |
| 1276 |
0 |
▶ | for (i = 1; i < objc; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 1; i < objc; i++) { |
0 |
0 |
0 |
|
| 1277 |
0 |
▶ | Tcl_DecrRefCount(objv[i]); |
Branch: 1 branch
| Branch | True | False | Total |
| Tcl_DecrRefCount(objv[i]); |
0 |
0 |
0 |
|
| 1278 |
|
| } |
| 1279 |
|
| |
| 1280 |
0 |
▶ | if (result != TCL_OK) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (result != TCL_OK) { |
0 |
0 |
0 |
|
| 1281 |
0 |
| croak(Tcl_GetStringResult(interp)); |
| 1282 |
|
| } |
| 1283 |
0 |
| prepare_Tcl_result(aTHX_ interp, "Tcl::invoke"); |
| 1284 |
|
| |
| 1285 |
0 |
▶ | if (objv != baseobjv) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (objv != baseobjv) { |
0 |
0 |
0 |
|
| 1286 |
0 |
| Safefree(objv); |
| 1287 |
|
| } |
| 1288 |
0 |
| SPAGAIN; |
| 1289 |
|
| #undef NUM_OBJS |
| 1290 |
|
| } |
| 1291 |
|
| |
| 1292 |
|
| |
| 1293 |
|
| void |
| 1294 |
|
| Tcl_icall(interp, sv, ...) |
| 1295 |
|
| Tcl interp |
| 1296 |
|
| SV * sv |
| 1297 |
|
| PPCODE: |
| 1298 |
|
| { |
| 1299 |
|
| /* |
| 1300 |
|
| * 'Tcl::icall' passes the args to Tcl to invoke. It will do |
| 1301 |
|
| * command tracing and call ::unknown mechanism for unrecognized |
| 1302 |
|
| * commands. |
| 1303 |
|
| */ |
| 1304 |
|
| #define NUM_OBJS 16 |
| 1305 |
|
| Tcl_Obj *baseobjv[NUM_OBJS]; |
| 1306 |
0 |
| Tcl_Obj **objv = baseobjv; |
| 1307 |
|
| int objc, i, result; |
| 1308 |
|
| |
| 1309 |
0 |
▶ | if (!initialized) { return; } |
Branch: 1 branch
| Branch | True | False | Total |
| if (!initialized) { return; } |
0 |
0 |
0 |
|
| 1310 |
|
| |
| 1311 |
0 |
| objc = items-1; |
| 1312 |
0 |
▶ | if (objc > NUM_OBJS) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (objc > NUM_OBJS) { |
0 |
0 |
0 |
|
| 1313 |
0 |
| New(666, objv, objc, Tcl_Obj *); |
| 1314 |
|
| } |
| 1315 |
|
| |
| 1316 |
0 |
| SP += items; |
| 1317 |
0 |
| PUTBACK; |
| 1318 |
0 |
▶ | for (i = 0; i < objc; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < objc; i++) { |
0 |
0 |
0 |
|
| 1319 |
|
| /* |
| 1320 |
|
| * Use efficient Sv to Tcl_Obj conversion. |
| 1321 |
|
| * This returns Tcl_Obj with refcount 1. |
| 1322 |
|
| * This can cause recursive calls if we have tied vars. |
| 1323 |
|
| */ |
| 1324 |
0 |
| objv[i] = TclObjFromSv(aTHX_ sv_mortalcopy(ST(i+1))); |
| 1325 |
0 |
| Tcl_IncrRefCount(objv[i]); |
| 1326 |
|
| } |
| 1327 |
0 |
| SP -= items; |
| 1328 |
0 |
| PUTBACK; |
| 1329 |
|
| |
| 1330 |
|
| /* |
| 1331 |
|
| * Reset current result and invoke using Tcl_EvalObjv. |
| 1332 |
|
| * This will trigger command traces and handle async signals. |
| 1333 |
|
| */ |
| 1334 |
|
| #if DEBUG_REFCOUNTS |
| 1335 |
|
| for (i = 1; i < objc; i++) { check_refcounts(objv[i]); } |
| 1336 |
|
| #endif |
| 1337 |
0 |
| Tcl_ResetResult(interp); |
| 1338 |
0 |
| result = Tcl_EvalObjv(interp, objc, objv, 0); |
| 1339 |
|
| |
| 1340 |
|
| /* |
| 1341 |
|
| * Decrement the ref counts for the argument objects created above |
| 1342 |
|
| */ |
| 1343 |
0 |
▶ | for (i = 0; i < objc; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < objc; i++) { |
0 |
0 |
0 |
|
| 1344 |
0 |
▶ | Tcl_DecrRefCount(objv[i]); |
Branch: 1 branch
| Branch | True | False | Total |
| Tcl_DecrRefCount(objv[i]); |
0 |
0 |
0 |
|
| 1345 |
|
| } |
| 1346 |
|
| |
| 1347 |
0 |
▶ | if (result != TCL_OK) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (result != TCL_OK) { |
0 |
0 |
0 |
|
| 1348 |
0 |
| croak(Tcl_GetStringResult(interp)); |
| 1349 |
|
| } |
| 1350 |
0 |
| prepare_Tcl_result(aTHX_ interp, "Tcl::icall"); |
| 1351 |
|
| |
| 1352 |
0 |
▶ | if (objv != baseobjv) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (objv != baseobjv) { |
0 |
0 |
0 |
|
| 1353 |
0 |
| Safefree(objv); |
| 1354 |
|
| } |
| 1355 |
0 |
| SPAGAIN; |
| 1356 |
|
| #undef NUM_OBJS |
| 1357 |
|
| } |
| 1358 |
|
| |
| 1359 |
|
| |
| 1360 |
|
| void |
| 1361 |
|
| Tcl_DESTROY(interp) |
| 1362 |
|
| Tcl interp |
| 1363 |
|
| CODE: |
| 1364 |
0 |
▶ | if (initialized) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (initialized) { |
0 |
0 |
0 |
|
| 1365 |
0 |
| Tcl_DeleteInterp(interp); |
| 1366 |
|
| /* |
| 1367 |
|
| * Remove from the global hash of live interps. |
| 1368 |
|
| */ |
| 1369 |
0 |
▶ | if (hvInterps) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (hvInterps) { |
0 |
0 |
0 |
|
| 1370 |
0 |
| (void) hv_delete(hvInterps, (const char *) interp, |
| 1371 |
|
| sizeof(Tcl), G_DISCARD); |
| 1372 |
|
| } |
| 1373 |
|
| } |
| 1374 |
|
| |
| 1375 |
|
| void |
| 1376 |
|
| Tcl__Finalize(interp=NULL) |
| 1377 |
|
| Tcl interp |
| 1378 |
|
| CODE: |
| 1379 |
|
| /* |
| 1380 |
|
| * This should be called from the END block - when we no |
| 1381 |
|
| * longer plan to use Tcl *AT ALL*. |
| 1382 |
|
| */ |
| 1383 |
12 |
▶ | if (!initialized) { return; } |
Branch: 1 branch
| Branch | True | False | Total |
| if (!initialized) { return; } |
12 |
0 |
12 |
|
| 1384 |
0 |
▶ | if (hvInterps) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (hvInterps) { |
0 |
0 |
0 |
|
| 1385 |
|
| /* |
| 1386 |
|
| * Delete all the global hash of live interps. |
| 1387 |
|
| */ |
| 1388 |
|
| HE *he; |
| 1389 |
|
| |
| 1390 |
0 |
| hv_iterinit(hvInterps); |
| 1391 |
0 |
| he = hv_iternext(hvInterps); |
| 1392 |
0 |
▶ | while (he) { |
Branch: 1 branch
| Branch | True | False | Total |
| while (he) { |
0 |
0 |
0 |
|
| 1393 |
|
| I32 len; |
| 1394 |
0 |
| interp = *((Tcl *) hv_iterkey(he, &len)); |
| 1395 |
0 |
| Tcl_DeleteInterp(interp); |
| 1396 |
0 |
| he = hv_iternext(hvInterps); |
| 1397 |
|
| } |
| 1398 |
0 |
| hv_undef(hvInterps); |
| 1399 |
0 |
| hvInterps = NULL; |
| 1400 |
|
| } |
| 1401 |
|
| #ifdef USE_TCL_STUBS |
| 1402 |
0 |
▶ | if (g_Interp) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (g_Interp) { |
0 |
0 |
0 |
|
| 1403 |
0 |
| Tcl_DeleteInterp(g_Interp); |
| 1404 |
0 |
| g_Interp = NULL; |
| 1405 |
|
| } |
| 1406 |
|
| #endif |
| 1407 |
0 |
| initialized = 0; |
| 1408 |
0 |
| Tcl_Finalize(); |
| 1409 |
|
| #ifdef USE_TCL_STUBS |
| 1410 |
0 |
▶ | if (tclHandle) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (tclHandle) { |
0 |
0 |
0 |
|
| 1411 |
0 |
| dlclose(tclHandle); |
| 1412 |
0 |
| tclHandle = NULL; |
| 1413 |
|
| } |
| 1414 |
|
| #endif |
| 1415 |
|
| |
| 1416 |
|
| |
| 1417 |
|
| void |
| 1418 |
|
| Tcl_Init(interp) |
| 1419 |
|
| Tcl interp |
| 1420 |
|
| CODE: |
| 1421 |
0 |
▶ | if (!initialized) { return; } |
Branch: 1 branch
| Branch | True | False | Total |
| if (!initialized) { return; } |
0 |
0 |
0 |
|
| 1422 |
0 |
▶ | if (tclKit_AppInit(interp) != TCL_OK) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (tclKit_AppInit(interp) != TCL_OK) { |
0 |
0 |
0 |
|
| 1423 |
0 |
| croak(Tcl_GetStringResult(interp)); |
| 1424 |
|
| } |
| 1425 |
|
| |
| 1426 |
|
| #ifdef HAVE_DDEINIT |
| 1427 |
|
| |
| 1428 |
|
| void |
| 1429 |
|
| Dde_Init(interp) |
| 1430 |
|
| Tcl interp |
| 1431 |
|
| CODE: |
| 1432 |
|
| Dde_Init(interp); |
| 1433 |
|
| |
| 1434 |
|
| #endif |
| 1435 |
|
| |
| 1436 |
|
| #ifdef HAVE_TKINIT |
| 1437 |
|
| |
| 1438 |
|
| void |
| 1439 |
|
| Tk_Init(interp) |
| 1440 |
|
| Tcl interp |
| 1441 |
|
| CODE: |
| 1442 |
|
| Tk_Init(interp); |
| 1443 |
|
| |
| 1444 |
|
| #endif |
| 1445 |
|
| |
| 1446 |
|
| #ifdef HAVE_TIXINIT |
| 1447 |
|
| |
| 1448 |
|
| void |
| 1449 |
|
| Tix_Init(interp) |
| 1450 |
|
| Tcl interp |
| 1451 |
|
| CODE: |
| 1452 |
|
| Tix_Init(interp); |
| 1453 |
|
| |
| 1454 |
|
| #endif |
| 1455 |
|
| |
| 1456 |
|
| #ifdef HAVE_BLTINIT |
| 1457 |
|
| |
| 1458 |
|
| void |
| 1459 |
|
| Blt_Init(interp) |
| 1460 |
|
| Tcl interp |
| 1461 |
|
| CODE: |
| 1462 |
|
| Blt_Init(interp); |
| 1463 |
|
| |
| 1464 |
|
| void |
| 1465 |
|
| Blt_StaticPackage(interp) |
| 1466 |
|
| Tcl interp |
| 1467 |
|
| PPCODE: |
| 1468 |
|
| Tcl_StaticPackage(interp, "BLT", Blt_Init, Blt_SafeInit); |
| 1469 |
|
| |
| 1470 |
|
| #endif |
| 1471 |
|
| |
| 1472 |
|
| #ifdef HAVE_MEMCHANINIT |
| 1473 |
|
| |
| 1474 |
|
| void |
| 1475 |
|
| Memchan_Init(interp) |
| 1476 |
|
| Tcl interp |
| 1477 |
|
| CODE: |
| 1478 |
|
| Memchan_Init(interp); |
| 1479 |
|
| |
| 1480 |
|
| #endif |
| 1481 |
|
| |
| 1482 |
|
| #ifdef HAVE_TRFINIT |
| 1483 |
|
| |
| 1484 |
|
| void |
| 1485 |
|
| Trf_Init(interp) |
| 1486 |
|
| Tcl interp |
| 1487 |
|
| CODE: |
| 1488 |
|
| Trf_Init(interp); |
| 1489 |
|
| |
| 1490 |
|
| #endif |
| 1491 |
|
| |
| 1492 |
|
| #ifdef HAVE_VFSINIT |
| 1493 |
|
| |
| 1494 |
|
| void |
| 1495 |
|
| Vfs_Init(interp) |
| 1496 |
|
| Tcl interp |
| 1497 |
|
| CODE: |
| 1498 |
|
| Vfs_Init(interp); |
| 1499 |
|
| |
| 1500 |
|
| #endif |
| 1501 |
|
| |
| 1502 |
|
| int |
| 1503 |
|
| Tcl_DoOneEvent(interp, flags) |
| 1504 |
|
| Tcl interp |
| 1505 |
|
| int flags |
| 1506 |
|
| CODE: |
| 1507 |
0 |
▶ | RETVAL = initialized ? Tcl_DoOneEvent(flags) : 0; |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL = initialized ? Tcl_DoOneEvent(flags) : 0; |
0 |
0 |
0 |
| RETVAL = initialized ? Tcl_DoOneEvent(flags) : 0; |
0 |
0 |
0 |
|
| 1508 |
|
| OUTPUT: |
| 1509 |
|
| RETVAL |
| 1510 |
|
| |
| 1511 |
|
| void |
| 1512 |
|
| Tcl_CreateCommand(interp,cmdName,cmdProc,clientData=&PL_sv_undef,deleteProc=&PL_sv_undef,flags=0) |
| 1513 |
|
| Tcl interp |
| 1514 |
|
| char * cmdName |
| 1515 |
|
| SV * cmdProc |
| 1516 |
|
| SV * clientData |
| 1517 |
|
| SV * deleteProc |
| 1518 |
|
| int flags |
| 1519 |
|
| CODE: |
| 1520 |
0 |
▶ | if (!initialized) { return; } |
Branch: 1 branch
| Branch | True | False | Total |
| if (!initialized) { return; } |
0 |
0 |
0 |
|
| 1521 |
0 |
▶ | if (SvIOK(cmdProc)) |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvIOK(cmdProc)) |
0 |
0 |
0 |
|
| 1522 |
0 |
| Tcl_CreateCommand(interp, cmdName, (Tcl_CmdProc *) SvIV(cmdProc), |
| 1523 |
0 |
| INT2PTR(ClientData, SvIV(clientData)), NULL); |
| 1524 |
|
| else { |
| 1525 |
0 |
| AV *av = (AV *) SvREFCNT_inc((SV *) newAV()); |
| 1526 |
0 |
| av_store(av, 0, newSVsv(cmdProc)); |
| 1527 |
0 |
| av_store(av, 1, newSVsv(clientData)); |
| 1528 |
0 |
| av_store(av, 2, newSVsv(ST(0))); |
| 1529 |
0 |
| av_store(av, 3, newSViv(flags)); |
| 1530 |
0 |
▶ | if (SvOK(deleteProc)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(deleteProc)) { |
0 |
0 |
0 |
|
| 1531 |
0 |
| av_store(av, 4, newSVsv(deleteProc)); |
| 1532 |
|
| } |
| 1533 |
0 |
| Tcl_CreateObjCommand(interp, cmdName, Tcl_PerlCallWrapper, |
| 1534 |
|
| (ClientData) av, Tcl_PerlCallDeleteProc); |
| 1535 |
|
| } |
| 1536 |
0 |
| ST(0) = &PL_sv_yes; |
| 1537 |
0 |
| XSRETURN(1); |
| 1538 |
|
| |
| 1539 |
|
| void |
| 1540 |
|
| Tcl_SetResult(interp, sv) |
| 1541 |
|
| Tcl interp |
| 1542 |
|
| SV * sv |
| 1543 |
|
| CODE: |
| 1544 |
0 |
▶ | if (!initialized) { return; } |
Branch: 1 branch
| Branch | True | False | Total |
| if (!initialized) { return; } |
0 |
0 |
0 |
|
| 1545 |
|
| { |
| 1546 |
0 |
| Tcl_Obj *objPtr = TclObjFromSv(aTHX_ sv); |
| 1547 |
|
| /* Tcl_SetObjResult will incr refcount */ |
| 1548 |
0 |
| Tcl_SetObjResult(interp, objPtr); |
| 1549 |
0 |
| ST(0) = ST(1); |
| 1550 |
0 |
| XSRETURN(1); |
| 1551 |
|
| } |
| 1552 |
|
| |
| 1553 |
|
| void |
| 1554 |
|
| Tcl_AppendElement(interp, str) |
| 1555 |
|
| Tcl interp |
| 1556 |
|
| char * str |
| 1557 |
|
| |
| 1558 |
|
| void |
| 1559 |
|
| Tcl_ResetResult(interp) |
| 1560 |
|
| Tcl interp |
| 1561 |
|
| |
| 1562 |
|
| SV * |
| 1563 |
|
| Tcl_AppendResult(interp, ...) |
| 1564 |
|
| Tcl interp |
| 1565 |
|
| int i = NO_INIT |
| 1566 |
|
| CODE: |
| 1567 |
0 |
▶ | if (initialized) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (initialized) { |
0 |
0 |
0 |
|
| 1568 |
0 |
| Tcl_Obj *objPtr = Tcl_GetObjResult(interp); |
| 1569 |
0 |
▶ | for (i = 1; i < items; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 1; i < items; i++) { |
0 |
0 |
0 |
|
| 1570 |
0 |
| Tcl_AppendObjToObj(objPtr, TclObjFromSv(aTHX_ ST(i))); |
| 1571 |
|
| } |
| 1572 |
0 |
| RETVAL = SvFromTclObj(aTHX_ objPtr); |
| 1573 |
|
| } else { |
| 1574 |
0 |
| RETVAL = &PL_sv_undef; |
| 1575 |
|
| } |
| 1576 |
|
| OUTPUT: |
| 1577 |
|
| RETVAL |
| 1578 |
|
| |
| 1579 |
|
| SV * |
| 1580 |
|
| Tcl_DeleteCommand(interp, cmdName) |
| 1581 |
|
| Tcl interp |
| 1582 |
|
| char * cmdName |
| 1583 |
|
| CODE: |
| 1584 |
0 |
▶ | RETVAL = boolSV(initialized ? Tcl_DeleteCommand(interp, cmdName) == TCL_OK:TRUE); |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL = boolSV(initialized ? Tcl_DeleteCommand(interp, cmdName) == TCL_OK:TRUE); |
0 |
0 |
0 |
| RETVAL = boolSV(initialized ? Tcl_DeleteCommand(interp, cmdName) == TCL_OK:TRUE); |
0 |
0 |
0 |
|
| 1585 |
|
| OUTPUT: |
| 1586 |
|
| RETVAL |
| 1587 |
|
| |
| 1588 |
|
| void |
| 1589 |
|
| Tcl_SplitList(interp, str) |
| 1590 |
|
| Tcl interp |
| 1591 |
|
| char * str |
| 1592 |
|
| int argc = NO_INIT |
| 1593 |
|
| char ** argv = NO_INIT |
| 1594 |
|
| char ** tofree = NO_INIT |
| 1595 |
|
| PPCODE: |
| 1596 |
0 |
▶ | if (Tcl_SplitList(interp, str, &argc, &argv) == TCL_OK) |
Branch: 1 branch
| Branch | True | False | Total |
| if (Tcl_SplitList(interp, str, &argc, &argv) == TCL_OK) |
0 |
0 |
0 |
|
| 1597 |
|
| { |
| 1598 |
0 |
| tofree = argv; |
| 1599 |
0 |
▶ | EXTEND(sp, argc); |
Branch: 2 branches
| Branch | True | False | Total |
| EXTEND(sp, argc); |
0 |
0 |
0 |
| EXTEND(sp, argc); |
0 |
0 |
0 |
|
| 1600 |
0 |
▶ | while (argc--) |
Branch: 1 branch
| Branch | True | False | Total |
| while (argc--) |
0 |
0 |
0 |
|
| 1601 |
0 |
| PUSHs(sv_2mortal(newSVpv(*argv++, 0))); |
| 1602 |
0 |
| ckfree((char *) tofree); |
| 1603 |
|
| } |
| 1604 |
|
| |
| 1605 |
|
| SV * |
| 1606 |
|
| Tcl_SetVar(interp, varname, value, flags = 0) |
| 1607 |
|
| Tcl interp |
| 1608 |
|
| char * varname |
| 1609 |
|
| SV * value |
| 1610 |
|
| int flags |
| 1611 |
|
| CODE: |
| 1612 |
0 |
| RETVAL = SvFromTclObj(aTHX_ Tcl_SetVar2Ex(interp, varname, NULL, |
| 1613 |
|
| TclObjFromSv(aTHX_ value), flags)); |
| 1614 |
|
| OUTPUT: |
| 1615 |
|
| RETVAL |
| 1616 |
|
| |
| 1617 |
|
| SV * |
| 1618 |
|
| Tcl_SetVar2(interp, varname1, varname2, value, flags = 0) |
| 1619 |
|
| Tcl interp |
| 1620 |
|
| char * varname1 |
| 1621 |
|
| char * varname2 |
| 1622 |
|
| SV * value |
| 1623 |
|
| int flags |
| 1624 |
|
| CODE: |
| 1625 |
0 |
| RETVAL = SvFromTclObj(aTHX_ Tcl_SetVar2Ex(interp, varname1, varname2, |
| 1626 |
|
| TclObjFromSv(aTHX_ value), flags)); |
| 1627 |
|
| OUTPUT: |
| 1628 |
|
| RETVAL |
| 1629 |
|
| |
| 1630 |
|
| SV * |
| 1631 |
|
| Tcl_GetVar(interp, varname, flags = 0) |
| 1632 |
|
| Tcl interp |
| 1633 |
|
| char * varname |
| 1634 |
|
| int flags |
| 1635 |
|
| CODE: |
| 1636 |
0 |
| RETVAL = SvFromTclObj(aTHX_ Tcl_GetVar2Ex(interp, varname, NULL, flags)); |
| 1637 |
|
| OUTPUT: |
| 1638 |
|
| RETVAL |
| 1639 |
|
| |
| 1640 |
|
| SV * |
| 1641 |
|
| Tcl_GetVar2(interp, varname1, varname2, flags = 0) |
| 1642 |
|
| Tcl interp |
| 1643 |
|
| char * varname1 |
| 1644 |
|
| char * varname2 |
| 1645 |
|
| int flags |
| 1646 |
|
| CODE: |
| 1647 |
0 |
| RETVAL = SvFromTclObj(aTHX_ Tcl_GetVar2Ex(interp, varname1, varname2, flags)); |
| 1648 |
|
| OUTPUT: |
| 1649 |
|
| RETVAL |
| 1650 |
|
| |
| 1651 |
|
| SV * |
| 1652 |
|
| Tcl_UnsetVar(interp, varname, flags = 0) |
| 1653 |
|
| Tcl interp |
| 1654 |
|
| char * varname |
| 1655 |
|
| int flags |
| 1656 |
|
| CODE: |
| 1657 |
0 |
▶ | RETVAL = boolSV(Tcl_UnsetVar2(interp, varname, NULL, flags) == TCL_OK); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = boolSV(Tcl_UnsetVar2(interp, varname, NULL, flags) == TCL_OK); |
0 |
0 |
0 |
|
| 1658 |
|
| OUTPUT: |
| 1659 |
|
| RETVAL |
| 1660 |
|
| |
| 1661 |
|
| SV * |
| 1662 |
|
| Tcl_UnsetVar2(interp, varname1, varname2, flags = 0) |
| 1663 |
|
| Tcl interp |
| 1664 |
|
| char * varname1 |
| 1665 |
|
| char * varname2 |
| 1666 |
|
| int flags |
| 1667 |
|
| CODE: |
| 1668 |
0 |
▶ | RETVAL = boolSV(Tcl_UnsetVar2(interp, varname1, varname2, flags) == TCL_OK); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = boolSV(Tcl_UnsetVar2(interp, varname1, varname2, flags) == TCL_OK); |
0 |
0 |
0 |
|
| 1669 |
|
| OUTPUT: |
| 1670 |
|
| RETVAL |
| 1671 |
|
| |
| 1672 |
|
| |
| 1673 |
|
| MODULE = Tcl PACKAGE = Tcl::List |
| 1674 |
|
| |
| 1675 |
|
| SV* |
| 1676 |
|
| as_string(SV* sv,...) |
| 1677 |
|
| PREINIT: |
| 1678 |
|
| Tcl_Obj* objPtr; |
| 1679 |
|
| int len; |
| 1680 |
|
| char *str; |
| 1681 |
|
| CODE: |
| 1682 |
0 |
| objPtr = TclObjFromSv(aTHX_ sv); |
| 1683 |
0 |
| Tcl_IncrRefCount(objPtr); |
| 1684 |
0 |
| str = Tcl_GetStringFromObj(objPtr, &len); |
| 1685 |
0 |
| RETVAL = newSVpvn(str, len); |
| 1686 |
|
| /* should turn on, but let's check this first for efficiency */ |
| 1687 |
0 |
▶ | if (len && has_highbit(str, len)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (len && has_highbit(str, len)) { |
0 |
0 |
0 |
| if (len && has_highbit(str, len)) { |
0 |
0 |
0 |
|
| 1688 |
0 |
| SvUTF8_on(RETVAL); |
| 1689 |
|
| } |
| 1690 |
0 |
▶ | Tcl_DecrRefCount(objPtr); |
Branch: 1 branch
| Branch | True | False | Total |
| Tcl_DecrRefCount(objPtr); |
0 |
0 |
0 |
|
| 1691 |
|
| OUTPUT: |
| 1692 |
|
| RETVAL |
| 1693 |
|
| |
| 1694 |
|
| |
| 1695 |
|
| MODULE = Tcl PACKAGE = Tcl::Var |
| 1696 |
|
| |
| 1697 |
|
| SV * |
| 1698 |
|
| FETCH(av, key = NULL) |
| 1699 |
|
| Tcl::Var av |
| 1700 |
|
| char * key |
| 1701 |
|
| SV * sv = NO_INIT |
| 1702 |
|
| Tcl interp = NO_INIT |
| 1703 |
|
| char * varname1 = NO_INIT |
| 1704 |
|
| int flags = 0; |
| 1705 |
|
| CODE: |
| 1706 |
|
| /* |
| 1707 |
|
| * This handles both hash and scalar fetches. The blessed object |
| 1708 |
|
| * passed in is [$interp, $varname, $flags] ($flags optional). |
| 1709 |
|
| */ |
| 1710 |
0 |
▶ | if (!initialized) { return; } |
Branch: 1 branch
| Branch | True | False | Total |
| if (!initialized) { return; } |
0 |
0 |
0 |
|
| 1711 |
0 |
▶ | if (AvFILL(av) != 1 && AvFILL(av) != 2) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (AvFILL(av) != 1 && AvFILL(av) != 2) { |
0 |
0 |
0 |
| if (AvFILL(av) != 1 && AvFILL(av) != 2) { |
0 |
0 |
0 |
|
| 1712 |
0 |
| croak("bad object passed to Tcl::Var::FETCH"); |
| 1713 |
|
| } |
| 1714 |
0 |
| sv = *av_fetch(av, 0, FALSE); |
| 1715 |
0 |
▶ | if (sv_derived_from(sv, "Tcl")) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (sv_derived_from(sv, "Tcl")) { |
0 |
0 |
0 |
|
| 1716 |
0 |
| IV tmp = SvIV((SV *) SvRV(sv)); |
| 1717 |
0 |
| interp = INT2PTR(Tcl, tmp); |
| 1718 |
|
| } |
| 1719 |
|
| else { |
| 1720 |
0 |
| croak("bad object passed to Tcl::Var::FETCH"); |
| 1721 |
|
| } |
| 1722 |
0 |
▶ | if (AvFILL(av) == 2) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (AvFILL(av) == 2) { |
0 |
0 |
0 |
|
| 1723 |
0 |
| flags = (int) SvIV(*av_fetch(av, 2, FALSE)); |
| 1724 |
|
| } |
| 1725 |
0 |
| varname1 = SvPV_nolen(*av_fetch(av, 1, FALSE)); |
| 1726 |
0 |
| RETVAL = SvFromTclObj(aTHX_ Tcl_GetVar2Ex(interp, varname1, key, flags)); |
| 1727 |
|
| OUTPUT: |
| 1728 |
|
| RETVAL |
| 1729 |
|
| |
| 1730 |
|
| void |
| 1731 |
|
| STORE(av, sv1, sv2 = NULL) |
| 1732 |
|
| Tcl::Var av |
| 1733 |
|
| SV * sv1 |
| 1734 |
|
| SV * sv2 |
| 1735 |
|
| SV * sv = NO_INIT |
| 1736 |
|
| Tcl interp = NO_INIT |
| 1737 |
|
| char * varname1 = NO_INIT |
| 1738 |
|
| Tcl_Obj * objPtr = NO_INIT |
| 1739 |
|
| int flags = 0; |
| 1740 |
|
| CODE: |
| 1741 |
|
| /* |
| 1742 |
|
| * This handles both hash and scalar stores. The blessed object |
| 1743 |
|
| * passed in is [$interp, $varname, $flags] ($flags optional). |
| 1744 |
|
| */ |
| 1745 |
0 |
▶ | if (!initialized) { return; } |
Branch: 1 branch
| Branch | True | False | Total |
| if (!initialized) { return; } |
0 |
0 |
0 |
|
| 1746 |
0 |
▶ | if (AvFILL(av) != 1 && AvFILL(av) != 2) |
Branch: 2 branches
| Branch | True | False | Total |
| if (AvFILL(av) != 1 && AvFILL(av) != 2) |
0 |
0 |
0 |
| if (AvFILL(av) != 1 && AvFILL(av) != 2) |
0 |
0 |
0 |
|
| 1747 |
0 |
| croak("bad object passed to Tcl::Var::STORE"); |
| 1748 |
0 |
| sv = *av_fetch(av, 0, FALSE); |
| 1749 |
0 |
▶ | if (sv_derived_from(sv, "Tcl")) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (sv_derived_from(sv, "Tcl")) { |
0 |
0 |
0 |
|
| 1750 |
0 |
| IV tmp = SvIV((SV *) SvRV(sv)); |
| 1751 |
0 |
| interp = INT2PTR(Tcl, tmp); |
| 1752 |
|
| } |
| 1753 |
|
| else |
| 1754 |
0 |
| croak("bad object passed to Tcl::Var::STORE"); |
| 1755 |
0 |
▶ | if (AvFILL(av) == 2) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (AvFILL(av) == 2) { |
0 |
0 |
0 |
|
| 1756 |
0 |
| flags = (int) SvIV(*av_fetch(av, 2, FALSE)); |
| 1757 |
|
| } |
| 1758 |
0 |
| varname1 = SvPV_nolen(*av_fetch(av, 1, FALSE)); |
| 1759 |
|
| /* |
| 1760 |
|
| * HASH: sv1 == key, sv2 == value |
| 1761 |
|
| * SCALAR: sv1 == value, sv2 NULL |
| 1762 |
|
| * Tcl_SetVar2Ex will incr refcount |
| 1763 |
|
| */ |
| 1764 |
0 |
▶ | if (sv2) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (sv2) { |
0 |
0 |
0 |
|
| 1765 |
0 |
| objPtr = TclObjFromSv(aTHX_ sv2); |
| 1766 |
0 |
| Tcl_SetVar2Ex(interp, varname1, SvPV_nolen(sv1), objPtr, flags); |
| 1767 |
|
| } |
| 1768 |
|
| else { |
| 1769 |
0 |
| objPtr = TclObjFromSv(aTHX_ sv1); |
| 1770 |
0 |
| Tcl_SetVar2Ex(interp, varname1, NULL, objPtr, flags); |
| 1771 |
|
| } |
| 1772 |
|
| |
| 1773 |
|
| MODULE = Tcl PACKAGE = Tcl |
| 1774 |
|
| |
| 1775 |
|
| BOOT: |
| 1776 |
|
| { |
| 1777 |
12 |
| SV *x = GvSV(gv_fetchpv("\030", TRUE, SVt_PV)); /* $^X */ |
| 1778 |
|
| #ifdef USE_TCL_STUBS |
| 1779 |
12 |
▶ | if (NpInitialize(aTHX_ x) == TCL_ERROR) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (NpInitialize(aTHX_ x) == TCL_ERROR) { |
12 |
0 |
12 |
|
| 1780 |
12 |
| croak("Unable to initialize Tcl"); |
| 1781 |
|
| } |
| 1782 |
|
| #else |
| 1783 |
|
| /* Ideally this would be passed the dll instance location. */ |
| 1784 |
|
| Tcl_FindExecutable(x && SvPOK(x) ? SvPV_nolen(x) : NULL); |
| 1785 |
|
| #if defined(HAVE_TKINIT) && defined(WIN32) |
| 1786 |
|
| /* HAVE_TKINIT means we're linking Tk statically with tcl.dll |
| 1787 |
|
| * so we need to perform same initialization as in |
| 1788 |
|
| * tk/win/tkWin32Dll.c |
| 1789 |
|
| * (unless all this goes statically into perl.dll; in this case |
| 1790 |
|
| * handle to perl.dll should be substituted TODO) |
| 1791 |
|
| * -- VKON |
| 1792 |
|
| */ |
| 1793 |
|
| TkWinSetHINSTANCE(_hinst); |
| 1794 |
|
| #endif |
| 1795 |
|
| #endif |
| 1796 |
0 |
| initialized = 1; |
| 1797 |
0 |
| hvInterps = newHV(); |
| 1798 |
|
| } |
| 1799 |
|
| |
| 1800 |
0 |
| tclBooleanTypePtr = Tcl_GetObjType("boolean"); |
| 1801 |
0 |
| tclByteArrayTypePtr = Tcl_GetObjType("bytearray"); |
| 1802 |
0 |
| tclDoubleTypePtr = Tcl_GetObjType("double"); |
| 1803 |
0 |
| tclIntTypePtr = Tcl_GetObjType("int"); |
| 1804 |
0 |
| tclListTypePtr = Tcl_GetObjType("list"); |
| 1805 |
0 |
| tclStringTypePtr = Tcl_GetObjType("string"); |
| 1806 |
0 |
| tclWideIntTypePtr = Tcl_GetObjType("wideInt"); |
| 1807 |
|
| |
| 1808 |
|
| /* set up constant subs */ |
| 1809 |
|
| { |
| 1810 |
0 |
| HV *stash = gv_stashpvn("Tcl", 3, TRUE); |
| 1811 |
0 |
| newCONSTSUB(stash, "OK", newSViv(TCL_OK)); |
| 1812 |
0 |
| newCONSTSUB(stash, "ERROR", newSViv(TCL_ERROR)); |
| 1813 |
0 |
| newCONSTSUB(stash, "RETURN", newSViv(TCL_RETURN)); |
| 1814 |
0 |
| newCONSTSUB(stash, "BREAK", newSViv(TCL_BREAK)); |
| 1815 |
0 |
| newCONSTSUB(stash, "CONTINUE", newSViv(TCL_CONTINUE)); |
| 1816 |
|
| |
| 1817 |
0 |
| newCONSTSUB(stash, "GLOBAL_ONLY", newSViv(TCL_GLOBAL_ONLY)); |
| 1818 |
0 |
| newCONSTSUB(stash, "NAMESPACE_ONLY", newSViv(TCL_NAMESPACE_ONLY)); |
| 1819 |
0 |
| newCONSTSUB(stash, "APPEND_VALUE", newSViv(TCL_APPEND_VALUE)); |
| 1820 |
0 |
| newCONSTSUB(stash, "LIST_ELEMENT", newSViv(TCL_LIST_ELEMENT)); |
| 1821 |
0 |
| newCONSTSUB(stash, "TRACE_READS", newSViv(TCL_TRACE_READS)); |
| 1822 |
0 |
| newCONSTSUB(stash, "TRACE_WRITES", newSViv(TCL_TRACE_WRITES)); |
| 1823 |
0 |
| newCONSTSUB(stash, "TRACE_UNSETS", newSViv(TCL_TRACE_UNSETS)); |
| 1824 |
0 |
| newCONSTSUB(stash, "TRACE_DESTROYED", newSViv(TCL_TRACE_DESTROYED)); |
| 1825 |
0 |
| newCONSTSUB(stash, "INTERP_DESTROYED", newSViv(TCL_INTERP_DESTROYED)); |
| 1826 |
0 |
| newCONSTSUB(stash, "LEAVE_ERR_MSG", newSViv(TCL_LEAVE_ERR_MSG)); |
| 1827 |
0 |
| newCONSTSUB(stash, "TRACE_ARRAY", newSViv(TCL_TRACE_ARRAY)); |
| 1828 |
|
| |
| 1829 |
0 |
| newCONSTSUB(stash, "LINK_INT", newSViv(TCL_LINK_INT)); |
| 1830 |
0 |
| newCONSTSUB(stash, "LINK_DOUBLE", newSViv(TCL_LINK_DOUBLE)); |
| 1831 |
0 |
| newCONSTSUB(stash, "LINK_BOOLEAN", newSViv(TCL_LINK_BOOLEAN)); |
| 1832 |
0 |
| newCONSTSUB(stash, "LINK_STRING", newSViv(TCL_LINK_STRING)); |
| 1833 |
0 |
| newCONSTSUB(stash, "LINK_READ_ONLY", newSViv(TCL_LINK_READ_ONLY)); |
| 1834 |
|
| |
| 1835 |
0 |
| newCONSTSUB(stash, "WINDOW_EVENTS", newSViv(TCL_WINDOW_EVENTS)); |
| 1836 |
0 |
| newCONSTSUB(stash, "FILE_EVENTS", newSViv(TCL_FILE_EVENTS)); |
| 1837 |
0 |
| newCONSTSUB(stash, "TIMER_EVENTS", newSViv(TCL_TIMER_EVENTS)); |
| 1838 |
0 |
| newCONSTSUB(stash, "IDLE_EVENTS", newSViv(TCL_IDLE_EVENTS)); |
| 1839 |
0 |
| newCONSTSUB(stash, "ALL_EVENTS", newSViv(TCL_ALL_EVENTS)); |
| 1840 |
0 |
| newCONSTSUB(stash, "DONT_WAIT", newSViv(TCL_DONT_WAIT)); |
| 1841 |
|
| |
| 1842 |
0 |
| newCONSTSUB(stash, "EVAL_GLOBAL", newSViv(TCL_EVAL_GLOBAL)); |
| 1843 |
0 |
| newCONSTSUB(stash, "EVAL_DIRECT", newSViv(TCL_EVAL_DIRECT)); |
| 1844 |
|
| } |