From 22b28ab9d23ce6ff657510b7b2d4c022ed70f565 Mon Sep 17 00:00:00 2001 From: Thomas Geppert Date: Mon, 22 Jul 2024 09:45:27 +0200 Subject: [PATCH 1/2] Implement record pointers as method parameters of a Dispatch Interface to get server side modifications of a record marshaled back to the client. --- com/win32com/client/build.py | 1 - com/win32com/src/oleargs.cpp | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/com/win32com/client/build.py b/com/win32com/client/build.py index b75f21821..4adecb57d 100644 --- a/com/win32com/client/build.py +++ b/com/win32com/client/build.py @@ -545,7 +545,6 @@ def _ResolveType(typerepr, itypeinfo): if was_user and subrepr in [ pythoncom.VT_DISPATCH, pythoncom.VT_UNKNOWN, - pythoncom.VT_RECORD, ]: # Drop the VT_PTR indirection return subrepr, sub_clsid, sub_doc diff --git a/com/win32com/src/oleargs.cpp b/com/win32com/src/oleargs.cpp index 33c925987..da3c7fed4 100644 --- a/com/win32com/src/oleargs.cpp +++ b/com/win32com/src/oleargs.cpp @@ -1572,6 +1572,7 @@ BOOL PythonOleArgHelper::MakeObjToVariant(PyObject *obj, VARIANT *var, PyObject // Nothing else to do - the code below sets the VT up correctly. break; case VT_RECORD: + case VT_RECORD | VT_BYREF: rc = PyObject_AsVARIANTRecordInfo(obj, var); break; case VT_CY: From 24651cb57eb31dfe61870249bc26084648e16183 Mon Sep 17 00:00:00 2001 From: Thomas Geppert Date: Wed, 31 Jul 2024 17:16:07 +0200 Subject: [PATCH 2/2] Added a untitest for record pointers as [ in, out ] method parameters. --- com/TestSources/PyCOMTest/PyCOMImpl.cpp | 8 ++++++++ com/TestSources/PyCOMTest/PyCOMImpl.h | 2 ++ com/TestSources/PyCOMTest/PyCOMTest.idl | 2 ++ com/win32com/test/testPyComTest.py | 12 ++++++++++++ 4 files changed, 24 insertions(+) diff --git a/com/TestSources/PyCOMTest/PyCOMImpl.cpp b/com/TestSources/PyCOMTest/PyCOMImpl.cpp index a4616fef0..d58c00f99 100644 --- a/com/TestSources/PyCOMTest/PyCOMImpl.cpp +++ b/com/TestSources/PyCOMTest/PyCOMImpl.cpp @@ -618,6 +618,14 @@ HRESULT CPyCOMTest::GetStruct(TestStruct1 *ret) *ret = r; return S_OK; } + +HRESULT CPyCOMTest::ModifyStruct(TestStruct1 *prec) +{ + prec->int_value = 100; + prec->str_value = SysAllocString(L"Nothing is as constant as change"); + return S_OK; +} + HRESULT CPyCOMTest::DoubleString(BSTR in, BSTR *out) { *out = SysAllocStringLen(NULL, SysStringLen(in) * 2); diff --git a/com/TestSources/PyCOMTest/PyCOMImpl.h b/com/TestSources/PyCOMTest/PyCOMImpl.h index e285268f1..50eb8dd0d 100644 --- a/com/TestSources/PyCOMTest/PyCOMImpl.h +++ b/com/TestSources/PyCOMTest/PyCOMImpl.h @@ -119,6 +119,8 @@ class CPyCOMTest : public IDispatchImpl