Changeset 391 for python/trunk/PC/os2emx/pythonpm.c
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/PC/os2emx/pythonpm.c
r2 r391 28 28 typedef struct 29 29 { 30 31 32 33 30 int argc; 31 char **argv; 32 HWND Frame; 33 int running; 34 34 } arglist; 35 35 … … 46 46 main(int argc, char **argv) 47 47 { 48 49 50 51 52 53 54 55 56 57 58 59 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; 60 60 61 62 63 61 /* init PM and create message queue */ 62 hab = WinInitialize(0); 63 hmq = WinCreateMsgQueue(hab, 0); 64 64 65 66 67 68 69 70 71 72 73 74 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); 75 75 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 } 99 94 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; 101 101 } 102 102 103 103 void PythonThread(void *argl) 104 104 { 105 106 105 HAB hab; 106 arglist *args; 107 107 108 109 108 /* PM initialisation */ 109 hab = WinInitialize(0); 110 110 111 112 113 114 111 /* start Python */ 112 args = (arglist *)argl; 113 args->running = 1; 114 PythonRC = Py_Main(args->argc, args->argv); 115 115 116 117 118 119 116 /* enter a critical section and send the termination message */ 117 DosEnterCritSec(); 118 args->running = 0; 119 WinPostMsg(args->Frame, WM_QUIT, NULL, NULL); 120 120 121 122 123 121 /* shutdown PM and terminate thread */ 122 WinTerminate(hab); 123 _endthread(); 124 124 }
Note:
See TracChangeset
for help on using the changeset viewer.