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.
#371
I was trying to implement the #400 functionality.
However, I realized that it is misleading to have a function annotation that allows named arguments to be accepted, since a dispmethod called via
IDispatch.Invoke
will raise an error when a named (with default value) argument is passed at runtime.So, I improved the process of instantiating
DISPPARAMS
so that it can also accept named arguments in dispmethod.Using
_argspec
passed toIDispatch.Invoke
, it completes default values for optional arguments that were not passed, to ensure that the passed argument names are correct.This added functionality is only triggered when named arguments are passed to dispmethod.
Same as before, when just only positional arguments are passed, the VARIANT array is assigned to
DISPPARAMS.rgvarg
in the reverse order.Therefore, this change does not break backward compatibility.
In the case that an element of
argspec
is not what the newly added processing expects, and an error is raised when passing named arguments, it can be avoided by passing only positional arguments.The
bound_named_property
has also been improved to allow passing named arguments.As for testing, I used Excel to verify that it is possible to pass named arguments to a dispmethod.
I have Excel in my development environment, so I can run this test and make sure it passes.
However, AppVeyor CI does not have Excel, so I am not able to fully guarantee End2End operation with CI.
Instead, I generously cover the test of
DISPPARAMS
instantiation process, which can be executed independent of Excel and the environment.commethod (and stdmethod) were originally designed to accept named arguments, but there were no tests to do so explicitly, so I added them.
If there is a dispmethod in an environment-independent library that can easily provide fixtures, I will try to test with that object as well, so I am looking for feedback.