Ignore:
Timestamp:
Mar 19, 2014, 11:11:30 AM (11 years ago)
Author:
dmik
Message:

python: Update vendor to 2.7.6.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/vendor/current/Modules/tkappinit.c

    r2 r388  
    1717#include <tk.h>
    1818
     19#include "tkinter.h"
     20
     21#ifdef TKINTER_PROTECT_LOADTK
     22/* See Tkapp_TkInit in _tkinter.c for the usage of tk_load_faile */
     23static int tk_load_failed;
     24#endif
     25
    1926int
    2027Tcl_AppInit(Tcl_Interp *interp)
    2128{
    22         Tk_Window main_window;
    23         const char * _tkinter_skip_tk_init;
     29    Tk_Window main_window;
     30    const char *_tkinter_skip_tk_init;
     31#ifdef TKINTER_PROTECT_LOADTK
     32    const char *_tkinter_tk_failed;
     33#endif
    2434
    2535#ifdef TK_AQUA
     
    2737#define MAX_PATH_LEN 1024
    2838#endif
    29         char tclLibPath[MAX_PATH_LEN], tkLibPath[MAX_PATH_LEN];
    30         Tcl_Obj*        pathPtr;
     39    char tclLibPath[MAX_PATH_LEN], tkLibPath[MAX_PATH_LEN];
     40    Tcl_Obj*            pathPtr;
    3141
    32         /* pre- Tcl_Init code copied from tkMacOSXAppInit.c */
    33         Tk_MacOSXOpenBundleResources (interp, "com.tcltk.tcllibrary",
    34         tclLibPath, MAX_PATH_LEN, 0);
     42    /* pre- Tcl_Init code copied from tkMacOSXAppInit.c */
     43    Tk_MacOSXOpenBundleResources (interp, "com.tcltk.tcllibrary",
     44    tclLibPath, MAX_PATH_LEN, 0);
    3545
    36         if (tclLibPath[0] != '\0') {
    37         Tcl_SetVar(interp, "tcl_library", tclLibPath, TCL_GLOBAL_ONLY);
    38                 Tcl_SetVar(interp, "tclDefaultLibrary", tclLibPath, TCL_GLOBAL_ONLY);
    39                 Tcl_SetVar(interp, "tcl_pkgPath", tclLibPath, TCL_GLOBAL_ONLY);
    40         }
    41        
    42         if (tclLibPath[0] != '\0') {
    43                 Tcl_SetVar(interp, "tcl_library", tclLibPath, TCL_GLOBAL_ONLY);
    44                 Tcl_SetVar(interp, "tclDefaultLibrary", tclLibPath, TCL_GLOBAL_ONLY);
    45                 Tcl_SetVar(interp, "tcl_pkgPath", tclLibPath, TCL_GLOBAL_ONLY);
    46         }
     46    if (tclLibPath[0] != '\0') {
     47    Tcl_SetVar(interp, "tcl_library", tclLibPath, TCL_GLOBAL_ONLY);
     48        Tcl_SetVar(interp, "tclDefaultLibrary", tclLibPath, TCL_GLOBAL_ONLY);
     49        Tcl_SetVar(interp, "tcl_pkgPath", tclLibPath, TCL_GLOBAL_ONLY);
     50    }
     51
     52    if (tclLibPath[0] != '\0') {
     53        Tcl_SetVar(interp, "tcl_library", tclLibPath, TCL_GLOBAL_ONLY);
     54        Tcl_SetVar(interp, "tclDefaultLibrary", tclLibPath, TCL_GLOBAL_ONLY);
     55        Tcl_SetVar(interp, "tcl_pkgPath", tclLibPath, TCL_GLOBAL_ONLY);
     56    }
    4757#endif
    48         if (Tcl_Init (interp) == TCL_ERROR)
    49                 return TCL_ERROR;
     58    if (Tcl_Init (interp) == TCL_ERROR)
     59        return TCL_ERROR;
    5060
    5161#ifdef TK_AQUA
    52         /* pre- Tk_Init code copied from tkMacOSXAppInit.c */
    53         Tk_MacOSXOpenBundleResources (interp, "com.tcltk.tklibrary",
    54             tkLibPath, MAX_PATH_LEN, 1);
     62    /* pre- Tk_Init code copied from tkMacOSXAppInit.c */
     63    Tk_MacOSXOpenBundleResources (interp, "com.tcltk.tklibrary",
     64        tkLibPath, MAX_PATH_LEN, 1);
    5565
    56         if (tclLibPath[0] != '\0') {
    57                 pathPtr = Tcl_NewStringObj(tclLibPath, -1);
    58         } else {
    59                 Tcl_Obj *pathPtr = TclGetLibraryPath();
    60         }
     66    if (tclLibPath[0] != '\0') {
     67        pathPtr = Tcl_NewStringObj(tclLibPath, -1);
     68    } else {
     69        Tcl_Obj *pathPtr = TclGetLibraryPath();
     70    }
    6171
    62         if (tkLibPath[0] != '\0') {
    63                 Tcl_Obj *objPtr;
     72    if (tkLibPath[0] != '\0') {
     73        Tcl_Obj *objPtr;
    6474
    65                 Tcl_SetVar(interp, "tk_library", tkLibPath, TCL_GLOBAL_ONLY);
    66                 objPtr = Tcl_NewStringObj(tkLibPath, -1);
    67                 Tcl_ListObjAppendElement(NULL, pathPtr, objPtr);
    68         }
     75        Tcl_SetVar(interp, "tk_library", tkLibPath, TCL_GLOBAL_ONLY);
     76        objPtr = Tcl_NewStringObj(tkLibPath, -1);
     77        Tcl_ListObjAppendElement(NULL, pathPtr, objPtr);
     78    }
    6979
    70         TclSetLibraryPath(pathPtr);
     80    TclSetLibraryPath(pathPtr);
    7181#endif
    7282
    7383#ifdef WITH_XXX
    74                 /* Initialize modules that don't require Tk */
     84        /* Initialize modules that don't require Tk */
    7585#endif
    7686
    77         _tkinter_skip_tk_init = Tcl_GetVar(interp, "_tkinter_skip_tk_init", TCL_GLOBAL_ONLY);
    78         if (_tkinter_skip_tk_init != NULL && strcmp(_tkinter_skip_tk_init, "1") == 0) {
    79                 return TCL_OK;
    80         }
    81         if (Tk_Init(interp) == TCL_ERROR)
    82                 return TCL_ERROR;
     87    _tkinter_skip_tk_init =     Tcl_GetVar(interp,
     88                    "_tkinter_skip_tk_init", TCL_GLOBAL_ONLY);
     89    if (_tkinter_skip_tk_init != NULL &&
     90                    strcmp(_tkinter_skip_tk_init, "1") == 0) {
     91        return TCL_OK;
     92    }
    8393
    84         main_window = Tk_MainWindow(interp);
     94#ifdef TKINTER_PROTECT_LOADTK
     95    _tkinter_tk_failed = Tcl_GetVar(interp,
     96                    "_tkinter_tk_failed", TCL_GLOBAL_ONLY);
     97
     98    if (tk_load_failed || (
     99                            _tkinter_tk_failed != NULL &&
     100                            strcmp(_tkinter_tk_failed, "1") == 0)) {
     101        Tcl_SetResult(interp, TKINTER_LOADTK_ERRMSG, TCL_STATIC);
     102        return TCL_ERROR;
     103    }
     104#endif
     105
     106    if (Tk_Init(interp) == TCL_ERROR) {
     107#ifdef TKINTER_PROTECT_LOADTK
     108        tk_load_failed = 1;
     109        Tcl_SetVar(interp, "_tkinter_tk_failed", "1", TCL_GLOBAL_ONLY);
     110#endif
     111        return TCL_ERROR;
     112    }
     113
     114    main_window = Tk_MainWindow(interp);
    85115
    86116#ifdef TK_AQUA
    87         TkMacOSXInitAppleEvents(interp);
    88         TkMacOSXInitMenus(interp);
     117    TkMacOSXInitAppleEvents(interp);
     118    TkMacOSXInitMenus(interp);
    89119#endif
    90    
     120
    91121#ifdef WITH_MOREBUTTONS
    92         {
    93                 extern Tcl_CmdProc studButtonCmd;
    94                 extern Tcl_CmdProc triButtonCmd;
     122    {
     123        extern Tcl_CmdProc studButtonCmd;
     124        extern Tcl_CmdProc triButtonCmd;
    95125
    96                 Tcl_CreateCommand(interp, "studbutton", studButtonCmd,
    97                                   (ClientData) main_window, NULL);
    98                 Tcl_CreateCommand(interp, "tributton", triButtonCmd,
    99                                   (ClientData) main_window, NULL);
    100         }
     126        Tcl_CreateCommand(interp, "studbutton", studButtonCmd,
     127                          (ClientData) main_window, NULL);
     128        Tcl_CreateCommand(interp, "tributton", triButtonCmd,
     129                          (ClientData) main_window, NULL);
     130    }
    101131#endif
    102132
    103133#ifdef WITH_PIL /* 0.2b5 and later -- not yet released as of May 14 */
    104         {
    105                 extern void TkImaging_Init(Tcl_Interp *);
    106                 TkImaging_Init(interp);
    107                 /* XXX TkImaging_Init() doesn't have the right return type */
    108                 /*Tcl_StaticPackage(interp, "Imaging", TkImaging_Init, NULL);*/
    109         }
     134    {
     135        extern void TkImaging_Init(Tcl_Interp *);
     136        TkImaging_Init(interp);
     137        /* XXX TkImaging_Init() doesn't have the right return type */
     138        /*Tcl_StaticPackage(interp, "Imaging", TkImaging_Init, NULL);*/
     139    }
    110140#endif
    111141
    112142#ifdef WITH_PIL_OLD /* 0.2b4 and earlier */
    113         {
    114                 extern void TkImaging_Init(void);
    115                 /* XXX TkImaging_Init() doesn't have the right prototype */
    116                 /*Tcl_StaticPackage(interp, "Imaging", TkImaging_Init, NULL);*/
    117         }
     143    {
     144        extern void TkImaging_Init(void);
     145        /* XXX TkImaging_Init() doesn't have the right prototype */
     146        /*Tcl_StaticPackage(interp, "Imaging", TkImaging_Init, NULL);*/
     147    }
    118148#endif
    119149
    120150#ifdef WITH_TIX
    121         {
    122                 extern int Tix_Init(Tcl_Interp *interp);
    123                 extern int Tix_SafeInit(Tcl_Interp *interp);
    124                 Tcl_StaticPackage(NULL, "Tix", Tix_Init, Tix_SafeInit);
    125         }
     151    {
     152        extern int Tix_Init(Tcl_Interp *interp);
     153        extern int Tix_SafeInit(Tcl_Interp *interp);
     154        Tcl_StaticPackage(NULL, "Tix", Tix_Init, Tix_SafeInit);
     155    }
    126156#endif
    127157
    128158#ifdef WITH_BLT
    129         {
    130                 extern int Blt_Init(Tcl_Interp *);
    131                 extern int Blt_SafeInit(Tcl_Interp *);
    132                 Tcl_StaticPackage(NULL, "Blt", Blt_Init, Blt_SafeInit);
    133         }
     159    {
     160        extern int Blt_Init(Tcl_Interp *);
     161        extern int Blt_SafeInit(Tcl_Interp *);
     162        Tcl_StaticPackage(NULL, "Blt", Blt_Init, Blt_SafeInit);
     163    }
    134164#endif
    135165
    136166#ifdef WITH_TOGL
    137         {
    138                 /* XXX I've heard rumors that this doesn't work */
    139                 extern int Togl_Init(Tcl_Interp *);
    140                 /* XXX Is there no Togl_SafeInit? */
    141                 Tcl_StaticPackage(NULL, "Togl", Togl_Init, NULL);
    142         }
     167    {
     168        /* XXX I've heard rumors that this doesn't work */
     169        extern int Togl_Init(Tcl_Interp *);
     170        /* XXX Is there no Togl_SafeInit? */
     171        Tcl_StaticPackage(NULL, "Togl", Togl_Init, NULL);
     172    }
    143173#endif
    144174
     
    146176
    147177#endif
    148         return TCL_OK;
     178    return TCL_OK;
    149179}
Note: See TracChangeset for help on using the changeset viewer.