Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/PC/os2emx/pythonpm.c

    r2 r391  
    2828typedef struct
    2929{
    30         int argc;
    31         char **argv;
    32         HWND Frame;
    33         int running;
     30    int argc;
     31    char **argv;
     32    HWND Frame;
     33    int running;
    3434} arglist;
    3535
     
    4646main(int argc, char **argv)
    4747{
    48         ULONG FrameFlags = FCF_TITLEBAR |
    49                            FCF_SYSMENU |
    50                            FCF_SIZEBORDER |
    51                            FCF_HIDEBUTTON |
    52                            FCF_SHELLPOSITION |
    53                            FCF_TASKLIST;
    54         HAB hab;
    55         HMQ hmq;
    56         HWND Client;
    57         QMSG qmsg;
    58         arglist args;
    59         int python_tid;
     48    ULONG FrameFlags = FCF_TITLEBAR |
     49                       FCF_SYSMENU |
     50                       FCF_SIZEBORDER |
     51                       FCF_HIDEBUTTON |
     52                       FCF_SHELLPOSITION |
     53                       FCF_TASKLIST;
     54    HAB hab;
     55    HMQ hmq;
     56    HWND Client;
     57    QMSG qmsg;
     58    arglist args;
     59    int python_tid;
    6060
    61         /* init PM and create message queue */
    62         hab = WinInitialize(0);
    63         hmq = WinCreateMsgQueue(hab, 0);
     61    /* init PM and create message queue */
     62    hab = WinInitialize(0);
     63    hmq = WinCreateMsgQueue(hab, 0);
    6464
    65         /* create a (hidden) Window to house the window procedure */
    66         args.Frame = WinCreateStdWindow(HWND_DESKTOP,
    67                                         0,
    68                                         &FrameFlags,
    69                                         NULL,
    70                                         "PythonPM",
    71                                         0L,
    72                                         0,
    73                                         0,
    74                                         &Client);
     65    /* create a (hidden) Window to house the window procedure */
     66    args.Frame = WinCreateStdWindow(HWND_DESKTOP,
     67                                    0,
     68                                    &FrameFlags,
     69                                    NULL,
     70                                    "PythonPM",
     71                                    0L,
     72                                    0,
     73                                    0,
     74                                    &Client);
    7575
    76         /* run Python interpreter in a thread */
    77         args.argc = argc;
    78         args.argv = argv;
    79         args.running = 0;
    80         if (-1 == (python_tid = _beginthread(PythonThread, NULL, 1024 * 1024, &args)))
    81         {
    82                 /* couldn't start thread */
    83                 WinAlarm(HWND_DESKTOP, WA_ERROR);
    84                 PythonRC = 1;
    85         }
    86         else
    87         {
    88                 /* process PM messages, until Python exits */
    89                 while (WinGetMsg(hab, &qmsg, NULLHANDLE, 0, 0))
    90                         WinDispatchMsg(hab, &qmsg);
    91                 if (args.running > 0)
    92                         DosKillThread(python_tid);
    93         }
    94                
    95         /* destroy window, shutdown message queue and PM */
    96         WinDestroyWindow(args.Frame);
    97         WinDestroyMsgQueue(hmq);
    98         WinTerminate(hab);
     76    /* run Python interpreter in a thread */
     77    args.argc = argc;
     78    args.argv = argv;
     79    args.running = 0;
     80    if (-1 == (python_tid = _beginthread(PythonThread, NULL, 1024 * 1024, &args)))
     81    {
     82        /* couldn't start thread */
     83        WinAlarm(HWND_DESKTOP, WA_ERROR);
     84        PythonRC = 1;
     85    }
     86    else
     87    {
     88        /* process PM messages, until Python exits */
     89        while (WinGetMsg(hab, &qmsg, NULLHANDLE, 0, 0))
     90            WinDispatchMsg(hab, &qmsg);
     91        if (args.running > 0)
     92            DosKillThread(python_tid);
     93    }
    9994
    100         return PythonRC;
     95    /* destroy window, shutdown message queue and PM */
     96    WinDestroyWindow(args.Frame);
     97    WinDestroyMsgQueue(hmq);
     98    WinTerminate(hab);
     99
     100    return PythonRC;
    101101}
    102102
    103103void PythonThread(void *argl)
    104104{
    105         HAB hab;
    106         arglist *args;
     105    HAB hab;
     106    arglist *args;
    107107
    108         /* PM initialisation */
    109         hab = WinInitialize(0);
     108    /* PM initialisation */
     109    hab = WinInitialize(0);
    110110
    111         /* start Python */
    112         args = (arglist *)argl;
    113         args->running = 1;
    114         PythonRC = Py_Main(args->argc, args->argv);
     111    /* start Python */
     112    args = (arglist *)argl;
     113    args->running = 1;
     114    PythonRC = Py_Main(args->argc, args->argv);
    115115
    116         /* enter a critical section and send the termination message */
    117         DosEnterCritSec();
    118         args->running = 0;
    119         WinPostMsg(args->Frame, WM_QUIT, NULL, NULL);
     116    /* enter a critical section and send the termination message */
     117    DosEnterCritSec();
     118    args->running = 0;
     119    WinPostMsg(args->Frame, WM_QUIT, NULL, NULL);
    120120
    121         /* shutdown PM and terminate thread */
    122         WinTerminate(hab);
    123         _endthread();
     121    /* shutdown PM and terminate thread */
     122    WinTerminate(hab);
     123    _endthread();
    124124}
Note: See TracChangeset for help on using the changeset viewer.