Hi,
I am calling a COM server (written in C++) from Python. The COM server defines methods:
interface IMatrix : IDispatch
{
...
[id(14), helpstring ("Copy matrix contents to a pointer to a C-style 2D double array")] HRESULT GetValuesRaw ( [in] unsigned int hi, [in] unsigned int lo);
[id(15), helpstring ("Copy matrix contents from a pointer to a C-style 2D double array")] HRESULT SetValuesRaw ( [in] unsigned int hi, [in] unsigned int lo);
}
Pywin32 does not pick up the unsigned int, but generates
def GetValuesRaw(self, hi=defaultNamedNotOptArg, lo=defaultNamedNotOptArg):
"""Copy matrix contents to a pointer to a C-style 2D double array"""
return self._oleobj_.InvokeTypes(14, LCID, 1, (24, 0), ((3, 1), (3, 1)),hi
, lo)
where the type id 3 stands for VT_I4 instead of VT_UI4. As you would expect this fails the first time bit 31 of hi or lo is set.
Is it a bug in pywin32?
If not, how can I influence gen_py so that it correctly recognizes the type? Do I have to write the IDL differently? Can I include hints?
Finally, what I really want to achieve is pass a 64-bit pointer from Python to the C++ COM server. Splitting it into the 32-bit hi/lo parts and passing them separately is my current solution. Am I overlooking a better option?
Thanks and best regards,
Klaus Noekel
Thanks for the report! Investigating this shows you are 100% correct and also led me to another bug - that OverFlowError exceptions passing too large integers are ignored with -1 silently passed. Fixed and checked into hg with tests as of 62ea09011278