[pywin32-checkins] pywin32/com/win32com/src univgw_dataconv.cpp, 1.12, 1.13
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2010-11-13 06:14:31
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv8218/src Modified Files: univgw_dataconv.cpp Log Message: fix stack alignment issues in 64bit universal gateway support Index: univgw_dataconv.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/univgw_dataconv.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** univgw_dataconv.cpp 19 Dec 2008 01:51:26 -0000 1.12 --- univgw_dataconv.cpp 13 Nov 2010 06:14:23 -0000 1.13 *************** *** 84,90 **** ! static inline void SizeOfVT(VARTYPE vt, int *pitem_size, int *pstack_size) { - int stack_size = -1; int item_size; if (vt & VT_BYREF) --- 84,89 ---- ! static inline bool SizeOfVT(VARTYPE vt, int *pitem_size, int *pstack_size) { int item_size; if (vt & VT_BYREF) *************** *** 152,163 **** default: assert(FALSE); ! item_size = 0; } } ! if (stack_size == -1) stack_size = item_size; ! if (item_size < 4 && item_size > 0) ! stack_size = 4; // everything widened on x86 if (pitem_size) *pitem_size = item_size; if (pstack_size) *pstack_size = stack_size; } --- 151,172 ---- default: assert(FALSE); ! PyErr_SetString(PyExc_NotImplementedError, "unknown variant type"); ! return FALSE; } } ! #ifdef _M_IX86 ! int stack_size = (item_size < 4) ? 4 : item_size; ! #elif _M_X64 ! // params > 64bits passed by address, and only VT_VARIANT is > 64bits. ! assert ((item_size <= 8) || ((vt & VT_TYPEMASK) == VT_VARIANT)); ! if (item_size > 8) item_size = 8; ! // stack always 64 bits. ! int stack_size = 8; ! #else ! #error Unknown platform ! #endif if (pitem_size) *pitem_size = item_size; if (pstack_size) *pstack_size = stack_size; + return TRUE; } *************** *** 170,174 **** int item_size = 0; int stack_size = 0; ! SizeOfVT((VARTYPE)vt, &item_size, &stack_size); if (item_size <= 0) { PyErr_Format(PyExc_ValueError, "The value %d (0x%x) is an invalid variant type", vt, vt); --- 179,184 ---- int item_size = 0; int stack_size = 0; ! if (!SizeOfVT((VARTYPE)vt, &item_size, &stack_size)) ! return NULL; if (item_size <= 0) { PyErr_Format(PyExc_ValueError, "The value %d (0x%x) is an invalid variant type", vt, vt); *************** *** 661,666 **** pb = pbArg + PyInt_AS_LONG(PyTuple_GET_ITEM(PyTuple_GET_ITEM(obArgTypes, i), 1)); vtArgType = (VARTYPE)PyInt_AS_LONG(obArgType); bIsByRef = vtArgType & VT_BYREF; ! VARTYPE vtConversionType = vtArgType & VT_TYPEMASK; if (vtArgType & VT_ARRAY) { --- 671,683 ---- pb = pbArg + PyInt_AS_LONG(PyTuple_GET_ITEM(PyTuple_GET_ITEM(obArgTypes, i), 1)); vtArgType = (VARTYPE)PyInt_AS_LONG(obArgType); + #ifdef _M_IX86 bIsByRef = vtArgType & VT_BYREF; ! #elif _M_X64 ! // params > 64bits always passed by address - and the only ! // arg we support > 64 bits is a VARIANT structure. ! bIsByRef = (vtArgType==VT_VARIANT) || (vtArgType & VT_BYREF); ! #else ! #error Unknown platform ! #endif VARTYPE vtConversionType = vtArgType & VT_TYPEMASK; if (vtArgType & VT_ARRAY) { *************** *** 714,718 **** V_VT(&var) = vtArgType; // Copy the data into the variant... ! SizeOfVT(V_VT(&var), (int *)&cb, NULL); memcpy(&V_I4(&var), pb, cb); // Convert it into a PyObject: --- 731,736 ---- V_VT(&var) = vtArgType; // Copy the data into the variant... ! if (!SizeOfVT(V_VT(&var), (int *)&cb, NULL)) ! goto Error; memcpy(&V_I4(&var), pb, cb); // Convert it into a PyObject: |