Implement the creation of SAFEARRAY(VT_RECORD) from a sequence of COM Records #2317
+82
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
and the possibility to use instances of this type as COM Record fields.
This PR addresses the following issue.
Given a COM interface that defines a COM Record of the following type in the IDL-file:
where the
T_RECORD_B
is another COM Record type with fields of just simple types,there is currently no way to assign the required SAFEARRAY instance to the
array_of_records
field of aT_RECORD_A
instance.The following code successfully creates all record instances.
However, assigning to the
array_of_records
field of theT_RECORD_A
instance raises an exception:This happens because the code is currently creating a SAFEARRAY(VT_VARIANT) with VARIANT elements of type VT_RECORD while the COM-server expects a SAFEARRAY(VT_RECORD), i.e. COM Record elements.
The modifications of the code implement the required logic to create a SAFEARRAY(VT_RECORD) and assign this as the value to a Record field.
To retrieve the value of such a Record field, the existing code of the
getattro
method in PyRecord.cpp was fixed.I'm wondering if the code in the else block starting at line 500:
was ever tested or used because I cannot see how it could have worked.