Yeah, pywin32 will see a byref ui1 and pass the address of an integer filled with the value of the integer objects. However, I'm not really sure what you are expecting this to do - passing the address of a Python integer object clearly isn't correct - or to put it another way - what exact are you hoping to pass as this parameter?

We could probably special-case VT_BYREF | VT_UI1 when a Python "buffer" object is passed and pass the address of that buffer - this already happens for a VT_ARRAY | VT_UI1 - but whether that would solve your problem depends on how you actually intend using that param...

Mark.

On 29/05/2013 4:26 AM, Jeremy Kloth wrote:
I have been struggling with getting pointer parameters to work with the
COM interface for VirtualBox.  In particular, the IFramebuffer
interface.  I cannot seem to get the following to give the expected results:

interface IFramebuffer : IDispatch
{
     // snipped to just the interesting definition
     HRESULT RequestResize (
         [in] ULONG aScreenId,
         [in] ULONG aPixelFormat,
         [in] BYTE * aVRAM,
         [in] ULONG aBitsPerPixel,
         [in] ULONG aBytesPerLine,
         [in] ULONG aWidth,
         [in] ULONG aHeight,
         [out, retval] BOOL * aFinished
     );
};

The type for aVRAM ends up being (correctly) VT_BYREF | VT_UI1.
  Unfortunately PyIDispatch (incorrectly) converts the parameter to just
VT_UI1.  The offending code path is: PyGatewayBase::Invoke() ->
invoke_setup() -> PyCom_PyObjectFromVariant() -> VariantCopyInd().

My not so informed understanding is that pythoncom considers all
VT_BYREF parameters as out-type parameters whereas, in this case at
least, it is not always such.  Indeed, in this case, the aVRAM parameter
needs to be the *address* not the *value* for an object to implement
IFramebuffer properly.

Note that the object implementing IFramebuffer is passed as argument to
another function much the same way as event listeners.

I believe the fix involves PyIDispatch somehow using the type
information to determine which parameters are not out-type and then to
not dereference those.

Any direction with this is greatly appreciated.

Jeremy Kloth


_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to