Thread: [pywin32-checkins] pywin32/win32/src win32gui.i,1.99,1.100
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Roger U. <ru...@us...> - 2007-01-12 05:54:39
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28214/win32/src Modified Files: win32gui.i Log Message: Return plain int handles via PyWinLong_FromHANDLE Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.99 retrieving revision 1.100 diff -C2 -d -r1.99 -r1.100 *** win32gui.i 11 Jan 2007 04:42:26 -0000 1.99 --- win32gui.i 12 Jan 2007 05:54:38 -0000 1.100 *************** *** 292,321 **** } ! %apply HCURSOR {long}; ! typedef long HCURSOR; ! ! %apply HINSTANCE {long}; ! typedef long HINSTANCE; ! ! %apply HMENU {long}; ! typedef long HMENU ! ! %apply HICON {long}; ! typedef long HICON ! ! %apply HGDIOBJ {long}; ! typedef long HGDIOBJ ! ! %apply HWND {long}; ! typedef long HWND ! ! %apply HDC {long}; ! typedef long HDC ! ! %apply HIMAGELIST {long}; ! typedef long HIMAGELIST ! ! %apply HACCEL {long}; ! typedef long HACCEL %apply COLORREF {long}; --- 292,304 ---- } ! // Handles types with no specific PyHANDLE subclass, returned to Python as plain ints or longs ! typedef float HDC, HWND, HCURSOR, HINSTANCE, HMENU, HICON, HGDIOBJ, HIMAGELIST, HACCEL; ! %typemap(python, in) HDC, HWND, HCURSOR, HINSTANCE, HMENU, HICON, HGDIOBJ, HIMAGELIST, HACCEL{ ! if (!PyWinObject_AsHANDLE($source, (HANDLE *)&$target, FALSE)) ! return NULL; ! } ! %typemap(python, out) HDC, HWND, HCURSOR, HINSTANCE, HMENU, HICON, HGDIOBJ, HIMAGELIST, HACCEL{ ! $target=PyWinLong_FromHANDLE($source); ! } %apply COLORREF {long}; *************** *** 345,350 **** %typemap(python,argout) MSG *OUTPUT{ PyObject *o; ! o = Py_BuildValue("iiiii(ii)", ! $source->hwnd, $source->message, $source->wParam, --- 328,333 ---- %typemap(python,argout) MSG *OUTPUT{ PyObject *o; ! o = Py_BuildValue("Niiii(ii)", ! PyWinLong_FromHANDLE($source->hwnd), $source->message, $source->wParam, *************** *** 541,546 **** %typemap(python,argout) PAINTSTRUCT *OUTPUT { PyObject *o; ! o = Py_BuildValue("(ll(iiii)lls#)", ! $source->hdc, $source->fErase, $source->rcPaint.left, $source->rcPaint.top, $source->rcPaint.right, $source->rcPaint.bottom, --- 524,529 ---- %typemap(python,argout) PAINTSTRUCT *OUTPUT { PyObject *o; ! o = Py_BuildValue("(Nl(iiii)lls#)", ! PyWinLong_FromHANDLE($source->hdc), $source->fErase, $source->rcPaint.left, $source->rcPaint.top, $source->rcPaint.right, $source->rcPaint.bottom, *************** *** 662,665 **** --- 645,652 ---- if (PyDict_Check(obFuncOrMap)) { PyObject *key = PyInt_FromLong(uMsg); + if (key==NULL){ + HandleError("Internal error converting Msg param of window procedure"); + return FALSE; + } obFunc = PyDict_GetItem(obFuncOrMap, key); Py_DECREF(key); *************** *** 668,677 **** } } ! if (obFunc==NULL) { ! PyErr_Clear(); return FALSE; ! } // We are dispatching to Python... ! PyObject *args = Py_BuildValue("llll", hWnd, uMsg, wParam, lParam); PyObject *ret = PyObject_CallObject(obFunc, args); Py_DECREF(args); --- 655,667 ---- } } ! if (obFunc==NULL) return FALSE; ! // We are dispatching to Python... ! PyObject *args = Py_BuildValue("Nlll", PyWinLong_FromHANDLE(hWnd), uMsg, wParam, lParam); ! if (args==NULL){ ! HandleError("Error building argument tuple for python callback"); ! return FALSE; ! } PyObject *ret = PyObject_CallObject(obFunc, args); Py_DECREF(args); *************** *** 690,694 **** LRESULT CALLBACK PyWndProcClass(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { ! PyObject *obFunc = (PyObject *)GetClassLong( hWnd, 0); LRESULT rc = 0; CEnterLeavePython _celp; --- 680,684 ---- LRESULT CALLBACK PyWndProcClass(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { ! PyObject *obFunc = (PyObject *)GetClassLongPtr( hWnd, 0); LRESULT rc = 0; CEnterLeavePython _celp; *************** *** 702,706 **** LRESULT CALLBACK PyDlgProcClass(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { ! PyObject *obFunc = (PyObject *)GetClassLong( hWnd, 0); LRESULT rc = 0; CEnterLeavePython _celp; --- 692,696 ---- LRESULT CALLBACK PyDlgProcClass(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { ! PyObject *obFunc = (PyObject *)GetClassLongPtr( hWnd, 0); LRESULT rc = 0; CEnterLeavePython _celp; *************** *** 715,719 **** { CEnterLeavePython _celp; ! PyObject *key = PyInt_FromLong((long)hWnd); PyObject *obInfo = PyDict_GetItem(g_HWNDMap, key); Py_DECREF(key); --- 705,709 ---- { CEnterLeavePython _celp; ! PyObject *key = PyWinLong_FromHANDLE(hWnd); PyObject *obInfo = PyDict_GetItem(g_HWNDMap, key); Py_DECREF(key); *************** *** 738,742 **** #endif _celp.acquire(); // in case we released above - safe if already acquired. ! PyObject *key = PyInt_FromLong((long)hWnd); if (PyDict_DelItem(g_HWNDMap, key) != 0) PyErr_Clear(); --- 728,732 ---- #endif _celp.acquire(); // in case we released above - safe if already acquired. ! PyObject *key = PyWinLong_FromHANDLE(hWnd); if (PyDict_DelItem(g_HWNDMap, key) != 0) PyErr_Clear(); *************** *** 757,761 **** // Replace the lParam with the one the user specified. lParam = PyInt_AsLong( PyTuple_GET_ITEM(obTuple, 1) ); ! PyObject *key = PyInt_FromLong((long)hWnd); if (g_DLGMap==NULL) g_DLGMap = PyDict_New(); --- 747,751 ---- // Replace the lParam with the one the user specified. lParam = PyInt_AsLong( PyTuple_GET_ITEM(obTuple, 1) ); ! PyObject *key = PyWinLong_FromHANDLE(hWnd); if (g_DLGMap==NULL) g_DLGMap = PyDict_New(); *************** *** 774,778 **** PyObject *obFunc = NULL; if (g_DLGMap) { ! PyObject *key = PyInt_FromLong((long)hWnd); obFunc = PyDict_GetItem(g_DLGMap, key); Py_XDECREF(key); --- 764,768 ---- PyObject *obFunc = NULL; if (g_DLGMap) { ! PyObject *key = PyWinLong_FromHANDLE(hWnd); obFunc = PyDict_GetItem(g_DLGMap, key); Py_XDECREF(key); *************** *** 791,795 **** if (uMsg==WM_DESTROY) { #endif ! PyObject *key = PyInt_FromLong((long)hWnd); if (g_DLGMap != NULL) --- 781,785 ---- if (uMsg==WM_DESTROY) { #endif ! PyObject *key = PyWinLong_FromHANDLE(hWnd); if (g_DLGMap != NULL) *************** *** 1578,1582 **** return NULL; } ! return Py_BuildValue("ll",(long) addr, len); } %} --- 1568,1572 ---- return NULL; } ! return Py_BuildValue("Nl", PyLong_FromVoidPtr(addr), len); } %} *************** *** 1929,1933 **** PyEnumWindowsCallback *cb = (PyEnumWindowsCallback *)lParam; CEnterLeavePython _celp; ! PyObject *args = Py_BuildValue("(iO)", hwnd, cb->extra); PyObject *ret = PyEval_CallObject(cb->func, args); Py_XDECREF(args); --- 1919,1923 ---- PyEnumWindowsCallback *cb = (PyEnumWindowsCallback *)lParam; CEnterLeavePython _celp; ! PyObject *args = Py_BuildValue("(NO)", PyWinLong_FromHANDLE(hwnd), cb->extra); PyObject *ret = PyEval_CallObject(cb->func, args); Py_XDECREF(args); *************** *** 2068,2072 **** int rc; Py_BEGIN_ALLOW_THREADS ! rc = DialogBoxParam((HINSTANCE)hinst, resid, (HWND)hwnd, PyDlgProcHDLG, (LPARAM)obExtra); Py_END_ALLOW_THREADS Py_DECREF(obExtra); --- 2058,2062 ---- int rc; Py_BEGIN_ALLOW_THREADS ! rc = DialogBoxParam(hinst, resid, hwnd, PyDlgProcHDLG, (LPARAM)obExtra); Py_END_ALLOW_THREADS Py_DECREF(obExtra); *************** *** 2117,2121 **** Py_BEGIN_ALLOW_THREADS HGLOBAL templ = (HGLOBAL) GlobalLock(h); ! rc = DialogBoxIndirectParam((HINSTANCE)hinst, (const DLGTEMPLATE *) templ, (HWND)hwnd, PyDlgProcHDLG, (LPARAM)obExtra); GlobalUnlock(h); GlobalFree(h); --- 2107,2111 ---- Py_BEGIN_ALLOW_THREADS HGLOBAL templ = (HGLOBAL) GlobalLock(h); ! rc = DialogBoxIndirectParam(hinst, (const DLGTEMPLATE *) templ, hwnd, PyDlgProcHDLG, (LPARAM)obExtra); GlobalUnlock(h); GlobalFree(h); *************** *** 2164,2168 **** Py_BEGIN_ALLOW_THREADS HGLOBAL templ = (HGLOBAL) GlobalLock(h); ! rc = CreateDialogIndirectParam((HINSTANCE)hinst, (const DLGTEMPLATE *) templ, (HWND)hwnd, PyDlgProcHDLG, (LPARAM)obExtra); GlobalUnlock(h); GlobalFree(h); --- 2154,2158 ---- Py_BEGIN_ALLOW_THREADS HGLOBAL templ = (HGLOBAL) GlobalLock(h); ! rc = CreateDialogIndirectParam(hinst, (const DLGTEMPLATE *) templ, hwnd, PyDlgProcHDLG, (LPARAM)obExtra); GlobalUnlock(h); GlobalFree(h); *************** *** 2370,2378 **** CURSORINFO ci; ci.cbSize = sizeof(ci); ! if (!PyArg_NoArgs(args)) return NULL; if (!::GetCursorInfo(&ci)) return PyWin_SetAPIError("GetCursorInfo"); ! return Py_BuildValue("ii(ii)", ci.flags, ci.hCursor, ci.ptScreenPos.x, ci.ptScreenPos.y); } %} --- 2360,2368 ---- CURSORINFO ci; ci.cbSize = sizeof(ci); ! if (!PyArg_ParseTuple(args,":GetCursorInfo")) return NULL; if (!::GetCursorInfo(&ci)) return PyWin_SetAPIError("GetCursorInfo"); ! return Py_BuildValue("iN(ii)", ci.flags, PyWinLong_FromHANDLE(ci.hCursor), ci.ptScreenPos.x, ci.ptScreenPos.y); } %} *************** *** 2418,2422 **** ha = ::CreateAcceleratorTable(accels, num); if (ha) ! ret = PyLong_FromVoidPtr((void *)ha); else PyWin_SetAPIError("CreateAcceleratorTable"); --- 2408,2412 ---- ha = ::CreateAcceleratorTable(accels, num); if (ha) ! ret = PyWinLong_FromHANDLE(ha); else PyWin_SetAPIError("CreateAcceleratorTable"); *************** *** 2490,2494 **** %{ ! // @pyswig int|CreateIconFromResource|Creates an icon or cursor from resource bits describing the icon. static PyObject *PyCreateIconFromResource(PyObject *self, PyObject *args) { --- 2480,2484 ---- %{ ! // @pyswig <o PyHANDLE>|CreateIconFromResource|Creates an icon or cursor from resource bits describing the icon. static PyObject *PyCreateIconFromResource(PyObject *self, PyObject *args) { *************** *** 2507,2511 **** if (!ret) return PyWin_SetAPIError("CreateIconFromResource"); ! return PyLong_FromVoidPtr(ret); } %} --- 2497,2501 ---- if (!ret) return PyWin_SetAPIError("CreateIconFromResource"); ! return PyWinLong_FromHANDLE(ret); } %} *************** *** 3085,3089 **** BOOL rc; Py_BEGIN_ALLOW_THREADS ! rc = SetWindowPlacement( (HWND)hwnd, &pment ); Py_END_ALLOW_THREADS if (!rc) --- 3075,3079 ---- BOOL rc; Py_BEGIN_ALLOW_THREADS ! rc = SetWindowPlacement(hwnd, &pment ); Py_END_ALLOW_THREADS if (!rc) *************** *** 3146,3150 **** return NULL; atom=(LPTSTR)PyLong_AsVoidPtr(obatom); ! if (atom==NULL) return NULL; // Only low word can be set when using an atom --- 3136,3140 ---- return NULL; atom=(LPTSTR)PyLong_AsVoidPtr(obatom); ! if (atom==NULL && PyErr_Occurred()) return NULL; // Only low word can be set when using an atom *************** *** 3670,3675 **** if (!objects_small) goto done; for (i=0;i<nicons;i++) { ! PyList_SET_ITEM(objects_large, i, PyInt_FromLong((long)rgLarge[i])); ! PyList_SET_ITEM(objects_small, i, PyInt_FromLong((long)rgSmall[i])); } ret = Py_BuildValue("OO", objects_large, objects_small); --- 3660,3665 ---- if (!objects_small) goto done; for (i=0;i<nicons;i++) { ! PyList_SET_ITEM(objects_large, i, PyWinLong_FromHANDLE(rgLarge[i])); ! PyList_SET_ITEM(objects_small, i, PyWinLong_FromHANDLE(rgSmall[i])); } ret = Py_BuildValue("OO", objects_large, objects_small); *************** *** 5981,5985 **** hdc=CreateDC(driver, device, dummyoutput, pdevmode); if (hdc!=NULL) ! ret = Py_BuildValue("l",hdc); else { PyWin_SetAPIError("CreateDC",GetLastError()); --- 5971,5975 ---- hdc=CreateDC(driver, device, dummyoutput, pdevmode); if (hdc!=NULL) ! ret = PyWinLong_FromHANDLE(hdc); else { PyWin_SetAPIError("CreateDC",GetLastError()); |