Back to index

python3.2  3.2.2
Classes | Defines | Functions | Variables
pythonpm.c File Reference
#include <os2.h>
#include <process.h>
#include "Python.h"

Go to the source code of this file.

Classes

struct  arglist

Defines

#define INCL_DOS
#define INCL_WIN

Functions

 DL_EXPORT (Py_Main(int)
void PythonThread (void *argl)

Variables

int PythonRC

Class Documentation

struct arglist

Definition at line 28 of file pythonpm.c.

Class Members
int argc
char ** argv
HWND Frame
int running

Define Documentation

#define INCL_DOS

Definition at line 20 of file pythonpm.c.

#define INCL_WIN

Definition at line 21 of file pythonpm.c.


Function Documentation

DL_EXPORT ( Py_Main int)

Definition at line 42 of file pythonpm.c.

{
    ULONG FrameFlags = FCF_TITLEBAR |
                       FCF_SYSMENU |
                       FCF_SIZEBORDER |
                       FCF_HIDEBUTTON |
                       FCF_SHELLPOSITION |
                       FCF_TASKLIST;
    HAB hab;
    HMQ hmq;
    HWND Client;
    QMSG qmsg;
    arglist args;
    int python_tid;

    /* init PM and create message queue */
    hab = WinInitialize(0);
    hmq = WinCreateMsgQueue(hab, 0);

    /* create a (hidden) Window to house the window procedure */
    args.Frame = WinCreateStdWindow(HWND_DESKTOP,
                                    0,
                                    &FrameFlags,
                                    NULL,
                                    "PythonPM",
                                    0L,
                                    0,
                                    0,
                                    &Client);

    /* run Python interpreter in a thread */
    args.argc = argc;
    args.argv = argv;
    args.running = 0;
    if (-1 == (python_tid = _beginthread(PythonThread, NULL, 1024 * 1024, &args)))
    {
        /* couldn't start thread */
        WinAlarm(HWND_DESKTOP, WA_ERROR);
        PythonRC = 1;
    }
    else
    {
        /* process PM messages, until Python exits */
        while (WinGetMsg(hab, &qmsg, NULLHANDLE, 0, 0))
            WinDispatchMsg(hab, &qmsg);
        if (args.running > 0)
            DosKillThread(python_tid);
    }

    /* destroy window, shutdown message queue and PM */
    WinDestroyWindow(args.Frame);
    WinDestroyMsgQueue(hmq);
    WinTerminate(hab);

    return PythonRC;
}

Here is the call graph for this function:

void PythonThread ( void argl)

Definition at line 103 of file pythonpm.c.

{
    HAB hab;
    arglist *args;

    /* PM initialisation */
    hab = WinInitialize(0);

    /* start Python */
    args = (arglist *)argl;
    args->running = 1;
    PythonRC = Py_Main(args->argc, args->argv);

    /* enter a critical section and send the termination message */
    DosEnterCritSec();
    args->running = 0;
    WinPostMsg(args->Frame, WM_QUIT, NULL, NULL);

    /* shutdown PM and terminate thread */
    WinTerminate(hab);
    _endthread();
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 40 of file pythonpm.c.