From: Roger U. <ru...@us...> - 2007-01-27 20:09:24
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5923/com/win32comext/shell/src Modified Files: PyIShellBrowser.cpp Log Message: 64-bit compat for make_param function Index: PyIShellBrowser.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/PyIShellBrowser.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PyIShellBrowser.cpp 22 Jan 2007 21:18:58 -0000 1.6 --- PyIShellBrowser.cpp 27 Jan 2007 20:09:20 -0000 1.7 *************** *** 262,293 **** // Little helper stolen from win32gui ! static BOOL make_param(PyObject *ob, long *pl) { ! long &l = *pl; ! if (ob==NULL || ob==Py_None) ! l = 0; ! else #ifdef UNICODE #define TCHAR_DESC "Unicode" ! if (PyUnicode_Check(ob)) ! l = (long)PyUnicode_AsUnicode(ob); #else #define TCHAR_DESC "String" ! if (PyString_Check(ob)) ! l = (long)PyString_AsString(ob); ! #endif ! else if (PyInt_Check(ob)) ! l = PyInt_AsLong(ob); ! else { ! PyBufferProcs *pb = ob->ob_type->tp_as_buffer; ! if (pb != NULL && pb->bf_getreadbuffer) { ! if(-1 == pb->bf_getreadbuffer(ob,0,(void **) &l)) ! return FALSE; ! } else { ! PyErr_SetString(PyExc_TypeError, "Must be a" TCHAR_DESC ", int, or buffer object"); ! return FALSE; } ! } ! return TRUE; } --- 262,295 ---- // Little helper stolen from win32gui ! // Need to change win32gui also, or move this function into pywintypes ! static BOOL make_param(PyObject *ob, WPARAM *pparam) { ! if (ob==NULL || ob==Py_None){ ! *pparam=NULL; ! return TRUE; ! } #ifdef UNICODE #define TCHAR_DESC "Unicode" ! if (PyUnicode_Check(ob)){ ! *pparam = (WPARAM)PyUnicode_AS_UNICODE(ob); ! return TRUE; ! } #else #define TCHAR_DESC "String" ! if (PyString_Check(ob)){ ! *pparam = (WPARAM)PyString_AS_STRING(ob); ! return TRUE; } ! #endif ! *pparam=(WPARAM)PyLong_AsVoidPtr(ob); ! if ((*pparam!=NULL) || !PyErr_Occurred()) ! return TRUE; ! ! PyErr_Clear(); ! PyBufferProcs *pb = ob->ob_type->tp_as_buffer; ! if (pb != NULL && pb->bf_getreadbuffer) ! return pb->bf_getreadbuffer(ob,0,(VOID **)pparam)!=-1; ! PyErr_SetString(PyExc_TypeError, "Must be a" TCHAR_DESC ", int, or buffer object"); ! return FALSE; } *************** *** 309,315 **** WPARAM wParam; LPARAM lParam; ! if (!make_param(obwparam, (long *)&wParam)) return NULL; ! if (!make_param(oblparam, (long *)&lParam)) return NULL; --- 311,318 ---- WPARAM wParam; LPARAM lParam; ! if (!make_param(obwparam, &wParam)) return NULL; ! // WPARAM and LPARAM are defined as UINT_PTR and LONG_PTR, so they can't be used interchangeably without a cast ! if (!make_param(oblparam, (WPARAM *)&lParam)) return NULL; *************** *** 321,325 **** if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pISB, IID_IShellBrowser ); ! return PyInt_FromLong(ret); } --- 324,329 ---- if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pISB, IID_IShellBrowser ); ! // LRESULT is defined as LONG_PTR. This should work for either 32 or 64 bit. ! return PyLong_FromLongLong(ret); } |